[PATCH i-g-t v2 24/43] tests/vkms_configfs: Test enablement without pipeline items

José Expósito jose.exposito89 at gmail.com
Thu Mar 13 17:32:59 UTC 2025


It shouldn't be possible to enable a device without creating and
attaching its pipeline items.

Test that the device is not enabled and also that no actual device was
created using libdrm.

Signed-off-by: José Expósito <jose.exposito89 at gmail.com>
---
 tests/vkms/vkms_configfs.c | 39 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/tests/vkms/vkms_configfs.c b/tests/vkms/vkms_configfs.c
index c36a795d6..c2cb9dbc0 100644
--- a/tests/vkms/vkms_configfs.c
+++ b/tests/vkms/vkms_configfs.c
@@ -22,6 +22,7 @@
 
 #include "drmtest.h"
 #include "igt.h"
+#include "igt_device_scan.h"
 #include "igt_vkms.h"
 
 struct invalid_value {
@@ -117,6 +118,20 @@ static bool attach(const char *src_path, const char *dst_path,
 	return ret == 0;
 }
 
+static bool find_device(const char *name, struct igt_device_card *card)
+{
+	igt_devices_scan();
+
+	return igt_device_find_card_by_sysname(name, card);
+}
+
+static bool device_exists(const char *name)
+{
+	struct igt_device_card card;
+
+	return find_device(name, &card);
+}
+
 /**
  * SUBTEST: device-default-files
  * Description: Test that creating a VKMS device creates the default files and
@@ -774,6 +789,29 @@ static void test_attach_connector_to_encoder(void)
 	igt_vkms_device_destroy(dev2);
 }
 
+/**
+ * SUBTEST: enable-no-pipeline-items
+ * Description: Try to enable a VKMS device without adding any pipeline items
+ *              and test that it fails.
+ */
+
+static void test_enable_no_pipeline_items(void)
+{
+	igt_vkms_t *dev;
+
+	dev = igt_vkms_device_create(__func__);
+	igt_assert(dev);
+
+	/* Try to enable it and check that the device is not set as enabled */
+	igt_vkms_device_set_enabled(dev, true);
+	igt_assert(!igt_vkms_device_is_enabled(dev));
+
+	/* Check that no actual device was created*/
+	igt_assert(!device_exists(__func__));
+
+	igt_vkms_device_destroy(dev);
+}
+
 igt_main
 {
 	struct {
@@ -799,6 +837,7 @@ igt_main
 		{ "attach-plane-to-crtc", test_attach_plane_to_crtc },
 		{ "attach-encoder-to-crtc", test_attach_encoder_to_crtc },
 		{ "attach-connector-to-encoder", test_attach_connector_to_encoder },
+		{ "enable-no-pipeline-items", test_enable_no_pipeline_items },
 	};
 
 	igt_fixture {
-- 
2.48.1



More information about the igt-dev mailing list