tests/mainloop: Fix assertions to really avoid race conditions

As the comment says, we may be delayed an arbitrary amount of time on
non-idle systems; update the assertions to reflect this.

This should fix periodic failures in the gnome-ostree continuous
integration system.

https://bugzilla.gnome.org/700460
This commit is contained in:
Colin Walters 2013-07-11 11:07:17 -04:00
parent 405936632a
commit ff68fca9e9

View File

@ -193,12 +193,16 @@ test_timeouts (void)
g_main_loop_run (loop);
/* this is a race condition; under some circumstances we might not get 10
* 100ms runs in 1050 ms, so consider 9 as "close enough" */
g_assert_cmpint (a, >=, 9);
/* We may be delayed for an arbitrary amount of time - for example,
* it's possible for all timeouts to fire exactly once.
*/
g_assert_cmpint (a, >, 0);
g_assert_cmpint (a, >=, b);
g_assert_cmpint (b, >=, c);
g_assert_cmpint (a, <=, 10);
g_assert_cmpint (b, ==, 4);
g_assert_cmpint (c, ==, 3);
g_assert_cmpint (b, <=, 4);
g_assert_cmpint (c, <=, 3);
g_main_loop_unref (loop);
g_main_context_unref (ctx);