[PATCH i-g-t RFC 12/13] tests/chamelium: Introduce test sleep

Louis Chauvet louis.chauvet at bootlin.com
Wed Jun 5 14:30:24 UTC 2024


Introduce a new test to ensures that if the display is changed during a
sleep, the new one is properly detected.

This is inspired from the v2 version.

Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
 lib/monitor_edids/monitor_edids_helper.h   |  3 +-
 tests/chamelium/v3/kms_chamelium_v3_edid.c | 56 ++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/lib/monitor_edids/monitor_edids_helper.h b/lib/monitor_edids/monitor_edids_helper.h
index ff5672058816..3e91cee423b8 100644
--- a/lib/monitor_edids/monitor_edids_helper.h
+++ b/lib/monitor_edids/monitor_edids_helper.h
@@ -12,8 +12,9 @@
 #define TESTS_CHAMELIUM_MONITOR_EDIDS_MONITOR_EDIDS_HELPER_H_
 
 #include <stdint.h>
+#include "igt.h"
 
-#include "chamelium/v2/igt_chamelium.h"
+struct chamelium_edid;
 
 /* Max Length can be increased as needed, when new EDIDs are added. */
 #define EDID_NAME_MAX_LEN 28
diff --git a/tests/chamelium/v3/kms_chamelium_v3_edid.c b/tests/chamelium/v3/kms_chamelium_v3_edid.c
index a85091a3c660..efd53b392f4f 100644
--- a/tests/chamelium/v3/kms_chamelium_v3_edid.c
+++ b/tests/chamelium/v3/kms_chamelium_v3_edid.c
@@ -154,6 +154,45 @@ static void edid_resolution_list(int drm_fd, struct igt_chamelium_rpc *chamelium
 	drmModeFreeConnector(connector);
 }
 
+static void test_suspend_resume_edid_change(int drm_fd, struct igt_chamelium_rpc *chamelium,
+					    struct chamelium_rpc_port_mapping *port_mapping,
+					    enum igt_suspend_state state,
+					    enum igt_suspend_test test)
+{
+	chamelium_edid_id base_edid, alt_edid;
+	drmModeConnectorPtr connector;
+
+	chamelium_reset_rpc(chamelium);
+
+	base_edid = chamelium_create_edid_rpc(chamelium, igt_kms_get_base_edid());
+	igt_assert(base_edid);
+	alt_edid = chamelium_create_edid_rpc(chamelium, igt_kms_get_alt_edid());
+	igt_assert(alt_edid);
+
+	chamelium_apply_edid_rpc(chamelium, port_mapping->port_id, base_edid);
+	chamelium_plug_rpc(chamelium, port_mapping->port_id);
+	connector = chamelium_rpc_port_mapping_get_connector(port_mapping, drm_fd);
+	igt_assert(igt_wait_for_connector_status(drm_fd, connector->connector_id, 10.0,
+						 DRM_MODE_CONNECTED));
+	drmModeFreeConnector(connector);
+	collect_and_compare_edid(drm_fd, port_mapping, igt_kms_get_base_edid());
+
+	chamelium_apply_edid_rpc(chamelium, port_mapping->port_id, alt_edid);
+
+	// Schedule the hpd pulse during the sleep state
+	chamelium_schedule_hpd_toggle_rpc(chamelium, port_mapping->port_id,
+					  igt_get_autoresume_delay(state) * 1000 / 2,
+					  true);
+	igt_system_suspend_autoresume(state, test);
+
+	connector = chamelium_rpc_port_mapping_get_connector(port_mapping, drm_fd);
+	igt_assert(igt_wait_for_connector_status(drm_fd, connector->connector_id, 10.0,
+						 DRM_MODE_CONNECTED));
+	drmModeFreeConnector(connector);
+
+	collect_and_compare_edid(drm_fd, port_mapping, igt_kms_get_alt_edid());
+}
+
 
 igt_main {
 	struct igt_chamelium_rpc *chamelium;
@@ -260,6 +299,23 @@ igt_main {
 		}
 	}
 
+	igt_describe("Check if hotplug during sleeping are correctly handled");
+	igt_subtest_with_dynamic("edid-edid-suspend-mem") {
+		struct chamelium_rpc_port_mapping *port, *tmp;
+		igt_list_for_each_entry_safe(port, tmp, chamelium_rpc_get_port_mapping(chamelium), link) {
+			igt_dynamic_f("port-%d", port->port_id) {
+				char *name;
+
+				name = chamelium_get_port_name_rpc(chamelium, port->port_id);
+				igt_info("Testing port %s (%s)\n", port->connector_name, name);
+				free(name);
+
+				test_suspend_resume_edid_change(drm_fd, chamelium, port, SUSPEND_STATE_MEM,
+								SUSPEND_TEST_NONE);
+			}
+		}
+	}
+
 	igt_fixture {
 		chamelium_rpc_uninit(chamelium);
 		drm_close_driver(drm_fd);

-- 
2.43.2



More information about the igt-dev mailing list