# HG changeset patch # User Eric Blake # Date 1363038032 21600 # Node ID 639f6021971742a2f951a3d139b2a43b6e1d17d8 # Parent 9855b352e525c1fb87815eb74cb5c0a06cdf3a75 tests: make it easier to bypass alarm time in debugger While auditing alarm usage, I noticed that test-regex had a nice idiom that made it easier to disable an alarm under glibc. Use it elsewhere, so future copy-and-paste will preserve the idiom. * tests/test-file-has-acl.c (main): Allow gdb to override alarm. * tests/test-memmem.c (main): Likewise. * tests/test-passfd.c (main): Likewise. * tests/test-ptsname.c (main): Likewise. * tests/test-ptsname_r.c (main): Likewise. * tests/test-strcasestr.c (main): Likewise. * tests/test-strstr.c (main): Likewise. Signed-off-by: Eric Blake diff -r 9855b352e525 -r 639f60219717 ChangeLog --- a/ChangeLog Mon Mar 11 14:51:33 2013 -0600 +++ b/ChangeLog Mon Mar 11 15:40:32 2013 -0600 @@ -1,5 +1,14 @@ 2013-03-11 Eric Blake + tests: make it easier to bypass alarm time in debugger + * tests/test-file-has-acl.c (main): Allow gdb to override alarm. + * tests/test-memmem.c (main): Likewise. + * tests/test-passfd.c (main): Likewise. + * tests/test-ptsname.c (main): Likewise. + * tests/test-ptsname_r.c (main): Likewise. + * tests/test-strcasestr.c (main): Likewise. + * tests/test-strstr.c (main): Likewise. + regex: port to mingw's recent addition of undeclared alarm * doc/posix-functions/alarm.texi (alarm): Document that alarm exists but still doesn't work in newer mingw. diff -r 9855b352e525 -r 639f60219717 tests/test-file-has-acl.c --- a/tests/test-file-has-acl.c Mon Mar 11 14:51:33 2013 -0600 +++ b/tests/test-file-has-acl.c Mon Mar 11 15:40:32 2013 -0600 @@ -49,8 +49,11 @@ #if HAVE_DECL_ALARM /* Declare failure if test takes too long, by using default abort caused by SIGALRM. */ - signal (SIGALRM, SIG_DFL); - alarm (5); + { + int alarm_value = 5; + signal (SIGALRM, SIG_DFL); + alarm (alarm_value); + } #endif #if USE_ACL diff -r 9855b352e525 -r 639f60219717 tests/test-memmem.c --- a/tests/test-memmem.c Mon Mar 11 14:51:33 2013 -0600 +++ b/tests/test-memmem.c Mon Mar 11 15:40:32 2013 -0600 @@ -43,8 +43,9 @@ caused by SIGALRM. All known platforms that lack alarm also lack memmem, and the replacement memmem is known to not take too long. */ + int alarm_value = 100; signal (SIGALRM, SIG_DFL); - alarm (100); + alarm (alarm_value); #endif { diff -r 9855b352e525 -r 639f60219717 tests/test-passfd.c --- a/tests/test-passfd.c Mon Mar 11 14:51:33 2013 -0600 +++ b/tests/test-passfd.c Mon Mar 11 15:40:32 2013 -0600 @@ -45,8 +45,9 @@ # if HAVE_DECL_ALARM /* Avoid hanging on failure. */ + int alarm_value = 5; signal (SIGALRM, SIG_DFL); - alarm (5); + alarm (alarm_value); # endif fdnull = open ("/dev/null", O_RDWR); diff -r 9855b352e525 -r 639f60219717 tests/test-ptsname.c --- a/tests/test-ptsname.c Mon Mar 11 14:51:33 2013 -0600 +++ b/tests/test-ptsname.c Mon Mar 11 15:40:32 2013 -0600 @@ -59,8 +59,9 @@ #if HAVE_DECL_ALARM /* Declare failure if test takes too long, by using default abort caused by SIGALRM. */ + int alarm_value = 5; signal (SIGALRM, SIG_DFL); - alarm (5); + alarm (alarm_value); #endif { diff -r 9855b352e525 -r 639f60219717 tests/test-ptsname_r.c --- a/tests/test-ptsname_r.c Mon Mar 11 14:51:33 2013 -0600 +++ b/tests/test-ptsname_r.c Mon Mar 11 15:40:32 2013 -0600 @@ -104,8 +104,9 @@ #if HAVE_DECL_ALARM /* Declare failure if test takes too long, by using default abort caused by SIGALRM. */ + int alarm_value = 5; signal (SIGALRM, SIG_DFL); - alarm (5); + alarm (alarm_value); #endif { diff -r 9855b352e525 -r 639f60219717 tests/test-strcasestr.c --- a/tests/test-strcasestr.c Mon Mar 11 14:51:33 2013 -0600 +++ b/tests/test-strcasestr.c Mon Mar 11 15:40:32 2013 -0600 @@ -37,8 +37,9 @@ caused by SIGALRM. All known platforms that lack alarm also lack strcasestr, and the replacement strcasestr is known to not take too long. */ + int alarm_value = 50; signal (SIGALRM, SIG_DFL); - alarm (50); + alarm (alarm_value); #endif { diff -r 9855b352e525 -r 639f60219717 tests/test-strstr.c --- a/tests/test-strstr.c Mon Mar 11 14:51:33 2013 -0600 +++ b/tests/test-strstr.c Mon Mar 11 15:40:32 2013 -0600 @@ -37,8 +37,9 @@ caused by SIGALRM. All known platforms that lack alarm also have a quadratic strstr, and the replacement strstr is known to not take too long. */ + int alarm_value = 50; signal (SIGALRM, SIG_DFL); - alarm (50); + alarm (alarm_value); #endif {