automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FYI 2/4] {testsuite-work} tests: also trap SIGQUIT; other fixes


From: Stefano Lattarini
Subject: [FYI 2/4] {testsuite-work} tests: also trap SIGQUIT; other fixes
Date: Tue, 13 Sep 2011 16:19:39 +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                    |   12 ++++++++++++
 tests/defs                   |   15 +++++++++++++++
 tests/self-check-cleanup.tap |   22 ++++++++++++++++++----
 3 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cbc6693..909b337 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2011-09-13  Stefano Lattarini  <address@hidden>
 
+       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  <address@hidden>
+
        test defs: work around weird ksh behaviour w.r.t. signal handling
        * tests/defs (is_blocked_signal): Use perl to determine whether a
        signal is trapped, since trying to do it portably within the shell
diff --git a/tests/defs b/tests/defs
index 9fed42e..f1822c8 100644
--- a/tests/defs
+++ b/tests/defs
@@ -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
diff --git a/tests/self-check-cleanup.tap b/tests/self-check-cleanup.tap
index c9d0bc9..d369c9f 100755
--- a/tests/self-check-cleanup.tap
+++ b/tests/self-check-cleanup.tap
@@ -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
 
 :
-- 
1.7.2.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]