diff mbox series

[6/8] qmi unit: Validate creation of services of the same type

Message ID 20240419164458.36078-6-steve.schrock@getcruise.com (mailing list archive)
State Accepted
Commit af2718346a2825e2264d9ca7fd63f13b3f1ff479
Headers show
Series [1/8] qmi unit: Link to dl | expand

Commit Message

Steve Schrock April 19, 2024, 4:44 p.m. UTC
Confirm that there are no problems when clients create services for
the same qmi type.
---
 unit/test-qmimodem-qmi.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/unit/test-qmimodem-qmi.c b/unit/test-qmimodem-qmi.c
index 0e15f898f845..8df8b56a79eb 100644
--- a/unit/test-qmimodem-qmi.c
+++ b/unit/test-qmimodem-qmi.c
@@ -221,8 +221,9 @@  static void perform_all_pending_work(void)
 static void test_create_services(const void *data)
 {
 	struct test_info *info = test_setup();
+	struct qmi_service *services[3];
 	uint32_t service_type;
-	int i;
+	size_t i;
 
 	perform_discovery(info);
 
@@ -256,6 +257,22 @@  static void test_create_services(const void *data)
 	perform_all_pending_work();
 	assert(l_queue_isempty(info->services));
 
+	/* Confirm that multiple services may be created for the same type */
+	service_type = unique_service_type(0);
+
+	for (i = 0; i < L_ARRAY_SIZE(services); i++) {
+		assert(qmi_service_create(info->device, service_type,
+						create_service_cb, info, NULL));
+		perform_all_pending_work();
+
+		assert(l_queue_length(info->services) == 1);
+		services[i] = l_queue_pop_head(info->services);
+		assert(services[i]);
+	}
+
+	for (i = 0; i < L_ARRAY_SIZE(services); i++)
+		qmi_service_unref(services[i]);
+
 	test_cleanup(info);
 }