]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
tests: Add the ability to multiply up test timeouts
authorSimon McVittie <smcv@collabora.com>
Mon, 27 Nov 2017 19:14:23 +0000 (19:14 +0000)
committerSimon McVittie <smcv@collabora.com>
Tue, 6 Feb 2018 19:14:27 +0000 (19:14 +0000)
Tests that brute-force OOM code paths can be rather slow.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=100317
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 5c91d85f3ed462dac1e011aab216c9021e826773)

test/dbus-daemon.c
test/internals/refs.c
test/relay.c
test/test-utils-glib.c
test/test-utils-glib.h

index f9d8f92338e297d19f3ae5accb435433e7c21c1d..a783b59379135a3f8d51e838fb6ea8fba8184769 100644 (file)
@@ -159,7 +159,7 @@ setup (Fixture *f,
   const Config *config = context;
 
   /* 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->ge = NULL;
index 3c6b438da529c59a5195a2ca6ca1a3fbac3e2657..b6ad5fe0f56400b0efad7123962eace9f6ed1311 100644 (file)
@@ -202,7 +202,7 @@ setup (Fixture *f,
     g_error ("OOM");
 
   /* 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_refs = N_REFS;
index d7c453abd2ff5c32940eebf606cae331f044c2bc..00e7966a75336c99859a43657476e02f8cd3d7b6 100644 (file)
@@ -122,7 +122,7 @@ static void
 setup (Fixture *f,
     gconstpointer data G_GNUC_UNUSED)
 {
-  test_timeout_reset ();
+  test_timeout_reset (1);
 
   f->ctx = test_main_context_get ();
   dbus_error_init (&f->e);
index 2fc1573d7fb3824083d235635244a8604b2d3032..adbe21c00123343fd2afe316c844db147984ccfc 100644 (file)
@@ -488,7 +488,7 @@ wrap_abort (int signal)
 #endif
 
 static void
-set_timeout (void)
+set_timeout (guint factor)
 {
   static guint timeout = 0;
 
@@ -500,11 +500,11 @@ set_timeout (void)
   if (timeout != 0)
     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
   /* The GLib main loop might not be running (we don't use it in every
    * 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. */
     {
@@ -522,7 +522,7 @@ test_init (int *argcp, char ***argvp)
 {
   g_test_init (argcp, argvp, NULL);
   g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
-  set_timeout ();
+  set_timeout (1);
 }
 
 static void
@@ -536,12 +536,13 @@ report_and_destroy (gpointer p)
 }
 
 void
-test_timeout_reset (void)
+test_timeout_reset (guint factor)
 {
   GTimer *timer = g_timer_new ();
 
-  g_test_message ("Resetting test timeout (reference: %p)", timer);
-  set_timeout ();
+  g_test_message ("Resetting test timeout (reference: %p; factor: %u)",
+      timer, factor);
+  set_timeout (factor);
 
   g_test_queue_destroy (report_and_destroy, timer);
 }
index f2f167caf79125de7ea71f94e81bddb3a9ffdfd8..3952309cfbad6afcf6fa554f9d99eda8e3d24415 100644 (file)
@@ -89,6 +89,6 @@ void test_rmdir_must_exist (const gchar *path);
 void test_rmdir_if_exists (const gchar *path);
 void test_mkdir (const gchar *path, gint mode);
 
-void test_timeout_reset (void);
+void test_timeout_reset (guint factor);
 
 #endif