Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH i-g-t 07/17] tests/gem_ctx_*: Use helpers
Date: Tue, 10 Feb 2015 19:05:50 +0100	[thread overview]
Message-ID: <1423591560-9471-7-git-send-email-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <1423591560-9471-1-git-send-email-daniel.vetter@ffwll.ch>

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 tests/gem_ctx_bad_destroy.c | 25 +++++--------------------
 tests/gem_ctx_create.c      | 11 ++---------
 tests/gem_ctx_exec.c        | 23 ++++-------------------
 3 files changed, 11 insertions(+), 48 deletions(-)

diff --git a/tests/gem_ctx_bad_destroy.c b/tests/gem_ctx_bad_destroy.c
index d848265c7802..368bf95f2fcb 100644
--- a/tests/gem_ctx_bad_destroy.c
+++ b/tests/gem_ctx_bad_destroy.c
@@ -38,18 +38,10 @@
 
 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
 {
-	struct local_drm_i915_context_destroy destroy;
 	uint32_t ctx_id;
-	int ret, fd;
+	int fd;
 
 	igt_skip_on_simulation();
 
@@ -57,24 +49,17 @@ igt_simple_main
 
 	ctx_id = gem_context_create(fd);
 
-	destroy.ctx_id = ctx_id;
 	/* Make sure a proper destroy works first */
-	ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
-	igt_assert(ret == 0);
+	gem_context_destroy(fd, ctx_id);
 
 	/* try double destroy */
-	ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
-	igt_assert(ret != 0 && errno == ENOENT);
+	igt_assert(__gem_context_destroy(fd, ctx_id) == -ENOENT);
 
 	/* destroy something random */
-	destroy.ctx_id = 2;
-	ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
-	igt_assert(ret != 0 && errno == ENOENT);
+	igt_assert(__gem_context_destroy(fd, 2) == -ENOENT);
 
 	/* Try to destroy the default context */
-	destroy.ctx_id = 0;
-	ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
-	igt_assert(ret != 0 && errno == ENOENT);
+	igt_assert(__gem_context_destroy(fd, 0) == -ENOENT);
 
 	close(fd);
 }
diff --git a/tests/gem_ctx_create.c b/tests/gem_ctx_create.c
index 522e7b1ca022..1c710fdebbf7 100644
--- a/tests/gem_ctx_create.c
+++ b/tests/gem_ctx_create.c
@@ -32,17 +32,10 @@
 #include "ioctl_wrappers.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
 {
 	int ret, fd;
-	struct local_drm_i915_gem_context_create create;
+	struct drm_i915_gem_context_create create;
 
 	igt_skip_on_simulation();
 
@@ -51,7 +44,7 @@ igt_simple_main
 
 	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_assert(ret == 0);
 	igt_assert(create.ctx_id != 0);
diff --git a/tests/gem_ctx_exec.c b/tests/gem_ctx_exec.c
index 7a6ed9b1f1d2..ca5bf640adaf 100644
--- a/tests/gem_ctx_exec.c
+++ b/tests/gem_ctx_exec.c
@@ -50,21 +50,6 @@
 
 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 */
 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. */
 		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));
 	}
 
@@ -191,12 +176,12 @@ igt_main
 		ctx_id = gem_context_create(fd);
 		igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) == 0);
 		gem_sync(fd, handle);
-		context_destroy(fd, ctx_id);
+		gem_context_destroy(fd, ctx_id);
 
 		ctx_id = gem_context_create(fd);
 		igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) == 0);
 		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);
 		gem_sync(fd, handle);
@@ -227,6 +212,6 @@ igt_main
 			gem_sync(fd, handle);
 		}
 
-		context_destroy(fd, ctx_id);
+		gem_context_destroy(fd, ctx_id);
 	}
 }
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-02-10 18:04 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 02/17] lib/ioctl: api polish for gem_context_has_param Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 03/17] lib/ioctl: gem_ prefix for igt_require_mmap_wc Daniel Vetter
2015-02-10 21:58   ` Chris Wilson
2015-02-11  8:37     ` Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 04/17] igt/ioctls: doc for gem_mmap Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 05/17] lib/ioctls: make gem_context_set/get_param infallible Daniel Vetter
2015-02-10 21:54   ` Chris Wilson
2015-02-11  8:42     ` Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 06/17] lib/ioctl: Add gem_context_destroy helpers Daniel Vetter
2015-02-10 18:05 ` Daniel Vetter [this message]
2015-02-10 18:05 ` [PATCH i-g-t 08/17] tests/gem_reset_stat: Use new ctx helpers Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 09/17] lib/ioctl: Document ctx param functions Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 10/17] tests: Add gem_ctx_param_basic Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 11/17] tests: Add invalid pad tests for ctx create/destroy Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 12/17] tests/gem_ppgtt: Start rcs before bcs for context tests Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 13/17] tests: Align subtest with naming convention Daniel Vetter
2015-02-10 21:53   ` Chris Wilson
2015-02-11  8:44     ` Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 14/17] lib/igt_aux: s/swap/igt_swap/ Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 15/17] tests/gem_wait: Adjust makefile Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 16/17] doc: Consolidate naming conventions into docbook Daniel Vetter
2015-02-10 18:06 ` [PATCH i-g-t 17/17] lib/igt_gt: Document and consolidate Daniel Vetter
2015-02-10 21:36 ` [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Chris Wilson
2015-02-10 21:56   ` Daniel Vetter
2015-02-10 21:59   ` [PATCH i-g-t] lib/chipset: Cache devid Daniel Vetter
2015-02-10 22:28     ` Chris Wilson
2015-02-10 22:37       ` Daniel Vetter
2015-02-10 22:39         ` Daniel Vetter
2015-02-10 22:45           ` Daniel Vetter
2015-02-10 22:50             ` Chris Wilson
2015-02-11  8:49               ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423591560-9471-7-git-send-email-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox