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
<https://salsa.debian.org/ci-team/autopkgtest>.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2018-08-17 15:48:50 +01:00
parent d9de6ab213
commit c3d15a9ead

View 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