summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drm-lease-manager/test/lease-manager-test.c83
-rw-r--r--drm-lease-manager/test/meson.build6
-rw-r--r--drm-lease-manager/test/test-drm-device.h12
3 files changed, 97 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..f6524ab 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,46 @@ 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);
+
+ ck_assert_str_eq(handles[0]->name, lconfig.lease_name);
+ 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 +528,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/meson.build b/drm-lease-manager/test/meson.build
index 7d42bec..bb97274 100644
--- a/drm-lease-manager/test/meson.build
+++ b/drm-lease-manager/test/meson.build
@@ -2,6 +2,10 @@ check_dep = dependency('check')
ls_inc = include_directories('..')
+test_c_args = [
+ '-Wno-missing-field-initializers', #not all tests explicitly initialize all lease config fields
+]
+
ls_objects = main.extract_objects(lease_server_files)
ls_test_sources = [
'lease-server-test.c',
@@ -12,6 +16,7 @@ ls_test = executable('lease-server-test',
sources: ls_test_sources,
objects: ls_objects,
dependencies: [check_dep, fff_dep, dlmcommon_dep, thread_dep],
+ c_args: test_c_args,
include_directories: ls_inc)
lm_objects = main.extract_objects(lease_manager_files)
@@ -24,6 +29,7 @@ lm_test = executable('lease-manager-test',
sources: lm_test_sources,
objects: lm_objects,
dependencies: [check_dep, fff_dep, dlmcommon_dep, drm_dep],
+ c_args: test_c_args,
include_directories: ls_inc)
test('DRM Lease manager - socket server test', ls_test, is_parallel: false)
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) \