]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: fix spurious failures due to ignored signals
authorStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 6 Sep 2011 15:10:21 +0000 (17:10 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 6 Sep 2011 15:29:46 +0000 (17:29 +0200)
* tests/defs (is_blocked_signal): New function.
* tests/parallel-tests-interrupt.test: Do not try to use/trap
signals that are ignored by the parent shell: they will be
ignored by all the child processes too.
* tests/self-check-exit.test: Likewise.
* tests/self-check-cleanup.test: Likewise, and do few minor
improvements and extensions since we are at it.

ChangeLog
tests/defs
tests/parallel-tests-interrupt.test
tests/self-check-cleanup.test
tests/self-check-exit.test

index 5b9f6e969ae0180f76ceba8851bcb7bd724ced56..54d75549b0fc7e69ca1b921d1ebadfeed49c90bb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-09-06  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       tests: fix spurious failures due to ignored signals
+       * tests/defs (is_blocked_signal): New function.
+       * tests/parallel-tests-interrupt.test: Do not try to use/trap
+       signals that are ignored by the parent shell: they will be
+       ignored by all the child processes too.
+       * tests/self-check-exit.test: Likewise.
+       * tests/self-check-cleanup.test: Likewise, and do few minor
+       improvements and extensions since we are at it.
+
 2011-09-05  Peter Rosin  <peda@lysator.liu.se>
 
        * tests/amhello-binpkg.test: Add missing $EXEEXT usage.
index fe73d855dbc81600a7e9d7bfb911a23f3f3f03f5..2c43bc172f6331df3d72483f1356338cc248ddf3 100644 (file)
@@ -153,6 +153,15 @@ is_newest ()
   test -z "$is_newest_files"
 }
 
+# is_blocked_signal SIGNAL-NUMBER
+# --------------------------------
+# Return success if the given signal number is blocked in the shell,
+# return a non-zero exit status and print a proper diagnostic otherwise.
+is_blocked_signal ()
+{
+  $SHELL -c "kill -$1 \$\$; echo '$me: signal $1 seems blocked'"
+}
+
 # AUTOMAKE_run status [options...]
 # --------------------------------
 # Run Automake with OPTIONS, and fail if automake
index 45e55d4ae021a3b264f6cafa9376bc91af156ab5..7305222399fc22d04e944d20b4339fc4b20f1157 100755 (executable)
@@ -57,6 +57,10 @@ $AUTOMAKE -a
 trapped_signals='1 2 13 15'
 
 for signum in $trapped_signals; do
+  if is_blocked_signal $signum; then
+    echo "$me: signal $signum is blocked, skipping part of the test"
+    continue
+  fi
   rm -f pid fail *.log *.log-t
   env signum=$signum $MAKE check && { ls -l; Exit 1; }
   ls -l
index 945194fb7a8bc5258e36d68e4221bdcb0ee6f385..9cfde1d3e8af31b5e2450f04a01636b4495de629 100755 (executable)
@@ -108,23 +108,21 @@ fi # $have_symlinks
 # Check that the cleanup trap does not remove the temporary
 # test directory in case of test failure, skip, hard-error,
 # or when receiving a signal.
-for bailout_command in \
-  'Exit 1' \
-  'Exit 2' \
-  'Exit 10' \
-  'Exit 77' \
-  'Exit 99' \
-  'Exit 126' \
-  'Exit 127' \
-  'Exit 255' \
-  'kill -1 $$' \
-  'kill -2 $$' \
-  'kill -9 $$' \
-  'kill -13 $$' \
-  'kill -15 $$' \
-; do
-  $SHELL -c  ". ./defs; : > foo; $bailout_command" dummy.test && Exit 1
+
+for st in 1 2 3 10 77 99 126 127 130 255; do
+  $SHELL -c  ". ./defs; : > foo; Exit $st" dummy.test && Exit 1
+  test -f dummy.dir/foo
+  rm -rf dummy.dir
+done
+
+for signum in 1 2 3 9 13 15; do
+  if is_blocked_signal $signum; then
+    echo "$me: signal $signum is blocked, skipping part of the test"
+    continue
+  fi
+  $SHELL -c  ". ./defs; : > foo; kill -$signum \$\$" dummy.test && Exit 1
   test -f dummy.dir/foo
+  rm -rf dummy.dir
 done
 
 :
index ca1af9b9a8e6f4837f899f16374f7369867d7c04..a07ba6971c59ffa2c424bc5870f4a51e7a098d66 100755 (executable)
@@ -50,6 +50,10 @@ done
 
 for sig in 1 2 13 15; do
 
+  if $SHELL -c "kill -$sig \$\$"; then
+    echo "$me: signal $sig is blocked, skipping part of the test"
+    continue
+  fi
   echo "* Try: kill -$sig \$\$"
   if test $sig -eq 2; then
     # Some Korn shells might otherwise get a spurious SIGINT