]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: cleanup trapping of signal names
authorPádraig Brady <P@draigBrady.com>
Mon, 9 Nov 2015 18:50:21 +0000 (18:50 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 10 Nov 2015 12:52:50 +0000 (12:52 +0000)
A side effect of this cleanup is we no longer
depend on our own kill command being built.

* init.cfg (require_trap_signame_): A new function to verify
that the shell supports specifying traps by signal name.
(require_kill_group_): A new function to ensure the shell
supports sending a signal to a group.
* tests/du/move-dir-while-traversing.sh: Ensure trap supports
signal names.
* tests/misc/stty-invalid.sh: Likewise.
* tests/misc/stty-pairs.sh: Likewise.
* tests/misc/stty-row-col.sh: Likewise.
* tests/misc/stty.sh: Likewise.
* tests/misc/sort-compress.sh: Likewise.  Also simplify trap call.
* tests/install/trap.sh: Likewise.
* tests/misc/timeout.sh: Likewise.
* tests/dd/stats.sh: Likewise.  Also use default kill command.
* tests/misc/timeout-group.sh: Likewise.

init.cfg
tests/dd/stats.sh
tests/du/move-dir-while-traversing.sh
tests/install/trap.sh
tests/misc/sort-compress.sh
tests/misc/stty-invalid.sh
tests/misc/stty-pairs.sh
tests/misc/stty-row-col.sh
tests/misc/stty.sh
tests/misc/timeout-group.sh
tests/misc/timeout.sh

index ef450d790c0e33e1473947965e22a860ca94a0f5..6f5f80bf300274a3831c2bbae1939a6c534b14c7 100644 (file)
--- a/init.cfg
+++ b/init.cfg
@@ -470,6 +470,20 @@ require_proc_pid_status_()
     kill $pid
 }
 
+# Does trap support signal names?
+# Old versions of ash did not.
+require_trap_signame_()
+{
+    (trap '' CHLD) || skip_ 'requires trap with signal name support'
+}
+
+# Does kill support sending signal to whole group?
+# dash 0.5.8 at least does not.
+require_kill_group_()
+{
+    kill -0 -- -1 || skip_ 'requires kill with group signalling support'
+}
+
 # Return nonzero if the specified path is on a file system for
 # which FIEMAP support exists.  Note some file systems (like ext3 and btrfs)
 # only support FIEMAP for files, not directories.
index a82c66d2050106046d1100865790aa57cb624bee..da2c2d25ff6f426f9acdb4406c8deb35b7bfa7d8 100755 (executable)
@@ -18,8 +18,9 @@
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ dd
+require_trap_signame_
 
-env kill -l | grep '^INFO$' && SIGINFO='INFO' || SIGINFO='USR1'
+kill -l | grep 'INFO' && SIGINFO='INFO' || SIGINFO='USR1'
 
 # This to avoid races in the USR1 case
 # as the dd process will terminate by default until
index 67bb34580742f67bacdb2acbf965f963b41aea59..a90f1c4f850348acd3f5ca8a1a3aa50326928e15 100755 (executable)
@@ -18,6 +18,7 @@
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ du
+require_trap_signame_
 
 # We use a python-inotify script, so...
 python -m pyinotify -h > /dev/null \
