From: Stefano Lattarini Date: Fri, 22 Apr 2011 22:02:23 +0000 (+0200) Subject: Merge branch 'maint' X-Git-Tag: ng-0.5a~195 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b0c8d59b79346861dd48242672b7aed7f863c9f;p=thirdparty%2Fautomake.git Merge branch 'maint' --- 3b0c8d59b79346861dd48242672b7aed7f863c9f diff --cc ChangeLog index 6aeafd510,4417d9b15..8821b0abc --- a/ChangeLog +++ b/ChangeLog @@@ -1,16 -1,16 +1,29 @@@ + 2011-04-22 Stefano Lattarini + + testsuite: more environment sanitization + * tests/defs.in: Sanity check: abort if any of `parallel_tests' + or `required' is in the environment. + ($sed_unindent_prog): Initialize to empty, to avoid interferences + from the environment. + * tests/self-check-me-in-env.test: Renamed to ... + * tests/self-check-env-sanitize.test: ... this, and extended. + * tests/Makefile.am (TESTS): Update. + (TESTS_ENVIRONMENT): Unset variables `parallel_tests' and + `required'. Adjust comments. + +2011-04-19 Stefano Lattarini + + tests: in self-checks, use $SHELL, not /bin/sh + * tests/self-check-me-in-env.test: Include `./defs-static' to get + the definition of `$SHELL'. Use `$SHELL' instead of `/bin/sh' to + execute the tests. + +2011-04-19 Stefano Lattarini + + tests: prefer AM_TESTS_ENVIRONMENT to TESTS_ENVIRONMENT + * tests/Makefile.am (TESTS_ENVIRONMENT): Renamed to ... + (AM_TESTS_ENVIRONMENT): ... this. + 2011-04-18 Stefano Lattarini tests: don't allow `$me' to be overridden from the environment diff --cc tests/Makefile.am index 1c1c200b7,3fca68e91..f748ef545 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@@ -33,76 -28,26 +33,79 @@@ txinfo5.tes include $(srcdir)/parallel-tests.am $(srcdir)/parallel-tests.am: gen-parallel-tests Makefile.am - (cd $(srcdir) && $(SHELL) ./gen-parallel-tests) >$@ + $(AM_V_GEN)($(am__cd) $(srcdir) && $(SHELL) ./gen-parallel-tests) >$@ + +$(parallel_tests): Makefile.am + $(AM_V_at)rm -f $@ $@-t + $(AM_V_GEN)input=`echo $@ | sed 's,.*/,,; s,-p.test$$,.test,'`; \ + { echo '#!/bin/sh'; \ + echo '# DO NOT EDIT! GENERATED AUTOMATICALLY!'; \ + echo; \ + echo '# Ensure proper definition of $$testsrcdir.'; \ + echo '. ./defs-static || exit 99'; \ + echo 'test -n "$$testsrcdir" || exit 99 # sanity check'; \ + echo; \ + echo "# Run the test with Automake's parallel-tests driver enabled."; \ + echo 'parallel_tests=yes'; \ + echo "# In the spirit of VPATH, we prefer a test in the build tree"; \ + echo "# over one in the source tree."; \ + echo "if test -f \"./$$input\"; then"; \ + echo " . \"./$$input\""; \ + echo 'else'; \ + echo " . \"\$$testsrcdir/$$input\""; \ + echo 'fi'; \ + } > $@-t + $(AM_V_at)chmod a+rx $@-t && mv -f $@-t $@ + +MAINTAINERCLEANFILES += $(parallel_tests) +EXTRA_DIST += gen-parallel-tests + + +include $(srcdir)/instspc-tests.am -$(parallel_tests): $(parallel_tests:-p.test=.test) Makefile.am - input=`echo $@ | sed 's,.*/,,; s,-p.test$$,.test,'`; \ - sed 's|^\. \./defs.*|parallel_tests=yes; &|' \ - < $(srcdir)/$$input >$@ - chmod a+rx $@ +$(srcdir)/instspc-tests.am: instspc-tests.sh Makefile.am + $(AM_V_GEN)($(am__cd) $(srcdir) \ + && $(SHELL) ./instspc-tests.sh --generate-makefile) >$@ + +$(instspc_tests): Makefile.am + $(AM_V_at)rm -f $@ $@-t + $(AM_V_GEN) :; \ + base=`expr 'x/$@' : 'x.*/instspc-\(.*\)\.test$$'`; \ + name=`expr x"$$base" : x'\(.*\)-'`; \ + action=`expr x"$$base" : x'.*-\(.*\)'`; \ + { \ + echo '#!/bin/sh'; \ + echo '# DO NOT EDIT! GENERATED AUTOMATICALLY!'; \ + echo; \ + echo '# Ensure proper definition of $$testsrcdir.'; \ + echo '. ./defs-static || exit 99'; \ + echo 'test -n "$$testsrcdir" || exit 99 # sanity check'; \ + echo; \ + echo "instspc_test_name='$$name'"; \ + echo "instspc_action='test-$$action'"; \ + echo ". \$$testsrcdir/instspc-tests.sh"; \ + } > $@-t + $(AM_V_at)chmod a+rx $@-t && mv -f $@-t $@ + +# All instspc-*.test tests work by sourcing the `instspc-tests.sh' +# script. Also, they all use shared data generated by the helper +# test `instspc-data.test', for reasons of speed. +instspc-data.log: instspc-tests.sh +$(instspc_tests:.test=.log): instspc-tests.sh instspc-data.log + +MAINTAINERCLEANFILES += $(instspc_tests) +EXTRA_DIST += instspc-tests.sh +XFAIL_TESTS += $(instspc_xfail_tests) -MAINTAINERCLEANFILES = $(parallel_tests) - # The testsuite variable `$me' should be overridable from the + # Some testsuite-influential variables should be overridable from the # test scripts, but not from the environment. - AM_TESTS_ENVIRONMENT = test x"$$me" = x || unset me; -TESTS_ENVIRONMENT = \ ++AM_TESTS_ENVIRONMENT = \ + test x"$$me" = x || unset me; \ + test x"$$required" = x || unset required; \ + test x"$$parallel_tests" = x || unset parallel_tests; TESTS = \ -self-check-env-sanitize.test \ -aclibobj.test \ aclocal.test \ aclocal3.test \ aclocal4.test \ @@@ -814,16 -659,7 +817,16 @@@ regex-obsolete.test req.test \ reqd.test \ reqd2.test \ +repeated-options.test \ rulepat.test \ +self-check-cleanup.test \ +self-check-dir.test \ ++self-check-env-sanitize.test \ +self-check-exit.test \ +self-check-is_newest.test \ +self-check-me.test \ - self-check-me-in-env.test \ +self-check-sanity.test \ +self-check-unindent.test \ sanity.test \ scripts.test \ seenc.test \ diff --cc tests/Makefile.in index 76e458803,67efb7773..859eed6ab --- a/tests/Makefile.in +++ b/tests/Makefile.in @@@ -284,89 -272,53 +284,93 @@@ target_alias = @target_alias top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -XFAIL_TESTS = \ -all.test \ -auxdir2.test \ -cond17.test \ -gcj6.test \ -pr8365-remake-timing.test \ -yacc-dist-nobuild-subdir.test \ -txinfo5.test - -parallel_tests = \ -check-exported-srcdir-p.test \ -check-tests-in-builddir-p.test \ -check-tests_environment-p.test \ -check-p.test \ -check10-p.test \ -check11-p.test \ -check2-p.test \ -check3-p.test \ -check4-p.test \ -check5-p.test \ -check6-p.test \ -check7-p.test \ -check8-p.test \ -check9-p.test \ -color-p.test \ -color2-p.test \ -comment9-p.test \ -dejagnu-p.test \ -exeext4-p.test \ -maken3-p.test \ -maken4-p.test \ -pr401-p.test \ -pr401b-p.test \ -pr401c-p.test - -MAINTAINERCLEANFILES = $(parallel_tests) +MAINTAINERCLEANFILES = $(parallel_tests) $(instspc_tests) +EXTRA_DIST = ChangeLog-old gen-parallel-tests instspc-tests.sh \ + $(TESTS) +XFAIL_TESTS = all.test auxdir2.test cond17.test gcj6.test \ + override-conditional-2.test pr8365-remake-timing.test \ + yacc-dist-nobuild-subdir.test txinfo5.test \ + $(instspc_xfail_tests) +parallel_tests = backcompat5-p.test check-exported-srcdir-p.test \ + check-tests-in-builddir-p.test check-tests_environment-p.test \ + check-p.test check10-p.test check11-p.test check12-p.test \ + check2-p.test check3-p.test check4-p.test check5-p.test \ + check6-p.test check7-p.test check8-p.test check9-p.test \ + color-p.test color2-p.test comment9-p.test dejagnu-p.test \ + exeext4-p.test maken3-p.test maken4-p.test \ + posixsubst-tests-p.test pr401-p.test pr401b-p.test \ + pr401c-p.test +instspc_tests = instspc-squote-build.test instspc-squote-install.test \ + instspc-dquote-build.test instspc-dquote-install.test \ + instspc-bquote-build.test instspc-bquote-install.test \ + instspc-sharp-build.test instspc-sharp-install.test \ + instspc-dollar-build.test instspc-dollar-install.test \ + instspc-bang-build.test instspc-bang-install.test \ + instspc-bslash-build.test instspc-bslash-install.test \ + instspc-ampersand-build.test instspc-ampersand-install.test \ + instspc-percent-build.test instspc-percent-install.test \ + instspc-leftpar-build.test instspc-leftpar-install.test \ + instspc-rightpar-build.test instspc-rightpar-install.test \ + instspc-pipe-build.test instspc-pipe-install.test \ + instspc-caret-build.test instspc-caret-install.test \ + instspc-tilde-build.test instspc-tilde-install.test \ + instspc-qmark-build.test instspc-qmark-install.test \ + instspc-star-build.test instspc-star-install.test \ + instspc-plus-build.test instspc-plus-install.test \ + instspc-minus-build.test instspc-minus-install.test \ + instspc-comma-build.test instspc-comma-install.test \ + instspc-colon-build.test instspc-colon-install.test \ + instspc-semicol-build.test instspc-semicol-install.test \ + instspc-equal-build.test instspc-equal-install.test \ + instspc-less-build.test instspc-less-install.test \ + instspc-more-build.test instspc-more-install.test \ + instspc-at-build.test instspc-at-install.test \ + instspc-lqbrack-build.test instspc-lqbrack-install.test \ + instspc-rqbrack-build.test instspc-rqbrack-install.test \ + instspc-lcbrack-build.test instspc-lcbrack-install.test \ + instspc-rcbrack-build.test instspc-rcbrack-install.test \ + instspc-space-build.test instspc-space-install.test \ + instspc-tab-build.test instspc-tab-install.test \ + instspc-linefeed-build.test instspc-linefeed-install.test \ + instspc-backspace-build.test instspc-backspace-install.test \ + instspc-formfeed-build.test instspc-formfeed-install.test \ + instspc-carriageret-build.test \ + instspc-carriageret-install.test \ + instspc-quadrigraph0-build.test \ + instspc-quadrigraph0-install.test \ + instspc-quadrigraph1-build.test \ + instspc-quadrigraph1-install.test \ + instspc-quadrigraph2-build.test \ + instspc-quadrigraph2-install.test \ + instspc-quadrigraph3-build.test \ + instspc-quadrigraph3-install.test \ + instspc-quadrigraph4-build.test \ + instspc-quadrigraph4-install.test instspc-a_b-build.test \ + instspc-a_b-install.test instspc-a__b-build.test \ + instspc-a__b-install.test instspc-a_lf_b-build.test \ + instspc-a_lf_b-install.test instspc-dotdotdot-build.test \ + instspc-dotdotdot-install.test instspc-dosdrive-build.test \ + instspc-dosdrive-install.test instspc-miscglob1-build.test \ + instspc-miscglob1-install.test instspc-miscglob2-build.test \ + instspc-miscglob2-install.test +instspc_xfail_tests = instspc-squote-build.test \ + instspc-dquote-build.test instspc-bquote-build.test \ + instspc-sharp-build.test instspc-dollar-build.test \ + instspc-bslash-build.test instspc-ampersand-build.test \ + instspc-linefeed-build.test instspc-quadrigraph0-build.test \ + instspc-a_lf_b-build.test instspc-squote-install.test \ + instspc-dquote-install.test instspc-bquote-install.test \ + instspc-sharp-install.test instspc-dollar-install.test \ + instspc-linefeed-install.test instspc-a_lf_b-install.test - # The testsuite variable `$me' should be overridable from the + # Some testsuite-influential variables should be overridable from the # test scripts, but not from the environment. - AM_TESTS_ENVIRONMENT = test x"$$me" = x || unset me; -TESTS_ENVIRONMENT = \ ++AM_TESTS_ENVIRONMENT = \ + test x"$$me" = x || unset me; \ + test x"$$required" = x || unset required; \ + test x"$$parallel_tests" = x || unset parallel_tests; + TESTS = \ -self-check-env-sanitize.test \ -aclibobj.test \ aclocal.test \ aclocal3.test \ aclocal4.test \ @@@ -1078,16 -930,7 +1082,16 @@@ regex-obsolete.test req.test \ reqd.test \ reqd2.test \ +repeated-options.test \ rulepat.test \ +self-check-cleanup.test \ +self-check-dir.test \ ++self-check-env-sanitize.test \ +self-check-exit.test \ +self-check-is_newest.test \ +self-check-me.test \ - self-check-me-in-env.test \ +self-check-sanity.test \ +self-check-unindent.test \ sanity.test \ scripts.test \ seenc.test \ diff --cc tests/defs index 6a8d06f0b,ef35d9fa5..797e54271 --- a/tests/defs +++ b/tests/defs @@@ -61,166 -46,82 +61,177 @@@ nl= # is defined initially, so that saving and restoring $IFS works. IFS=$sp$tab$nl -# Ensure we are running from the right directory. -test -f ./defs || { - echo "defs: not found in current directory" 1>&2 - exit 1 +# Ensure $testsrcdir is set correctly. +test -f "$testsrcdir/defs-static.in" || { + echo "$me: $testsrcdir/defs-static.in not found, check \$testsrcdir" >&2 + exit 99 } -if test -z "$srcdir"; then - # compute $srcdir. - srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'` - test "$srcdir" = $0 && srcdir=. -else :; fi - -# Ensure $srcdir is set correctly. -test -f "$srcdir/defs.in" || { - echo "$srcdir/defs.in not found, check \$srcdir" 1>&2 - exit 1 +# Ensure $testbuilddir is set correctly. +test -f "$testbuilddir/defs-static" || { + echo "$me: $testbuilddir/defs-static not found, check \$testbuilddir" >&2 + 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 - me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'` -elif env | grep '^me=' >/dev/null; then - echo "$0: variable \`me' is set in the environment: this is unsafe" >&2 - exit 99 -fi - + # Check that the environment is properly sanitized. + for var in required parallel_tests; do + if env | grep "^$var=" >/dev/null; then + echo "$me: variable \`$var' is set in the environment:" \ + "this is unsafe" >&2 + exit 99 + fi + done + unset var + -# 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 +# 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. ## +## ---------------------------- ## + +# 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 + (exit $1) + exit $1 +} + +# 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" +} -APIVERSION='@APIVERSION@' -PATH_SEPARATOR='@PATH_SEPARATOR@' - -# Make sure we override the user shell. -SHELL='@SHELL@' -export SHELL -# User can override various tools used. -test -z "$PERL" && PERL='@PERL@' -test -z "$MAKE" && MAKE=make -test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@" -test -z "$AUTOHEADER" && AUTOHEADER="@am_AUTOHEADER@" -test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate -test -z "$MISSING" && MISSING=`pwd`/../lib/missing -# Use -Werror because this also turns some Perl warnings into error. -# (Tests for which this is inappropriate should use -Wno-error.) -test -z "$ACLOCAL" && ACLOCAL="aclocal-$APIVERSION -Werror" -# Extra flags to pass to aclocal before all other flags added by this script. -ACLOCAL_TESTSUITE_FLAGS= -export ACLOCAL_TESTSUITE_FLAGS - -# See how Automake should be run. We put --foreign as the default -# strictness to avoid having to create lots and lots of files. A test -# can override this by specifying a different strictness. Use -Wall -# -Werror by default. Tests for which this is inappropriate -# (e.g. when testing that a warning is enabled by a specific switch) -# should use -Wnone or/and -Wno-error -test -z "$AUTOMAKE" && AUTOMAKE="automake-$APIVERSION --foreign -Werror -Wall" - -PATH="`pwd`$PATH_SEPARATOR$PATH" +# 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 +} + +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. + + +## ----------------------------------------------------------- ## +## 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" -# Some shells forget to export modified environment variables. -# (See note about `export' in the Autoconf manual.) -export PATH +# 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. diff --cc tests/self-check-env-sanitize.test index 966088dcf,9d18d9e59..a8aaec01e --- a/tests/self-check-env-sanitize.test +++ b/tests/self-check-env-sanitize.test @@@ -16,15 -16,15 +16,16 @@@ # Sanity check for the automake testsuite. # Make sure that the testsuite initialization code complains when - # $me is set in the environment. + # some testsuite-influential variables are set in the environment. +. ./defs-static || exit 1 + set -x --exec 5>&1 - env me=foo $SHELL -c '. ./defs' foo.test && exit 1 - env me=foo $SHELL -c '. ./defs' foo.test 2>&1 1>&5 \ - | grep "variable \`me' is set in the environment.*unsafe" || exit 1 + for var in me parallel_tests required; do - env "$var=foo" /bin/sh -c '. ./defs' foo.test && exit 1 - env "$var=foo" /bin/sh -c '. ./defs' foo.test 2>&1 1>&5 \ ++ env "$var=foo" $SHELL -c '. ./defs' foo.test && exit 1 ++ env "$var=foo" $SHELL -c '. ./defs' foo.test 2>&1 1>&5 \ + | grep "variable \`$var' is set in the environment.*unsafe" || exit 1 + done :