Hash :
84e12c32
Author :
Date :
2013-05-17T13:45:44
tests: sanitize 'unset' usages
In some shells (e.g., Solaris 10 /bin/ksh, or NetBSD 5.1 /bin/sh),
"unset VAR" returns a non-zero exit status in case the VAR variable
is already unset. This doesn't interact well with our usage of
"set -e" in the testsuite. So far, we've avoided spurious failures
by either explicitly ignoring the exit status from unset:
unset VAR || :
or explicitly ensuring that a variable is set, before trying to
unset it:
VAR=; unset VAR
But we can do better, by aliasing the 'unset' command to a custom
function that will take care of these details for us. This will
avoid us annoying spurious failures in the future, failures that
have already bitten us too much times. For an example, refer to
commit 'v1.12.2-88-g5b1dae5' of 2012-08-05 (tests: avoid tons of
spurious failures on NetBSD).
* t/ax/test-lib.sh (_am_unset): New function.
(unset): New alias to it.
(_am_exit): Adjust comments.
* t/ax/am-test-lib.sh: No need to temporary disable the 'errexit'
shell flag when unsetting variables that are potentially already
unset.
(am_process_requirements): Adjust to remove a now-useless
workaround related to unset.
* t/aclocal-macrodir.tap: Likewise.
* t/aclocal-macrodirs.tap: Likewise.
* t/auxdir-autodetect.sh: Likewise.
* t/ax/am-test-lib.sh: Likewise.
* t/ax/test-lib.sh: Likewise.
* t/check-tests-in-builddir.sh: Likewise.
* t/dist-formats.tap: Likewise.
* t/distcheck-configure-flags-am.sh: Likewise.
* t/distcheck-configure-flags.sh: Likewise.
* t/java-empty-classpath.sh: Likewise.
* t/javaflags.sh: Likewise.
* t/lflags.sh: Likewise.
* t/lflags2.sh: Likewise.
* t/lisp-flags.sh: Likewise.
* t/lisp6.sh: Likewise.
* t/missing-auxfile-stops-makefiles-creation.sh: Likewise.
* t/parallel-am.sh: Likewise.
* t/parallel-am2.sh: Likewise.
* t/parallel-am3.sh: Likewise.
* t/parallel-tests-log-override-recheck.sh: Likewise.
* t/pkg-config-macros.sh: Likewise.
* t/python-missing.sh: Likewise.
* t/python-too-old.sh: Likewise.
* t/python11.sh: Likewise.
* t/self-check-dir.tap: Likewise.
* t/self-check-report.sh: Likewise.
* t/self-check-seq.tap: Likewise.
* t/silent-configsite.sh: Likewise.
* t/suffix6c.sh: Likewise.
* t/tar-override.sh: Likewise.
* t/tests-environment-and-log-compiler.sh: Likewise.
* t/vala-configure.sh: Likewise.
* t/werror3.sh: Likewise.
* t/yflags-cmdline-override.sh: Likewise.
* t/yflags.sh: Likewise.
* t/yflags2.sh: Likewise.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
#! /bin/sh
# Copyright (C) 2008-2013 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/>.
# Test parallel automake execution.
# There are several hypotheses to be tested: Independently of the number
# of threads used by automake,
# 0) the generated Makefile.in files must be identical without --add-missing,
# 1) the Makefile.in that distributes auxiliary files must be generated
# after all other ones, so all installed aux files are caught,
# 2) normal automake output should have identical content and be ordered
# in the same way, when --add-missing is not passed, or when
# --add-missing is passed but there are no concurrent file requirements
# (i.e., two Makefile.am files call for the same needed aux file)
# 3) normal automake output should be identical and ordered in the same way
# with --add-missing, even with concurrent file requirements, and the
# installation of aux files should be race-free,
# 4) warning and normal error output should be identical, in that duplicate
# warnings should be omitted in the same way as without threads,
# 5) fatal error and debug messages could be identical. This is not
# intended, though.
#
# This test checks (0), (1), and (2). See sister tests for further coverage.
required=perl-threads
. test-init.sh
cat > configure.ac << 'END'
AC_INIT([parallel-am], [1.0])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE
AC_PROG_CC
AM_PATH_LISPDIR
AM_PATH_PYTHON
AC_CONFIG_FILES([Makefile])
END
cat > Makefile.am << 'END'
SUBDIRS =
END
list='1 2 3 4 5 6 7 8 9'
for i in $list; do
echo "AC_CONFIG_FILES([sub$i/Makefile])" >> configure.ac
echo "SUBDIRS += sub$i" >> Makefile.am
mkdir sub$i
echo > sub$i/Makefile.am
done
# Use an include chain to cause a nontrivial location object to be
# serialized through a thread queue.
echo 'include foo.am' >> sub7/Makefile.am
echo 'include bar.am' > sub7/foo.am
echo 'python_PYTHON = foo.py' > sub7/bar.am
echo 'lisp_LISP = foo.el' >> sub8/Makefile.am
echo 'bin_PROGRAMS = p' >> sub9/Makefile.am
rm -f install-sh missing depcomp
mkdir build-aux
$ACLOCAL
# This test may have to be run several times in order to expose the
# race that, when the last Makefile.in (the toplevel one) is created
# before the other ones have finished, not all auxiliary files may
# be installed yet, thus some may not be distributed.
#
# Further, automake output should be stable.
# Generate expected output using the non-threaded code.
unset AUTOMAKE_JOBS
AUTOMAKE_run --add-missing
mv stderr expected
Makefile_ins=$(find . -name Makefile.in)
for file in $Makefile_ins; do
mv $file $file.exp
done
AUTOMAKE_JOBS=5
export AUTOMAKE_JOBS
for run in 1 2 3 4 5 6 7; do
rm -f build-aux/* sub*/Makefile.in
AUTOMAKE_run --add-missing
diff stderr expected
for file in $Makefile_ins; do
diff $file $file.exp
done
done
: