diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-02-06 23:06:00 +0100 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-02-13 09:35:36 +0100 |
commit | 7a03ddf994f089e795c2b6c4122fdf490f11bef0 (patch) | |
tree | 7e26c7425f6dc9cb5d8a4167a0238181e8572ca4 /tests/gem_ctx_bad_destroy.c | |
parent | 6f582f70e1b344c6d0e20f312f376892553af55e (diff) |
tests: Add invalid pad tests for ctx create/destroy
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 <daniel.vetter@intel.com>
Diffstat (limited to 'tests/gem_ctx_bad_destroy.c')
-rw-r--r-- | tests/gem_ctx_bad_destroy.c | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/tests/gem_ctx_bad_destroy.c b/tests/gem_ctx_bad_destroy.c index 368bf95f..ee897638 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); } |