summaryrefslogtreecommitdiff
path: root/test/test-utils-glib.c
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2017-09-27 13:14:39 +0100
committerSimon McVittie <smcv@collabora.com>2017-09-27 14:45:49 +0100
commit3d557ff7b155d1e0f1cdbfd82cff0ac7ed1b7c4b (patch)
tree29014f8bdc2d88424a86271818f3c12c41e6160c /test/test-utils-glib.c
parent5aca0fc1a5bc0b7918839bc692747b1f57c3285c (diff)
downloaddbus-3d557ff7b155d1e0f1cdbfd82cff0ac7ed1b7c4b.tar.gz
tests: In slower tests, make the timeout per-test-case
Some test-cases in the dbus-daemon and relay tests spam the bus with thousands of messages, which can take 25 seconds on slower CPUs like MIPS. Similarly, the refs test spams millions of refcount operations, which it appears might take more than a minute on PA-RISC (HPPA). To get an idea of how close we are to having a problem on other architectures, log a message and start a timer when we reset the timeout in setup(), and log the elapsed time when we reach teardown(). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103009 Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com>
Diffstat (limited to 'test/test-utils-glib.c')
-rw-r--r--test/test-utils-glib.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/test/test-utils-glib.c b/test/test-utils-glib.c
index 73416bb6..9dc58b97 100644
--- a/test/test-utils-glib.c
+++ b/test/test-utils-glib.c
@@ -485,18 +485,20 @@ wrap_abort (int signal)
}
#endif
-void
-test_init (int *argcp, char ***argvp)
+static void
+set_timeout (void)
{
- g_test_init (argcp, argvp, NULL);
- g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
+ static guint timeout = 0;
/* Prevent tests from hanging forever. This is intended to be long enough
* that any reasonable regression test on any reasonable hardware would
* have finished. */
#define TIMEOUT 60
- g_timeout_add_seconds (TIMEOUT, time_out, NULL);
+ if (timeout != 0)
+ g_source_remove (timeout);
+
+ timeout = g_timeout_add_seconds (TIMEOUT, 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. */
@@ -514,6 +516,35 @@ test_init (int *argcp, char ***argvp)
}
void
+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 ();
+}
+
+static void
+report_and_destroy (gpointer p)
+{
+ GTimer *timer = p;
+
+ g_test_message ("Time since timeout reset %p: %.3f seconds",
+ timer, g_timer_elapsed (timer, NULL));
+ g_timer_destroy (timer);
+}
+
+void
+test_timeout_reset (void)
+{
+ GTimer *timer = g_timer_new ();
+
+ g_test_message ("Resetting test timeout (reference: %p)", timer);
+ set_timeout ();
+
+ g_test_queue_destroy (report_and_destroy, timer);
+}
+
+void
test_progress (char symbol)
{
if (g_test_verbose () && isatty (1))