diff options
author | Bruno Haible <bruno@clisp.org> | 2019-04-28 11:21:41 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2019-04-28 11:21:41 +0200 |
commit | 5b891d3d9e310d4faa175f3a97921c466c907ba1 (patch) | |
tree | e8c100ba5e962e262382dd252b648b6743a8d893 /tests | |
parent | a4398f60f17e3de5463540311bd6bc5c33045822 (diff) | |
download | gnulib-5b891d3d9e310d4faa175f3a97921c466c907ba1.tar.gz |
tls tests: Prevent that the test takes too long.
* tests/test-tls.c: Include <signal.h>, <unistd.h>.
(main): Let the test fail if it takes more than 10 minutes.
* modules/tls-tests (configure.ac): Test whether 'alarm' is declared.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-tls.c | 13 |
1 files changed, 13 insertions, 0 deletions
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 <signal.h> +# include <unistd.h> +#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 (); |