diff mbox series

[API-NEXT,v4,2/2] validation: queue: test queue max_num per type

Message ID 20170413144051.22456-2-petri.savolainen@linaro.org
State Accepted
Commit 8367530231e7cd4c33c63b789a5ed8322b51e58f
Headers show
Series [API-NEXT,v4,1/2] api: queue: added queue size param | expand

Commit Message

Petri Savolainen April 13, 2017, 2:40 p.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.11.0
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c
index fcf4bf5b..1114c95c 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 1f7913a1..6a13c006 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)