[igt-dev] [PATCH i-g-t 6/9] tests/kms_lease: Test drop/set_master interactions

Daniel Vetter daniel.vetter at ffwll.ch
Wed Feb 20 16:25:27 UTC 2019


- make sure leases change master status together with lessor
- make sure lease can't change the master status

Cc: Keith Packard <keithp at keithp.com>
Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
---
 tests/kms_lease.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/tests/kms_lease.c b/tests/kms_lease.c
index 207a598d6f5a..e69964dd3990 100644
--- a/tests/kms_lease.c
+++ b/tests/kms_lease.c
@@ -834,6 +834,48 @@ static void possible_crtcs_filtering(data_t *data)
 	drmModeFreeResources(resources);
 }
 
+static bool is_master(int fd)
+{
+	/* FIXME: replace with drmIsMaster once we bumped libdrm version */
+	return drmAuthMagic(fd, 0) != -EACCES;
+}
+static void master_vs_lease(data_t *data)
+{
+	uint32_t object_ids[3];
+	struct local_drm_mode_create_lease mcl;
+
+	object_ids[0] = data->master.display.pipes[0].crtc_id;
+	object_ids[1] = data->master.display.outputs[0].id;
+	object_ids[2] = igt_pipe_get_plane_type(&data->master.display.pipes[0],
+						DRM_PLANE_TYPE_PRIMARY)->drm_plane->plane_id;
+	mcl.object_ids = (uint64_t) (uintptr_t) object_ids;
+	mcl.object_count = 3;
+	mcl.flags = 0;
+
+	igt_assert_eq(create_lease(data->master.fd, &mcl), 0);
+
+	igt_assert_eq(drmDropMaster(mcl.fd), -1);
+	igt_assert_eq(errno, EINVAL);
+
+	igt_assert(is_master(data->master.fd));
+	igt_assert(is_master(mcl.fd));
+
+	do_or_die(drmDropMaster(data->master.fd));
+
+	igt_assert(!is_master(data->master.fd));
+	igt_assert(!is_master(mcl.fd));
+
+	igt_assert_eq(drmSetMaster(mcl.fd), -1);
+	igt_assert_eq(errno, EINVAL);
+
+	do_or_die(drmSetMaster(data->master.fd));
+
+	igt_assert(is_master(data->master.fd));
+	igt_assert(is_master(mcl.fd));
+
+	close(mcl.fd);
+}
+
 igt_main
 {
 	data_t data;
@@ -872,4 +914,7 @@ igt_main
 
 	igt_subtest("possible-crtcs-filtering")
 		possible_crtcs_filtering(&data);
+
+	igt_subtest("master-vs-lease")
+		master_vs_lease(&data);
 }
-- 
2.14.4



More information about the igt-dev mailing list