From c3d15a9eade40627a8ea5ded95068c6d2294cdf5 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 17 Aug 2018 15:48:50 +0100 Subject: [PATCH] tests: Allow timeout to be multiplied by an arbitrary factor Running tests under instrumentation (libasan) or emulation (qemu) is not fast. Inspired by the --timeout-factor option in . Signed-off-by: Simon McVittie --- test/test-utils-glib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test-utils-glib.c b/test/test-utils-glib.c index 04d98aa54..083c9bfcd 100644 --- a/test/test-utils-glib.c +++ b/test/test-utils-glib.c @@ -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 -- 2.47.3