]> Savannah Git Hosting - gnulib.git/commitdiff
lock tests: Prevent that the test takes too long.
authorBruno Haible <bruno@clisp.org>
Sat, 27 Apr 2019 22:19:33 +0000 (00:19 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 27 Apr 2019 22:19:33 +0000 (00:19 +0200)
* tests/test-lock.c: Include <signal.h>, <unistd.h>.
(main): Let the test fail if it takes more than 10 minutes.
* modules/lock-tests (configure.ac): Test whether 'alarm' is declared.

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

index 98b9c6c87e6385b60cbef03f3dde4b72acba6094..50bdc3639978dac9b4048899759236182caab20d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-04-27  Bruno Haible  <bruno@clisp.org>
+
+       lock tests: Prevent that the test takes too long.
+       * tests/test-lock.c: Include <signal.h>, <unistd.h>.
+       (main): Let the test fail if it takes more than 10 minutes.
+       * modules/lock-tests (configure.ac): Test whether 'alarm' is declared.
+
 2019-04-27  Bruno Haible  <bruno@clisp.org>
 
        localename: Fix crash on mingw (regression from 2018-11-23).
index 802471e0f16ac084bad56d4f1dfce9a2d9319ecc..5d647fa813432b3053432c8ab6bad498bf406501 100644 (file)
@@ -11,6 +11,7 @@ yield
 
 configure.ac:
 AC_CHECK_HEADERS_ONCE([semaphore.h])
+AC_CHECK_DECLS_ONCE([alarm])
 
 Makefile.am:
 TESTS += test-rwlock1 test-lock test-once1 test-once2
index 1ad0c72dcb6b9aeec270697ab0b054bdc661728a..166f85b13b79e6b8bd8e8432f05f08bb2b4f658a 100644 (file)
 # include <unistd.h>
 #endif
 
+#if HAVE_DECL_ALARM
+# include <signal.h>
+# include <unistd.h>
+#endif
+
 #if ENABLE_DEBUGGING
 # define dbgprintf printf
 #else
@@ -715,6 +720,14 @@ test_once (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 ();