[igt-dev] [PATCH i-g-t 9/9] tests/kms_lease: exercise uevent

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


And make sure we get the LEASE=1 value, indicating a lessee change.

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

diff --git a/tests/kms_lease.c b/tests/kms_lease.c
index d082a7988eaa..26dfc6fa4a15 100644
--- a/tests/kms_lease.c
+++ b/tests/kms_lease.c
@@ -40,6 +40,8 @@
 #include <sys/time.h>
 #include <sys/wait.h>
 
+#include <libudev.h>
+
 #include <drm.h>
 
 IGT_TEST_DESCRIPTION("Test of CreateLease.");
@@ -976,6 +978,67 @@ static void implicit_plane_lease(data_t *data)
 	drmSetClientCap(data->master.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
 }
 
+static void lease_uevent(data_t *data)
+{
+	int lease_fd;
+	struct local_drm_mode_list_lessees mll;
+	struct udev_monitor *uevent_monitor;
+	struct udev *udev;
+	struct udev_device *dev;
+	const char *lease;
+	struct pollfd udev_fd;
+
+	udev = udev_new();
+	igt_assert(udev);
+
+	uevent_monitor = udev_monitor_new_from_netlink(udev, "udev");
+	igt_assert(uevent_monitor);
+
+	do_or_die(udev_monitor_filter_add_match_subsystem_devtype(uevent_monitor,
+								  "drm",
+								  "drm_minor"));
+	do_or_die(udev_monitor_enable_receiving(uevent_monitor));
+
+	/* netlink is not synchronous ... */
+	udev_fd.fd = udev_monitor_get_fd(uevent_monitor);
+	udev_fd.revents = 0;
+	udev_fd.events = POLLIN;
+
+	poll(&udev_fd, 1, 100);
+	dev = udev_monitor_receive_device(uevent_monitor);
+	igt_assert(!dev);
+
+	lease_fd = create_simple_lease(data->master.fd, data);
+
+	poll(&udev_fd, 1, 100);
+	dev = udev_monitor_receive_device(uevent_monitor);
+	igt_assert(!dev);
+
+	mll.pad = 0;
+	mll.count_lessees = 0;
+	mll.lessees_ptr = 0;
+	igt_assert_eq(list_lessees(data->master.fd, &mll), 0);
+	igt_assert_eq(mll.count_lessees, 1);
+
+	close(lease_fd);
+
+	poll(&udev_fd, 1, 100);
+	dev = udev_monitor_receive_device(uevent_monitor);
+	igt_assert(dev);
+
+	lease = udev_device_get_property_value(dev, "LEASE");
+	igt_assert(lease);
+	igt_assert(strcmp(lease, "1") == 0);
+
+	udev_device_unref(dev);
+
+	mll.lessees_ptr = 0;
+	igt_assert_eq(list_lessees(data->master.fd, &mll), 0);
+	igt_assert_eq(mll.count_lessees, 0);
+
+	udev_monitor_unref(uevent_monitor);
+}
+
 igt_main
 {
 	data_t data;
@@ -1023,4 +1086,7 @@ igt_main
 
 	igt_subtest("implicit-plane-lease")
 		implicit_plane_lease(&data);
+
+	igt_subtest("lease-uevent")
+		lease_uevent(&data);
 }
-- 
2.14.4



More information about the igt-dev mailing list