From: Pádraig Brady
Date: Sat, 13 Nov 2021 12:15:17 +0000 (+0000)
Subject: tests: avoid false failure in env-signal-handler.sh
X-Git-Tag: v9.1~187
X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2378a531432d21c574830f0e24f7f46fe7daceca;p=thirdparty%2Fcoreutils.git
tests: avoid false failure in env-signal-handler.sh
* tests/misc/env-signal-handler.sh: Use retry_delay_ to
avoid a false failure under load, where env hasn't setup
the SIGINT handling before timeout(1) sends the SIGINT.
Fixes https://bugs.gnu.org/51793
---
diff --git a/tests/misc/env-signal-handler.sh b/tests/misc/env-signal-handler.sh
index aa6ec8dacf..e3d6fe6a12 100755
--- a/tests/misc/env-signal-handler.sh
+++ b/tests/misc/env-signal-handler.sh
@@ -82,62 +82,44 @@ compare /dev/null err4 || fail=1
# env test - block signal handler
env --block-signal true || fail=1
+env_ignore_delay_()
+{
+ local delay="$1"
+
+ # The first 'env' is just to ensure timeout is not a shell built-in.
+ env timeout --verbose --kill-after=.1 --signal=INT $delay \
+ env $env_opt sleep 10 > /dev/null 2>outt
+ # check only the first two lines from stderr, which are printed by timeout.
+ # (operating systems might add more messages, like "killed").
+ sed -n '1,2p' outt > out || framework_failure_
+ compare exp out
+}
+
# Baseline test - ignore signal handler
# -------------------------------------
-# Kill 'sleep' after 1 second with SIGINT - it should terminate (as SIGINT's
-# default action is to terminate a program).
-# (The first 'env' is just to ensure timeout is not the shell's built-in.)
-env timeout --verbose --kill-after=.1 --signal=INT .1 \
- sleep 10 > /dev/null 2>err5
-
-printf "timeout: sending signal INT to command 'sleep'\n" > exp-err5 \
- || framework_failure_
-
-compare exp-err5 err5 || fail=1
-
+# Terminate 'sleep' with SIGINT
+# (SIGINT's default action is to terminate a program).
+cat <<\EOF >exp || framework_failure_
+timeout: sending signal INT to command 'env'
+EOF
+env_opt='' retry_delay_ env_ignore_delay_ .1 6 || fail=1
# env test - ignore signal handler
# --------------------------------
-# Use env to silence (ignore) SIGINT - "seq" should continue running
-# after timeout sends SIGINT, and be killed after 1 second using SIGKILL.
-
-cat>exp-err6 <