[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lock tests: prevent that the test takes too long
From: |
Bruno Haible |
Subject: |
lock tests: prevent that the test takes too long |
Date: |
Sun, 28 Apr 2019 10:22:16 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; ) |
The 'test-lock' program took too long before the improvements done in
December 2016 / January 2017. But still, it takes a too long time on
Linux/ia64.
A test suite should never "hang". Better fail the test.
2019-04-27 Bruno Haible <address@hidden>
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.
diff --git a/tests/test-lock.c b/tests/test-lock.c
index 1ad0c72..166f85b 100644
--- a/tests/test-lock.c
+++ b/tests/test-lock.c
@@ -120,6 +120,11 @@
# 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 ();
diff --git a/modules/lock-tests b/modules/lock-tests
index 802471e..5d647fa 100644
--- a/modules/lock-tests
+++ b/modules/lock-tests
@@ -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
- lock tests: prevent that the test takes too long,
Bruno Haible <=