]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
tests: Allow timeout to be multiplied by an arbitrary factor
authorSimon McVittie <smcv@collabora.com>
Fri, 17 Aug 2018 14:48:50 +0000 (15:48 +0100)
committerSimon McVittie <smcv@collabora.com>
Tue, 11 Dec 2018 12:47:22 +0000 (12:47 +0000)
Running tests under instrumentation (libasan) or emulation (qemu)
is not fast.

Inspired by the --timeout-factor option in
<https://salsa.debian.org/ci-team/autopkgtest>.

Signed-off-by: Simon McVittie <smcv@collabora.com>
test/test-utils-glib.c

index 04d98aa549a028bb1c83af59da6c4cafd9fca994..083c9bfcd6ef5d989c068a475db6e19bf49b1e49 100644 (file)
@@ -576,6 +576,8 @@ static void
 set_timeout (guint factor)
 {
   static guint timeout = 0;
+  const gchar *env_factor_str;
+  guint64 env_factor = 1;
 
   /* Prevent tests from hanging forever. This is intended to be long enough
    * that any reasonable regression test on any reasonable hardware would
@@ -588,6 +590,18 @@ set_timeout (guint factor)
   if (RUNNING_ON_VALGRIND)
     factor = factor * 10;
 
+  env_factor_str = g_getenv ("DBUS_TEST_TIMEOUT_MULTIPLIER");
+
+  if (env_factor_str != NULL)
+    {
+      env_factor = g_ascii_strtoull (env_factor_str, NULL, 10);
+
+      if (env_factor == 0)
+        g_error ("Invalid DBUS_TEST_TIMEOUT_MULTIPLIER %s", env_factor_str);
+
+      factor = factor * env_factor;
+    }
+
   timeout = g_timeout_add_seconds (TIMEOUT * factor, time_out, NULL);
 #ifdef G_OS_UNIX
   /* The GLib main loop might not be running (we don't use it in every