[Intel-gfx] [PATCH i-g-t 07/17] tests/gem_ctx_*: Use helpers
Daniel Vetter
daniel.vetter at ffwll.ch
Tue Feb 10 10:05:50 PST 2015
Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
tests/gem_ctx_bad_destroy.c | 25 +++++--------------------
tests/gem_ctx_create.c | 11 ++---------
tests/gem_ctx_exec.c | 23 ++++-------------------
3 files changed, 11 insertions(+), 48 deletions(-)
diff --git a/tests/gem_ctx_bad_destroy.c b/tests/gem_ctx_bad_destroy.c
index d848265c7802..368bf95f2fcb 100644
--- a/tests/gem_ctx_bad_destroy.c
+++ b/tests/gem_ctx_bad_destroy.c
@@ -38,18 +38,10 @@
IGT_TEST_DESCRIPTION("Negative test cases for destroy contexts.");
-struct local_drm_i915_context_destroy {
- __u32 ctx_id;
- __u32 pad;
-};
-
-#define CONTEXT_DESTROY_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2e, struct local_drm_i915_context_destroy)
-
igt_simple_main
{
- struct local_drm_i915_context_destroy destroy;
uint32_t ctx_id;
- int ret, fd;
+ int fd;
igt_skip_on_simulation();
@@ -57,24 +49,17 @@ igt_simple_main
ctx_id = gem_context_create(fd);
- destroy.ctx_id = ctx_id;
/* Make sure a proper destroy works first */
- ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
- igt_assert(ret == 0);
+ gem_context_destroy(fd, ctx_id);
/* try double destroy */
- ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
- igt_assert(ret != 0 && errno == ENOENT);
+ igt_assert(__gem_context_destroy(fd, ctx_id) == -ENOENT);
/* destroy something random */
- destroy.ctx_id = 2;
- ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
- igt_assert(ret != 0 && errno == ENOENT);
+ igt_assert(__gem_context_destroy(fd, 2) == -ENOENT);
/* Try to destroy the default context */
- destroy.ctx_id = 0;
- ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
- igt_assert(ret != 0 && errno == ENOENT);
+ igt_assert(__gem_context_destroy(fd, 0) == -ENOENT);
close(fd);
}
diff --git a/tests/gem_ctx_create.c b/tests/gem_ctx_create.c
index 522e7b1ca022..1c710fdebbf7 100644
--- a/tests/gem_ctx_create.c
+++ b/tests/gem_ctx_create.c
@@ -32,17 +32,10 @@
#include "ioctl_wrappers.h"
#include "drmtest.h"
-struct local_drm_i915_gem_context_create {
- __u32 ctx_id;
- __u32 pad;
-};
-
-#define CONTEXT_CREATE_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2d, struct local_drm_i915_gem_context_create)
-
igt_simple_main
{
int ret, fd;
- struct local_drm_i915_gem_context_create create;
+ struct drm_i915_gem_context_create create;
igt_skip_on_simulation();
@@ -51,7 +44,7 @@ igt_simple_main
fd = drm_open_any_render();
- ret = drmIoctl(fd, CONTEXT_CREATE_IOCTL, &create);
+ ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create);
igt_skip_on(ret != 0 && (errno == ENODEV || errno == EINVAL));
igt_assert(ret == 0);
igt_assert(create.ctx_id != 0);
diff --git a/tests/gem_ctx_exec.c b/tests/gem_ctx_exec.c
index 7a6ed9b1f1d2..ca5bf640adaf 100644
--- a/tests/gem_ctx_exec.c
+++ b/tests/gem_ctx_exec.c
@@ -50,21 +50,6 @@
IGT_TEST_DESCRIPTION("Test basic context switch functionality.");
-struct local_drm_i915_gem_context_destroy {
- __u32 ctx_id;
- __u32 pad;
-};
-
-#define CONTEXT_DESTROY_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2e, struct local_drm_i915_gem_context_destroy)
-
-static void context_destroy(int fd, uint32_t ctx_id)
-{
- struct local_drm_i915_gem_context_destroy destroy;
- destroy.ctx_id = ctx_id;
- do_ioctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
-#include "igt_aux.h"
-}
-
/* Copied from gem_exec_nop.c */
static int exec(int fd, uint32_t handle, int ring, int ctx_id)
{
@@ -183,7 +168,7 @@ igt_main
/* check that we can create contexts. */
ctx_id = gem_context_create(fd);
- context_destroy(fd, ctx_id);
+ gem_context_destroy(fd, ctx_id);
gem_write(fd, handle, 0, batch, sizeof(batch));
}
@@ -191,12 +176,12 @@ igt_main
ctx_id = gem_context_create(fd);
igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) == 0);
gem_sync(fd, handle);
- context_destroy(fd, ctx_id);
+ gem_context_destroy(fd, ctx_id);
ctx_id = gem_context_create(fd);
igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) == 0);
gem_sync(fd, handle);
- context_destroy(fd, ctx_id);
+ gem_context_destroy(fd, ctx_id);
igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) < 0);
gem_sync(fd, handle);
@@ -227,6 +212,6 @@ igt_main
gem_sync(fd, handle);
}
- context_destroy(fd, ctx_id);
+ gem_context_destroy(fd, ctx_id);
}
}
--
2.1.4
More information about the Intel-gfx
mailing list