summaryrefslogtreecommitdiff
path: root/tests/misc/timeout-group
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2011-11-03 01:42:43 +0000
committerPádraig Brady <P@draigBrady.com>2011-11-03 18:36:28 +0000
commit6603e37c1f602c27d990cc0020b58567d8c5b6e2 (patch)
treed2cce79c467598b14401a901a336b592da244ad0 /tests/misc/timeout-group
parentaa6448b8d506e8948f0ef0239e23019ef9566a98 (diff)
downloadcoreutils-6603e37c1f602c27d990cc0020b58567d8c5b6e2.tar.xz
tests: avoid signal issues in timeout-group
These issues were seen on an OpenSuse 10.3 system (kernel 2.6.22.5 x86_64, glibc 2.6.1-18, bash updated to 4.2), and also on a 64 bit SLES system with a 2.6.16 kernel. Both systems had 2 CPUs. There were two issues seen. 1. Occasionally the timeout.cmd shell script would block SIGINT until the sleep command exited. 2. Much less frequently the signal handler in the timeout command itself was ignored, causing SIGALRM to kill the process. * tests/misc/timeout-group: Detect the above two cases, and skip rather than fail. Note only issue 2. causes a failure unless skipped, but we skip for case 1. also, for diagnostic purposes.
Diffstat (limited to 'tests/misc/timeout-group')
-rwxr-xr-xtests/misc/timeout-group15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/misc/timeout-group b/tests/misc/timeout-group
index 5d31551d3..4c4bbaa40 100755
--- a/tests/misc/timeout-group
+++ b/tests/misc/timeout-group
@@ -73,14 +73,25 @@ rm -f int.received timeout.running
# commands that create their own group
# This didn't work before 8.13.
+start=$(date +%s)
+
# Note the first timeout must send a signal that
# the second is handling for it to be propagated to the command.
# SIGINT, SIGTERM, SIGALRM etc. are implicit.
timeout -sALRM 30 timeout -sINT 25 ./timeout.cmd 20&
+pid=$!
# Wait 6.3s for timeout.cmd to start
retry_delay_ check_timeout_cmd_running .1 6 || fail=1
-kill -ALRM $! # trigger the alarm of the first timeout command
-wait
+kill -ALRM $pid # trigger the alarm of the first timeout command
+wait $pid
+ret=$?
+test $ret -eq 124 ||
+ skip_ "timeout returned $ret. SIGALRM not handled?"
test -e int.received || fail=1
+end=$(date +%s)
+
+test $(expr $end - $start) -lt 20 ||
+ skip_ "timeout.cmd didn't receive a signal until after sleep?"
+
Exit $fail