[PATCH i-g-t v2 11/43] lib/vkms: Test CRTC default files
José Expósito
jose.exposito89 at gmail.com
Thu Mar 13 17:32:46 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 eb3830685..e780e4af2 100644
--- a/lib/igt_vkms.c
+++ b/lib/igt_vkms.c
@@ -226,6 +226,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
@@ -449,3 +464,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 b5f9a5b24..d44131407 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 76aa6e432..ab15f29f9 100644
--- a/tests/vkms/vkms_configfs.c
+++ b/tests/vkms/vkms_configfs.c
@@ -310,6 +310,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];
+
+ 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 {
@@ -323,6 +351,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.48.1
More information about the igt-dev
mailing list