From: Stefano Lattarini Date: Sat, 11 Jun 2011 10:22:15 +0000 (+0200) Subject: Merge branch 'maint' into testsuite-work X-Git-Tag: ng-0.5a~89^2~195 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=391f55ae47ddbe43a5fc4524f7ec9bb0d67689c0;p=thirdparty%2Fautomake.git Merge branch 'maint' into testsuite-work * maint: test defs: new function 'fatal_', for hard errors --- 391f55ae47ddbe43a5fc4524f7ec9bb0d67689c0 diff --cc ChangeLog index e1fc2694b,5b3053dff..6ada906ea --- a/ChangeLog +++ b/ChangeLog @@@ -1,178 -1,20 +1,195 @@@ + 2011-06-08 Stefano Lattarini + + test defs: new function 'fatal_', for hard errors + Before this patch, the only way offered by tests/defs to + properly signal a hard error was the `framework_failure_' + function. But the error message issued by that function, + as its name would suggest, refers to a set-up failure in the + testsuite, while hard errors can obviously also be due to + other reasons. The best way to fix this inconsistency is to + introduce a new function with a more general error message. + Inspired by a recent similar change to Gnulib's tests/init.sh. - * tests/defs.in (fatal_): New function. ++ * tests/defs (fatal_): New function. + * tests/README (Section "Writing test cases" subsection "Do"): + Suggest the use of `fatal_', not of `framework_failure_', for + generic hard errors. The latter should be reserved for "real" + set-up failures. + +2011-06-07 Stefano Lattarini + + tests: `lib/' shell scripts transparently tested also with $SHELL + With the previous commit, the user could prefer the use of $SHELL + over /bin/sh in some tests checking the Automake-provided shell + scripts by manually exporting `test_prefer_config_shell' to "yes" + in the environment. With this commit, we ensure that such tests + *always* and *transparently* run using both $SHELL and /bin/sh + to execute the checked scripts. The `test_prefer_config_shell' + variable becomes an internal detail, and is no more meant to be + manually defined or overridden. + * tests/defs-static.in: Check that `test_prefer_config_shell' is + not exported in the environment. Error out if this is the case. + * tests/config-shell-tests.sh: New file, driver script to run + checks on the shell scripts in `lib/' using the $SHELL determined + at configure time instead of the default system shell /bin/sh. + * Makefile.am (TESTS_EXTENSIONS): Add `.shtst'. + (SHTST_LOG_COMPILER): Define, it calls `config-shell-tests.sh'. + (config_shell_tests): Define to a list of tests that wraps other + `*.test' tests using `config-shell-tests.sh'. + ($(config_shell_tests)): Dummy dependency declaration required + in order to have make actually produce expected log files from + the `.shtst.log' suffix rule. + (EXTRA_DIST): Distribute `config-shell-tests.sh'. + (TESTS): Add `$(config_shell_tests)'. + * tests/self-check-env-sanitize.test: Update, by checking that + `test_prefer_config_shell' isn't exported in the environment. + +2011-06-07 Stefano Lattarini + + tests: can use also $SHELL to check shell scripts from `lib/' + * tests/ar-lib.test: If the variable `$test_prefer_config_shell' + is set to "yes", run the script under test with configure-time + determined $SHELL, rather than with /bin/sh. + The `$test_prefer_config_shell' variable defaults to empty, but + can be overridden at runtime by the user, thus allowing more + coverage. + * tests/compile.test: Likewise. + * tests/compile2.test: Likewise. + * tests/compile3.test: Likewise. + * tests/compile4.test: Likewise. + * tests/compile5.test: Likewise. + * tests/compile6.test: Likewise. + * tests/instsh2.test: Likewise. + * tests/instsh3.test: Likewise. + * tests/mkinst3.test: Likewise. + * tests/missing.test: Likewise. + * tests/missing2.test: Likewise. + * tests/missing3.test: Likewise. + * tests/missing5.test: Likewise. + * tests/defs (get_shell_script): New subroutine, factoring out + code common to the tests above. + (xsi-lib-shell): If `$test_prefer_config_shell' is set to "yes", + check that $SHELL, not /bin/sh, supports XSI constructs, as we + expect the test will use $SHELL and not /bin/sh to run the + script being tested. + +2011-06-07 Stefano Lattarini + + tests defs: better requirements for XSI shells + This change avoids potential spurious failures with tests using + the requirement 'xsi-shell' to mean that they want */bin/sh* (not + $SHELL) to be XSI-conforming. This idiom used to work before + commit `v1.11-874-g1321be7' (as back then the test scripts were + unconditionally run with /bin/sh), but has become inconsistent + now that the test scripts re-execute themselves with configure + determined $SHELL. + The described spurious failures have already occurred in practice, + for examples on Solaris systems which also had GNU Bash installed. + From a suggestion by Peter Rosin. See discussion at: + + * tests/defs (xsi-shell): Now check that $SHELL, rather than the + shell currently running the test script, is an XSI shell. + (xsi-bin-sh): New requirement, checking that /bin/sh (which can + differ from $SHELL) is an XSI shell. + (xsi-lib-shell): New requirement, checking that the shell that + should be used to test the Automake-provided scripts from `lib/' + is an XSI shell. For the moment, this is just an alias for + `xsi-bin-sh'. + (require_xsi): New subroutine, used to factor out code common to + the requirements above. + ($xsi_shell_code): New variable, contains shell code supposed to + work only with XSI shells. Used by the new subroutine above. + * tests/ar-lib.test ($required): Require 'xsi-lib-shell' instead + of 'xsi-shell', since the script we test here is run with /bin/sh, + not with $SHELL. + * tests/compile3.test: Likewise. + * tests/compile6.test: Likewise. + +2011-06-05 Stefano Lattarini + + tests: fix typo-related error in auxdir2.test + * tests/auxdir2.test (configure.in): Close m4 quoting in the + argument to AC_CONFIG_AUX_DIR. Without this, aclocal fails with + "ERROR: end of file in string". This problem hasn't been exposed + by the testsuite before because this test is in XFAIL_TESTS, so + its failure went unnoticed, even if it was due to a wrong cause. + Bug introduced in commit v1.11-249-g49ac3de. + +2011-06-05 Stefano Lattarini + + self tests: check that `$me' can be overridden + * tests/self-check-me.test: Check that `$me' can be overridden + before sourcing ./defs, with or without sourcing ./defs-static + beforehand, and that this override is honored. Update heading + comments. + +2011-06-02 Stefano Lattarini + + self tests: fix another spurious failure + Our ad-hoc usage of `tests/defs' in the testsuite's self tests + stopped working properly when we made the test scripts re-execute + themselves with the configure-time $SHELL. Fix this. + Fixes a regression introduced by commit 'v1.11-874-g1321be7'. + * tests/self-check-exit.test: Export `AM_TESTS_REEXEC' to "no" + before running the self tests. This fixes a spurious failure + present only when the test was run by hand. + +2011-06-02 Stefano Lattarini + + silent-rules tests: fix spurious failures with Sun Studio C++ + * tests/silentcxx.test: The C++ compiler from Sun Studio is named + `CC'. Account for this in our grepping checks on the make output. + Since we are at it, throw in a couple of improvements to comments + and formatting. + * tests/silent-many-generic.test: The C++ compiler from Sun Studio + is named `CC', and this can cause spurious failures in our grepping + of the make output. Work around this by using a wrapper script + around the C++ compiler (generated on the fly), since filtering the + make output proved to be too fragile. + +2011-06-02 Stefano Lattarini + + tests: fix spurious failure in backcompat2.test on NetBSD + * tests/backcompat2.test: Add trailing `:' in the body of a `for' + loop, in case the last command there might have an exit status + different 0. This work around `set -e' issues in some BSD shells, + e.g., NetBSD /bin/ksh. + +2011-06-02 Stefano Lattarini + + tests: fix spurious failure in autohdr3.test + * tests/autohder3.test (Makefile.am): Let `test' depend on `all', + so that config.h header is truly remade. + Remove now useless call to `$MAKE' when non-GNU make is in use. + Failure introduced by commit `v1.11-895-g5e62b96'. + +2011-06-02 Stefano Lattarini + + tests: fix spurious failure of cond29.test on NetBSD + * tests/cond29.test: Skip if we cannot safely limit the maximal + size of used virtual memory to 20K. This fixes a spurious failure + on NetBSD. + Bug introduced in commit `v1.11-885-g908d335'. + +2011-06-02 Stefano Lattarini + + maintcheck: fix again few more failures + * tests/cond29.test: To please the `sc_tests_Exit_not_exit' + maintainer check, avoid using `sh -c "exit 0"' where a simple + `sh -c :' will do. + * tests/depmod-data.test: Use creative quoting to avoid + spuriously triggering the `sc_tests_Exit_not_exit' maintainer + check. + +2011-06-02 Stefano Lattarini + + maintcheck: fix some more failures + * tests/instdir-ltlib.test: Use creative quoting to avoid + spuriously triggering the `sc_rm_minus_f' maintainer check. + * tests/instdir-prog.test: Likewise. + * tests/instspc-data.test: Use creative quoting to avoid + spuriously triggering the `sc_tests_Exit_not_exit' maintainer + check. + 2011-06-02 Stefano Lattarini maintcheck: fix some failures, extend some checks diff --cc tests/defs index e8ff92e0a,000000000..b65989a9b mode 100644,000000..100644 --- a/tests/defs +++ b/tests/defs @@@ -1,762 -1,0 +1,763 @@@ +# -*- shell-script -*- +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009, 2010, 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 . + + +# IMPORTANT NOTE: This file should execute correctly with any system's +# /bin/sh shell, and not only with configure-time detected $CONFIG_SHELL, +# until differently and explicitly specified. + + +## -------------------------------------------------------- ## +## Source static setup and definitions for the testsuite. ## +## -------------------------------------------------------- ## + +# This code needs to be 'set -e' clean. + +# Ensure we are running from the right directory. +test -f ./defs-static || { + echo "$0: ./defs-static: not found in current directory" >&2 + exit 99 +} + +# Source the shell sanitization and variables' definitions. +. ./defs-static || exit 99 + +# The name of the current test (without the `.test' suffix). +# Test scripts can override it if they need to (but this should +# be done carefully, and *before* including ./defs). +if test -z "$me"; then + # Guard against failure to spawn sed (seen on MSYS), or empty $argv0. + me=`echo "$argv0" | sed -e 's,.*[\\/],,;s/\.test$//'` \ + && test -n "$me" \ + || { echo "$argv0: failed to define \$me" >&2; exit 99; } +fi + +## ---------------------- ## +## Early sanity checks. ## +## ---------------------- ## + +# A single whitespace character. +sp=' ' +# A tabulation character. +tab=' ' +# A newline character. +nl=' +' + +# As autoconf-generated configure scripts do, ensure that IFS +# is defined initially, so that saving and restoring $IFS works. +IFS=$sp$tab$nl + +# Ensure $testsrcdir is set correctly. +test -f "$testsrcdir/defs-static.in" || { + echo "$me: $testsrcdir/defs-static.in not found, check \$testsrcdir" >&2 + exit 99 +} + +# Ensure $testbuilddir is set correctly. +test -f "$testbuilddir/defs-static" || { + echo "$me: $testbuilddir/defs-static not found, check \$testbuilddir" >&2 + exit 99 +} + + +## ------------------------------------ ## +## Ensure we run with a proper shell. ## +## ------------------------------------ ## + +# Make sure we run with the shell detected at configure time (unless +# the user forbids it). +case ${AM_TESTS_REEXEC-yes} in + n|no|false|0) + ;; + *) + # Ensure we can find ourselves. + if test ! -f "$0"; then + echo "$me: unable to find myself: $0" >&2 + exit 99 + fi + AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC + # Cannot simply do `opts=$-', since the content of $- is not + # portable among different shells. So try to propagate only + # the portable and interesting options. + case $- in + *x*v*|*v*x) opts=-vx;; + *v*) opts=-v;; + *x*) opts=-x;; + *) opts=;; + esac + echo $me: exec $SHELL $opts "$0" "$*" + exec $SHELL $opts "$0" ${1+"$@"} + echo "$me: failed to re-execute with $SHELL" >&2 + exit 99 + ;; +esac + +# NOTE: From this point on, we can assume this file is being executed +# by the configure-time detected $CONFIG_SHELL. + + +## ---------------------- ## +## Environment cleanup. ## +## ---------------------- ## + +# Unset some MAKE... variables that may cause $MAKE to act like a +# recursively invoked sub-make. Any $MAKE invocation in a test is +# conceptually an independent invocation, not part of the main +# 'automake' build. +unset MFLAGS MAKEFLAGS AM_MAKEFLAGS MAKELEVEL __MKLVL__ MAKE_JOBS_FIFO +# Unset verbosity flag. +unset V +# Also unset variables that will let `make -e install' divert +# files into unwanted directories. +unset DESTDIR +unset prefix exec_prefix bindir datarootdir datadir docdir dvidir +unset htmldir includedir infodir libdir libexecdir localedir mandir +unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir +# The tests call `make -e' but we do not want $srcdir from the environment +# to override the definition from the Makefile. +unset srcdir +# Also unset variables that control our test driver. While not +# conceptually independent, they cause some changed semantics we +# need to control (and test for) in some of the tests to ensure +# backward-compatible behavior. +unset TESTS_ENVIRONMENT +unset DISABLE_HARD_ERRORS +unset TESTS +unset TEST_LOG_COMPILER +unset TEST_LOGS +unset RECHECK_LOGS +unset VERBOSE + + +## ---------------------------- ## +## Auxiliary shell functions. ## +## ---------------------------- ## + +# This is used in `Exit' and in the exit trap. See comments in the latter +# for more information, +am__test_skipped=no + +# We use a trap below for cleanup. This requires us to go through +# hoops to get the right exit status transported through the signal. +# So use `Exit STATUS' instead of `exit STATUS' inside of the tests. +# Turn off errexit here so that we don't trip the bug with OSF1/Tru64 +# sh inside this function. +Exit () +{ + set +e + # See comments in the exit trap for the reason we do this. + test 77 = $1 && am__test_skipped=yes + (exit $1); exit $1 +} + +# Print warnings (e.g., about skipped and failed tests) to this file +# number. Override by putting, say: +# stderr_fileno_=9; export stderr_fileno_; exec 9>&2; +# in the definition of AM_TESTS_ENVIRONMENT. +# This is useful when using automake's parallel tests mode, to print the +# reason for skip/failure to console, rather than to the *.log files. +: ${stderr_fileno_=2} + +# Copied from Gnulib's `tests/init.sh'. +warn_ () { echo "$@" 1>&$stderr_fileno_; } +fail_ () { warn_ "$me: failed test: $@"; Exit 1; } +skip_ () { warn_ "$me: skipped test: $@"; Exit 77; } ++fatal_ () { warn_ "$me: hard error: $@"; Exit 99; } +framework_failure_ () { warn_ "$me: set-up failure: $@"; Exit 99; } + +# cross_compiling +# --------------- +# Tell whether we are cross-compiling. This is especially useful to skip +# tests (or portions of them) that requires a native compiler. +cross_compiling () +{ + test x"$host_alias" != x && test x"$build_alias" != x"$host_alias" +} + +# is_newest FILE FILES +# -------------------- +# Return false if any file in FILES is newer than FILE. +# Resolve ties in favor of FILE. +is_newest () +{ + is_newest_files=`find "$@" -newer "$1"` + test -z "$is_newest_files" +} + +# AUTOMAKE_run status [options...] +# -------------------------------- +# Run Automake with OPTIONS, and fail if automake +# does not exit with STATUS. +AUTOMAKE_run () +{ + expected_exitcode=$1 + shift + exitcode=0 + $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$? + cat stderr >&2 + cat stdout + test $exitcode = $expected_exitcode || Exit 1 +} + +# AUTOMAKE_fails [options...] +# --------------------------- +# Run Automake with OPTIONS, and fail if automake +# does not exit with STATUS. +AUTOMAKE_fails () +{ + AUTOMAKE_run 1 ${1+"$@"} +} + +# using_gmake +# ----------- +# Return success if $MAKE is GNU make, return failure otherwise. +# Caches the result for speed reasons. +using_gmake () +{ + case $am__using_gmake in + yes) + return 0;; + no) + return 1;; + '') + # Use --version AND -v, because SGI Make doesn't fail on --version. + # Also grep for GNU because newer versions of FreeBSD make do + # not complain about `--version' (they seem to silently ignore it). + if $MAKE --version -v | grep GNU; then + am__using_gmake=yes + return 0 + else + am__using_gmake=no + return 1 + fi;; + *) + echo "invalid value for \$am__using_gmake: '$am__using_gmake'" >&2 + Exit 99;; + esac +} +am__using_gmake="" # Avoid interferences from the environment. + +commented_sed_unindent_prog=' + /^$/b # Nothing to do for empty lines. + x # Get x into pattern space. + /^$/{ # No prior x, go prepare it. + g # Copy this 1st non-blank line into pattern space. + s/^\(['"$tab"' ]*\).*/x\1/ # Prepare x in pattern space. + } # Now: x in pattern and in hold. + G # Build x\n in pattern space, and + h # duplicate it into hold space. + s/\n.*$// # Restore x in pattern space, and + x # exchange with the above duplicate in hold space. + s/^x\(.*\)\n\1// # Remove leading from . + s/^x.*\n// # Restore when there is no leading . +' + +# unindent [input files...] +# ------------------------- +# Remove the "proper" amount of leading whitespace from the given files, +# and output the result on stdout. That amount is determined by looking +# at the leading whitespace of the first non-blank line in the input +# files. If no input file is specified, standard input is implied. +unindent () +{ + if test x"$sed_unindent_prog" = x; then + sed_unindent_prog=`printf '%s\n' "$commented_sed_unindent_prog" | sed -e "s/ *# .*//"` + fi + sed "$sed_unindent_prog" ${1+"$@"} +} +sed_unindent_prog="" # Avoid interferences from the environment. + +# get_shell_script SCRIPT-NAME +# ----------------------------- +# Fetch an Automake-provided test script from the `lib/' directory into +# the current directory, and, if the `$test_prefer_config_shell' variable +# is set to "yes", modify its shebang line to use $SHELL instead of +# /bin/sh. +get_shell_script () +{ + if test x"$test_prefer_config_shell" = x"yes"; then + sed "1s|#!.*|#! $SHELL|" "$top_testsrcdir/lib/$1" > "$1" + chmod a+x "$1" + else + cp "$top_testsrcdir/lib/$1" . + fi + sed 10q "$1" # For debugging. +} + +# require_xsi SHELL +# ----------------- +# Skip the test if the given shell fails to support common XSI constructs. +require_xsi () +{ + test $# -eq 1 || framework_failure_ "require_xsi needs exactly one arg" + echo "$me: trying some XSI constructs with $1" + $1 -c "$xsi_shell_code" || skip_ "$1 lacks XSI features" +} +# Shell code supposed to work only with XSI shells. Keep this in sync +# with libtool.m4:_LT_CHECK_SHELL_FEATURES. +xsi_shell_code=' + _lt_dummy="a/b/c" + test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,b/c, \ + && eval '\''test $(( 1 + 1 )) -eq 2 \ + && test "${#_lt_dummy}" -eq 5'\' + + +## ----------------------------------------------------------- ## +## Checks for required tools, and additional setups (if any) ## +## required by them. ## +## ----------------------------------------------------------- ## + +# Print it here, so that the user will see it also if the test +# will be skipped due to some tool missing in $PATH itself. +echo "$PATH" + +# So that we can force the use of correct gcc, g++ etc., consistently +# with cross-compilation settings. +if cross_compiling; then + am__tool_prefix="$host_alias-" +else + am__tool_prefix= +fi + +# Look for (and maybe set up) required tools and/or system features; skip +# the current test if they are not found. +for tool in : $required +do + # Check that each required tool is present. + case $tool in + :) ;; + cc) + test "$CC" = false && skip_ "no C compiler available";; + c++) + test "$CXX" = false && skip_ "no C++ compiler available";; + fortran) + test "$FC" = false && skip_ "no Fortran compiler available";; + fortran77) + test "$F77" = false && skip_ "no Fortran 77 compiler available";; + xsi-shell) + require_xsi "$SHELL";; + xsi-bin-sh) + require_xsi "/bin/sh";; + xsi-lib-shell) + if test x"$test_prefer_config_shell" = x"yes"; then + require_xsi "$SHELL" + else + require_xsi "/bin/sh" + fi + ;; + bzip2) + # Do not use --version, bzip2 still tries to compress stdin. + echo "$me: running bzip2 --help" + bzip2 --help \ + || skip_ "required program \`bzip2' not available" + ;; + cl) + CC=cl + export CC + echo "$me: running $CC -?" + $CC -? || skip_ "Microsoft C compiler \`$CC' not available" + ;; + cscope) + # Sun cscope is interactive without redirection. + echo "$me: running cscope --version > $priv_check_temp) >/dev/null 2>&1 + overwrite_status=$? + rm -f $priv_check_temp + if test $overwrite_status -eq 0; then + skip_ "cannot drop file write permissions" + fi + unset priv_check_temp overwrite_status + ;; + perl-threads) + if test "$WANT_NO_THREADS" = "yes"; then + skip_ "Devel::Cover cannot cope with threads" + fi + ;; + native) + cross_compiling && skip_ "doesn't work in cross-compile mode" + ;; + python) + # Python doesn't support --version, it has -V + echo "$me: running python -V" + python -V || skip_ "python interpreter not available" + ;; + ro-dir) + # Skip this test case if read-only directories aren't supported + # (e.g., under DOS.) + ro_dir_temp=ro_dir.$$ + mkdir $ro_dir_temp || exit 99 + chmod a-w $ro_dir_temp || exit 99 + (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null + create_status=$? + rm -rf $ro_dir_temp + if test $create_status -eq 0; then + skip_ "cannot drop directory write permissions" + fi + unset ro_dir_temp create_status + ;; + rst2html) + # Try the variants that are tried in check.am. + while :; do + for r2h in $RST2HTML rst2html rst2html.py; do + echo "$me: running $r2h --version" + $r2h --version && break 2 + done + skip_ "no proper rst2html program found" + done + unset r2h + ;; + runtest) + # DejaGnu's runtest program. We rely on being able to specify + # the program on the runtest command-line. This requires + # DejaGnu 1.4.3 or later. + echo "$me: running runtest SOMEPROGRAM=someprogram --version" + runtest SOMEPROGRAM=someprogram --version \ + || skip_ "DejaGnu is not available" + ;; + tex) + # No all versions of Tex support `--version', so we use + # a configure check. + if test -z "$TEX"; then + skip_ "TeX is required, but it wasn't found by configure" + fi + ;; + texi2dvi-o) + # Texi2dvi supports `-o' since Texinfo 4.1. + echo "$me: running texi2dvi -o /dev/null --version" + texi2dvi -o /dev/null --version \ + || skip_ "required program \`texi2dvi' not available" + ;; + flex) + # Since flex is required, we pick LEX for ./configure. + LEX=flex + export LEX + echo "$me: running flex --version" + flex --version || skip_ "required program \`flex' not available" + ;; + lex) + test "$LEX" = false && skip_ "no Lex program available" + if test -z "$LEX"; then + # The user hasn't explicitly specified any lex program in the + # environment, so we try to use flex, skipping the test if it's + # not found. + LEX=flex + export LEX + echo "$me: running flex --version" + flex --version || skip_ "required program \`flex' not available" + fi + ;; + yacc) + test "$YACC" = false && skip_ "no Yacc program available" + if test -z "$YACC"; then + # The user hasn't explicitly specified any yacc program in the + # environment, so we try to use bison, skipping the test if it's + # not found. + YACC='bison -y' + export YACC + echo "$me: running bison --version" + bison --version || skip_ "required program \`bison' not available" + fi + ;; + *) + # Generic case: the tool must support --version. + echo "$me: running $tool --version" + # It is not likely but possible that $tool is a special builtin, + # in which case the shell is allowed to exit after an error. + # So, please leave the subshell here. + ($tool --version) || skip_ "required program \`$tool' not available" + ;; + esac +done + +# Using just `$testbuilddir' for the check here is ok, since the +# further temporary subdirectory where the test will be run is +# ensured not to contain any whitespace character. +case $testbuilddir in + *\ *|*\ *) + case " $required " in + *' libtool '* | *' libtoolize '* ) + skip_ "libtool has problems with spaces in builddir name";; + esac + ;; +esac + +# This test is necessary, although Automake's configure script bails out +# when $srcdir contains spaces. This is because $testsrcdir is in not +# configure-time $srcdir, but is instead configure-time $abs_srcdir, and +# that is allowed to contain spaces. +case $testsrcdir in + *\ * |*\ *) + case " $required " in + *' libtool '* | *' libtoolize '* | *' gettext '* ) + skip_ "spaces in srcdir name: libtool/gettext tests won't work";; + esac + ;; +esac + +# We might need extra macros, e.g., from Libtool or Gettext. +# Find them on the system. +# Use `-I $top_testsrcdir/m4' in addition to `--acdir=$top_testsrcdir/m4', +# because the other `-I' directories added for libtool and gettext might +# contain files from an old version of Automake that we don't want to use. +# Use `-Wno-syntax' because we do not want our test suite to fail because +# some third-party .m4 file is underquoted. +case " $required " in + *' libtool '* | *' libtoolize '* | *' gettext '* ) + aclocaldir=$testprefix/share/aclocal + extra_includes="" + if test -f $aclocaldir/dirlist; then + extra_includes=` + <$aclocaldir/dirlist \ + sed 's/#.*//;s/[ ][ ]*$//g' \ + | while read dir; do test ! -d "$dir" || echo "-I $dir"; done` + else :; fi + + libtool_found=no + gettext_found=no + for d in $extra_includes $aclocaldir ; do + test "x$d" != x-I || continue + if test -f "$d/libtool.m4"; then + libtool_found=yes + fi + if test -f "$d/gettext.m4"; then + gettext_found=yes + fi + done + case " $required " in + *' libtool '*|*' libtoolize '*) + if test $libtool_found != yes; then + # Write more diagnostic to the log file than to the console. + echo "$me: \`libtool.m4' wasn't found in directories" \ + "$aclocaldir $extra_includes" + skip_ "libtool m4 macros won't be found by aclocal" + fi + ;; + *' gettext '*) + if test $gettext_found != yes; then + # Write more diagnostic to the log file than to the console. + echo "$me: \`gettext.m4' wasn't found in directories" \ + "$aclocaldir $extra_includes" + skip_ "gettext m4 macros won't be found by aclocal" + fi + ;; + esac + ACLOCAL="$ACLOCAL -Wno-syntax -I $top_testsrcdir/m4 $extra_includes -I $aclocaldir" + unset libtool_found gettext_found + unset extra_includes aclocaldir + ;; +esac + + +## ---------------------------------------------------------------- ## +## Create and set up of the temporary directory used by the test. ## +## Set up of the exit trap for cleanup of said directory. ## +## ---------------------------------------------------------------- ## + +# This might be used in testcases checking distribution-related features. +# Test scripts are free to override this if they need to. +distdir=$me-1.0 + +# The subdirectory where the current test script will run and write its +# temporary/data files. This will be created shortly, and will be removed +# by the cleanup trap below if the test passes. If the test doesn't pass, +# this directory will be kept, to facilitate debugging. +testSubDir=$me.dir + +test ! -d $testSubDir || { + find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";" + rm -rf $testSubDir +} +mkdir $testSubDir + +cd ./$testSubDir + +if test "$sh_errexit_works" = yes; then + trap 'exit_status=$? + set +e + cd "$testbuilddir" + # This is to ensure that a test script does give a SKIP outcome just + # because a command in it happens to exit with status 77. This + # behaviour, while from time to time useful to developers, is not + # meant to be enabled by default, as it could cause spurious failures + # in the wild. Thus it will be enabled only when the variable + # "am_explicit_skips" is set to a "true" value. + case $am_explicit_skips in + [yY]|[yY]es|1) + if test $exit_status -eq 77 && test $am__test_skipped != yes; then + exit_status=78 + fi + ;; + esac + case $exit_status,$keep_testdirs in + 0,) + find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";" + rm -rf $testSubDir + ;; + esac + test "$signal" != 0 && echo "$me: caught signal $signal" + echo "$me: exit $exit_status" + exit $exit_status + ' 0 + for signal in 1 2 13 15; do + trap 'signal='$signal'; { Exit 99; }' $signal + done + signal=0 +fi + +# Copy in some files we need. +for file in install-sh missing depcomp; do + cp "$top_testsrcdir/lib/$file" . || Exit 99 +done + +# Build appropriate environment in test directory. Eg create +# configure.in, touch all necessary files, etc. +# Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending +# still produces a valid configure.ac. But then, tests running +# config.status really need to append AC_OUTPUT. +{ + echo "AC_INIT([$me], [1.0])" + if test x"$parallel_tests" = x"yes"; then + echo "AM_INIT_AUTOMAKE([parallel-tests])" + else + echo "AM_INIT_AUTOMAKE" + fi + echo "AC_CONFIG_FILES([Makefile])" +} >configure.in + +## ---------------- ## +## Ready to go... ## +## ---------------- ## + +set -x +set -e + +pwd