[PATCH i-g-t v4 09/41] lib/vkms: Test CRTC default files
José Expósito
jose.exposito89 at gmail.com
Thu Aug 7 07:45:18 UTC 2025
Add a helper to create a CRTC and a test checking that the default
files and directories are created.
Reviewed-by: Louis Chauvet <louis.chauvet at bootlin.com>
Signed-off-by: José Expósito <jose.exposito89 at gmail.com>
---
lib/igt_vkms.c | 27 +++++++++++++++++++++++++++
lib/igt_vkms.h | 4 ++++
tests/vkms/vkms_configfs.c | 29 +++++++++++++++++++++++++++++
3 files changed, 60 insertions(+)
diff --git a/lib/igt_vkms.c b/lib/igt_vkms.c
index 2c9ab607e..0c193e33f 100644
--- a/lib/igt_vkms.c
+++ b/lib/igt_vkms.c
@@ -225,6 +225,21 @@ void igt_vkms_get_plane_type_path(igt_vkms_t *dev, const char *name, char *path,
VKMS_FILE_PLANE_TYPE, path, len);
}
+/**
+ * igt_vkms_get_crtc_path:
+ * @dev: Device containing the CRTC
+ * @name: CRTC name
+ * @path: Output path
+ * @len: Maximum @path length
+ *
+ * Returns the plane path.
+ */
+void igt_vkms_get_crtc_path(igt_vkms_t *dev, const char *name, char *path,
+ size_t len)
+{
+ get_pipeline_item_path(dev, VKMS_PIPELINE_ITEM_CRTC, name, path, len);
+}
+
/**
* igt_vkms_device_create:
* @name: VKMS device name
@@ -448,3 +463,15 @@ void igt_vkms_plane_set_type(igt_vkms_t *dev, const char *name, int type)
write_int(path, type);
}
+
+/**
+ * igt_vkms_device_add_crtc:
+ * @dev: Device to add the CRTC to
+ * @name: CRTC name
+ *
+ * Add a new CRTC to the VKMS device.
+ */
+void igt_vkms_device_add_crtc(igt_vkms_t *dev, const char *name)
+{
+ add_pipeline_item(dev, VKMS_PIPELINE_ITEM_CRTC, name);
+}
diff --git a/lib/igt_vkms.h b/lib/igt_vkms.h
index 95828fb11..1062675f3 100644
--- a/lib/igt_vkms.h
+++ b/lib/igt_vkms.h
@@ -27,6 +27,8 @@ void igt_vkms_get_plane_path(igt_vkms_t *dev, const char *name, char *path,
size_t len);
void igt_vkms_get_plane_type_path(igt_vkms_t *dev, const char *name, char *path,
size_t len);
+void igt_vkms_get_crtc_path(igt_vkms_t *dev, const char *name, char *path,
+ size_t len);
igt_vkms_t *igt_vkms_device_create(const char *name);
void igt_vkms_device_destroy(igt_vkms_t *dev);
@@ -39,4 +41,6 @@ void igt_vkms_device_add_plane(igt_vkms_t *dev, const char *name);
int igt_vkms_plane_get_type(igt_vkms_t *dev, const char *name);
void igt_vkms_plane_set_type(igt_vkms_t *dev, const char *name, int type);
+void igt_vkms_device_add_crtc(igt_vkms_t *dev, const char *name);
+
#endif /* __IGT_VKMS_H__ */
diff --git a/tests/vkms/vkms_configfs.c b/tests/vkms/vkms_configfs.c
index 6adb74213..6fd0350a4 100644
--- a/tests/vkms/vkms_configfs.c
+++ b/tests/vkms/vkms_configfs.c
@@ -309,6 +309,34 @@ static void test_plane_valid_values(void)
igt_vkms_device_destroy(dev);
}
+/**
+ * SUBTEST: crtc-default-files
+ * Description: Test that creating a CRTC creates the default files and
+ * directories.
+ */
+
+static void test_crtc_default_files(void)
+{
+ igt_vkms_t *dev;
+ char path[PATH_MAX];
+
+ static const char *files[] = {
+ "writeback",
+ };
+
+ dev = igt_vkms_device_create(__func__);
+ igt_assert(dev);
+
+ igt_vkms_device_add_crtc(dev, "crtc0");
+ igt_vkms_get_crtc_path(dev, "crtc0", path, sizeof(path));
+
+ assert_default_files(path,
+ files, ARRAY_SIZE(files),
+ NULL, 0);
+
+ igt_vkms_device_destroy(dev);
+}
+
igt_main
{
struct {
@@ -322,6 +350,7 @@ igt_main
{ "plane-default-values", test_plane_default_values },
{ "plane-wrong-values", test_plane_wrong_values },
{ "plane-valid-values", test_plane_valid_values },
+ { "crtc-default-files", test_crtc_default_files },
};
igt_fixture {
--
2.50.1
More information about the igt-dev
mailing list