[PATCH i-g-t 38/39] lib/vkms: Test changing enabled device connectors
José Expósito
jose.exposito89 at gmail.com
Tue Feb 18 16:50:10 UTC 2025
Test that, once a VKMS device is enabled, the connector values, with
the exception of status, can't change and that deleting it or the
attached encoders doesn't change the VKMS device.
Connector hot-plug/unplug is not covered by this test.
Signed-off-by: José Expósito <jose.exposito89 at gmail.com>
---
lib/igt_vkms.c | 12 +++++++
lib/igt_vkms.h | 1 +
tests/vkms/vkms_configfs.c | 64 ++++++++++++++++++++++++++++++++++++++
3 files changed, 77 insertions(+)
diff --git a/lib/igt_vkms.c b/lib/igt_vkms.c
index 95fbf5773..af9197b23 100644
--- a/lib/igt_vkms.c
+++ b/lib/igt_vkms.c
@@ -703,6 +703,18 @@ void igt_vkms_device_add_connector(igt_vkms_t *dev, const char *name)
add_pipeline_item(dev, VKMS_PIPELINE_ITEM_CONNECTOR, name);
}
+/**
+ * igt_vkms_device_remove_connector:
+ * @dev: Device to remove the connector from
+ * @name: Connector name
+ *
+ * Remove an existing connector from the VKMS device.
+ */
+bool igt_vkms_device_remove_connector(igt_vkms_t *dev, const char *name)
+{
+ return remove_pipeline_item(dev, VKMS_PIPELINE_ITEM_CONNECTOR, name);
+}
+
/**
* igt_vkms_connector_get_status:
* @dev: Device the connector belongs to
diff --git a/lib/igt_vkms.h b/lib/igt_vkms.h
index b82282a11..f2233b91a 100644
--- a/lib/igt_vkms.h
+++ b/lib/igt_vkms.h
@@ -95,6 +95,7 @@ bool igt_vkms_encoder_detach_crtc(igt_vkms_t *dev, const char *encoder_name,
const char *crtc_name);
void igt_vkms_device_add_connector(igt_vkms_t *dev, const char *name);
+bool igt_vkms_device_remove_connector(igt_vkms_t *dev, const char *name);
int igt_vkms_connector_get_status(igt_vkms_t *dev, const char *name);
void igt_vkms_connector_set_status(igt_vkms_t *dev, const char *name,
int status);
diff --git a/tests/vkms/vkms_configfs.c b/tests/vkms/vkms_configfs.c
index be311e77e..47a6a81ff 100644
--- a/tests/vkms/vkms_configfs.c
+++ b/tests/vkms/vkms_configfs.c
@@ -1675,6 +1675,69 @@ static void test_enabled_encoder_cannot_change(void)
igt_vkms_device_destroy(dev);
}
+/**
+ * SUBTEST: enabled-connector-cannot-change
+ * Description: Test that, once a VKMS device is enabled, the connector values,
+ * with the exception of status, can't change and that deleting it
+ * or the attached encoders doesn't change the VKMS device.
+ * Connector hot-plug/unplug is not covered by this test.
+ */
+
+static void test_enabled_connector_cannot_change(void)
+{
+ igt_vkms_t *dev;
+
+ igt_vkms_config_t cfg = {
+ .device_name = __func__,
+ .planes = {
+ {
+ .name = "plane0",
+ .type = DRM_PLANE_TYPE_PRIMARY,
+ .possible_crtcs = { "crtc0"},
+ },
+ {
+ .name = "plane1",
+ .type = DRM_PLANE_TYPE_PRIMARY,
+ .possible_crtcs = { "crtc1"},
+ },
+ },
+ .crtcs = {
+ { .name = "crtc0" },
+ { .name = "crtc1" },
+ },
+ .encoders = {
+ { .name = "encoder0", .possible_crtcs = { "crtc0" } },
+ { .name = "encoder1", .possible_crtcs = { "crtc1" } },
+ },
+ .connectors = {
+ {
+ .name = "connector0",
+ .status = DRM_MODE_CONNECTED,
+ .possible_encoders = { "encoder0" },
+ },
+ },
+ };
+
+ dev = igt_vkms_device_create_from_config(&cfg);
+ igt_assert(dev);
+
+ igt_vkms_device_set_enabled(dev, true);
+ igt_assert(igt_vkms_device_is_enabled(dev));
+ assert_device_config(&cfg);
+
+ /* Try to change values */
+ igt_assert(!igt_vkms_connector_attach_encoder(dev, "connector0",
+ "encoder1"));
+
+ /* Deleting pipeline items doesn't affect the device */
+ igt_assert(igt_vkms_connector_detach_encoder(dev, "connector0",
+ "encoder0"));
+ igt_assert(igt_vkms_device_remove_connector(dev, "connector0"));
+ assert_device_config(&cfg);
+
+ igt_vkms_device_destroy(dev);
+}
+
igt_main
{
struct {
@@ -1715,6 +1778,7 @@ igt_main
{ "enabled-plane-cannot-change", test_enabled_plane_cannot_change },
{ "enabled-crtc-cannot-change", test_enabled_crtc_cannot_change },
{ "enabled-encoder-cannot-change", test_enabled_encoder_cannot_change },
+ { "enabled-connector-cannot-change", test_enabled_connector_cannot_change },
};
igt_fixture {
--
2.48.1
More information about the igt-dev
mailing list