From: Bruno Haible Date: Sun, 28 Apr 2019 09:21:41 +0000 (+0200) Subject: tls tests: Prevent that the test takes too long. X-Git-Tag: v1.0~4967 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=5b891d3d9e310d4faa175f3a97921c466c907ba1;p=gnulib.git tls tests: Prevent that the test takes too long. * tests/test-tls.c: Include , . (main): Let the test fail if it takes more than 10 minutes. * modules/tls-tests (configure.ac): Test whether 'alarm' is declared. --- diff --git a/ChangeLog b/ChangeLog index 50bdc36399..8bdf14314d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2019-04-28 Bruno Haible + + tls tests: Prevent that the test takes too long. + * tests/test-tls.c: Include , . + (main): Let the test fail if it takes more than 10 minutes. + * modules/tls-tests (configure.ac): Test whether 'alarm' is declared. + 2019-04-27 Bruno Haible lock tests: Prevent that the test takes too long. diff --git a/modules/tls-tests b/modules/tls-tests index 107cfe45f6..562e36b21d 100644 --- a/modules/tls-tests +++ b/modules/tls-tests @@ -6,6 +6,7 @@ thread yield configure.ac: +AC_CHECK_DECLS_ONCE([alarm]) Makefile.am: TESTS += test-tls diff --git a/tests/test-tls.c b/tests/test-tls.c index b2066b3ecc..6bfa6ff4b1 100644 --- a/tests/test-tls.c +++ b/tests/test-tls.c @@ -54,6 +54,11 @@ #include "glthread/thread.h" #include "glthread/yield.h" +#if HAVE_DECL_ALARM +# include +# include +#endif + #if ENABLE_DEBUGGING # define dbgprintf printf #else @@ -184,6 +189,14 @@ test_tls (void) int main () { +#if HAVE_DECL_ALARM + /* Declare failure if test takes too long, by using default abort + caused by SIGALRM. */ + int alarm_value = 600; + signal (SIGALRM, SIG_DFL); + alarm (alarm_value); +#endif + #if TEST_PTH_THREADS if (!pth_init ()) abort ();