]> Savannah Git Hosting - gnulib.git/commitdiff
tls tests: Prevent that the test takes too long.
authorBruno Haible <bruno@clisp.org>
Sun, 28 Apr 2019 09:21:41 +0000 (11:21 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 28 Apr 2019 09:21:41 +0000 (11:21 +0200)
* 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.

ChangeLog
modules/tls-tests
tests/test-tls.c

index 50bdc3639978dac9b4048899759236182caab20d..8bdf14314d865ea2f46c304184f4f3e8774875de 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-04-28  Bruno Haible  <bruno@clisp.org>
+
+       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.
+
 2019-04-27  Bruno Haible  <bruno@clisp.org>
 
        lock tests: Prevent that the test takes too long.
index 107cfe45f65e73106072a080bc12920f441dc74d..562e36b21d623951a0c207b45e0b4c4645ae2f61 100644 (file)
@@ -6,6 +6,7 @@ thread
 yield
 
 configure.ac:
+AC_CHECK_DECLS_ONCE([alarm])
 
 Makefile.am:
 TESTS += test-tls
index b2066b3eccc20d3e5f9d42efb47cebe16ff2565e..6bfa6ff4b1520540dde0d5e6b7ae0e042261b929 100644 (file)
 #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 ();