Bug 619031 - method-calls-in-thread test failing
authorRyan Lortie <desrt@desrt.ca>
Tue, 18 May 2010 21:25:43 +0000 (17:25 -0400)
committerRyan Lortie <desrt@desrt.ca>
Tue, 18 May 2010 21:25:43 +0000 (17:25 -0400)
The test was assuming that g_timeout_add() waited for at least the amount of
time given to it before running the function.  This is not the case -- the
function can be run as much as 1ms early.  Make the lower time bound asserted
in the test more permissive to account for this.

gio/tests/gdbus-threading.c

index 3fe0f7b..6bfda51 100644 (file)
@@ -364,6 +364,11 @@ on_proxy_appeared (GDBusConnection *connection,
    * a number of times. We do this so each set of calls add up to 4000
    * milliseconds.
    *
+   * The dbus test server that this code calls into uses glib timeouts
+   * to do the sleeping which have only a granularity of 1ms.  It is
+   * therefore possible to lose as much as 40ms; the test could finish
+   * in slightly less than 4 seconds.
+   *
    * We run this test twice - first with async calls in each thread, then
    * again with sync calls
    */
@@ -438,8 +443,8 @@ on_proxy_appeared (GDBusConnection *connection,
 
       //g_debug ("Elapsed time for %s = %d msec", n == 0 ? "async" : "sync", elapsed_msec);
 
-      /* elapsed_msec should be 4000 msec + change for overhead */
-      g_assert_cmpint (elapsed_msec, >=, 4000);
+      /* elapsed_msec should be 4000 msec +/- change for overhead/inaccuracy */
+      g_assert_cmpint (elapsed_msec, >=, 3950);
       g_assert_cmpint (elapsed_msec,  <, 5000);
 
       g_print (" ");