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 <lucab@debian.org>
This commit is contained in:
parent
bddf357baf
commit
a1e159f04e
@ -57,7 +57,7 @@ static void repeat_1_cb(uv_timer_t* handle, int status) {
|
|||||||
r = uv_timer_again(&repeat_2);
|
r = uv_timer_again(&repeat_2);
|
||||||
ASSERT(r == 0);
|
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);
|
uv_close((uv_handle_t*)handle, close_cb);
|
||||||
/* We're not calling uv_timer_again on repeat_2 any more, so after this */
|
/* We're not calling uv_timer_again on repeat_2 any more, so after this */
|
||||||
/* timer_2_cb is expected. */
|
/* timer_2_cb is expected. */
|
||||||
@ -134,7 +134,6 @@ TEST_IMPL(timer_again) {
|
|||||||
|
|
||||||
LOGF("Test took %ld ms (expected ~700 ms)\n",
|
LOGF("Test took %ld ms (expected ~700 ms)\n",
|
||||||
(long int)(uv_now(uv_default_loop()) - start_time));
|
(long int)(uv_now(uv_default_loop()) - start_time));
|
||||||
ASSERT(700 <= uv_now(uv_default_loop()) - start_time);
|
|
||||||
|
|
||||||
MAKE_VALGRIND_HAPPY();
|
MAKE_VALGRIND_HAPPY();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user