mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-10 17:36:11 +00:00
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>
This commit is contained in:
parent
6f582f70e1
commit
7a03ddf994
@ -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();
|
||||
|
||||
igt_skip_on_simulation();
|
||||
|
||||
fd = drm_open_any_render();
|
||||
|
||||
ctx_id = gem_context_create(fd);
|
||||
|
||||
/* Make sure a proper destroy works first */
|
||||
gem_context_destroy(fd, ctx_id);
|
||||
ctx_id = gem_context_create(fd);
|
||||
/* Make sure a proper destroy works first */
|
||||
gem_context_destroy(fd, ctx_id);
|
||||
}
|
||||
|
||||
/* try double destroy */
|
||||
igt_assert(__gem_context_destroy(fd, ctx_id) == -ENOENT);
|
||||
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);
|
||||
}
|
||||
|
||||
/* destroy something random */
|
||||
igt_assert(__gem_context_destroy(fd, 2) == -ENOENT);
|
||||
igt_subtest("invalid-ctx")
|
||||
igt_assert(__gem_context_destroy(fd, 2) == -ENOENT);
|
||||
|
||||
/* Try to destroy the default context */
|
||||
igt_assert(__gem_context_destroy(fd, 0) == -ENOENT);
|
||||
igt_subtest("invalid-default-ctx")
|
||||
igt_assert(__gem_context_destroy(fd, 0) == -ENOENT);
|
||||
|
||||
close(fd);
|
||||
igt_subtest("invalid-pad") {
|
||||
struct drm_i915_gem_context_destroy destroy;
|
||||
|
||||
ctx_id = gem_context_create(fd);
|
||||
|
||||
memset(&destroy, 0, sizeof(destroy));
|
||||
destroy.ctx_id = ctx_id;
|
||||
destroy.pad = 1;
|
||||
|
||||
igt_assert(drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy) < 0 &&
|
||||
errno == EINVAL);
|
||||
gem_context_destroy(fd, ctx_id);
|
||||
}
|
||||
|
||||
igt_fixture
|
||||
close(fd);
|
||||
}
|
||||
|
@ -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_skip_on_simulation();
|
||||
igt_subtest("basic") {
|
||||
create.ctx_id = rand();
|
||||
create.pad = 0;
|
||||
|
||||
create.ctx_id = rand();
|
||||
create.pad = rand();
|
||||
|
||||
fd = drm_open_any_render();
|
||||
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);
|
||||
}
|
||||
|
||||
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_subtest("invalid-pad") {
|
||||
create.ctx_id = rand();
|
||||
create.pad = 0;
|
||||
|
||||
close(fd);
|
||||
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);
|
||||
|
||||
create.pad = 1;
|
||||
|
||||
igt_assert(drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create) < 0 &&
|
||||
errno == EINVAL);
|
||||
}
|
||||
|
||||
igt_fixture
|
||||
close(fd);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user