Hash :
e1177186
Author :
Date :
2011-09-06T17:10:21
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
#! /bin/sh
# Copyright (C) 2011 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Check that the parallel-tests driver removed incomplete log files
# when interrupt upon some signal. This test is definitely too hacky,
# but we couldn't find a better way to deal with inter-processes
# signals and the whole process-synchronization mess.
parallel_tests=yes
. ./defs || Exit 1
cat >> configure.in << 'END'
AC_OUTPUT
END
cat > Makefile.am << 'END'
TESTS = foo.test
## Ugly, but required by foo.test. See below.
TEST_LOG_COMPILER = echo $$$$ > pid && exec 9>&2 && $(SHELL) -x
END
# This is hacky and ugly, but has the great advantage of avoiding us a lot
# of pain with background processes and related synchronization issues.
cat > foo.test << 'END'
#!/bin/sh
exec 2>&9
echo "foo is starting to run"
ls -l >&2
cat foo.log-t >&2 || : > fail
grep '^foo is starting to run$' foo.log-t >&2 || : > fail
cat pid >&2 || : > fail
kill -$signum `cat pid` || : > fail
END
chmod a+x foo.test
$ACLOCAL
$AUTOCONF
$AUTOMAKE -a
./configure
# The only signals that can be trapped portable are 1 "SIGHUP",
# 2 "SIGINT", 13 "SIGPIPE" and 15 "SIGTERM".
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
cat foo.log-t || :
cat foo.log || :
cat test-suite.log || :
test -f fail && Exit 1
test -f foo.log-t && Exit 1
test -f foo.log && Exit 1
done
: