diff mbox series

[v3,2/2] validation: queue: test queue max_num per type

Message ID 1491214261-7177-2-git-send-email-petri.savolainen@linaro.org
State Superseded
Headers show
Series [v3,1/2] api: queue: added queue size param | expand

Commit Message

Petri Savolainen April 3, 2017, 10:11 a.m. UTC
Updated implementation and test with type specific number of
queues.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
 platform/linux-generic/odp_queue.c            |  2 ++
 test/common_plat/validation/api/queue/queue.c | 49 +++++++++++++++++----------
 2 files changed, 34 insertions(+), 17 deletions(-)

-- 
2.8.1
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c
index fcf4bf5..1114c95 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -175,6 +175,8 @@  int odp_queue_capability(odp_queue_capability_t *capa)
 	capa->max_ordered_locks = sched_fn->max_ordered_locks();
 	capa->max_sched_groups  = sched_fn->num_grps();
 	capa->sched_prios       = odp_schedule_num_prio();
+	capa->plain.max_num     = capa->max_queues;
+	capa->sched.max_num     = capa->max_queues;
 
 	return 0;
 }
diff --git a/test/common_plat/validation/api/queue/queue.c b/test/common_plat/validation/api/queue/queue.c
index 1f7913a..6a13c00 100644
--- a/test/common_plat/validation/api/queue/queue.c
+++ b/test/common_plat/validation/api/queue/queue.c
@@ -56,7 +56,7 @@  void queue_test_capa(void)
 	odp_queue_param_t qparams;
 	char name[ODP_QUEUE_NAME_LEN];
 	odp_queue_t queue[MAX_QUEUES];
-	uint32_t num_queues, i;
+	uint32_t num_queues, min, i, j;
 
 	memset(&capa, 0, sizeof(odp_queue_capability_t));
 	CU_ASSERT(odp_queue_capability(&capa) == 0);
@@ -65,34 +65,49 @@  void queue_test_capa(void)
 	CU_ASSERT(capa.max_ordered_locks != 0);
 	CU_ASSERT(capa.max_sched_groups != 0);
 	CU_ASSERT(capa.sched_prios != 0);
+	CU_ASSERT(capa.plain.max_num != 0);
+	CU_ASSERT(capa.sched.max_num != 0);
+
+	min = capa.plain.max_num;
+	if (min > capa.sched.max_num)
+		min = capa.sched.max_num;
+
+	CU_ASSERT(capa.max_queues >= min);
 
 	for (i = 0; i < ODP_QUEUE_NAME_LEN; i++)
 		name[i] = 'A' + (i % 26);
 
 	name[ODP_QUEUE_NAME_LEN - 1] = 0;
 
-	if (capa.max_queues > MAX_QUEUES)
-		num_queues = MAX_QUEUES;
-	else
-		num_queues = capa.max_queues;
-
 	odp_queue_param_init(&qparams);
 
-	for (i = 0; i < num_queues; i++) {
-		generate_name(name, i);
-		queue[i] = odp_queue_create(name, &qparams);
+	for (j = 0; j < 2; j++) {
+		if (j == 0) {
+			num_queues = capa.plain.max_num;
+		} else {
+			num_queues = capa.sched.max_num;
+			qparams.type = ODP_QUEUE_TYPE_SCHED;
+		}
+
+		if (num_queues > MAX_QUEUES)
+			num_queues = MAX_QUEUES;
 
-		if (queue[i] == ODP_QUEUE_INVALID) {
-			CU_FAIL("Queue create failed");
-			num_queues = i;
-			break;
+		for (i = 0; i < num_queues; i++) {
+			generate_name(name, i);
+			queue[i] = odp_queue_create(name, &qparams);
+
+			if (queue[i] == ODP_QUEUE_INVALID) {
+				CU_FAIL("Queue create failed");
+				num_queues = i;
+				break;
+			}
+
+			CU_ASSERT(odp_queue_lookup(name) != ODP_QUEUE_INVALID);
 		}
 
-		CU_ASSERT(odp_queue_lookup(name) != ODP_QUEUE_INVALID);
+		for (i = 0; i < num_queues; i++)
+			CU_ASSERT(odp_queue_destroy(queue[i]) == 0);
 	}
-
-	for (i = 0; i < num_queues; i++)
-		CU_ASSERT(odp_queue_destroy(queue[i]) == 0);
 }
 
 void queue_test_mode(void)