From a4398f60f17e3de5463540311bd6bc5c33045822 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 28 Apr 2019 00:19:33 +0200 Subject: [PATCH] lock tests: Prevent that the test takes too long. * tests/test-lock.c: Include , . (main): Let the test fail if it takes more than 10 minutes. * modules/lock-tests (configure.ac): Test whether 'alarm' is declared. --- ChangeLog | 7 +++++++ modules/lock-tests | 1 + tests/test-lock.c | 13 +++++++++++++ 3 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index 98b9c6c87e..50bdc36399 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2019-04-27 Bruno Haible + + lock tests: Prevent that the test takes too long. + * tests/test-lock.c: Include , . + (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 localename: Fix crash on mingw (regression from 2018-11-23). diff --git a/modules/lock-tests b/modules/lock-tests index 802471e0f1..5d647fa813 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 diff --git a/tests/test-lock.c b/tests/test-lock.c index 1ad0c72dcb..166f85b13b 100644 --- a/tests/test-lock.c +++ b/tests/test-lock.c @@ -120,6 +120,11 @@ # include #endif +#if HAVE_DECL_ALARM +# include +# include +#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 (); -- 2.39.5