[PATCH i-g-t v4 11/41] lib/vkms: Test CRTC invalid values
José Expósito
jose.exposito89 at gmail.com
Thu Aug 7 07:45:20 UTC 2025
For a VKMS CRTC, it is only possible to set invalid values in the
writeback connector status.
Test that setting wrong values fails and that the CRTC status is not
accidentally changed.
Reviewed-by: Louis Chauvet <louis.chauvet at bootlin.com>
Signed-off-by: José Expósito <jose.exposito89 at gmail.com>
---
lib/igt_vkms.c | 18 ++++++++++++++++++
lib/igt_vkms.h | 2 ++
tests/vkms/vkms_configfs.c | 26 ++++++++++++++++++++++++++
3 files changed, 46 insertions(+)
diff --git a/lib/igt_vkms.c b/lib/igt_vkms.c
index 51eb48c44..0b8fd6500 100644
--- a/lib/igt_vkms.c
+++ b/lib/igt_vkms.c
@@ -508,3 +508,21 @@ bool igt_vkms_crtc_is_writeback_enabled(igt_vkms_t *dev, const char *name)
return read_bool(path);
}
+
+/**
+ * igt_vkms_crtc_set_writeback_enabled:
+ * @dev: Device the CRTC belongs to
+ * @name: CRTC name
+ * @writeback: Enable or disable the writeback connector
+ *
+ * Set the VKMS CRTC writeback connector is status.
+ */
+void igt_vkms_crtc_set_writeback_enabled(igt_vkms_t *dev, const char *name,
+ bool writeback)
+{
+ char path[PATH_MAX];
+
+ igt_vkms_get_crtc_writeback_path(dev, name, path, sizeof(path));
+
+ write_bool(path, writeback);
+}
diff --git a/lib/igt_vkms.h b/lib/igt_vkms.h
index 5d3610057..651339221 100644
--- a/lib/igt_vkms.h
+++ b/lib/igt_vkms.h
@@ -45,5 +45,7 @@ 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);
bool igt_vkms_crtc_is_writeback_enabled(igt_vkms_t *dev, const char *name);
+void igt_vkms_crtc_set_writeback_enabled(igt_vkms_t *dev, const char *name,
+ bool writeback);
#endif /* __IGT_VKMS_H__ */
diff --git a/tests/vkms/vkms_configfs.c b/tests/vkms/vkms_configfs.c
index ec5cc6ee7..0a62f3d02 100644
--- a/tests/vkms/vkms_configfs.c
+++ b/tests/vkms/vkms_configfs.c
@@ -356,6 +356,31 @@ static void test_crtc_default_values(void)
igt_vkms_device_destroy(dev);
}
+/**
+ * SUBTEST: crtc-wrong-values
+ * Description: Check that setting unexpected values doesn't work.
+ */
+
+static void test_crtc_wrong_values(void)
+{
+ igt_vkms_t *dev;
+ char path[PATH_MAX];
+
+ /* Test invalid values for "writeback" */
+ dev = igt_vkms_device_create(__func__);
+ igt_assert(dev);
+
+ igt_vkms_device_add_crtc(dev, "crtc0");
+ igt_vkms_crtc_set_writeback_enabled(dev, "crtc0", true);
+ igt_assert(igt_vkms_crtc_is_writeback_enabled(dev, "crtc0"));
+ igt_vkms_get_crtc_writeback_path(dev, "crtc0", path, sizeof(path));
+
+ assert_wrong_bool_values(path);
+ igt_assert(igt_vkms_crtc_is_writeback_enabled(dev, "crtc0"));
+
+ igt_vkms_device_destroy(dev);
+}
+
igt_main
{
struct {
@@ -371,6 +396,7 @@ igt_main
{ "plane-valid-values", test_plane_valid_values },
{ "crtc-default-files", test_crtc_default_files },
{ "crtc-default-values", test_crtc_default_values },
+ { "crtc-wrong-values", test_crtc_wrong_values },
};
igt_fixture {
--
2.50.1
More information about the igt-dev
mailing list