aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamian Hobson-Garcia <dhobsong@igel.co.jp>2022-04-05 12:11:37 +0900
committerDamian Hobson-Garcia <dhobsong@igel.co.jp>2022-04-05 12:15:20 +0900
commitfc95ae0d89c3aeec26398dfe2eb2bd0a3f2d53e3 (patch)
treee566da1eada96977897c5ec53bf8b2fbed262b58
parent1dfb4cdb60a4531f709b0e4986e5f1a515a7e6d4 (diff)
test/lease-manager: Add named lease tests
Add tests for named connectors in lease configurations. Also ensure that the naming convention is not broken when no lease configuration is given. Change-Id: I1e4c591183a2f0c155bedc6b71a37b37a2b01451 Signed-off-by: Damian Hobson-Garcia <dhobsong@igel.co.jp>
-rw-r--r--drm-lease-manager/test/lease-manager-test.c82
-rw-r--r--drm-lease-manager/test/test-drm-device.h12
2 files changed, 90 insertions, 4 deletions
diff --git a/drm-lease-manager/test/lease-manager-test.c b/drm-lease-manager/test/lease-manager-test.c
index eb4f1b3..c23d362 100644
--- a/drm-lease-manager/test/lease-manager-test.c
+++ b/drm-lease-manager/test/lease-manager-test.c
@@ -360,6 +360,47 @@ START_TEST(create_and_revoke_lease)
}
END_TEST
+/* Test lease names */
+/* Test details: Create some leases and verify that they have the correct names
+ * Expected results: lease names should match the expected values
+ */
+START_TEST(verify_lease_names)
+{
+ int lease_cnt = 3;
+ bool res = setup_drm_test_device(lease_cnt, lease_cnt, lease_cnt, 0);
+ ck_assert_int_eq(res, true);
+
+ drmModeConnector connectors[] = {
+ CONNECTOR_FULL(CONNECTOR_ID(0), ENCODER_ID(0), &ENCODER_ID(0), 1,
+ DRM_MODE_CONNECTOR_HDMIA, 1),
+ CONNECTOR_FULL(CONNECTOR_ID(1), ENCODER_ID(1), &ENCODER_ID(1), 1,
+ DRM_MODE_CONNECTOR_LVDS, 3),
+ CONNECTOR_FULL(CONNECTOR_ID(2), ENCODER_ID(2), &ENCODER_ID(2), 1,
+ DRM_MODE_CONNECTOR_eDP, 6),
+ };
+
+ drmModeEncoder encoders[] = {
+ ENCODER(ENCODER_ID(0), CRTC_ID(0), 0x7),
+ ENCODER(ENCODER_ID(1), CRTC_ID(1), 0x7),
+ ENCODER(ENCODER_ID(2), CRTC_ID(2), 0x7),
+ };
+
+ setup_test_device_layout(connectors, encoders, NULL);
+
+ const char *expected_names[] = {
+ "card3-HDMI-A-1",
+ "card3-LVDS-3",
+ "card3-eDP-6",
+ };
+
+ struct lease_handle **handles = create_leases(lease_cnt, NULL);
+
+ for (int i = 0; i < lease_cnt; i++) {
+ ck_assert_str_eq(handles[i]->name, expected_names[i]);
+ }
+}
+END_TEST
+
static void add_lease_management_tests(Suite *s)
{
TCase *tc = tcase_create("Lease management");
@@ -367,6 +408,7 @@ static void add_lease_management_tests(Suite *s)
tcase_add_checked_fixture(tc, test_setup, test_shutdown);
tcase_add_test(tc, create_and_revoke_lease);
+ tcase_add_test(tc, verify_lease_names);
suite_add_tcase(s, tc);
}
@@ -438,6 +480,45 @@ START_TEST(single_failed_lease)
}
END_TEST
+/* named_connector_config */
+/* Test details: Test specifying connectors by name in config
+ * Expected results: A handle is created for each named connector
+ */
+
+START_TEST(named_connector_config)
+{
+ int out_cnt = 2, plane_cnt = 0, lease_cnt = 1;
+
+ ck_assert_int_eq(
+ setup_drm_test_device(out_cnt, out_cnt, out_cnt, plane_cnt), true);
+
+ drmModeConnector connectors[] = {
+ CONNECTOR_FULL(CONNECTOR_ID(0), ENCODER_ID(0), &ENCODER_ID(0), 1,
+ DRM_MODE_CONNECTOR_HDMIA, 1),
+ CONNECTOR_FULL(CONNECTOR_ID(1), ENCODER_ID(1), &ENCODER_ID(1), 1,
+ DRM_MODE_CONNECTOR_VGA, 3),
+ };
+
+ drmModeEncoder encoders[] = {
+ ENCODER(ENCODER_ID(0), CRTC_ID(0), 0x1),
+ ENCODER(ENCODER_ID(1), CRTC_ID(1), 0x2),
+ };
+
+ setup_test_device_layout(connectors, encoders, NULL);
+
+ struct lease_config lconfig = {
+ .lease_name = "Lease Config Test 1",
+ .cnames = 2,
+ .connector_names = (char *[]){"HDMI-A-1", "VGA-3"},
+ };
+
+ struct lease_handle **handles = create_leases(lease_cnt, &lconfig);
+
+ CHECK_LEASE_OBJECTS(handles[0], CRTC_ID(0), CONNECTOR_ID(0), CRTC_ID(1),
+ CONNECTOR_ID(1));
+}
+END_TEST
+
static void add_lease_config_tests(Suite *s)
{
TCase *tc = tcase_create("Lease configuration");
@@ -446,6 +527,7 @@ static void add_lease_config_tests(Suite *s)
tcase_add_test(tc, multiple_connector_lease);
tcase_add_test(tc, single_failed_lease);
+ tcase_add_test(tc, named_connector_config);
suite_add_tcase(s, tc);
}
diff --git a/drm-lease-manager/test/test-drm-device.h b/drm-lease-manager/test/test-drm-device.h
index e2e5f52..897e0f7 100644
--- a/drm-lease-manager/test/test-drm-device.h
+++ b/drm-lease-manager/test/test-drm-device.h
@@ -63,10 +63,14 @@ int create_lease(int fd, const uint32_t *objects, int num_objects, int flags,
#define PLANE_ID(x) (test_device.plane_resources.planes[x])
#define LESSEE_ID(x) (test_device.leases.lessee_ids[x])
-#define CONNECTOR(cid, eid, encs, enc_cnt) \
- { \
- .connector_id = cid, .encoder_id = eid, \
- .count_encoders = enc_cnt, .encoders = encs, \
+#define CONNECTOR(cid, eid, encs, enc_cnt) \
+ CONNECTOR_FULL(cid, eid, encs, enc_cnt, DRM_MODE_CONNECTOR_Unknown, cid)
+
+#define CONNECTOR_FULL(cid, eid, encs, enc_cnt, type, type_id) \
+ { \
+ .connector_id = cid, .encoder_id = eid, \
+ .count_encoders = enc_cnt, .encoders = encs, \
+ .connector_type = type, .connector_type_id = type_id, \
}
#define ENCODER(eid, crtc, crtc_mask) \