[igt-dev] [PATCH i-g-t 4/4] tests: Use igt_device_set/drop_master

Daniel Vetter daniel.vetter at ffwll.ch
Thu Feb 28 17:17:23 UTC 2019


Suggested by Chris.

Cc: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 tests/core_setmaster_vs_auth.c |  6 ++++--
 tests/kms_flip_event_leak.c    | 10 ++++------
 tests/kms_lease.c              | 11 ++++++-----
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/tests/core_setmaster_vs_auth.c b/tests/core_setmaster_vs_auth.c
index c335ddff3a2d..f9e97c7a57ef 100644
--- a/tests/core_setmaster_vs_auth.c
+++ b/tests/core_setmaster_vs_auth.c
@@ -39,6 +39,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <igt_device.h>
+
 IGT_TEST_DESCRIPTION("Check that drop/setMaster correctly transfer master "
 		     "state");
 
@@ -56,8 +58,8 @@ igt_simple_main
 
 	/* Open an fd an make it master */
 	master2 = drm_open_driver(DRIVER_ANY);
-	do_or_die(drmDropMaster(master1));
-	do_or_die(drmSetMaster(master2));
+	igt_device_drop_master(master1);
+	igt_device_set_master(master2);
 
 	/* Auth shouldn't work since we're authenticating with a different
 	 * master than the one we got the magic from. */
diff --git a/tests/kms_flip_event_leak.c b/tests/kms_flip_event_leak.c
index 50f880ad3738..ef9befdd481d 100644
--- a/tests/kms_flip_event_leak.c
+++ b/tests/kms_flip_event_leak.c
@@ -28,6 +28,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <igt_device.h>
 
 typedef struct {
 	int drm_fd;
@@ -63,11 +64,9 @@ static void test(data_t *data, enum pipe pipe, igt_output_t *output)
 
 	fd = drm_open_driver(DRIVER_ANY);
 
-	ret = drmDropMaster(data->drm_fd);
-	igt_assert_eq(ret, 0);
+	igt_device_drop_master(data->drm_fd);
 
-	ret = drmSetMaster(fd);
-	igt_assert_eq(ret, 0);
+	igt_device_set_master(fd);
 
 	igt_create_color_fb(fd, mode->hdisplay, mode->vdisplay,
 			    DRM_FORMAT_XRGB8888,
@@ -81,8 +80,7 @@ static void test(data_t *data, enum pipe pipe, igt_output_t *output)
 	ret = close(fd);
 	igt_assert_eq(ret, 0);
 
-	ret = drmSetMaster(data->drm_fd);
-	igt_assert_eq(ret, 0);
+	igt_device_set_master(data->drm_fd);
 
 	igt_plane_set_fb(primary, NULL);
 	igt_output_set_pipe(output, PIPE_ANY);
diff --git a/tests/kms_lease.c b/tests/kms_lease.c
index 4823121e8cf4..6546b21f31d7 100644
--- a/tests/kms_lease.c
+++ b/tests/kms_lease.c
@@ -43,6 +43,7 @@
 #include <libudev.h>
 
 #include <drm.h>
+#include <igt_device.h>
 
 IGT_TEST_DESCRIPTION("Test of CreateLease.");
 
@@ -877,7 +878,7 @@ static void master_vs_lease(data_t *data)
 	igt_assert(is_master(data->master.fd));
 	igt_assert(is_master(lease_fd));
 
-	do_or_die(drmDropMaster(data->master.fd));
+	igt_device_drop_master(data->master.fd);
 
 	igt_assert(!is_master(data->master.fd));
 	igt_assert(!is_master(lease_fd));
@@ -885,7 +886,7 @@ static void master_vs_lease(data_t *data)
 	igt_assert_eq(drmSetMaster(lease_fd), -1);
 	igt_assert_eq(errno, EINVAL);
 
-	do_or_die(drmSetMaster(data->master.fd));
+	igt_device_set_master(data->master.fd);
 
 	igt_assert(is_master(data->master.fd));
 	igt_assert(is_master(lease_fd));
@@ -908,8 +909,8 @@ static void multimaster_lease(data_t *data)
 
 	_create_simple_lease(master2_fd, data, -EACCES);
 
-	do_or_die(drmDropMaster(data->master.fd));
-	do_or_die(drmSetMaster(master2_fd));
+	igt_device_drop_master(data->master.fd);
+	igt_device_set_master(master2_fd);
 
 	igt_assert(!is_master(data->master.fd));
 	igt_assert(!is_master(lease_fd));
@@ -921,7 +922,7 @@ static void multimaster_lease(data_t *data)
 	close(master2_fd); /* close is an implicit DropMaster */
 	igt_assert(!is_master(lease2_fd));
 
-	do_or_die(drmSetMaster(data->master.fd));
+	igt_device_set_master(data->master.fd);
 	igt_assert(is_master(data->master.fd));
 	igt_assert(is_master(lease_fd));
 
-- 
2.14.4



More information about the igt-dev mailing list