summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2019-08-24 15:48:46 +0100
committerSimon McVittie <smcv@debian.org>2020-02-24 11:39:47 +0000
commit9735b9f3952b3253f2c76d02aff94b63e11b60e7 (patch)
tree4465217b6577d398d81dfa2f2c53795ebda0595c
parenta0a93fecc84d897f0cfca564a8afff17080151b2 (diff)
Terminate tests with SIGALRM if they take more than 120 seconds
The Debian autobuilders run cogl's build-time tests to get an idea of how much can be expected to work on each supported architecture. We're currently ignoring test failures and running the tests for information only, but if a test hangs, that will still cause the build to fail (and tie up an autobuilder until a rather long timeout is reached). The fork of cogl in Mutter uses a 120 second timeout for tests in its Meson build system, but other than that it's purely an arbitrary number. dbus uses a similar alarm()-based watchdog, as do a couple of tests in GLib. Bug-Debian: https://bugs.debian.org/935592 Signed-off-by: Simon McVittie <smcv@debian.org> Forwarded: https://gitlab.gnome.org/GNOME/cogl/merge_requests/11 Gbp-Pq: Name Terminate-tests-with-SIGALRM-if-they-take-more-than-120-s.patch
-rw-r--r--configure.ac2
-rw-r--r--test-fixtures/test-utils.c9
2 files changed, 11 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 4fc9cb5e..746da3b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1361,6 +1361,8 @@ dnl ================================================================
dnl Checks for library functions.
dnl ================================================================
+AC_CHECK_FUNCS_ONCE([alarm])
+
dnl The 'ffs' function is part of C99 so it isn't always
dnl available. Cogl has a fallback if needed.
dnl
diff --git a/test-fixtures/test-utils.c b/test-fixtures/test-utils.c
index 59e3fd8c..faa9e1f7 100644
--- a/test-fixtures/test-utils.c
+++ b/test-fixtures/test-utils.c
@@ -2,6 +2,10 @@
#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
#include "test-unit.h"
#include "test-utils.h"
@@ -146,6 +150,11 @@ test_utils_init (TestFlags requirement_flags,
"$ make test-report");
counter++;
+#ifdef HAVE_ALARM
+ /* Kill the test with SIGALRM if it takes more than this many seconds */
+ alarm (120);
+#endif
+
if (is_boolean_env_set ("COGL_TEST_VERBOSE") ||
is_boolean_env_set ("V"))
cogl_test_is_verbose = TRUE;