From: Stefano Lattarini Date: Wed, 16 Feb 2011 12:00:59 +0000 (+0100) Subject: Merge branch 'maint' X-Git-Tag: ng-0.5a~231 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95ce684f09a47df6fc165311c5372066e0e28f9f;p=thirdparty%2Fautomake.git Merge branch 'maint' --- 95ce684f09a47df6fc165311c5372066e0e28f9f diff --cc ChangeLog index c3ff53b7b,4563585da..12b8e9f8d --- a/ChangeLog +++ b/ChangeLog @@@ -1,3 -1,9 +1,10 @@@ + 2011-02-16 Stefano Lattarini + Ralf Wildenhues + + test defs: add subroutine for input unindenting + * tests/defs.in (unindent): New subroutine. ++ * tests/instspc-tests.sh: Use it. + 2011-02-15 Stefano Lattarini python: report the 'PYTHON' influential environment variable diff --cc tests/defs index 4e277884d,ffe21e1de..a32ef1563 --- a/tests/defs +++ b/tests/defs @@@ -55,109 -46,60 +55,127 @@@ 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 $testbuilddir is set correctly. +test -f "$testbuilddir/defs-static" || { + echo "$me: $testbuilddir/defs-static not found, check \$testbuilddir" >&2 + exit 99 +} -# Ensure $srcdir is set correctly. -test -f "$srcdir/defs.in" || { - echo "$srcdir/defs.in not found, check \$srcdir" 1>&2 - exit 1 +# 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" } -me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'` - -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+"$@"} +} + ++# 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 () ++{ ++ cat ${1+"$@"} > deindent.tmp ++ indentation=`sed . + +# +# Driver script to generate and run tests checking that building from, +# or installing to, directories with shell metacharacters succeed. +# +# Original report from James Amundson about file names with spaces. +# Other characters added by Paul Eggert. +# +# This script fulfills a threefold role: +# 1. It generates a Makefile.am snippet, containing the definition +# of proper lists of tests. +# 2. It sets up a directory containing some common data files and +# autotools-generated files used by said generated tests (this +# is done for speed reasons only). +# 3. It is sourced by said generated tests with proper parameters +# pre-set, to run the "meat" of the checks. +# This setup might seem a tricky and over-engineered abuse, but past +# (painful) experiences showed that it is indeed required, because +# the test generation code and test execution code tend to be +# inextricably coupled and intertwined. +# + +# Be more Bourne compatible (snippet copied from `tests/defs'). +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi + +set -e + +# Sanity and usage checks. +if test x"$instspc_action" = x; then + if test "$#,$1" = "1,--generate-makefile"; then + instspc_action=generate-makefile + else + echo "$0: empty action and no proper command line" >&2 + exit 99 + fi +elif test $# -gt 0; then + echo "$0: action specified and command line arguments used" >&2 + exit 99 +fi + +case $instspc_action in + generate-makefile|generate-data) + ;; + test-build|test-install) + if test x"$instspc_test_name" = x; then + echo "$0: test name undefined for action '$instspc_action'" >&2 + exit 99 + fi + ;; + *) + echo "$0: invalid action: '$instspc_action'" + exit 99 + ;; +esac + +# Helper subroutine for test data definition. +# Usage: define_problematic_string NAME STRING +define_problematic_string () +{ + tst=$1 + shift + eval "instspc__$tst=\$1" || exit 99 + shift + instspc_names_list="$instspc_names_list $tst" + # Some of the "problematic" characters cannot be used in the name of + # a build or install directory on a POSIX host. These lists should + # be empty, but are not due to limitations in Autoconf, Automake, Make, + # M4, or the shell. + case " $* " in *' fail-build '*|*' build-fail '*) + instspc_xfail_builds_list="$instspc_xfail_builds_list $tst";; + esac + case " $* " in *' fail-install '*|*' install-fail '*) + instspc_xfail_installs_list="$instspc_xfail_installs_list $tst";; + esac +} + +# Helper subroutines for creation of input data files. + - unindent () - { - sed 's/^ *//' # we don't strip leading tabs -- this is deliberate! - } - +create_input_data () +{ + mkdir sub + + unindent > configure.in << 'EOF' + AC_INIT([instspc], [1.0]) + AM_INIT_AUTOMAKE + AC_CONFIG_FILES([Makefile]) + AC_PROG_CC + AC_PROG_RANLIB + AC_OUTPUT +EOF + + : > sub/base.h + : > sub/nobase.h + : > sub/base.dat + : > sub/nobase.dat + : > sub/base.sh + : > sub/nobase.sh + + unindent > source.c << 'EOF' + int + main (int argc, char **argv) + { + return 0; + } +EOF + + unindent > Makefile.am << 'EOF' + foodir = $(prefix)/foo + fooexecdir = $(prefix)/foo + + foo_HEADERS = sub/base.h + nobase_foo_HEADERS = sub/nobase.h + + dist_foo_DATA = sub/base.dat + nobase_dist_foo_DATA = sub/nobase.dat + + dist_fooexec_SCRIPTS = sub/base.sh + nobase_dist_fooexec_SCRIPTS = sub/nobase.sh + + fooexec_PROGRAMS = sub/base + nobase_fooexec_PROGRAMS = sub/nobase + sub_base_SOURCES = source.c + sub_nobase_SOURCES = source.c + + fooexec_LIBRARIES = sub/libbase.a + nobase_fooexec_LIBRARIES = sub/libnobase.a + sub_libbase_a_SOURCES = source.c + sub_libnobase_a_SOURCES = source.c + + .PHONY: test-install-sep + test-install-sep: install + test -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.h' + test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.h' + test -f '$(DESTDIR)/$(file)-prefix/foo/base.h' + test -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.dat' + test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.dat' + test -f '$(DESTDIR)/$(file)-prefix/foo/base.dat' + test -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.sh' + test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.sh' + test -f '$(DESTDIR)/$(file)-prefix/foo/base.sh' + test -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase$(EXEEXT)' + test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase$(EXEEXT)' + test -f '$(DESTDIR)/$(file)-prefix/foo/base$(EXEEXT)' + test -f '$(DESTDIR)/$(file)-prefix/foo/sub/libnobase.a' + test ! -f '$(DESTDIR)/$(file)-prefix/foo/libnobase.a' + test -f '$(DESTDIR)/$(file)-prefix/foo/libbase.a' +EOF + + $ACLOCAL + $AUTOCONF + $AUTOMAKE -a + + : > success +} + +# Be sure to avoid interferences from the environment. +instspc_names_list='' +instspc_xfail_builds_list='' +instspc_xfail_installs_list='' + + +# ================= # +# Test data begin # +# ----------------- # + +# Some control characters that are white space. +bs='' # back space +cr=' ' # carriage return +ff=' ' # form feed +ht=' ' # horizontal tab +lf=' +' # line feed (aka newline) + +# Hack to save typing and make code visually clearer. +def=define_problematic_string + +$def squote \' fail-build fail-install +$def dquote '"' fail-build fail-install +$def bquote '`' fail-build fail-install +$def sharp '#' fail-build fail-install +$def dollar '$' fail-build fail-install +$def bang '!' +$def bslash '\' fail-build +$def ampersand '&' fail-build +$def percent '%' +$def leftpar '(' +$def rightpar ')' +$def pipe '|' +$def caret '^' +$def tilde '~' +$def qmark '?' +$def star '*' +$def plus '+' +$def minus '-' +$def comma ',' +$def colon ':' +$def semicol ';' +$def equal '=' +$def less '<' +$def more '>' +$def at '@' +$def lqbrack '[' +$def rqbrack ']' +$def lcbrack '{' +$def rcbrack '}' +$def space ' ' +$def tab "$ht" +$def linefeed "$lf" fail-build fail-install +$def backspace "$bs" +$def formfeed "$ff" +$def carriageret "$cr" +$def quadrigraph0 '@&t@' fail-build +$def quadrigraph1 '@<:@' +$def quadrigraph2 '@:>@' +$def quadrigraph3 '@S|@' +$def quadrigraph4 '@%:@' +$def a_b 'a b' +$def a__b 'a b' +$def a_lf_b "a${lf}b" fail-build fail-install +$def dotdotdot '...' +$def dosdrive 'a:' +$def miscglob1 '?[a-z]*' +$def miscglob2 '.*?[0-9]' + +unset def + +# --------------- # +# Test data end # +# =============== # + + +if test x"$instspc_action" = x"generate-makefile"; then + # We must generate a makefile fragment on stdout. It must refer + # to all tests at once, hence the loop below. + echo '## Generated by instspc-tests.sh. DO NOT EDIT!' + echo 'instspc_tests =' + echo 'instspc_xfail_tests =' + for test_name in $instspc_names_list; do + echo "instspc_tests += instspc-$test_name-build.test" + echo "instspc_tests += instspc-$test_name-install.test" + done + for test_name in $instspc_xfail_builds_list; do + echo "instspc_xfail_tests += instspc-$test_name-build.test" + done + for test_name in $instspc_xfail_installs_list; do + echo "instspc_xfail_tests += instspc-$test_name-install.test" + done + exit 0 +fi + +# We'll need the full setup provided by `tests/defs'. Temporarily disable +# the errexit flag, since the setup code might not be prepared to deal +# with it. +set +e +. ./defs || Exit 99 +set -e + +# The directory set up by the `generate-data' action should contain all +# the files we need. So remove the other files created by ./defs. And +# check we really are in a temporary `*.dir' directory in the build tree, +# since the last thing we want is to remove some random user files! +test -f ../defs-static && test -f ../defs || Exit 99 +case `pwd` in *.dir);; *) Exit 99;; esac +rm -f * + +if test x"$instspc_action" = x"generate-data"; then + # We must *not* remove the test directory, since its contents must be + # used by following dependent tests. + keep_testdirs=yes + create_input_data + Exit 0 +fi + +### If we are still here, we have to run a test ... + +eval "instspc_test_string=\${instspc__$instspc_test_name}" || Exit 99 +if test x"$instspc_test_string" = x; then + echo "$me: invalid test name: '$instspc_test_name'" >&2 + Exit 99 +fi + +test -f ../instspc-data.dir/success || { + echo "$me: setup by instspc-data.test failed" >&2 + Exit 99 +} + +# Skip if this system doesn't support these characters in file names. +mkdir "./$instspc_test_string" || Exit 77 + +case $instspc_action in + test-build) + dest=`pwd`/_dest + relbuilddir=../.. + cd "./$instspc_test_string" + ;; + test-install) + dest=`pwd`/$instspc_test_string + relbuilddir=.. + ;; + *) + echo "$me: internal error: invalid action '$instspc_action'" + Exit 99 + ;; +esac + +$relbuilddir/instspc-data.dir/configure \ + --prefix "/$instspc_test_string-prefix" +$MAKE +# Some make implementations eliminate leading and trailing whitespace +# from macros passed on the command line, and some eliminate leading +# whitespace from macros set from environment variables, so prepend +# './' and use the latter here. +# Tru64 sh -e needs '|| Exit' in order to work correctly. +DESTDIR="$dest" file="./$instspc_test_string" $MAKE -e test-install-sep \ + || Exit 1 + +: