tests: remove unused getopt header includes
[platform/upstream/intel-gpu-tools.git] / tests / gem_lut_handle.c
index 10fa22b..d3f6f73 100644 (file)
@@ -36,7 +36,7 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 #define BATCH_SIZE             (1024*1024)
@@ -82,9 +82,12 @@ static int exec(int fd, uint32_t handle, unsigned int flags)
        i915_execbuffer2_set_context_id(execbuf, 0);
        execbuf.rsvd2 = 0;
 
-       return drmIoctl(fd,
-                       DRM_IOCTL_I915_GEM_EXECBUFFER2,
-                       &execbuf);
+       if (drmIoctl(fd,
+                    DRM_IOCTL_I915_GEM_EXECBUFFER2,
+                    &execbuf))
+               return -errno;
+
+       return 0;
 }
 
 static int many_exec(int fd, uint32_t batch, int num_exec, int num_reloc, unsigned flags)
@@ -154,6 +157,8 @@ static int many_exec(int fd, uint32_t batch, int num_exec, int num_reloc, unsign
        ret = drmIoctl(fd,
                       DRM_IOCTL_I915_GEM_EXECBUFFER2,
                       &execbuf);
+       if (ret < 0)
+               ret = -errno;
 
        for (n = 0; n < num_exec; n++)
                gem_close(fd, gem_exec[n].handle);
@@ -164,16 +169,8 @@ static int many_exec(int fd, uint32_t batch, int num_exec, int num_reloc, unsign
        return ret;
 }
 
-#define _fail(x) ((x) == -1 && errno == ENOENT)
-#define ASSERT(x) do {                                         \
-       if (!(x)) {                                             \
-               fprintf(stderr, "%s:%d failed, errno=%d\n",     \
-                       __FUNCTION__, __LINE__, errno);         \
-               abort();                                        \
-       }                                                       \
-} while (0)
-#define fail(x) ASSERT(_fail(x))
-#define pass(x) ASSERT(!_fail(x))
+#define fail(x) igt_assert((x) == -ENOENT)
+#define pass(x) igt_assert((x) == 0)
 
 igt_simple_main
 {
@@ -195,8 +192,7 @@ igt_simple_main
        fail(exec(fd, handle, USE_LUT | BROKEN));
 
        for (i = 2; i <= SLOW_QUICK(65536, 8); i *= 2) {
-               if (many_exec(fd, handle, i+1, i+1, NORMAL) == -1 &&
-                   errno == ENOSPC)
+               if (many_exec(fd, handle, i+1, i+1, NORMAL) == -ENOSPC)
                        break;
 
                pass(many_exec(fd, handle, i-1, i-1, NORMAL));