mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-10 01:16:18 +00:00
tests/gem_ctx_*: Use helpers
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
09b8211d41
commit
ccc4261dc3
@ -38,18 +38,10 @@
|
|||||||
|
|
||||||
IGT_TEST_DESCRIPTION("Negative test cases for destroy contexts.");
|
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
|
igt_simple_main
|
||||||
{
|
{
|
||||||
struct local_drm_i915_context_destroy destroy;
|
|
||||||
uint32_t ctx_id;
|
uint32_t ctx_id;
|
||||||
int ret, fd;
|
int fd;
|
||||||
|
|
||||||
igt_skip_on_simulation();
|
igt_skip_on_simulation();
|
||||||
|
|
||||||
@ -57,24 +49,17 @@ igt_simple_main
|
|||||||
|
|
||||||
ctx_id = gem_context_create(fd);
|
ctx_id = gem_context_create(fd);
|
||||||
|
|
||||||
destroy.ctx_id = ctx_id;
|
|
||||||
/* Make sure a proper destroy works first */
|
/* Make sure a proper destroy works first */
|
||||||
ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
|
gem_context_destroy(fd, ctx_id);
|
||||||
igt_assert(ret == 0);
|
|
||||||
|
|
||||||
/* try double destroy */
|
/* try double destroy */
|
||||||
ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
|
igt_assert(__gem_context_destroy(fd, ctx_id) == -ENOENT);
|
||||||
igt_assert(ret != 0 && errno == ENOENT);
|
|
||||||
|
|
||||||
/* destroy something random */
|
/* destroy something random */
|
||||||
destroy.ctx_id = 2;
|
igt_assert(__gem_context_destroy(fd, 2) == -ENOENT);
|
||||||
ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
|
|
||||||
igt_assert(ret != 0 && errno == ENOENT);
|
|
||||||
|
|
||||||
/* Try to destroy the default context */
|
/* Try to destroy the default context */
|
||||||
destroy.ctx_id = 0;
|
igt_assert(__gem_context_destroy(fd, 0) == -ENOENT);
|
||||||
ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
|
|
||||||
igt_assert(ret != 0 && errno == ENOENT);
|
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
@ -32,17 +32,10 @@
|
|||||||
#include "ioctl_wrappers.h"
|
#include "ioctl_wrappers.h"
|
||||||
#include "drmtest.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
|
igt_simple_main
|
||||||
{
|
{
|
||||||
int ret, fd;
|
int ret, fd;
|
||||||
struct local_drm_i915_gem_context_create create;
|
struct drm_i915_gem_context_create create;
|
||||||
|
|
||||||
igt_skip_on_simulation();
|
igt_skip_on_simulation();
|
||||||
|
|
||||||
@ -51,7 +44,7 @@ igt_simple_main
|
|||||||
|
|
||||||
fd = drm_open_any_render();
|
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_skip_on(ret != 0 && (errno == ENODEV || errno == EINVAL));
|
||||||
igt_assert(ret == 0);
|
igt_assert(ret == 0);
|
||||||
igt_assert(create.ctx_id != 0);
|
igt_assert(create.ctx_id != 0);
|
||||||
|
@ -50,21 +50,6 @@
|
|||||||
|
|
||||||
IGT_TEST_DESCRIPTION("Test basic context switch functionality.");
|
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 */
|
/* Copied from gem_exec_nop.c */
|
||||||
static int exec(int fd, uint32_t handle, int ring, int ctx_id)
|
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. */
|
/* check that we can create contexts. */
|
||||||
ctx_id = gem_context_create(fd);
|
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));
|
gem_write(fd, handle, 0, batch, sizeof(batch));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,12 +176,12 @@ igt_main
|
|||||||
ctx_id = gem_context_create(fd);
|
ctx_id = gem_context_create(fd);
|
||||||
igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) == 0);
|
igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) == 0);
|
||||||
gem_sync(fd, handle);
|
gem_sync(fd, handle);
|
||||||
context_destroy(fd, ctx_id);
|
gem_context_destroy(fd, ctx_id);
|
||||||
|
|
||||||
ctx_id = gem_context_create(fd);
|
ctx_id = gem_context_create(fd);
|
||||||
igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) == 0);
|
igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) == 0);
|
||||||
gem_sync(fd, handle);
|
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);
|
igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) < 0);
|
||||||
gem_sync(fd, handle);
|
gem_sync(fd, handle);
|
||||||
@ -227,6 +212,6 @@ igt_main
|
|||||||
gem_sync(fd, handle);
|
gem_sync(fd, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
context_destroy(fd, ctx_id);
|
gem_context_destroy(fd, ctx_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user