We've missed them, and the kernel isn't nasty enough and forgot to
check them. To add these tests convert the existing create/destroy
tests over to subtests.

v2: Do the basic create/destroy in ctx_bad_destroy in a fixture
so that all the tests skip properly.

Signed-off-by: Daniel Vetter <[email protected]>
---
 tests/gem_ctx_bad_destroy.c | 48 +++++++++++++++++++++++++++++++--------------
 tests/gem_ctx_create.c      | 42 +++++++++++++++++++++++++++------------
 2 files changed, 63 insertions(+), 27 deletions(-)

diff --git a/tests/gem_ctx_bad_destroy.c b/tests/gem_ctx_bad_destroy.c
index 368bf95f2fcb..ee89763870ef 100644
--- a/tests/gem_ctx_bad_destroy.c
+++ b/tests/gem_ctx_bad_destroy.c
@@ -38,28 +38,46 @@
 
 IGT_TEST_DESCRIPTION("Negative test cases for destroy contexts.");
 
-igt_simple_main
+uint32_t ctx_id;
+int fd;
+
+igt_main
 {
-       uint32_t ctx_id;
-       int fd;
+       igt_fixture {
+               fd = drm_open_any_render();
+
+               ctx_id = gem_context_create(fd);
+               /* Make sure a proper destroy works first */
+               gem_context_destroy(fd, ctx_id);
+       }
 
-       igt_skip_on_simulation();
+       /* try double destroy */
+       igt_subtest("double-destroy") {
+               ctx_id = gem_context_create(fd);
+               gem_context_destroy(fd, ctx_id);
+               igt_assert(__gem_context_destroy(fd, ctx_id) == -ENOENT);
+       }
 
-       fd = drm_open_any_render();
+       igt_subtest("invalid-ctx")
+               igt_assert(__gem_context_destroy(fd, 2) == -ENOENT);
 
-       ctx_id = gem_context_create(fd);
+       igt_subtest("invalid-default-ctx")
+               igt_assert(__gem_context_destroy(fd, 0) == -ENOENT);
 
-       /* Make sure a proper destroy works first */
-       gem_context_destroy(fd, ctx_id);
+       igt_subtest("invalid-pad") {
+               struct drm_i915_gem_context_destroy destroy;
 
-       /* try double destroy */
-       igt_assert(__gem_context_destroy(fd, ctx_id) == -ENOENT);
+               ctx_id = gem_context_create(fd);
 
-       /* destroy something random */
-       igt_assert(__gem_context_destroy(fd, 2) == -ENOENT);
+               memset(&destroy, 0, sizeof(destroy));
+               destroy.ctx_id = ctx_id;
+               destroy.pad = 1;
 
-       /* Try to destroy the default context */
-       igt_assert(__gem_context_destroy(fd, 0) == -ENOENT);
+               igt_assert(drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, 
&destroy) < 0 &&
+                          errno == EINVAL);
+               gem_context_destroy(fd, ctx_id);
+       }
 
-       close(fd);
+       igt_fixture
+               close(fd);
 }
diff --git a/tests/gem_ctx_create.c b/tests/gem_ctx_create.c
index 1c710fdebbf7..046c974dfb6a 100644
--- a/tests/gem_ctx_create.c
+++ b/tests/gem_ctx_create.c
@@ -32,22 +32,40 @@
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 
-igt_simple_main
+int ret, fd;
+struct drm_i915_gem_context_create create;
+
+igt_main
 {
-       int ret, fd;
-       struct drm_i915_gem_context_create create;
+       igt_fixture
+               fd = drm_open_any_render();
+
+       igt_subtest("basic") {
+               create.ctx_id = rand();
+               create.pad = 0;
+
+
+               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);
+       }
 
-       igt_skip_on_simulation();
+       igt_subtest("invalid-pad") {
+               create.ctx_id = rand();
+               create.pad = 0;
 
-       create.ctx_id = rand();
-       create.pad = rand();
+               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);
 
-       fd = drm_open_any_render();
+               create.pad = 1;
 
-       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);
+               igt_assert(drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, 
&create) < 0 &&
+                          errno == EINVAL);
+       }
 
-       close(fd);
+       igt_fixture
+               close(fd);
 }
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to