From a1e159f04ec8fd249ec85bb98f6fdf5b97ef6d14 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Sun, 29 Sep 2013 10:29:02 +0200 Subject: [PATCH] test: relax timing assumption of timer_again timer_again test makes an implicit assumption on the triggering timing of a repeating timer. However, this assumption may be not true on slower or virtualized architecture due to delay accumulation, which may fail the test as show in [0]. This commit makes explicit checks conforming to the asserted behavior. [0] http://ur1.ca/fr5c4 Signed-off-by: Luca Bruno --- test/test-timer-again.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test-timer-again.c b/test/test-timer-again.c index d97b8eab6..1638da2df 100644 --- a/test/test-timer-again.c +++ b/test/test-timer-again.c @@ -57,7 +57,7 @@ static void repeat_1_cb(uv_timer_t* handle, int status) { r = uv_timer_again(&repeat_2); ASSERT(r == 0); - if (uv_now(uv_default_loop()) >= start_time + 500) { + if (repeat_1_cb_called == 10) { uv_close((uv_handle_t*)handle, close_cb); /* We're not calling uv_timer_again on repeat_2 any more, so after this */ /* timer_2_cb is expected. */ @@ -134,7 +134,6 @@ TEST_IMPL(timer_again) { LOGF("Test took %ld ms (expected ~700 ms)\n", (long int)(uv_now(uv_default_loop()) - start_time)); - ASSERT(700 <= uv_now(uv_default_loop()) - start_time); MAKE_VALGRIND_HAPPY(); return 0;