index 0851ba623ae37025fb22e734267808638d51a09a..157d1bc1f293b925be180b4aeb1017bdbdb9919f 100755 (executable)
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ ginstall
+require_trap_signame_
 
 
 # Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh.
 (
-  # ash doesn't support "trap '' CHLD"; it knows only signal numbers.
-  sig=$(env kill -l CHLD 2>/dev/null) && trap '' $sig
+  trap '' CHLD
 
   # Before 2004-04-21, install would infloop, in the 'while (wait...' loop:
   exec ginstall -s "$abs_top_builddir/src/ginstall$EXEEXT" .
index 584110e129d3a5336c3d79af33a49c1326cbe8f0..7cb5df8354b37db7158de9d327cbfef830fc408c 100755 (executable)
@@ -18,6 +18,7 @@
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ sort
+require_trap_signame_
 
 seq -w 2000 > exp || framework_failure_
 tac exp > in || framework_failure_
@@ -38,8 +39,7 @@ chmod +x gzip
 # Ensure 'sort' is immune to parent's SIGCHLD handler
 # Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh.
 (
-  # ash doesn't support "trap '' CHLD"; it knows only signal numbers.
-  sig=$(env kill -l CHLD 2>/dev/null) && trap '' $sig
+  trap '' CHLD
 
   # This should force the use of child processes for "compression"
   PATH=.:$PATH exec sort -S 1k --compress-program=gzip in > /dev/null
index 881146f65627a82ba6a8cc01008a5c7a744c5a7a..49c208622efa3dbc5c5ccf481b6f8bb8e966c76a 100755 (executable)
@@ -19,6 +19,8 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ stty
 require_controlling_input_terminal_
+require_trap_signame_
+
 trap '' TTOU # Ignore SIGTTOU
 
 
index 129c22f0f5b49a5136787956888704d10005cd4c..0494343d7d63f611fa96263c8ed211d9f26a4a94 100755 (executable)
@@ -23,6 +23,8 @@ expensive_
 
 # Make sure there's a tty on stdin.
 require_controlling_input_terminal_
+require_trap_signame_
+
 trap '' TTOU # Ignore SIGTTOU
 
 # Get the reversible settings from stty.c.
index 0616812ee0ffe554bd31fa566b0a112ef8cd06ae..8c18df661b98523b9b13e5b26be468e8841736eb 100755 (executable)
@@ -32,6 +32,8 @@ export LC_ALL
 print_ver_ stty
 
 require_controlling_input_terminal_
+require_trap_signame_
+
 trap '' TTOU # Ignore SIGTTOU
 
 # Versions of GNU stty from shellutils-1.9.2c and earlier failed
index 5e39b72e576d00705ec2056088397226c57eb16f..217891a1a1936ec66110de7fd035dff861e40f90 100755 (executable)
@@ -21,6 +21,8 @@
 print_ver_ stty
 
 require_controlling_input_terminal_
+require_trap_signame_
+
 trap '' TTOU # Ignore SIGTTOU
 
 # Get the reversible settings from stty.c.
index d47f0dc83d28d8be7ff37c8b443bacc7dbd6b4cc..029048f40974858cb73152985d2603a5170edc02 100755 (executable)
@@ -18,6 +18,8 @@
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ timeout
+require_trap_signame_
+require_kill_group_
 
 # construct a program group hierarchy as follows:
 #  timeout-group - foreground group
@@ -66,8 +68,7 @@ setsid ./group.sh & pid=$!
 # Wait 6.3s for timeout.cmd to start
 retry_delay_ check_timeout_cmd_running .1 6 || fail=1
 # Simulate a Ctrl-C to the group to test timely exit
-# Note dash doesn't support signalling groups (a leading -)
-env kill -INT -- -$pid
+kill -INT -- -$pid
 wait
 test -e int.received || fail=1
 
index 3cebd3302c5533b4189eee60bf546b13cdf99ec6..ec77d61e8f164b70b5779a7879672ac3b43da139 100755 (executable)
@@ -18,6 +18,7 @@
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ timeout
+require_trap_signame_
 
 # no timeout
 timeout 10 true || fail=1
@@ -50,8 +51,7 @@ test $? = 124 && fail=1
 # Ensure 'timeout' is immune to parent's SIGCHLD handler
 # Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh.
 (
-  # ash doesn't support "trap '' CHLD"; it knows only signal numbers.
-  sig=$(env kill -l CHLD 2>/dev/null) && trap '' $sig
+  trap '' CHLD
 
   exec timeout 10 true
 ) || fail=1