aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>2015-07-24 16:31:34 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-08-04 15:30:27 +0300
commit3b09d8928f599c80cae0aa46be8db8ccaf5d800a (patch)
tree9530723b46ffbc3f6b07caa7ce14368a388e92f2
parent6788a0e25b2f9c244668cf3d6f71d0f2eaefd32f (diff)
example: timer: use ability to indicate that event was lost
In case if for some reason one of the TMOs was lost, the test will be polling forever in order to take it and delete. It can be used to indicate that event was lost. Just abort the test if it cannot receive one of the "last" TMOs for some period. Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r--example/timer/odp_timer_test.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index 5d04686e0..933dc3b9e 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -21,6 +21,7 @@
#define MAX_WORKERS 32 /**< Max worker threads */
#define NUM_TMOS 10000 /**< Number of timers */
+#define WAIT_NUM 10 /**< Max tries to rx last tmo per worker */
/** Test arguments */
@@ -88,6 +89,7 @@ static void test_abs_timeouts(int thr, test_globals_t *gbls)
uint64_t tick;
struct test_timer *ttp;
odp_timeout_t tmo;
+ uint32_t num_workers = gbls->num_workers;
EXAMPLE_DBG(" [%i] test_timeouts\n", thr);
@@ -117,6 +119,7 @@ static void test_abs_timeouts(int thr, test_globals_t *gbls)
tick = odp_timer_current_tick(gbls->tp);
while (1) {
+ int wait = 0;
odp_event_t ev;
odp_timer_set_t rc;
@@ -142,6 +145,9 @@ static void test_abs_timeouts(int thr, test_globals_t *gbls)
ev = odp_schedule(&queue, sched_tmo);
/* Check if odp_schedule() timed out, possibly there
* are no remaining timeouts to receive */
+ if (++wait > WAIT_NUM &&
+ odp_atomic_load_u32(&gbls->remain) < num_workers)
+ EXAMPLE_ABORT("At least one TMO was lost\n");
} while (ev == ODP_EVENT_INVALID &&
(int)odp_atomic_load_u32(&gbls->remain) > 0);
@@ -169,7 +175,7 @@ static void test_abs_timeouts(int thr, test_globals_t *gbls)
if (!rx_num)
EXAMPLE_ABORT("Unexpected timeout received (timer %x, tick %"PRIu64")\n",
ttp->tim, tick);
- else if (rx_num > gbls->num_workers)
+ else if (rx_num > num_workers)
continue;
odp_timeout_free(odp_timeout_from_event(ttp->ev));