diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-08-19 10:55:28 +0200 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-08-19 10:55:28 +0200 |
commit | 9ad062d0b30f307cd5045ba03eeb7d2fa90487b0 (patch) | |
tree | e215be7c844065804d2ef8ca4c18c4c7499b5639 /tests | |
parent | 23eee394893541fa531543e8fb4b12610599817c (diff) |
lib/drmtest: extract gem_create_context
libdrm requirements are now up to it.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gem_ctx_bad_destroy.c | 22 | ||||
-rw-r--r-- | tests/gem_ctx_bad_exec.c | 24 | ||||
-rw-r--r-- | tests/gem_ctx_exec.c | 24 |
3 files changed, 4 insertions, 66 deletions
diff --git a/tests/gem_ctx_bad_destroy.c b/tests/gem_ctx_bad_destroy.c index aec27958..78526187 100644 --- a/tests/gem_ctx_bad_destroy.c +++ b/tests/gem_ctx_bad_destroy.c @@ -34,33 +34,13 @@ #include "i915_drm.h" #include "drmtest.h" -struct local_drm_i915_context_create { - __u32 ctx_id; - __u32 pad; -}; - struct local_drm_i915_context_destroy { __u32 ctx_id; __u32 pad; }; -#define CONTEXT_CREATE_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2d, struct local_drm_i915_context_create) #define CONTEXT_DESTROY_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2e, struct local_drm_i915_context_destroy) -static uint32_t context_create(int fd) -{ - struct local_drm_i915_context_create create; - int ret; - - ret = drmIoctl(fd, CONTEXT_CREATE_IOCTL, &create); - if (ret == -1 && (errno == ENODEV || errno == EINVAL)) - igt_skip(); - else if (ret) - abort(); - - return create.ctx_id; -} - static void handle_bad(int ret, int lerrno, int expected, const char *desc) { if (ret != 0 && lerrno != expected) { @@ -84,7 +64,7 @@ int main(int argc, char *argv[]) fd = drm_open_any(); - ctx_id = context_create(fd); + ctx_id = gem_context_create(fd); destroy.ctx_id = ctx_id; /* Make sure a proper destroy works first */ diff --git a/tests/gem_ctx_bad_exec.c b/tests/gem_ctx_bad_exec.c index 8e80a620..348b2f8f 100644 --- a/tests/gem_ctx_bad_exec.c +++ b/tests/gem_ctx_bad_exec.c @@ -46,28 +46,6 @@ #include "i915_drm.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) - -static uint32_t context_create(int fd) -{ - struct local_drm_i915_gem_context_create create; - int ret; - - ret = drmIoctl(fd, CONTEXT_CREATE_IOCTL, &create); - if (ret == -1 && (errno == ENODEV || errno == EINVAL)) { - igt_skip(); - } else if (ret) { - abort(); - } - - return create.ctx_id; -} - /* Copied from gem_exec_nop.c */ static int exec(int fd, uint32_t handle, int ring, int ctx_id) { @@ -116,7 +94,7 @@ int main(int argc, char *argv[]) igt_fixture { fd = drm_open_any(); - ctx_id = context_create(fd); + ctx_id = gem_context_create(fd); handle = gem_create(fd, 4096); gem_write(fd, handle, 0, batch, sizeof(batch)); diff --git a/tests/gem_ctx_exec.c b/tests/gem_ctx_exec.c index 2d1a7deb..7b5be567 100644 --- a/tests/gem_ctx_exec.c +++ b/tests/gem_ctx_exec.c @@ -45,33 +45,13 @@ #include "i915_drm.h" #include "drmtest.h" -struct local_drm_i915_gem_context_create { - __u32 ctx_id; - __u32 pad; -}; - struct local_drm_i915_gem_context_destroy { __u32 ctx_id; __u32 pad; }; -#define CONTEXT_CREATE_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2d, struct local_drm_i915_gem_context_create) #define CONTEXT_DESTROY_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2e, struct local_drm_i915_gem_context_destroy) -static uint32_t context_create(int fd) -{ - struct local_drm_i915_gem_context_create create; - int ret; - - ret = drmIoctl(fd, CONTEXT_CREATE_IOCTL, &create); - if (ret == -1 && (errno == ENODEV || errno == EINVAL)) - igt_skip(); - else if (ret) - abort(); - - return create.ctx_id; -} - static void context_destroy(int fd, uint32_t ctx_id) { struct local_drm_i915_gem_context_destroy destroy; @@ -125,14 +105,14 @@ int main(int argc, char *argv[]) fd = drm_open_any(); - ctx_id = context_create(fd); + ctx_id = gem_context_create(fd); handle = gem_create(fd, 4096); gem_write(fd, handle, 0, batch, sizeof(batch)); igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) == 0); context_destroy(fd, ctx_id); - ctx_id = context_create(fd); + ctx_id = gem_context_create(fd); igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) == 0); context_destroy(fd, ctx_id); |