I've pushed the attached patch to master. The new tests pass on Debian GNU/Linux and on Solaris with /bin/sh and XPG4 make.
Regards, Stefano -*-*- * tests/parallel-tests-interrupt.test: New test. * tests/parallel-tests-reset-term.test: Likewise. * tests/Makefile.am (TESTS): Update. --- ChangeLog | 7 +++ tests/Makefile.am | 2 + tests/Makefile.in | 2 + tests/parallel-tests-interrupt.test | 71 +++++++++++++++++++++++++++ tests/parallel-tests-reset-term.test | 89 ++++++++++++++++++++++++++++++++++ 5 files changed, 171 insertions(+), 0 deletions(-) create mode 100755 tests/parallel-tests-interrupt.test create mode 100755 tests/parallel-tests-reset-term.test
From eeef872d6ada65684fec203c6ce585d5872f8e27 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini <stefano.lattar...@gmail.com> Date: Sun, 17 Apr 2011 17:28:04 +0200 Subject: [PATCH] coverage: more tests on the parallel-tests driver * tests/parallel-tests-interrupt.test: New test. * tests/parallel-tests-reset-term.test: Likewise. * tests/Makefile.am (TESTS): Update. --- ChangeLog | 7 +++ tests/Makefile.am | 2 + tests/Makefile.in | 2 + tests/parallel-tests-interrupt.test | 71 +++++++++++++++++++++++++++ tests/parallel-tests-reset-term.test | 89 ++++++++++++++++++++++++++++++++++ 5 files changed, 171 insertions(+), 0 deletions(-) create mode 100755 tests/parallel-tests-interrupt.test create mode 100755 tests/parallel-tests-reset-term.test diff --git a/ChangeLog b/ChangeLog index a7541e8..21acbc1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2011-04-17 Stefano Lattarini <stefano.lattar...@gmail.com> + coverage: more tests on the parallel-tests driver + * tests/parallel-tests-interrupt.test: New test. + * tests/parallel-tests-reset-term.test: Likewise. + * tests/Makefile.am (TESTS): Update. + +2011-04-17 Stefano Lattarini <stefano.lattar...@gmail.com> + check: new developer-reserved AM_TESTS_SETUP variable For reference, see the discussion at: <http://lists.gnu.org/archive/html/automake-patches/2011-01/msg00213.html> diff --git a/tests/Makefile.am b/tests/Makefile.am index 0bf882c..09791be 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -704,6 +704,8 @@ parallel-tests10.test \ parallel-tests-am_tests_setup.test \ parallel-tests-unreadable-log.test \ parallel-tests-subdir.test \ +parallel-tests-interrupt.test \ +parallel-tests-reset-term.test \ parse.test \ percent.test \ percent2.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 531374e..13c03b0 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -968,6 +968,8 @@ parallel-tests10.test \ parallel-tests-am_tests_setup.test \ parallel-tests-unreadable-log.test \ parallel-tests-subdir.test \ +parallel-tests-interrupt.test \ +parallel-tests-reset-term.test \ parse.test \ percent.test \ percent2.test \ diff --git a/tests/parallel-tests-interrupt.test b/tests/parallel-tests-interrupt.test new file mode 100755 index 0000000..45e55d4 --- /dev/null +++ b/tests/parallel-tests-interrupt.test @@ -0,0 +1,71 @@ +#! /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 + 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 + +: diff --git a/tests/parallel-tests-reset-term.test b/tests/parallel-tests-reset-term.test new file mode 100755 index 0000000..c98a6b5 --- /dev/null +++ b/tests/parallel-tests-reset-term.test @@ -0,0 +1,89 @@ +#! /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 correctly handle overrides of +# the TERM variable by either TESTS_ENVIRONMENT and AM_TESTS_SETUP. + +parallel_tests=yes +. ./defs || Exit 1 + +esc='[' + +# Check that grep can parse nonprinting characters. +# BSD 'grep' works from a pipe, but not a seekable file. +# GNU or BSD 'grep -a' works on files, but is not portable. +case `echo "$esc" | $FGREP "$esc"` in + "$esc") ;; + *) echo "$me: $FGREP can't parse nonprinting characters" >&2; Exit 77;; +esac + +cat >> configure.in << 'END' +AC_OUTPUT +END + +cat > Makefile.am << 'END' +AM_COLOR_TESTS = always +AUTOMAKE_OPTIONS = color-tests +TESTS = foobar +END + +cat > foobar << 'END' +#!/bin/sh +echo "TERM='$TERM'" +echo "expected_term='$expected_term'" +test x"$TERM" = x"$expected_term" +END +chmod a+x foobar + +mkcheck () +{ + if env AM_COLOR_TESTS=always $* $MAKE check > stdout; then + rc=0 + else + rc=1 + fi + cat stdout + cat foobar.log + cat test-suite.log + return $rc +} + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a +./configure + +TERM=ansi; export TERM +expected_term=dumb; export expected_term +mkcheck TESTS_ENVIRONMENT='TERM=dumb' +cat stdout | grep "PASS.*foobar" | $FGREP "$esc" + +TERM=dumb; export TERM +expected_term=ansi; export expected_term +mkcheck TESTS_ENVIRONMENT='TERM=ansi' +cat stdout | $FGREP "$esc" && Exit 1 + +TERM=ansi; export TERM +expected_term=dumb; export expected_term +mkcheck AM_TESTS_SETUP='TERM=dumb' +cat stdout | grep "PASS.*foobar" | $FGREP "$esc" + +TERM=dumb; export TERM +expected_term=ansi; export expected_term +mkcheck AM_TESTS_SETUP='TERM=ansi' +cat stdout | $FGREP "$esc" && Exit 1 + +: -- 1.7.2.3