Commit 5c91d85f authored by Simon McVittie's avatar Simon McVittie

tests: Add the ability to multiply up test timeouts

Tests that brute-force OOM code paths can be rather slow.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=100317Reviewed-by: Philip Withnall's avatarPhilip Withnall <withnall@endlessm.com>
Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
parent f59b4f92
...@@ -159,7 +159,7 @@ setup (Fixture *f, ...@@ -159,7 +159,7 @@ setup (Fixture *f,
const Config *config = context; const Config *config = context;
/* Some tests are fairly slow, so make the test timeout per-test */ /* Some tests are fairly slow, so make the test timeout per-test */
test_timeout_reset (); test_timeout_reset (1);
f->ctx = test_main_context_get (); f->ctx = test_main_context_get ();
f->ge = NULL; f->ge = NULL;
......
...@@ -202,7 +202,7 @@ setup (Fixture *f, ...@@ -202,7 +202,7 @@ setup (Fixture *f,
g_error ("OOM"); g_error ("OOM");
/* This can be fairly slow, so make the test timeout per-test */ /* This can be fairly slow, so make the test timeout per-test */
test_timeout_reset (); test_timeout_reset (1);
f->n_threads = N_THREADS; f->n_threads = N_THREADS;
f->n_refs = N_REFS; f->n_refs = N_REFS;
......
...@@ -122,7 +122,7 @@ static void ...@@ -122,7 +122,7 @@ static void
setup (Fixture *f, setup (Fixture *f,
gconstpointer data G_GNUC_UNUSED) gconstpointer data G_GNUC_UNUSED)
{ {
test_timeout_reset (); test_timeout_reset (1);
f->ctx = test_main_context_get (); f->ctx = test_main_context_get ();
dbus_error_init (&f->e); dbus_error_init (&f->e);
......
...@@ -569,7 +569,7 @@ wrap_abort (int signal) ...@@ -569,7 +569,7 @@ wrap_abort (int signal)
#endif #endif
static void static void
set_timeout (void) set_timeout (guint factor)
{ {
static guint timeout = 0; static guint timeout = 0;
...@@ -581,11 +581,11 @@ set_timeout (void) ...@@ -581,11 +581,11 @@ set_timeout (void)
if (timeout != 0) if (timeout != 0)
g_source_remove (timeout); g_source_remove (timeout);
timeout = g_timeout_add_seconds (TIMEOUT, time_out, NULL); timeout = g_timeout_add_seconds (TIMEOUT * factor, time_out, NULL);
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
/* The GLib main loop might not be running (we don't use it in every /* The GLib main loop might not be running (we don't use it in every
* test). Die with SIGALRM shortly after if necessary. */ * test). Die with SIGALRM shortly after if necessary. */
alarm (TIMEOUT + 10); alarm ((TIMEOUT * factor) + 10);
/* Get a log message and a core dump from the SIGALRM. */ /* Get a log message and a core dump from the SIGALRM. */
{ {
...@@ -603,7 +603,7 @@ test_init (int *argcp, char ***argvp) ...@@ -603,7 +603,7 @@ test_init (int *argcp, char ***argvp)
{ {
g_test_init (argcp, argvp, NULL); g_test_init (argcp, argvp, NULL);
g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id="); g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
set_timeout (); set_timeout (1);
} }
static void static void
...@@ -617,12 +617,13 @@ report_and_destroy (gpointer p) ...@@ -617,12 +617,13 @@ report_and_destroy (gpointer p)
} }
void void
test_timeout_reset (void) test_timeout_reset (guint factor)
{ {
GTimer *timer = g_timer_new (); GTimer *timer = g_timer_new ();
g_test_message ("Resetting test timeout (reference: %p)", timer); g_test_message ("Resetting test timeout (reference: %p; factor: %u)",
set_timeout (); timer, factor);
set_timeout (factor);
g_test_queue_destroy (report_and_destroy, timer); g_test_queue_destroy (report_and_destroy, timer);
} }
......
...@@ -97,7 +97,7 @@ void test_rmdir_must_exist (const gchar *path); ...@@ -97,7 +97,7 @@ void test_rmdir_must_exist (const gchar *path);
void test_rmdir_if_exists (const gchar *path); void test_rmdir_if_exists (const gchar *path);
void test_mkdir (const gchar *path, gint mode); void test_mkdir (const gchar *path, gint mode);
void test_timeout_reset (void); void test_timeout_reset (guint factor);
void test_oom (void) _DBUS_GNUC_NORETURN; void test_oom (void) _DBUS_GNUC_NORETURN;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment