Test checks scheduler time correctness using time API.
Signed-off-by: Ivan Khoronzhuk <[email protected]>
---
Patch is based on api-next, as it uses new time API.
test/validation/scheduler/scheduler.c | 47 +++++++++++++++++++++++++++++++++--
1 file changed, 45 insertions(+), 2 deletions(-)
diff --git a/test/validation/scheduler/scheduler.c
b/test/validation/scheduler/scheduler.c
index 2e157a5..5aa3818 100644
--- a/test/validation/scheduler/scheduler.c
+++ b/test/validation/scheduler/scheduler.c
@@ -48,6 +48,8 @@
#define CHAOS_NDX_TO_PTR(n) ((void *)(uintptr_t)n)
#define CHAOS_WAIT_FAIL (5 * ODP_TIME_SEC_IN_NS)
+#define ODP_WAIT_TOLERANCE 20000000
+
/* Test global variables */
typedef struct {
int num_workers;
@@ -114,13 +116,54 @@ static int exit_schedule_loop(void)
void scheduler_test_wait_time(void)
{
+ int i;
+ odp_queue_t queue;
uint64_t wait_time;
+ odp_queue_param_t qp;
+ odp_time_t lower_limit, upper_limit, tolerance;
+ odp_time_t start_time, end_time, diff, etalon_time;
+ /* check on read */
wait_time = odp_schedule_wait_time(0);
wait_time = odp_schedule_wait_time(1);
- wait_time = odp_schedule_wait_time((uint64_t)-1LL);
- CU_ASSERT(wait_time > 0);
+ /* check ODP_SCHED_NO_WAIT */
+ odp_queue_param_init(&qp);
+ queue = odp_queue_create("dummy_queue", ODP_QUEUE_TYPE_SCHED, &qp);
+ CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);
+
+ wait_time = odp_schedule_wait_time(ODP_TIME_SEC_IN_NS);
+ start_time = odp_time_local();
+ odp_schedule(&queue, ODP_SCHED_NO_WAIT);
+ end_time = odp_time_local();
+
+ diff = odp_time_diff(end_time, start_time);
+ tolerance = odp_time_local_from_ns(ODP_WAIT_TOLERANCE);
+ lower_limit = ODP_TIME_NULL;
+ upper_limit = tolerance;
+
+ CU_ASSERT(odp_time_cmp(diff, lower_limit) >= 0);
+ CU_ASSERT(odp_time_cmp(diff, upper_limit) <= 0);
+
+ /* check time correctness */
+ start_time = odp_time_local();
+ for (i = 1; i < 6; i++) {
+ odp_schedule(&queue, wait_time);
+ printf("%d..", i);
+ }
+ end_time = odp_time_local();
+
+ diff = odp_time_diff(end_time, start_time);
+ tolerance = odp_time_local_from_ns(ODP_WAIT_TOLERANCE);
+
+ etalon_time = odp_time_local_from_ns(5 * ODP_TIME_SEC_IN_NS);
+ lower_limit = odp_time_diff(etalon_time, tolerance);
+ upper_limit = odp_time_sum(etalon_time, tolerance);
+
+ CU_ASSERT(odp_time_cmp(diff, lower_limit) >= 0);
+ CU_ASSERT(odp_time_cmp(diff, upper_limit) <= 0);
+
+ CU_ASSERT_FATAL(odp_queue_destroy(queue) == 0);
}
void scheduler_test_num_prio(void)
--
1.9.1
_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp