[Intel-gfx] [PATCH igt] tests: Use igt_device_set_master

Chris Wilson chris at chris-wilson.co.uk
Fri Dec 8 18:11:59 UTC 2017


A few tests only require DRM_MASTER privileges for a subset of gen or
tests, and so open the device as normal and conditionally call
drmSetMaster. Translate these over to using igt_device_set_master(),
which includes a bit more debugging for when it fails.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/gem_exec_nop.c    | 3 ++-
 tests/gem_exec_params.c | 6 ++++--
 tests/gem_exec_store.c  | 3 ++-
 tests/gem_ringfill.c    | 3 ++-
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index b5f158078..668dcb949 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -26,6 +26,7 @@
  */
 
 #include "igt.h"
+#include "igt_device.h"
 #include "igt_rand.h"
 #include "igt_sysfs.h"
 
@@ -710,7 +711,7 @@ igt_main
 
 	igt_subtest("headless") {
 		/* Requires master for changing display modes */
-		igt_require(drmSetMaster(device) == 0);
+		igt_device_set_master(device);
 		headless(device, handle);
 	}
 
diff --git a/tests/gem_exec_params.c b/tests/gem_exec_params.c
index 5b72072b2..e1c48b408 100644
--- a/tests/gem_exec_params.c
+++ b/tests/gem_exec_params.c
@@ -26,6 +26,8 @@
  */
 
 #include "igt.h"
+#include "igt_device.h"
+
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -341,10 +343,10 @@ igt_main
 	}
 
 	igt_subtest("secure-non-master") {
-		do_or_die(drmDropMaster(fd));
+		igt_device_drop_master(fd);
 		execbuf.flags = I915_EXEC_RENDER | I915_EXEC_SECURE;
 		RUN_FAIL(EPERM);
-		do_or_die(drmSetMaster(fd));
+		igt_device_set_master(fd);
 		igt_assert(drmIoctl(fd,
 				    DRM_IOCTL_I915_GEM_EXECBUFFER2,
 				    &execbuf) == 0);
diff --git a/tests/gem_exec_store.c b/tests/gem_exec_store.c
index 545a4b561..31a2c0967 100644
--- a/tests/gem_exec_store.c
+++ b/tests/gem_exec_store.c
@@ -28,6 +28,7 @@
  */
 
 #include "igt.h"
+#include "igt_device.h"
 #include "igt_gt.h"
 #include <strings.h>
 
@@ -320,7 +321,7 @@ igt_main
 
 		gen = print_welcome(fd);
 		if (gen > 3 && gen < 6) /* ctg and ilk need secure batches */
-			igt_require(drmSetMaster(fd) == 0);
+			igt_device_set_master(fd);
 
 		igt_require_gem(fd);
 		igt_require(gem_can_store_dword(fd, 0));
diff --git a/tests/gem_ringfill.c b/tests/gem_ringfill.c
index 84cd49c19..c3376a675 100644
--- a/tests/gem_ringfill.c
+++ b/tests/gem_ringfill.c
@@ -32,6 +32,7 @@
  */
 
 #include "igt.h"
+#include "igt_device.h"
 #include "igt_gt.h"
 #include "igt_vgem.h"
 
@@ -360,7 +361,7 @@ igt_main
 		igt_require(gem_can_store_dword(fd, 0));
 		gen = intel_gen(intel_get_drm_devid(fd));
 		if (gen > 3 && gen < 6) { /* ctg and ilk need secure batches */
-			igt_require(drmSetMaster(fd) == 0);
+			igt_device_set_master(fd);
 			master = true;
 		}
 
-- 
2.15.1



More information about the Intel-gfx mailing list