aboutsummaryrefslogtreecommitdiff
path: root/test/validation/api/scheduler/scheduler.c
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@nokia.com>2019-02-07 10:31:24 +0200
committerMatias Elo <matiaselo@users.noreply.github.com>2019-02-13 09:35:05 +0200
commit695362d8a9aa83eb5cbd7ab1f72d3a3c670fb177 (patch)
tree2350b284e9f8aa1ac1c7d9633222143390eada59 /test/validation/api/scheduler/scheduler.c
parent486e4d5231eb84618ccf9ed2bf3ba1e9e2531bba (diff)
validation: sched: order ignore param test
Added simple, single threaded test to check that events from an ordered queue can be forwarded to a plain queue which ignores ordering (created with ODP_QUEUE_ORDER_IGNORE). Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com> Reviewed-by: Stanislaw Kardach <skardach@marvell.com>
Diffstat (limited to 'test/validation/api/scheduler/scheduler.c')
-rw-r--r--test/validation/api/scheduler/scheduler.c123
1 files changed, 119 insertions, 4 deletions
diff --git a/test/validation/api/scheduler/scheduler.c b/test/validation/api/scheduler/scheduler.c
index bdcd7b2dc..50238ffe8 100644
--- a/test/validation/api/scheduler/scheduler.c
+++ b/test/validation/api/scheduler/scheduler.c
@@ -23,7 +23,7 @@
#define NUM_GROUPS 2
#define MAX_QUEUES (64 * 1024)
-#define TEST_QUEUE_SIZE_NUM_EV 50
+#define DEFAULT_NUM_EV 50
#define MAX_FLOWS 16
#define FLOW_TEST_NUM_EV (10 * MAX_FLOWS)
@@ -437,7 +437,7 @@ static void scheduler_test_queue_size(void)
ODP_SCHED_SYNC_ORDERED};
CU_ASSERT_FATAL(odp_queue_capability(&queue_capa) == 0);
- queue_size = TEST_QUEUE_SIZE_NUM_EV;
+ queue_size = DEFAULT_NUM_EV;
odp_schedule_config_init(&default_config);
if (default_config.queue_size &&
queue_size > default_config.queue_size)
@@ -446,7 +446,7 @@ static void scheduler_test_queue_size(void)
odp_pool_param_init(&pool_param);
pool_param.buf.size = 100;
pool_param.buf.align = 0;
- pool_param.buf.num = TEST_QUEUE_SIZE_NUM_EV;
+ pool_param.buf.num = DEFAULT_NUM_EV;
pool_param.type = ODP_POOL_BUFFER;
pool = odp_pool_create("test_queue_size", &pool_param);
@@ -489,7 +489,7 @@ static void scheduler_test_queue_size(void)
}
num = 0;
- for (j = 0; j < 100 * TEST_QUEUE_SIZE_NUM_EV; j++) {
+ for (j = 0; j < 100 * DEFAULT_NUM_EV; j++) {
ev = odp_schedule(&from, ODP_SCHED_NO_WAIT);
if (ev == ODP_EVENT_INVALID)
@@ -507,6 +507,120 @@ static void scheduler_test_queue_size(void)
CU_ASSERT_FATAL(odp_pool_destroy(pool) == 0);
}
+static void scheduler_test_order_ignore(void)
+{
+ odp_queue_capability_t queue_capa;
+ odp_schedule_config_t default_config;
+ odp_pool_t pool;
+ odp_pool_param_t pool_param;
+ odp_queue_param_t queue_param;
+ odp_queue_t ordered, plain, from;
+ odp_event_t ev;
+ odp_buffer_t buf;
+ uint32_t j, queue_size, num;
+ int ret;
+
+ odp_schedule_config_init(&default_config);
+ CU_ASSERT_FATAL(odp_queue_capability(&queue_capa) == 0);
+
+ queue_size = DEFAULT_NUM_EV;
+ if (default_config.queue_size &&
+ queue_size > default_config.queue_size)
+ queue_size = default_config.queue_size;
+
+ if (queue_capa.plain.max_size &&
+ queue_size > queue_capa.plain.max_size)
+ queue_size = queue_capa.plain.max_size;
+
+ odp_pool_param_init(&pool_param);
+ pool_param.buf.size = 100;
+ pool_param.buf.align = 0;
+ pool_param.buf.num = DEFAULT_NUM_EV;
+ pool_param.type = ODP_POOL_BUFFER;
+
+ pool = odp_pool_create("test_order_ignore", &pool_param);
+
+ CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+ /* Ensure that scheduler is empty */
+ for (j = 0; j < 10;) {
+ ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT);
+ CU_ASSERT(ev == ODP_EVENT_INVALID);
+
+ if (ev != ODP_EVENT_INVALID)
+ odp_event_free(ev);
+ else
+ j++;
+ }
+
+ odp_queue_param_init(&queue_param);
+ queue_param.type = ODP_QUEUE_TYPE_SCHED;
+ queue_param.sched.prio = odp_schedule_default_prio();
+ queue_param.sched.sync = ODP_SCHED_SYNC_ORDERED;
+ queue_param.sched.group = ODP_SCHED_GROUP_ALL;
+
+ ordered = odp_queue_create("ordered", &queue_param);
+ CU_ASSERT_FATAL(ordered != ODP_QUEUE_INVALID);
+
+ odp_queue_param_init(&queue_param);
+ queue_param.type = ODP_QUEUE_TYPE_PLAIN;
+ queue_param.order = ODP_QUEUE_ORDER_IGNORE;
+
+ plain = odp_queue_create("plain", &queue_param);
+ CU_ASSERT_FATAL(plain != ODP_QUEUE_INVALID);
+
+ num = 0;
+ for (j = 0; j < queue_size; j++) {
+ buf = odp_buffer_alloc(pool);
+ CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID);
+
+ ev = odp_buffer_to_event(buf);
+ ret = odp_queue_enq(ordered, ev);
+
+ if (ret)
+ odp_event_free(ev);
+ else
+ num++;
+ }
+
+ CU_ASSERT(num == queue_size);
+
+ num = 0;
+ for (j = 0; j < 100 * DEFAULT_NUM_EV; j++) {
+ ev = odp_schedule(&from, ODP_SCHED_NO_WAIT);
+
+ if (ev == ODP_EVENT_INVALID)
+ continue;
+
+ CU_ASSERT(from == ordered);
+ ret = odp_queue_enq(plain, ev);
+
+ if (ret)
+ odp_event_free(ev);
+ else
+ num++;
+ }
+
+ CU_ASSERT(num == queue_size);
+
+ num = 0;
+ for (j = 0; j < 100 * DEFAULT_NUM_EV; j++) {
+ ev = odp_queue_deq(plain);
+
+ if (ev == ODP_EVENT_INVALID)
+ continue;
+
+ odp_event_free(ev);
+ num++;
+ }
+
+ CU_ASSERT(num == queue_size);
+
+ CU_ASSERT_FATAL(odp_queue_destroy(ordered) == 0);
+ CU_ASSERT_FATAL(odp_queue_destroy(plain) == 0);
+ CU_ASSERT_FATAL(odp_pool_destroy(pool) == 0);
+}
+
static void scheduler_test_groups(void)
{
odp_pool_t p;
@@ -2136,6 +2250,7 @@ odp_testinfo_t scheduler_suite[] = {
ODP_TEST_INFO(scheduler_test_queue_destroy),
ODP_TEST_INFO(scheduler_test_wait),
ODP_TEST_INFO(scheduler_test_queue_size),
+ ODP_TEST_INFO(scheduler_test_order_ignore),
ODP_TEST_INFO(scheduler_test_groups),
ODP_TEST_INFO(scheduler_test_pause_resume),
ODP_TEST_INFO(scheduler_test_ordered_lock),