diff mbox

[PATCHv5,1/6] validation: odp_timer.c: avoid cunit warnings for late timeouts

Message ID 1423124161-18716-2-git-send-email-ola.liljedahl@linaro.org
State Accepted
Commit fb2c563dae28d6402b56062468ed532f9a6feb5d
Headers show

Commit Message

Ola Liljedahl Feb. 5, 2015, 8:15 a.m. UTC
Don't report late timeouts using CU_FAIL as this interferes with the cunit
test framework. Just count and report the number of late timeouts.

Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org>
---
(This document/code contribution attached is provided under the terms of
agreement LES-LTM-21309)

 test/validation/odp_timer.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c
index c0b6f67..c098b20 100644
--- a/test/validation/odp_timer.c
+++ b/test/validation/odp_timer.c
@@ -12,6 +12,7 @@ 
 #include <unistd.h>
 #include <odp.h>
 #include "odp_cunit_common.h"
+#include "test_debug.h"
 
 /** @private Timeout range in milliseconds (ms) */
 #define RANGE_MS 2000
@@ -28,6 +29,9 @@  static odp_pool_t tbp;
 /** @private Timer pool handle used by all threads */
 static odp_timer_pool_t tp;
 
+/** @private Count of timeouts delivered too late */
+static odp_atomic_u32_t ndelivtoolate;
+
 /** @private min() function */
 static int min(int a, int b)
 {
@@ -90,7 +94,8 @@  static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick)
 		if (tick < prev_tick) {
 			printf("Too late tick: %"PRIu64" prev_tick %"PRIu64"\n",
 			       tick, prev_tick);
-			CU_FAIL("Timeout delivered late");
+			/* We don't report late timeouts using CU_FAIL */
+			odp_atomic_inc_u32(&ndelivtoolate);
 		}
 	}
 
@@ -317,6 +322,9 @@  static void test_odp_timer_all(void)
 	/* Initialize barrier used by worker threads for synchronization */
 	odp_barrier_init(&test_barrier, num_workers);
 
+	/* Initialize the shared timeout counter */
+	odp_atomic_init_u32(&ndelivtoolate, 0);
+
 	/* Create and start worker threads */
 	pthrd_arg thrdarg;
 	thrdarg.testcase = 0;
@@ -325,6 +333,8 @@  static void test_odp_timer_all(void)
 
 	/* Wait for worker threads to exit */
 	odp_cunit_thread_exit(&thrdarg);
+	printf("Number of timeouts delivered/received too late: %u\n",
+	       odp_atomic_load_u32(&ndelivtoolate));
 
 	/* Check some statistics after the test */
 	if (odp_timer_pool_info(tp, &tpinfo) != 0)