]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: also trap SIGQUIT; other fixes
authorStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 13 Sep 2011 12:37:02 +0000 (14:37 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 13 Sep 2011 12:37:02 +0000 (14:37 +0200)
Some shells seems to just ignore SIGQUIT under some circumstances,
even when it is not blocked; however, if the signal it trapped,
the trap gets correctly executed.

* tests/defs [$sh_errexit_works = yes]: Also trap SIGQUIT. Add
extensive explanation of why we do so.
* tests/self-check-cleanup.tap: Improve and fix to ensure that an
earlier failure does not prevent the rest of the test to execute.
Problem revealed by a failure in `self-check-cleanup.tap'.

ChangeLog
tests/defs
tests/self-check-cleanup.tap

index cbc669319636e10f8a137be4e120d6db7a28b8d0..909b3377244ec330de9830698ce08856cde6855d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2011-09-13  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       tests: also trap SIGQUIT; other fixes
+       Some shells seems to just ignore SIGQUIT under some circumstances,
+       even when it is not blocked; however, if the signal it trapped,
+       the trap gets correctly executed.
+       * tests/defs [$sh_errexit_works = yes]: Also trap SIGQUIT. Add
+       extensive explanation of why we do so.
+       * tests/self-check-cleanup.tap: Improve and fix to ensure that an
+       earlier failure does not prevent the rest of the test to execute.
+       Problem revealed by a failure in `self-check-cleanup.tap'.
+
 2011-09-13  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        test defs: work around weird ksh behaviour w.r.t. signal handling
index 9fed42e4cc4c0339a002d36ed8c3b7ccf1ba7f88..f1822c8ef35c260723a982f45ea158b358367bbd 100644 (file)
@@ -963,6 +963,21 @@ if test "$sh_errexit_works" = yes; then
   trap "fatal_ 'caught signal SIGHUP'" 1
   trap "fatal_ 'caught signal SIGINIT'" 2
   trap "fatal_ 'caught signal SIGTERM'" 15
+  # Various shells seems to just ignore SIGQUIT under some circumstances,
+  # even if the signal is not blocked; however, if the signal it trapped,
+  # the trap gets correctly executed.  So we also trap SIGQUIT.
+  # Here is a list of some shells that have been verified to exhibit the
+  # problematic behavior with SIGQUIT:
+  #  - zsh 4.3.12 on Debian GNU/Linux
+  #  - /bin/ksh and /usr/xpg4/bin/sh on Solaris 10
+  #  - Bash 3.2.51 on Solaris 10 and bash 4.1.5 on Debian GNU/Linux
+  #  - AT&T ksh on Debian Gnu/Linux (deb package ksh, version 93u-1)
+  # OTOH, at least these shells that do *not* exhibit that behaviour:
+  #  - modern version of the Almquist Shell (at least 0.5.5.1), on
+  #    both Solaris and GNU/Linux
+  #  - Solaris 10 /bin/sh
+  #  - public domain Korn Shell, version 5.2.14, on Debian GNU/Linux
+  trap "fatal_ 'caught signal SIGQUIT'" 3
   # Ignore further SIGPIPE in the trap code.  This is required to avoid
   # a very weird issue with some shells, at least when the execution of
   # the automake testsuite is driven by the `prove' utility: if prove
index c9d0bc9ba022822343b139a78b46c685ff31af26..d369c9f22c34b725ca7748a4751dbbfcf7984164 100755 (executable)
@@ -42,6 +42,14 @@ export have_symlinks # Is used also by spawned shells.
 
 dir=dummy.dir
 
+# Don't let a failure poison all subsequent tests.
+do_clean ()
+{
+  test -d $dir || return 0
+  find $dir -type d -exec chmod u+rwx '{}' ';' || :
+  rm -rf $dir
+}
+
 # Check that pre-test cleanup works also with directories with
 # "null" permissions, and containing broken symlinks.
 mkdir $dir $dir/sub
@@ -56,9 +64,11 @@ chmod 000 $dir/sub/* $dir/file $dir/symlink
 chmod 000 $dir/sub $dir
 command_ok_ "pre-cleanup can deal with null-perms testdir" \
             $SHELL -c  '. ./defs' dummy.test
-command_ok_ "pre-cleanup removed null-perms testdir"
+command_ok_ "pre-cleanup removed null-perms testdir" \
             eval 'test ! -f $dir && test ! -d $dir && test ! -r $dir'
 
+do_clean
+
 # Check that post-test cleanup works also with directories with
 # "null" permissions, and containing broken symlinks.
 command_ok_ "post-cleanup can deal with null-perms testdir" \
@@ -78,9 +88,11 @@ command_ok_ "post-cleanup can deal with null-perms testdir" \
   chmod 000 dir/sub dir
   :
 ' dummy.test
-command_ok_ "post-cleanup removed null-perms testdir"
+command_ok_ "post-cleanup removed null-perms testdir" \
             eval 'test ! -f $dir && test ! -d $dir && test ! -r $dir'
 
+do_clean
+
 # Check that pre-test cleanup does not unduly change the permissions of
 # files to which symlinks in the temporary test directory point to.
 if test $have_symlinks = yes; then
@@ -123,6 +135,8 @@ else # $have_symlinks = no
   skip_row_ 6 "symlinks not supported"
 fi
 
+do_clean
+
 # 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.
@@ -136,7 +150,7 @@ for st in 1 2 3 10 77 99 126 127 130 255; do
   " dummy.test
   command_ok_ "testdir not removed if exiting with status $st" \
               test -f dummy.dir/foo
-  rm -rf dummy.dir
+  do_clean
 done
 
 for sig in 1 2 3 9 13 15; do
@@ -152,7 +166,7 @@ for sig in 1 2 3 9 13 15; do
   " dummy.test
   command_ok_ "testdir not removed if getting signal $sig" \
               test -f dummy.dir/foo
-  rm -rf dummy.dir
+  do_clean
 done
 
 :