diff options
author | Mathieu Lirzin <mthl@gnu.org> | 2017-09-20 00:08:59 +0200 |
---|---|---|
committer | Mathieu Lirzin <mthl@gnu.org> | 2017-09-20 00:08:59 +0200 |
commit | 7508174f4a6c19eeda89a7e18b8d1398fe85ccf0 (patch) | |
tree | 2938ba28267cfc6d6cba0b763f80e4b32ce49b03 /t/ax | |
parent | c2757b974cb4c182333859edb45a01194550bc0e (diff) | |
parent | ced195a8556b68eab3dd0887e07a97c6ae4917bf (diff) | |
download | automake-7508174f4a6c19eeda89a7e18b8d1398fe85ccf0.tar.gz |
Merge branch 'minor'
Diffstat (limited to 't/ax')
-rw-r--r-- | t/ax/am-test-lib.sh | 1063 | ||||
-rw-r--r-- | t/ax/cc-no-c-o.in | 41 | ||||
-rw-r--r-- | t/ax/deltree.pl | 34 | ||||
-rw-r--r-- | t/ax/depcomp.sh | 417 | ||||
-rw-r--r-- | t/ax/distcheck-hook-m4.am | 30 | ||||
-rw-r--r-- | t/ax/extract-testsuite-summary.pl | 30 | ||||
-rwxr-xr-x | t/ax/is | 57 | ||||
-rwxr-xr-x | t/ax/is_newest | 42 | ||||
-rw-r--r-- | t/ax/runtest.in | 130 | ||||
-rw-r--r-- | t/ax/shell-no-trail-bslash.in | 85 | ||||
-rw-r--r-- | t/ax/tap-functions.sh | 231 | ||||
-rw-r--r-- | t/ax/tap-setup.sh | 47 | ||||
-rw-r--r-- | t/ax/tap-summary-aux.sh | 357 | ||||
-rw-r--r-- | t/ax/test-defs.in | 201 | ||||
-rw-r--r-- | t/ax/test-init.sh | 29 | ||||
-rw-r--r-- | t/ax/test-lib.sh | 317 | ||||
-rw-r--r-- | t/ax/testsuite-summary-checks.sh | 102 | ||||
-rw-r--r-- | t/ax/trivial-test-driver | 102 |
18 files changed, 3315 insertions, 0 deletions
diff --git a/t/ax/am-test-lib.sh b/t/ax/am-test-lib.sh new file mode 100644 index 000000000..3c4bf0120 --- /dev/null +++ b/t/ax/am-test-lib.sh @@ -0,0 +1,1063 @@ +# -*- shell-script -*- +# +# Copyright (C) 1996-2017 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 <https://www.gnu.org/licenses/>. + +######################################################## +### IMPORTANT NOTE: keep this file 'set -e' clean. ### +######################################################## + +# Do not source several times. +test ${am_test_lib_sourced-no} = yes && return 0 +am_test_lib_sourced=yes + +# A literal escape character. Used by test checking colored output. +esc='' + +# 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 + +## ---------------------- ## +## Environment cleanup. ## +## ---------------------- ## + +# Unset some make-related 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 +unset __MKLVL__ MAKE_JOBS_FIFO # For BSD make. +unset DMAKE_CHILD DMAKE_DEF_PRINTED DMAKE_MAX_JOBS # For Solaris dmake. +# Unset verbosity flag. +unset V +# Also unset variables that might influence "make install". +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 +# Unset variables that might influence "make distcheck". +unset DISTCHECK_CONFIGURE_FLAGS AM_DISTCHECK_CONFIGURE_FLAGS +# Used by install rules for info files. +unset AM_UPDATE_INFO_DIR +# We don't want to use the $srcdir value exported by the test driver. +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 AM_TESTS_ENVIRONMENT +unset DISABLE_HARD_ERRORS +unset AM_COLOR_TESTS +unset TESTS +unset XFAIL_TESTS +unset TEST_LOGS +unset TEST_SUITE_LOG +unset RECHECK_LOGS +unset VERBOSE +for pfx in TEST_ SH_ TAP_ ''; do + unset ${pfx}LOG_COMPILER + unset ${pfx}LOG_COMPILE # Not a typo! + unset ${pfx}LOG_FLAGS + unset AM_${pfx}LOG_FLAGS + unset ${pfx}LOG_DRIVER + unset ${pfx}LOG_DRIVER_FLAGS + unset AM_${pfx}LOG_DRIVER_FLAGS +done +unset pfx + +# 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 () +{ + # Quoting from the autoconf manual: + # ... [$host_alias and $build both] default to the result of running + # config.guess, unless you specify either --build or --host. In + # this case, the default becomes the system type you specified. + # If you specify both, *and they're different*, configure enters + # cross compilation mode (so it doesn't run any tests that require + # execution). + test x"$host_alias" != x && test x"$build_alias" != x"$host_alias" +} + +# is_blocked_signal SIGNAL-NUMBER +# -------------------------------- +# Return success if the given signal number is blocked in the shell, +# return a non-zero exit status and print a proper diagnostic otherwise. +is_blocked_signal () +{ + # Use perl, since trying to do this portably in the shell can be + # very tricky, if not downright impossible. For reference, see: + # <https://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html> + if $PERL -w -e ' + use strict; + use warnings FATAL => "all"; + use POSIX; + my %oldsigaction = (); + sigaction('"$1"', 0, \%oldsigaction); + exit ($oldsigaction{"HANDLER"} eq "IGNORE" ? 0 : 77); + '; then + return 0 + elif test $? -eq 77; then + return 1 + else + fatal_ "couldn't determine whether signal $1 is blocked" + fi +} + +# single_quote STRING +# ------------------- +# Single-quote STRING for the shell, also dealing with embedded single +# quotes. Place the result in the '$am_result', that is thus to be +# considered public. +single_quote () +{ + am_result=$1 + case $am_result in + *\'*) am_result=$(printf '%s\n' "$*" | sed -e "s/'/'\\\\''/g");; + esac + am_result="'$am_result'" +} + +# append_single_quoted VARIABLE STRING +# ------------------------------------ +append_single_quoted () +{ + am__var=$1; shift + single_quote "$1" # Sets 'am_result'. + eval "${am__var}=\${$am__var:+\"\${$am__var} \"}\$am_result" + unset am__var am_result +} + +# is_valid_varname STRING +# ----------------------- +# Tell whether STRING is a valid name for a shell variable. Return 0 +# if yes, return 1 if not. +is_valid_varname () +{ + # FIXME: is the below truly portable even for LC_COLLATE != "C" ? + case $1 in + [0-9]*) return 1;; + *[!a-zA-Z0-9_]*) return 1;; + esac + return 0 +} + +# run_make [-e STATUS] [-O] [-E] [-M] [--] [VAR=VAL ...] [MAKE-ARGS...] +# --------------------------------------------------------------------- +# +# Run $MAKE with the given command-line, and fail if it doesn't exit with +# STATUS (default: 0). If STATUS is "FAIL", then any exit status > 0 is +# acceptable. If STATUS is "IGNORE", any exit value is acceptable. +# +# Other options: +# +# -O save the standard output from make on disk, in a regular file +# named 'stdout'. +# +# -E save the standard error from make on disk, in a regular file +# named 'stderr'. +# +# -M save both the standard output and standard error from make on +# disk, in a regular file named 'output'. This option supersedes +# both the '-O' and '-E' options. +# +# This function also handle command-line override of variable definition +# in a smart way, using AM_MAKEFLAGS if a non-GNU make implementation +# is in use. +# +run_make () +{ + am__make_redirect_stdout=no + am__make_redirect_stderr=no + am__make_redirect_stdall=no + am__make_flags= + am__make_rc_exp=0 + # Follow-up code might want to analyse this, so mark is as + # publicly accessible (no double undesrscore). + am_make_rc=0 + # Parse options for this function. + while test $# -gt 0; do + case $1 in + -e) am__make_rc_exp=$2; shift;; + -O) am__make_redirect_stdout=yes;; + -E) am__make_redirect_stderr=yes;; + -M) am__make_redirect_stdall=yes;; + --) shift; break;; + *) break;; + esac + shift + done + + # Use append mode here to avoid dropping output. See automake bug#11413 + if using_gmake; then + # We can trust GNU make to correctly pass macro definitions given + # on the command line down to sub-make invocations, and this allow + # us to have a vary simple implementation: delegate all the work + # to GNU make. + : + else + # We have to explicitly parse arguments passed to make. Not 100% + # safe w.r.t. options like '-I' that can have an argument, but + # should be good enough for our usages so far. + for am__x + do + case $am__x in + *=*) + am__maybe_var=${am__x%%=*} + am__maybe_val=${am__x#*=} + am__maybe_def="${am__maybe_var}=${am__maybe_val}" + # Some variables should be portably overridable from the command + # line, even when using non-GNU make. + case $am__maybe_var in + V|\ + DESTDIR|\ + SHELL|\ + VERBOSE|\ + DISABLE_HARD_ERRORS|\ + DISTCHECK_CONFIGURE_FLAGS) + ;; + *) + if is_valid_varname "$am__maybe_var"; then + append_single_quoted am__make_flags "$am__maybe_def" + fi + esac + unset am__maybe_var am__maybe_val am__maybe_def + ;; + esac + done + unset am__x + fi + + if test x"$am__make_flags" != x; then + set AM_MAKEFLAGS="$am__make_flags" ${1+"$@"} + unset am__make_flags + fi + + # In redirecting make output below, use append mode, to avoid + # dropping output. See automake bug#11413 for details. + # The exit status of 253 is a more-or-less random choice, to + # help us catch possible errors in redirections and error out + # accordingly. + ( + : exec $MAKE ${1+"$@"} # Display traces for future command. + set +x # We need to remove them now, not to pollute redirected stderr. + if test $am__make_redirect_stdall = yes; then + : > output && exec 1>>output 2>&1 || exit 253 + else + if test $am__make_redirect_stdout = yes; then + : > stdout && exec 1>>stdout || exit 253 + fi + if test $am__make_redirect_stderr = yes; then + : > stderr && exec 2>>stderr || exit 253 + fi + fi + exec $MAKE ${1+"$@"} + ) || am_make_rc=$? + + if test $am_make_rc -eq 253; then + fatal_ "run_make: problems in redirecting make output" + fi + + if test $am__make_redirect_stdall = yes; then + cat output || fatal_ "displaying make output" + else + if test $am__make_redirect_stdout = yes; then + cat stdout || fatal_ "displaying make output" + fi + if test $am__make_redirect_stderr = yes; then + cat stderr >&2 || fatal_ "displaying make output" + fi + fi + + case $am__make_rc_exp in + IGNORE) + : Ignore exit status + ;; + FAIL) + test $am_make_rc -gt 0 || return 1 + ;; + *) + test $am__make_rc_exp -ge 0 && test $am__make_rc_exp -le 255 \ + || fatal_ "invalid expected exit status: '$am__make_rc_exp'" + test $am_make_rc -eq $am__make_rc_exp || return 1 + ;; + esac +} + +# AUTOMAKE_run [-e STATUS] [-d DESCRIPTION] [--] [AUTOMAKE-ARGS...] +# ----------------------------------------------------------------- +# Run automake with AUTOMAKE-ARGS, and fail if it doesn't exit with +# STATUS. Should be polymorphic for TAP and "plain" tests. The +# DESCRIPTION, when provided, is used for console reporting, only if +# the TAP protocol is in use in the current test script. +AUTOMAKE_run () +{ + am__desc= + am__exp_rc=0 + while test $# -gt 0; do + case $1 in + -d) am__desc=$2; shift;; + -e) am__exp_rc=$2; shift;; + --) shift; break;; + # Don't fail on unknown option: assume they (and the rest of the + # command line) are to be passed verbatim to automake (so stop our + # own option parsing). + *) break;; + esac + shift + done + am__got_rc=0 + $AUTOMAKE ${1+"$@"} >stdout 2>stderr || am__got_rc=$? + cat stderr >&2 + cat stdout + if test $am_test_protocol = none; then + test $am__got_rc -eq $am__exp_rc || exit 1 + return + fi + if test -z "$am__desc"; then + if test $am__got_rc -eq $am__exp_rc; then + am__desc="automake exited $am__got_rc" + else + am__desc="automake exited $am__got_rc, expecting $am__exp_rc" + fi + fi + command_ok_ "$am__desc" test $am__got_rc -eq $am__exp_rc +} + +# AUTOMAKE_fails [-d DESCRIPTION] [OPTIONS...] +# -------------------------------------------- +# Run automake with OPTIONS, and fail if doesn't exit with status 1. +# Should be polymorphic for TAP and "plain" tests. The DESCRIPTION, +# when provided, is used for console reporting, only if the TAP +# protocol is in use in the current test script. +AUTOMAKE_fails () +{ + AUTOMAKE_run -e 1 ${1+"$@"} +} + +# extract_configure_help { --OPTION | VARIABLE-NAME } [FILES] +# ----------------------------------------------------------- +# Use this to extract from the output of "./configure --help" (or similar) +# the description or help message associated to the given --OPTION or +# VARIABLE-NAME. +extract_configure_help () +{ + am__opt_re='' am__var_re='' + case $1 in + --*'=') am__opt_re="^ $1";; + --*'[=]') am__opt_re='^ '$(printf '%s\n' "$1" | sed 's/...$//')'\[=';; + --*) am__opt_re="^ $1( .*|$)";; + *) am__var_re="^ $1( .*|$)";; + esac + shift + if test x"$am__opt_re" != x; then + LC_ALL=C awk ' + /'"$am__opt_re"'/ { print; do_print = 1; next; } + /^$/ { do_print = 0; next } + /^ --/ { do_print = 0; next } + (do_print == 1) { print } + ' ${1+"$@"} + else + LC_ALL=C awk ' + /'"$am__var_re"'/ { print; do_print = 1; next; } + /^$/ { do_print = 0; next } + /^ [A-Z][A-Z0-9_]* / { do_print = 0; next } + /^ [A-Z][A-Z0-9_]*$/ { do_print = 0; next } + (do_print == 1) { print } + ' ${1+"$@"} + fi +} + +# grep_configure_help { --OPTION | VARIABLE-NAME } REGEXP +# ------------------------------------------------------- +# Grep the section of "./configure --help" output associated with either +# --OPTION or VARIABLE-NAME for the given *extended* regular expression. +grep_configure_help () +{ + ./configure --help > am--all-help \ + || { cat am--all-help; exit 1; } + cat am--all-help + extract_configure_help "$1" am--all-help > am--our-help \ + || { cat am--our-help; exit 1; } + cat am--our-help + $EGREP "$2" am--our-help || exit 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;; + *) + fatal_ "invalid value for \$am__using_gmake: '$am__using_gmake'";; + esac +} +am__using_gmake="" # Avoid interferences from the environment. + +# make_can_chain_suffix_rules +# --------------------------- +# Return 0 if $MAKE is a make implementation that can chain suffix rules +# automatically, return 1 otherwise. Caches the result for speed reasons. +make_can_chain_suffix_rules () +{ + if test -z "$am__can_chain_suffix_rules"; then + if using_gmake; then + am__can_chain_suffix_rules=yes + return 0 + else + mkdir am__chain.dir$$ + cd am__chain.dir$$ + unindent > Makefile << 'END' + .SUFFIXES: .u .v .w + .u.v: ; cp $< $@ + .v.w: ; cp $< $@ +END + echo make can chain suffix rules > foo.u + if $MAKE foo.w && diff foo.u foo.w; then + am__can_chain_suffix_rules=yes + else + am__can_chain_suffix_rules=no + fi + cd .. + rm -rf am__chain.dir$$ + fi + fi + case $am__can_chain_suffix_rules in + yes) return 0;; + no) return 1;; + *) fatal_ "make_can_chain_suffix_rules: internal error";; + esac +} +am__can_chain_suffix_rules="" # Avoid interferences from the environment. + +# useless_vpath_rebuild +# --------------------- +# Tell whether $MAKE suffers of the bug triggering automake bug#7884. +# For example, this happens with FreeBSD make, since in a VPATH build +# it tends to rebuilt files for which there is an explicit or even just +# a suffix rule, even if said files are already available in the VPATH +# directory. +useless_vpath_rebuild () +{ + if test -z "$am__useless_vpath_rebuild"; then + if using_gmake; then + am__useless_vpath_rebuild=no + return 1 + fi + mkdir am__vpath.dir$$ + cd am__vpath.dir$$ + touch foo.a foo.b bar baz + mkdir build + cd build + unindent > Makefile << 'END' + .SUFFIXES: .a .b + VPATH = .. + all: foo.b baz + .PHONY: all + .a.b: ; cp $< $@ + baz: bar ; cp ../baz bar +END + if run_make all && test ! -e foo.b && test ! -e bar; then + am__useless_vpath_rebuild=no + else + am__useless_vpath_rebuild=yes + fi + cd ../.. + rm -rf am__vpath.dir$$ + fi + case $am__useless_vpath_rebuild in + yes) return 0;; + no) return 1;; + "") ;; + *) fatal_ "useless_vpath_rebuild: internal error";; + esac +} +am__useless_vpath_rebuild="" + +yl_distcheck () { useless_vpath_rebuild || run_make distcheck ${1+"$@"}; } + +null_install () +{ + for am__v in nulldirs destdir instdir; do + if ! eval 'test -n "$'$am__v'"'; then + fatal_ "null_install() invoked with \$$am__v unset" + fi + done + unset am__v + case $#,$1 in + 0,) + am__inst='install';; + 1,-t|1,--texi) + am__inst='install install-html install-dvi install-ps install-pdf';; + *) + fatal_ "null_install(): invalid usage";; + esac + run_make $nulldirs $am__inst + test ! -e "$instdir" + run_make $nulldirs $am__inst DESTDIR="$destdir" + test ! -e "$instdir" + test ! -e "$destdir" + run_make -M $nulldirs uninstall + # Creative quoting below to please maintainer-check. + grep 'rm'' ' output && exit 1 + run_make -M $nulldirs uninstall DESTDIR="$destdir" + # Creative quoting below to please maintainer-check. + grep 'rm'' ' output && exit 1 + : # For 'set -e'. +} + +# count_test_results total=N pass=N fail=N xpass=N xfail=N skip=N error=N +# ----------------------------------------------------------------------- +# Check that a testsuite run driven by the parallel-tests harness has +# had the specified numbers of test results (specified by kind). +# This function assumes that the output of "make check" or "make recheck" +# has been saved in the 'stdout' file in the current directory, and its +# log in the 'test-suite.log' file. +count_test_results () +{ + # Use a subshell so that we won't pollute the script namespace. + ( + # TODO: Do proper checks on the arguments? + total=ERR pass=ERR fail=ERR xpass=ERR xfail=ERR skip=ERR error=ERR + eval "$@" + # For debugging. + $EGREP -i '(total|x?pass|x?fail|skip|error)' stdout || : + rc=0 + # Avoid spurious failures with shells with "overly sensible" + # errexit shell flag, such as e.g., Solaris /bin/sh. + set +e + test $(grep -c '^PASS:' stdout) -eq $pass || rc=1 + test $(grep -c '^XFAIL:' stdout) -eq $xfail || rc=1 + test $(grep -c '^SKIP:' stdout) -eq $skip || rc=1 + test $(grep -c '^FAIL:' stdout) -eq $fail || rc=1 + test $(grep -c '^XPASS:' stdout) -eq $xpass || rc=1 + test $(grep -c '^ERROR:' stdout) -eq $error || rc=1 + grep "^# TOTAL: *$total$" stdout || rc=1 + grep "^# PASS: *$pass$" stdout || rc=1 + grep "^# XFAIL: *$xfail$" stdout || rc=1 + grep "^# SKIP: *$skip$" stdout || rc=1 + grep "^# FAIL: *$fail$" stdout || rc=1 + grep "^# XPASS: *$xpass$" stdout || rc=1 + grep "^# ERROR: *$error$" stdout || rc=1 + test $rc -eq 0 + ) +} + +# get_shell_script SCRIPT-NAME +# ----------------------------- +# Fetch an Automake-provided shell script from the 'lib/' directory into +# the current directory, and, if the '$am_test_prefer_config_shell' +# variable is set to "yes", modify its shebang line to use $SHELL instead +# of /bin/sh. +get_shell_script () +{ + am_source=$1 am_target=${2-$1} + test ! -f "$am_target" || rm -f "$am_target" || return 99 + if test x"$am_test_prefer_config_shell" = x"yes"; then + sed "1s|#!.*|#! $SHELL|" "$am_scriptdir/$am_source" > "$am_target" \ + && chmod a+x "$am_target" \ + || return 99 + else + cp -f "$am_scriptdir/$am_source" "$am_target" || return 99 + fi + sed 10q "$am_target" # For debugging. + unset am_target am_source +} + +# fetch_tap_driver +# ---------------- +# Fetch the Automake-provided TAP driver from the 'lib/' directory into +# the current directory, and edit its shebang line so that it will be +# run with the proper shell. +fetch_tap_driver () +{ + AM_TAP_AWK=$AWK; export AM_TAP_AWK + get_shell_script tap-driver.sh tap-driver +} + + +# require_xsi SHELL +# ----------------- +# Skip the test if the given shell fails to support common XSI constructs. +require_xsi () +{ + test $# -eq 1 || fatal_ "require_xsi needs exactly one argument" + echo "$me: trying some XSI constructs with $1" + $1 -c "$xsi_shell_code" || skip_all_ "$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'\' + +# $PYTHON and support for PEP-3147. Needed to check our python-related +# install rules. +python_has_pep3147 () +{ + if test -z "$am_pep3147_tag"; then + am_pep3147_tag=$($PYTHON -c 'import imp; print(imp.get_tag())') \ + || am_pep3147_tag=none + fi + test $am_pep3147_tag != none +} +am_pep3147_tag= + +# pyc_location [-p] [FILE] +# ------------------------ +# Determine what the actual location of the given '.pyc' or '.pyo' +# byte-compiled file should be, taking into account PEP-3147. Save +# the location in the '$am_pyc_file' variable. If the '-p' option +# is given, print the location on the standard output as well. +pyc_location () +{ + case $#,$1 in + 2,-p) am_pyc_print=yes; shift;; + 1,*) am_pyc_print=no;; + *) fatal_ "pyc_location: invalid usage";; + esac + if python_has_pep3147; then + case $1 in + */*) am_pyc_dir=${1%/*} am_pyc_base=${1##*/};; + *) am_pyc_dir=. am_pyc_base=$1;; + esac + am_pyc_ext=${am_pyc_base##*.} + am_pyc_base=${am_pyc_base%.py?} + am_pyc_file=$am_pyc_dir/__pycache__/$am_pyc_base.$am_pep3147_tag.$am_pyc_ext + else + am_pyc_file=$1 + fi + test $am_pyc_print = no || printf '%s\n' "$am_pyc_file" +} + +# py_installed [--not] FILE +# -------------------------- +# Check that the given python FILE has been installed (resp. *not* +# installed, if the '--not' option is specified). If FILE is a +# byte-compiled '.pyc' file, the new installation layout specified +# by PEP-3147 will be taken into account. +py_installed () +{ + case $#,$1 in + 1,*) am_test_py_file='test -f';; + 2,--not) am_test_py_file='test ! -e'; shift;; + *) fatal_ "pyc_installed: invalid usage";; + esac + case $1 in + *.py[co]) pyc_location "$1"; am_target_py_file=$am_pyc_file;; + *) am_target_py_file=$1;; + esac + $am_test_py_file "$am_target_py_file" +} + +# Usage: require_compiler_ {cc|c++|fortran|fortran77} +require_compiler_ () +{ + case $# in + 0) fatal_ "require_compiler_: missing argument";; + 1) ;; + *) fatal_ "require_compiler_: too many arguments";; + esac + case $1 in + cc) + am__comp_lang="C" + am__comp_var=CC + am__comp_flag_vars='CFLAGS CPPFLAGS' + ;; + c++) + am__comp_lang="C++" + am__comp_var=CXX + am__comp_flag_vars='CXXFLAGS CPPFLAGS' + ;; + fortran) + am__comp_lang="Fortran" + am__comp_var=FC + am__comp_flag_vars='FCFLAGS' + ;; + fortran77) + am__comp_lang="Fortran 77" + am__comp_var=F77 + am__comp_flag_vars='FFLAGS' + ;; + esac + shift + eval "am__comp_prog=\${$am__comp_var}" \ + || fatal_ "expanding \${$am__comp_var} in require_compiler_" + case $am__comp_prog in + "") + fatal_ "botched configuration: \$$am__comp_var is empty";; + false) + skip_all_ "no $am__comp_lang compiler available";; + autodetect|autodetected) + # Let the ./configure commands in the test script try to determine + # these automatically. + unset $am__comp_var $am__comp_flag_vars;; + *) + # Pre-set these for the ./configure commands in the test script. + export $am__comp_var $am__comp_flag_vars;; + esac + # Delete private variables. + unset am__comp_lang am__comp_prog am__comp_var am__comp_flag_vars +} + +## ----------------------------------------------------------- ## +## Checks for required tools, and additional setups (if any) ## +## required by them. ## +## ----------------------------------------------------------- ## + +require_tool () +{ + am_tool=$1 + case $1 in + cc|c++|fortran|fortran77) + require_compiler_ $1;; + -c-o) + if test x"$AM_TESTSUITE_SIMULATING_NO_CC_C_O" = x"yes"; then + skip_all_ "need a C compiler that grasps -c and -o together" + fi + ;; + xsi-lib-shell) + if test x"$am_test_prefer_config_shell" = x"yes"; then + require_xsi "$SHELL" + else + require_xsi "/bin/sh" + fi + ;; + bzip2) + # Do not use --version, older versions bzip2 still tries to compress + # stdin. + echo "$me: running bzip2 --help" + bzip2 --help \ + || skip_all_ "required program 'bzip2' not available" + ;; + cl) + CC=cl + # Don't export CFLAGS, as that could have been initialized to only + # work with the C compiler detected at configure time. If the user + # wants CFLAGS to also influence 'cl', he can still export CFLAGS + # in the environment "by hand" before calling the testsuite. + export CC CPPFLAGS + echo "$me: running $CC -?" + # The IRAF package (http://iraf.noao.edu/) contains a 'cl' program + # which is interactive, and which could cause the testsuite to hang + # if its standard input is not redirected. See automake bug#14707. + $CC -? </dev/null \ + || skip_all_ "Microsoft C compiler '$CC' not available" + ;; + icl) + CC=icl + # Don't export CFLAGS, as that could have been initialized to only + # work with the C compiler detected at configure time. If the user + # wants CFLAGS to also influence 'icl', he can still export CFLAGS + # in the environment "by hand" before calling the testsuite. + export CC CPPFLAGS + echo "$me: running $CC -?" + $CC -? >/dev/null \ + || skip_all_ "Intel C compiler '$CC' not available" + ;; + etags) + # Exuberant Ctags will create a TAGS file even + # when asked for --help or --version. (Emacs's etags + # does not have such problem.) Use -o /dev/null + # to make sure we do not pollute the build directory. + echo "$me: running etags --version -o /dev/null" + etags --version -o /dev/null \ + || skip_all_ "required program 'etags' not available" + ;; + GNUmake) + for am_make in "$MAKE" gmake gnumake :; do + MAKE=$am_make + am__using_gmake= # Invalidate cache used by 'using_gmake()'. + test "$MAKE" = : && break + echo "$me: determine whether $MAKE is GNU make" + using_gmake && break + : For shells with busted 'set -e'. + done + test "$MAKE" = : && skip_all_ "this test requires GNU make" + export MAKE + unset am_make + ;; + gcj) + GCJ=$GNU_GCJ GCJFLAGS=$GNU_GCJFLAGS; export GCJ GCJFLAGS + test "$GCJ" = false && skip_all_ "GNU Java compiler unavailable" + : For shells with busted 'set -e'. + ;; + gcc) + CC=$GNU_CC CFLAGS=$GNU_CFLAGS; export CC CFLAGS CPPFLAGS + test "$CC" = false && skip_all_ "GNU C compiler unavailable" + : For shells with busted 'set -e'. + ;; + g++) + CXX=$GNU_CXX CXXFLAGS=$GNU_CXXFLAGS; export CXX CXXFLAGS CPPFLAGS + test "$CXX" = false && skip_all_ "GNU C++ compiler unavailable" + : For shells with busted 'set -e'. + ;; + gfortran) + FC=$GNU_FC FCFLAGS=$GNU_FCFLAGS; export FC FCFLAGS + test "$FC" = false && skip_all_ "GNU Fortran compiler unavailable" + case " $required " in + *\ g77\ *) ;; + *) F77=$FC FFLAGS=$FCFLAGS; export F77 FFLAGS;; + esac + ;; + g77) + F77=$GNU_F77 FFLAGS=$GNU_FFLAGS; export F77 FFLAGS + test "$F77" = false && skip_all_ "GNU Fortran 77 compiler unavailable" + case " $required " in + *\ gfortran\ *) ;; + *) FC=$F77 FCFLAGS=$FFLAGS; export FC FCFLAGS;; + esac + ;; + grep-nonprint) + # Check that grep can parse nonprinting characters correctly. + # 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" | grep .)$(echo "$esc" | grep "$esc") in + "$esc$esc") ;; + *) skip_ "grep can't handle nonprinting characters correctly";; + esac + ;; + javac) + # The Java compiler from JDK 1.5 (and presumably earlier versions) + # cannot handle the '-version' option by itself: it bails out + # telling that source files are missing. Adding also the '-help' + # option seems to solve the problem. + echo "$me: running javac -version -help" + javac -version -help || skip_all_ "Sun Java compiler not available" + ;; + java) + # See the comments above about 'javac' for why we use also '-help'. + echo "$me: running java -version -help" + java -version -help || skip_all_ "Sun Java interpreter not found" + ;; + lib) + AR=lib; export AR + # Attempting to create an empty archive will actually not + # create the archive, but lib will output its version. + echo "$me: running $AR -out:defstest.lib" + $AR -out:defstest.lib \ + || skip_all_ "Microsoft 'lib' utility not available" + ;; + makedepend) + echo "$me: running makedepend -f-" + makedepend -f- \ + || skip_all_ "required program 'makedepend' not available" + ;; + mingw) + uname_s=$(uname -s || echo UNKNOWN) + echo "$me: system name: $uname_s" + case $uname_s in + MINGW*) ;; + *) skip_all_ "this test requires MSYS in MinGW mode" ;; + esac + unset uname_s + ;; + non-root) + # Skip this test case if the user is root. + # We try to append to a read-only file to detect this. + priv_check_temp=am--priv-check.$$ + touch $priv_check_temp && chmod a-w $priv_check_temp \ + || framework_failure_ "creating unwritable file $priv_check_temp" + # Not a useless use of subshell: lesser shells might bail + # out if a builtin fails. + overwrite_status=0 + (echo foo >> $priv_check_temp) || overwrite_status=$? + rm -f $priv_check_temp + if test $overwrite_status -eq 0; then + skip_all_ "cannot drop file write permissions" + fi + unset priv_check_temp overwrite_status + ;; + # Extra quoting required to avoid maintainer-check spurious failures. + 'perl-threads') + if test "$WANT_NO_THREADS" = "yes"; then + skip_all_ "Devel::Cover cannot cope with threads" + fi + ;; + native) + # Don't use "&&" here, to avoid a bug of 'set -e' present in + # some (even relatively recent) versions of the BSD shell. + # We add the dummy "else" branch for extra safety. + ! cross_compiling || skip_all_ "doesn't work in cross-compile mode" + ;; + python) + PYTHON=${PYTHON-python} + # Older python versions don't support --version, they have -V. + echo "$me: running $PYTHON -V" + $PYTHON -V || skip_all_ "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 && chmod a-w $ro_dir_temp \ + || framework_failure_ "creating unwritable directory $ro_dir_temp" + # Not a useless use of subshell: lesser shells might bail + # out if a builtin fails. + create_status=0 + (: > $ro_dir_temp/probe) || create_status=$? + rm -rf $ro_dir_temp + if test $create_status -eq 0; then + skip_all_ "cannot drop directory write permissions" + fi + unset ro_dir_temp create_status + ;; + 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_all_ "DejaGnu is not available" + ;; + tex) + # No all versions of Tex support '--version', so we use + # a configure check. + if test -z "$TEX"; then + skip_all_ "TeX is required, but it wasn't found by configure" + fi + ;; + lex) + test x"$LEX" = x"false" && skip_all_ "lex not found or disabled" + export LEX + ;; + yacc) + test x"$YACC" = x"false" && skip_all_ "yacc not found or disabled" + export YACC + ;; + flex) + LEX=flex; export LEX + echo "$me: running flex --version" + flex --version || skip_all_ "required program 'flex' not available" + ;; + bison) + YACC='bison -y'; export YACC + echo "$me: running bison --version" + bison --version || skip_all_ "required program 'bison' not available" + ;; + valac) + echo "$me: running valac --version" + if ! valac --version; then + skip_all_ "required program 'valac' not available" + elif cross_compiling; then + skip_all_ "cross-compiling valac-generated C files is brittle" + fi + # TODO: We also know we need GNU make, the C compiler, and pkg-config + # here, but there is no easy way to express this with the current + # code organization. We should improve the situation, sooner or + # later. At which point the tests requiring 'valac' can drop the + # explicit requirements for those tools. + ;; + *) + # Generic case: the tool must support --version. + echo "$me: running $1 --version" + # It is not likely but possible that the required tool is a special + # builtin, in which case the shell is allowed to exit after an error. + # So we need the subshell here. Also, some tools, like Sun cscope, + # can be interactive without redirection. + ($1 --version) </dev/null \ + || skip_all_ "required program '$1' not available" + ;; + esac +} + +process_requirements () +{ + # Look for (and maybe set up) required tools and/or system features; + # skip the current test if they are not found. + for am_tool in $*; do + require_tool $am_tool + done + # We might need extra m4 macros, e.g., for Libtool or Gettext. + for am_tool in gettext libtool pkg-config; do + case " $required " in + # The lack of whitespace after $am_tool is intended. + *" $am_tool"*) . ./t/$am_tool-macros.dir/get.sh;; + esac + done + unset am_tool +} + +## ---------------------------------------------------------------- ## +## Create and set up of the temporary directory used by the test. ## +## ---------------------------------------------------------------- ## + +am_setup_testdir () +{ + # 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. + am_test_subdir=${argv0#$am_rel_srcdir/} + case $am_test_subdir in + */*) am_test_subdir=${am_test_subdir%/*}/$me.dir;; + *) am_test_subdir=$me.dir;; + esac + test ! -e $am_test_subdir || rm_rf_ $am_test_subdir \ + || framework_failure_ "removing old test subdirectory" + $MKDIR_P $am_test_subdir \ + || framework_failure_ "creating test subdirectory" + cd $am_test_subdir \ + || framework_failure_ "cannot chdir into test subdirectory" + if test x"$am_create_testdir" != x"empty"; then + cp "$am_scriptdir"/install-sh "$am_scriptdir"/missing \ + "$am_scriptdir"/compile "$am_scriptdir"/depcomp . \ + || framework_failure_ "fetching common files from $am_scriptdir" + # Build appropriate environment in test directory. E.g., create + # configure.ac, 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"$am_serial_tests" = x"yes"; then + echo "AM_INIT_AUTOMAKE([serial-tests])" + else + echo "AM_INIT_AUTOMAKE" + fi + echo "AC_CONFIG_FILES([Makefile])" + } >configure.ac || framework_failure_ "creating configure.ac skeleton" + fi +} + +am_extra_info () +{ + echo "Running from installcheck: $am_running_installcheck" + echo "Test Protocol: $am_test_protocol" + echo "PATH = $PATH" +} diff --git a/t/ax/cc-no-c-o.in b/t/ax/cc-no-c-o.in new file mode 100644 index 000000000..fd51482e4 --- /dev/null +++ b/t/ax/cc-no-c-o.in @@ -0,0 +1,41 @@ +#! @AM_TEST_RUNNER_SHELL@ +# Copyright (C) 2012-2017 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 <https://www.gnu.org/licenses/>. + +# A "C compiler" that chokes when the '-c' and '-o' options are passed +# together to it on the command line. See also automake bug#13378. + +am_CC=${AM_TESTSUITE_GNU_CC-'@GNU_CC@'} + +seen_c=false +seen_o=false + +for arg +do + case $arg in + -c) + seen_c=true;; + # It is acceptable not to leave a space between the '-o' option + # and its argument, so we have to cater for that. + -o|-o*) + seen_o=true;; + esac + if $seen_c && $seen_o; then + echo "$0: both '-o' and '-c' seen on the command line" >&2 + exit 2 + fi +done + +exec $am_CC "$@" diff --git a/t/ax/deltree.pl b/t/ax/deltree.pl new file mode 100644 index 000000000..f239057aa --- /dev/null +++ b/t/ax/deltree.pl @@ -0,0 +1,34 @@ +#!/usr/bin/env perl +# deltree: recursively removes file and directory, +# trying to handle permissions and other complications. + +# Copyright (C) 2013-2017 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 <https://www.gnu.org/licenses/>. + +use strict; +use warnings FATAL => 'all'; +use File::Path qw/rmtree/; + +my $exit_status = 0; +local $SIG{__WARN__} = sub { warn "@_"; $exit_status = 1; }; + +foreach my $path (@ARGV) { + local $@ = undef; + rmtree ($path); +} + +exit $exit_status; + +# vim: ft=perl ts=4 sw=4 et diff --git a/t/ax/depcomp.sh b/t/ax/depcomp.sh new file mode 100644 index 000000000..09cf99933 --- /dev/null +++ b/t/ax/depcomp.sh @@ -0,0 +1,417 @@ +#! /bin/sh +# Copyright (C) 2012-2017 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 <https://www.gnu.org/licenses/>. + +# Check dependency tracking in various flavours. +# Contains both libtool and non-libtool case. +# Sourced by the various (autogenerated) 'depcomp*.tap' tests. +# Examples of reported failures that motivated those test are +# listed below. + +# ------------------------------------------------------------------------- + +# <https://lists.gnu.org/archive/html/automake-patches/2011-04/msg00028.html> +# +# Here's the bug: makedepend will prefix VPATH to the object file name, +# thus the second make will invoke depcomp with object='../../src/foo.o', +# causing errors such as: +# +# touch: cannot touch '../../src/.deps/foo.TPo': No such file or directory +# makedepend: error: cannot open "../../src/.deps/foo.TPo" +# ../../depcomp: line 560: ../../src/.deps/foo.TPo: No such file or directory + +# ------------------------------------------------------------------------- + +# <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=8473> +# <https://lists.gnu.org/archive/html/automake-patches/2011-04/msg00079.html> +# +# Here's the bug: hp depmode will prefix VPATH to the object file name, +# thus the second gmake will invoke depcomp with object='../../src/foo.o', +# causing errors such as (broken on multiple lines for clarity): +# +# cpp: "", line 0: error 4066: Cannot create +# "../../gllib/.deps/nonblocking.TPo" file for +# "-M../../gllib/.deps/nonblocking.TPo" option. +# (No such file or directory[errno=2]) +# + +# ------------------------------------------------------------------------- + +# <https://lists.gnu.org/archive/html/automake-patches/2011-04/msg00140.html> +# <https://lists.gnu.org/archive/html/automake-patches/2011-05/msg00019.html> +# +# A partial failure of an earlier version of this test; some bad +# post-processing of the '*.Po' files led to the following broken +# contents of 'src/sub/.deps/subfoo.Po': +# +# > sub/subfoo.o: ../../depmod-data.dir/src/sub/subfoo.c \ +# > ../../depmod-data.dir/src/foo.h +# > ../../depmod-data.dir/src/sub/subfoo.c \: +# > ../../depmod-data.dir/src/foo.h: +# +# which caused make to die with an error like: +# +# "sub/.deps/subfoo.Po:3: *** missing separator. Stop." + +# ------------------------------------------------------------------------- + +# This code expects test-init.sh has already been included in advance. + +ocwd=$(pwd) || fatal_ "getting current working directory" +longpath=this-is/a-path/which-has/quite-a/definitely/truly/long_long_name +cachevar=am_cv_CC_dependencies_compiler_type + +srctree=depmod-1.0 +mkdir $srctree +cd $srctree + +cd_top () +{ + cd "$ocwd" || fatal_ "cannot chdir back to top directory" +} + +delete () +{ + test -f "$1" || fatal_ "$1: file does not exist" + rm -f "$1" || fatal_ "$1: couldn't remove" +} + +edit () +{ + file=$1; shift + sed "$@" <"$file" > t && mv -f t "$file" \ + || fatal_ "$file: editing of file failed" +} + +rewrite () +{ + file=$1; shift + "$@" > "$file" || fatal_ "$file: couldn't rewrite" +} + +setup_srcdir () +{ + srcdir=$1 # This is intended to be global. + mkdir -p "$srcdir" \ + || fatal_ "couldn't create source directory '$srcdir'" + cp -pR "$ocwd/$srctree"/* "$srcdir"/ \ + || fatal_ "couldn't populate source directory '$srcdir'" +} + + +check_no_depfiles () +{ + find . -name '*.Plo' -o -name '*.Po' | grep . && return 1 + return 0 +} + +check_distclean () +{ + # "make distcleancheck" can only run from a VPATH build. + if test $vpath = no; then + make_ok distclean && check_no_depfiles + else + $MAKE distcleancheck + fi +} + +cat > configure.ac <<END +AC_INIT([$me], [1.0]) +AC_CONFIG_AUX_DIR([build-aux]) +AM_INIT_AUTOMAKE([subdir-objects]) +AC_PROG_CC +AM_PROG_AR +$(if test $depcomp_with_libtool = yes; then + echo AC_PROG_LIBTOOL + else + echo AC_PROG_RANLIB + fi) +AC_CONFIG_FILES([Makefile src/Makefile]) +AC_OUTPUT +END + +mkdir build-aux sub src src/sub2 + +case $depcomp_with_libtool in + yes) + po=Plo objext=lo a=la + normalized_target=libfoo_la + # On platforms requiring that no undefined symbols exist in order + # to build shared libraries (e.g. Windows DLLs), you have to + # explicitly declare that the libtool library you are building + # does not actually have any undefined symbols, for libtool to + # even try to build it as a shared library. Without that + # explicit declaration, libtool falls back to a static library + # only, regardless of any --enable-shared flags etc. + LIBPRIMARY=LTLIBRARIES LINKADD=LIBADD NOUNDEF=-no-undefined + libbaz_ldflags="libbaz_${a}_LDFLAGS = $NOUNDEF" + echo lib_LTLIBRARIES = libfoo.la >> Makefile.am + make_ok () + { + run_make -M -- ${1+"$@"} + $FGREP 'unknown directive' output && return 1 + rm -f output + # Checks for stray files possibly left around by less common + # depmodes. + find . -name '*.[ud]' | grep . && return 1 + return 0 + } + ;; + no) + po=Po objext='$(OBJEXT)' a=a + normalized_target=foo + LIBPRIMARY=LIBRARIES LINKADD=LDADD NOUNDEF= + libbaz_ldflags= + echo bin_PROGRAMS = foo >> Makefile.am + make_ok () + { + $MAKE ${1+"$@"} + } + ;; + *) + fatal_ "invalid value '$depcomp_with_libtool' for variable" \ + "\$depcomp_with_libtool" + ;; +esac + +cat >> Makefile.am <<END +SUBDIRS = src +# We include subfoo only to be sure that the munging in depcomp +# doesn't remove too much from the object file name. +${normalized_target}_SOURCES = foo.c sub/subfoo.c foo.h sub/subfoo.h +${normalized_target}_LDFLAGS = $NOUNDEF +${normalized_target}_${LINKADD} = src/libbaz.$a + +.PHONY: grep-test +grep-test: +## For debugging. + cat \$(DEPDIR)/foo.$po || : + cat sub/\$(DEPDIR)/subfoo.$po || : + cat src/\$(DEPDIR)/baz.$po || : + cat src/sub2/\$(DEPDIR)/sub2foo.$po || : +## Checks are done here. + grep '^foo.$objext.*:' \$(DEPDIR)/foo.$po + grep '^sub/subfoo\.$objext.*:' sub/\$(DEPDIR)/subfoo.$po + grep '^baz\.$objext.*:' src/\$(DEPDIR)/baz.$po + grep '^sub2/sub2foo\.$objext.*:' src/sub2/\$(DEPDIR)/sub2foo.$po +END + +cat > src/Makefile.am <<END +noinst_${LIBPRIMARY} = libbaz.$a +# We include sub2foo only to be sure that the munging in depcomp +# doesn't remove too much from the object file name. +libbaz_${a}_SOURCES = baz.c sub2/sub2foo.c baz.h sub2/sub2foo.h +$libbaz_ldflags +END + +cat > foo.c <<'END' +#include "foo.h" +#include "src/baz.h" +#include <stdlib.h> +int main (void) +{ + printf ("foo bar\n"); + exit (EXIT_SUCCESS + subfoo () + baz ()); +} +END + +cat > foo.h <<'END' +#include <stdio.h> +#include "sub/subfoo.h" +END + +cat > sub/subfoo.c <<'END' +#include "sub/subfoo.h" +int subfoo (void) { return 0; } +END + +echo '/* empty */' > src/sub2/sub2foo.h + +cat > sub/subfoo.h <<'END' +#include <stdio.h> +extern int subfoo (void); +END + +cat > src/baz.c <<'END' +#include "baz.h" +int baz (void) { return 0; } +END + +cat > src/baz.h <<'END' +extern int baz (void); +END + +cat > src/sub2/sub2foo.c <<'END' +#include "sub2foo.h" +int sub2foo (void) { return 0; } +END + +test $depcomp_with_libtool = no || libtoolize \ + || fatal_ "libtoolize failed" +$ACLOCAL && $AUTOCONF && $AUTOMAKE -a \ + || fatal_ "autotools failed" +test -f build-aux/depcomp \ + || fatal_ "depcomp script not installed" + +# To offer extra coverage for the depmodes (like "aix" of "hp2") where the +# name of the compiler-generated depfiles can depend on whether libtool is +# in use *and* on which kind of libraries libtool is building (static, +# shared, or both), we would like to run the libtool-oriented tests thrice: +# once after having run configure with the '--disable-shared' option, once +# after having run it with the '--enable-shared' options, and once by +# leaving it to configure to automatically select which kind of library (or +# libraries) to build. +# +# But doing such three-fold checks unconditionally for all the depmodes +# would slow down the already too slow libtool tests unacceptably (up to a +# 150-200% factor), with no real gain in coverage for most of the depmodes. +# So, since the depmodes that would benefit from the extra tests are never +# forced to configure in out tests below, but can only be automatically +# selected by '--enable-dependency-tracking', we make this threefold check +# only in this later case. + +if test $depmode,$depcomp_with_libtool = auto,yes; then + do_all_tests () + { + do_test default + do_test noshared --disable-shared + do_test nostatic --disable-static + } +else + do_all_tests () { do_test; } +fi + +case $depmode in + auto) + displayed_depmode='..*' # At least one character long. + cfg_deptrack=--enable-dependency-tracking ;; + disabled) + displayed_depmode=none + cfg_deptrack=--disable-dependency-tracking ;; + *) + displayed_depmode="(cached) $depmode" + cfg_deptrack="$cachevar=$depmode" + # Sanity check: ensure the cache variable we force is truly + # used by configure. + $FGREP $cachevar configure \ + || fatal_ "configure lacks required cache variable '$cachevar'";; +esac + +cd_top + +do_test () +{ + cd_top + if test $vpath = no; then + pfx="in-tree build" + else + pfx="$vpath VPATH" + fi + if test $# -gt 0; then + subdir=$1; shift + pfx="$pfx, $subdir" + test -d $subdir || mkdir $subdir || fatal_ "creating directory $subdir" + cd $subdir + fi + pfx="[$pfx]" + case $vpath in + simple) + mkdir -p vpath-simple/build + cd vpath-simple/build + setup_srcdir .. + ;; + long) + mkdir -p vpath-long/src vpath-long/wrk + cd vpath-long/wrk + setup_srcdir ../src/$longpath + ;; + absolute) + mkdir -p vpath-abs/build + cd vpath-abs/build + absdir=$(cd .. && pwd) || fatal_ "getting absolute directory" + setup_srcdir "$absdir/vpath-abs" + unset absdir + ;; + no) + mkdir intree + cd intree + setup_srcdir . + ;; + *) + fatal_ "invalid value '$vpath' for variable \$vpath" + ;; + esac + + command_ok_ \ + "$pfx configure" \ + "$srcdir/configure" $cfg_deptrack ${1+"$@"} >stdout + cat stdout + + command_ok_ \ + "$pfx right depmode selected" \ + grep "^checking dependency style .*\.\.\. $displayed_depmode$" stdout + rm -f stdout + + command_ok_ "$pfx simple make" make_ok + # Some bugs in VPATH builds only kick in during a rebuild. + command_ok_ "$pfx clean & rebuild" eval '$MAKE clean && make_ok' + + if test $depmode = disabled; then + command_ok_ "$pfx no dependency files generated" check_no_depfiles + r=ok \ + && grep "[ $tab]depmode=none" Makefile \ + && rewrite "$srcdir"/src/sub2/sub2foo.h echo 'choke me' \ + && delete "$srcdir"/sub/subfoo.h \ + && make_ok \ + || r='not ok' + result_ "$r" "$pfx dependency tracking is truly disabled" + elif grep "[ $tab]depmode=none" Makefile; then + skip_row_ 2 -r "automatic dependency tracking couldn't be activated" + else + command_ok_ "$pfx generated $po files look correct" $MAKE grep-test + r=ok \ + && : "Some checks in the subdir." \ + && $sleep \ + && : "Ensure rebuild rules really kick in." \ + && rewrite "$srcdir"/src/sub2/sub2foo.h echo 'choke me' \ + && cd src \ + && not $MAKE \ + && cd .. \ + && : "Ensure the deleted header bug is fixed." \ + && delete "$srcdir"/src/sub2/sub2foo.h \ + && edit "$srcdir"/src/sub2/sub2foo.c -e 1d \ + && cd src \ + && make_ok \ + && : "Now do similar checks for the parent directory." \ + && cd .. \ + && rewrite "$srcdir"/sub/subfoo.h echo 'choke me' \ + && not $MAKE \ + && delete "$srcdir"/sub/subfoo.h \ + && edit "$srcdir"/sub/subfoo.c -e 1d \ + && edit "$srcdir"/foo.h -e 2d \ + && make_ok \ + || r='not ok' + result_ "$r" "$pfx dependency tracking works" + fi + + command_ok_ "$pfx make distclean" check_distclean + cd_top +} + +for vpath in no simple long absolute; do + do_all_tests +done + +: diff --git a/t/ax/distcheck-hook-m4.am b/t/ax/distcheck-hook-m4.am new file mode 100644 index 000000000..9442a9896 --- /dev/null +++ b/t/ax/distcheck-hook-m4.am @@ -0,0 +1,30 @@ +## Data files for some tests. Not used in the automake build system. +## +## Copyright (C) 2011-2017 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 <https://www.gnu.org/licenses/>. + +distcheck-hook: + @fatal () { echo "$@: $$*" >&2; exit 1; }; \ + $(am__cd) $(distdir) && chmod u+w . && mkdir _m4 \ + || fatal "cannot setup distdir"; \ + $(ACLOCAL) -I _m4 $(ACLOCAL_AMFLAGS) --install --output=_am.m4 \ + || fatal "cannot regenerate aclocal.m4"; \ + lst=`ls _m4 | tr '\012\015' ' '`; \ + if test -n "$$lst"; then \ + fatal "required m4 files not distributed or outdated: $$lst"; \ + fi; \ + $(AUTOCONF) -o /dev/null || fatal "can't remake configure"; \ + rm -rf _m4 _am.m4 autom4te.cache && chmod a-w . \ + || fatal "cannot reset distdir" diff --git a/t/ax/extract-testsuite-summary.pl b/t/ax/extract-testsuite-summary.pl new file mode 100644 index 000000000..284eefdcf --- /dev/null +++ b/t/ax/extract-testsuite-summary.pl @@ -0,0 +1,30 @@ +#! /usr/bin/env perl +# Extract the testsuite summary generated by the parallel testsuite +# harness from the output of "make check". + +# Copyright (C) 2012-2017 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 <https://www.gnu.org/licenses/>. + +use warnings FATAL => 'all'; +use strict; + +my $br = '=' x 76; +my @sections = (''); +while (<>) + { + push @sections, $_, '' if /$br/; + $sections[-1] .= $_ if !/$br/; + } +print @sections[1..$#sections-1]; diff --git a/t/ax/is b/t/ax/is new file mode 100755 index 000000000..ba6ea4445 --- /dev/null +++ b/t/ax/is @@ -0,0 +1,57 @@ +#! /bin/sh +# Copyright (C) 2012-2017 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 <https://www.gnu.org/licenses/>. + +# Test that two whitespace-separated lists are equal. +# Assumes the two lists are passed on the command line separated by +# a '==' string. +# This script is useful to test equality of lists in makefile rules, +# in the face of variables defined through line-continuations, +# automake rewrites and expansions of empty variables. + +# NOTE: keep this file Bourne-compatible, for the sake of systems with +# non-POSIX /bin/sh (like Solaris). + +set -e +set -u + +# Initialize before unsetting, for shells (like older bash or Solaris +# ksh) that fail to unset variables that are already unset. +exp= got=; unset exp got +seen_eqeq=no +while test $# -gt 0; do + if test x"$1" = x"=="; then + if test $seen_eqeq = no; then + seen_eqeq=yes + else + echo "$0: more than one '==' argument seen on command line" >&2 + exit 2 + fi + else + if test $seen_eqeq = no; then + got=${got+"$got "}$1 + else + exp=${exp+"$exp "}$1 + fi + fi + shift +done + +if test $seen_eqeq = no; then + echo "$0: no '==' argument seen on command line" >&2 + exit 2 +fi + +test x"${exp-}" = x"${got-}" diff --git a/t/ax/is_newest b/t/ax/is_newest new file mode 100755 index 000000000..e62c132d1 --- /dev/null +++ b/t/ax/is_newest @@ -0,0 +1,42 @@ +#! /bin/sh +# Copyright (C) 2012-2017 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 <https://www.gnu.org/licenses/>. + +# Usage: is_newest FILE FILES +# Fail if any file in FILES is newer than FILE, and print the list of +# such files on the standard error. Resolve ties in favor of FILE. + +# NOTE: keep this file Bourne-compatible, for the sake of systems with +# non-POSIX /bin/sh (like Solaris). + +set -u + +me=is_newest + +if test $# -lt 2; then + echo "$me: too few arguments" >&2 + exit 2 +fi + +file=$1; shift +newer_files=`find "$@" -prune -newer "$file"` || exit $? + +if test -n "$newer_files"; then + echo "$me: these files are newer than '$file':" >&2 + for f in $newer_files; do echo "* $f" >&2; done + exit 1 +fi + +exit 0 diff --git a/t/ax/runtest.in b/t/ax/runtest.in new file mode 100644 index 000000000..80a6b1a29 --- /dev/null +++ b/t/ax/runtest.in @@ -0,0 +1,130 @@ +#!@AM_TEST_RUNNER_SHELL@ +# @configure_input@ +# +# Copyright (C) 2012-2017 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 <https://www.gnu.org/licenses/>. + +# Run an Automake test from the command line. + +set -e; set -u + +: ${AM_TEST_RUNNER_SHELL='@AM_TEST_RUNNER_SHELL@'} +: ${AM_PROVE_CMD='prove'} +: ${AM_PROVEFLAGS='--merge --verbose'} +: ${srcdir='@srcdir@'} +: ${abs_srcdir='@abs_srcdir@'} +: ${abs_builddir='@abs_builddir@'} +: ${PATH_SEPARATOR='@PATH_SEPARATOR@'} + +# For sourcing of extra "shell libraries" by our test scripts. As per +# POSIX, sourcing a file with '.' will cause it to be looked up in $PATH +# in case it is given with a relative name containing no slashes. +if test "$srcdir" != .; then + PATH=$abs_srcdir/t/ax$PATH_SEPARATOR$PATH +fi +PATH=$abs_builddir/t/ax$PATH_SEPARATOR$PATH +export PATH + +# For use by the testsuite framework. The Automake test harness +# define this, so we better do the same. +export srcdir + +# Some testsuite-influential variables should be overridable from the +# test scripts, but not from the environment. +# Keep this in sync with the 'Makefile.am:AM_TESTS_ENVIRONMENT'. +for v in \ + required \ + am_test_protocol \ + am_serial_tests \ + am_test_prefer_config_shell \ + am_original_AUTOMAKE \ + am_original_ACLOCAL \ + am_test_lib_sourced \ + test_lib_sourced \ +; do + eval "$v= && unset $v" || exit 1 +done +unset v + +xecho () { printf '%s\n' "$*"; } +error () { echo "$0: $*" >&2; exit 255; } + +# Some shell flags should be passed over to the test scripts. +shell_opts= +while test $# -gt 0; do + case $1 in + --help) + xecho "Usage: $0 [--shell=PATH] [-k] [SHELL-OPTIONS]" \ + "[VAR=VALUE ...] TEST [TEST-OPTIONS]" + exit $? + ;; + --shell) + test $# -gt 1 || error "missing argument for option '$1'" + AM_TEST_RUNNER_SHELL=$2 + shift + ;; + --shell=*) + AM_TEST_RUNNER_SHELL=${1#--shell=} + ;; + -o) + test $# -gt 1 || error "missing argument for option '$1'" + shell_opts="$shell_opts -o $2" + shift + ;; + -k|--keep-testdir|--keep-testdirs) + keep_testdirs=yes; export keep_testdirs;; + -*) + # Assume it is an option to pass through to the shell. + shell_opts="$shell_opts $1";; + *=*) + var=${1%%=*} val=${1#*=} + xecho "$var" | LC_ALL=C grep '^[a-zA-Z_][a-zA-Z0-9_]*$' >/dev/null \ + || error "'$var': invalid variable name" + eval "$var=\$val && export $var" || exit 1 + ;; + *) + break;; + esac + shift +done + +test $# -gt 0 || error "missing argument" + +tst=$1; shift + +case $tst in + /*) ;; + *) if test -f ./$tst; then + tst=./$tst + # Support for VPATH build. + elif test -f $srcdir/$tst; then + tst=$srcdir/$tst + else + error "could not find test '$tst'" + fi + ;; +esac + +case $tst in + *.sh) + exec $AM_TEST_RUNNER_SHELL $shell_opts "$tst" ${1+"$@"} ;; + *.tap) + exec "$AM_PROVE_CMD" $AM_PROVEFLAGS -e \ + "$AM_TEST_RUNNER_SHELL $shell_opts" "$tst" ${1+"$@"} ;; + *) + error "test '$tst' has an unrecognized extension" ;; +esac + +error "dead code reached" diff --git a/t/ax/shell-no-trail-bslash.in b/t/ax/shell-no-trail-bslash.in new file mode 100644 index 000000000..fc7b54107 --- /dev/null +++ b/t/ax/shell-no-trail-bslash.in @@ -0,0 +1,85 @@ +#! @AM_TEST_RUNNER_SHELL@ +# Copyright (C) 2012-2017 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 <https://www.gnu.org/licenses/>. + +# A "shell" that chokes on '-c' commands and/or shell scripts having +# a trailing '\' character (possibly followed by whitespace only). +# This is to emulate problems seen in older bash versions (e.g., bash +# 2.05b). See also automake bug#10436. + +set -u + +am_SHELL=${AM_TESTSUITE_SHELL-'@SHELL@'} + +( + set -e + shell_command=; unset shell_command + shell_script=; unset shell_script + while test $# -gt 0; do + case $1 in + # The shell might be invoked by make e.g. as "sh -ec" or "sh -ce". + # Be liberal (in the spirit of defensive programming) and accept + # both forms. + -*c*) shell_command=$2; shift;; + -?*) ;; + *) break;; + esac + shift + done + + if test x${shell_command+"set"} != x"set"; then + if test $# -gt 0; then + shell_script=$1 + shell_command=$(cat <"$shell_script") + else + # Some make implementations, like *BSD's, pass the recipes to the + # shell through its standard input. Trying to run our extra checks + # in this case would be too tricky, so we just skip them. + exit 0 + fi + fi + original_shell_command=$shell_command + + tab=' ' + nl=' +' + case "$shell_command" in + *" "|*"$tab"|*"$nl") + shell_command=$(printf '%s\n' "$shell_command" | tr -d " $tab$nl");; + esac + + case "$shell_command" in + *\\) + { + printf '%s\n' "$0: recipe/script ends with backslash character" + printf '%s\n' "=== BEGIN recipe/script" + if test x${shell_script+"set"} = x"set"; then + cat <"$shell_script" + else + printf '%s\n' "$original_shell_command" + fi + printf '%s\n' "=== END recipe/script" + } >&2 + exit 1 + ;; + esac +) + +if test $? -gt 0; then + # Some of our scripts or makefile recipes had invalid contents. + exit 3 +fi + +exec ${AM_TESTSUITE_SHELL-'@SHELL@'} ${1+"$@"} diff --git a/t/ax/tap-functions.sh b/t/ax/tap-functions.sh new file mode 100644 index 000000000..efa85a42d --- /dev/null +++ b/t/ax/tap-functions.sh @@ -0,0 +1,231 @@ +# -*- shell-script -*- +# +# Copyright (C) 2011-2017 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 <https://www.gnu.org/licenses/>. + +# Helper functions used by TAP-producing tests of the Automake testsuite. + +# +# IMPORTANT: All the functions defined in this file can *not* be used +# from within a subshell, unless explicitly noted otherwise. +# + +# The counts of the TAP test results seen so far: total count and +# per-result counts. +tap_count_=0 +tap_pass_count_=0 +tap_skip_count_=0 +tap_fail_count_=0 +tap_xfail_count_=0 +tap_xpass_count_=0 + +# not COMMAND [ARGS...] +# --------------------- +# Run the given command and invert its exit status. +not () { ! "$@"; } + +# plan_ [unknown|later|lazy|now|NUMBER-OF-PLANNED-TESTS] +# ------------------------------------------------------ +# Print a TAP plan for the given number of tests. This must be called +# before reporting any test result. If called with the special argument +# "unknown" or "later", it will do nothing, expecting the calling script +# to declare the plan later. If called with the special argument "lazy" +# or "now", it will print a TAP plan that accounts for the number of tests +# seen so far. +plan_ () +{ + if test $# -eq 0; then + bailout_ "plan_: missing argument" + elif test $# -ge 2; then + bailout_ "plan_: too many arguments" + elif test x"$planned_" != x"none" && test x"$planned_" != x"later"; then + bailout_ "plan_: called to many times" + elif test x"$1" = x"unknown" || test x"$1" = x"later"; then + # This means we want to get back later to declaring the TAP plan. + planned_=later + return 0 + elif test x"$1" = x"lazy" || test x"$1" = x"now"; then + planned_=$tap_count_ # Number of test results seen so far. + elif test $1 -ge 0; then + planned_=$1 + else + bailout_ "plan_: invalid argument '$1'" + fi + echo "1..$planned_" +} +planned_=none + +# diag_ [EXPLANATION] +# ------------------ +# Report the given text as TAP diagnostic. Assumes the string denoting +# TAP diagnostic lines is stored in the '$diag_string_' variable; this is +# done to allow better interplay with TAP drivers that allow such a string +# to be configured. +diag_ () +{ + test $# -eq 0 || echo "$diag_string_ $*" +} + +# Used by the 'diag_' function above. User-overridable. +diag_string_="#" + +# warn_ [EXPLANATION] +# ------------------ +# Give a warning (using TAP diagnostic). +warn_ () +{ + case $# in + 0) diag_ "WARNING: (unknown warning)";; + *) diag_ "WARNING: $*";; + esac +} + +# result_ RESULT [-D DIRECTIVE] [-r REASON] [--] [DESCRIPTION...] +# --------------------------------------------------------------- +# Report a test case with the given RESULT (valid values are "ok" and +# "not ok") and the given DESCRIPTION (if any). If DIRECTIVE is given +# and non-empty (valid values being "TODO" and "SKIP"), it will be +# reported too, with the REASON (if given) appended. +result_ () +{ + set +x # Don't pollute the log files. + test $# -gt 0 || bailout_ "result_: missing argument" + tap_result_=$1; shift + case $tap_result_ in + "ok"|"not ok") ;; + *) bailout_ "result_: invalid result '$tap_result'" ;; + esac + tap_directive_= tap_reason_= + while test $# -gt 0; do + case $1 in + -D|--directive) tap_directive_=$2; shift;; + -r|--reason) tap_reason_=$2; shift;; + --) shift; break;; + -*) bailout_ "result_: invalid option '$1'";; + *) break;; + esac + shift + done + case $tap_directive_ in + ""|TODO|SKIP) ;; + *) bailout_ "result_: invalid directive '$directive_'" ;; + esac + tap_count_=$(($tap_count_ + 1)) + case $tap_result_,$tap_directive_ in + ok,) # Passed. + tap_pass_count_=$(($tap_pass_count_ + 1)) ;; + not\ ok,TODO) # Expected failure. + tap_xfail_count_=$(($tap_xfail_count_ + 1)) ;; + not\ ok,*) # Failed. + tap_fail_count_=$(($tap_fail_count_ + 1)) ;; + ok,TODO) # Unexpected pass. + tap_xpass_count_=$(($tap_xpass_count_ + 1)) ;; + ok,SKIP) # Skipped. + tap_skip_count_=$(($tap_skip_count_ + 1)) ;; + *) # Can't happen. + bailout_ "internal error in 'result_'" ;; + esac + tap_text_="$tap_result_ $tap_count_" + if test x"$*" != x; then + tap_text_="$tap_text_ - $*" + fi + if test x"$tap_directive_" != x; then + tap_text_="$tap_text_ # $tap_directive_"${tap_reason_:+" $tap_reason_"} + fi + printf '%s\n' "$tap_text_" + set -x # Restore shell xtraces. +} + +# Shorthands for common usages of 'result_'. +ok_ () { result_ 'ok' ${1+"$@"}; } +not_ok_ () { result_ 'not ok' ${1+"$@"}; } +skip_ () { result_ 'ok' -D SKIP ${1+"$@"}; } + +# skip_row_ COUNT [-r REASON] [--] [DESCRIPTION...] +# ------------------------------------------------- +# Report a COUNT of skipped test, with the given reason and descriptions +# (if any). Useful to avoid cascade failures in case a fair number of +# tests depend on an earlier one that failed. +skip_row_ () +{ + skip_count_=$1; shift + for i_ in $(seq_ $skip_count_); do skip_ ${1+"$@"}; done +} + +# skip_all_ [REASON ...] +# ---------------------- +# Skip all the tests in a test script. Must be used before calling 'plan_' +# or reporting any test result. Can't be used from within a subshell. +skip_all_ () +{ + echo "1..0 # SKIP" ${1+"$@"} + planned_=0 + exit 0 +} + +# bailout_ [REASON ...] +# --------------------- +# Stop the execution of the current test suite right now, due to an +# unrecoverable error. Can be called at any point, but cannot be used +# from within a subshell. +bailout_ () +{ + echo 'Bail out!' ${1+"$@"} + exit 99 +} + +# fatal_ [REASON ...] +# ------------------- +# Same as 'bailout_'; for compatibility with 'plain-functions.sh'. +fatal_ () +{ + bailout_ ${1+"$@"} +} + +# framework_failure_ [REASON ...] +# ------------------------------- +# Stop the execution of the current test suite right now, due to an +# unrecoverable error in the set-up of the test case. Can be called +# at any point, but cannot be used from within a subshell. +framework_failure_ () +{ + bailout_ "set-up failure"${1+": $*"} +} + +# command_ok_ TEST-DESCRIPTION [OPTIONS..] [--] CMD [ARGS...] +# ----------------------------------------------------------- +# Helper subroutine for when a TAP result must be determined by the +# outcome of a command. +command_ok_ () +{ + tap_directive_= tap_reason_= + test $# -gt 0 || bailout_ "command_ok_: missing argument" + tap_description_=$1; shift + while test $# -gt 0; do + case $1 in + -D|--directive) tap_directive_=$2; shift;; + -r|--reason) tap_reason_=$2; shift;; + --) shift; break;; + -*) bailout_ "command_ok_: invalid option '$1'";; + *) break;; + esac + shift + done + tap_result_="ok"; "$@" || tap_result_="not ok" + result_ "$tap_result_" -D "$tap_directive_" -r "$tap_reason_" \ + -- "$tap_description_" +} + +: diff --git a/t/ax/tap-setup.sh b/t/ax/tap-setup.sh new file mode 100644 index 000000000..64580c4cf --- /dev/null +++ b/t/ax/tap-setup.sh @@ -0,0 +1,47 @@ +#! /bin/sh +# Copyright (C) 2011-2017 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 <https://www.gnu.org/licenses/>. + +# Auxiliary shell script that copies the common data and files used by +# many tests on TAP support into the current directory. It should be +# sourced by client test scripts, and assumes the auxiliary test +# 'tap-common-setup.test' has been run beforehand (it will error out +# if this is not the case). + +# Check that we are running from a proper directory: last thing we want +# is to overwrite some random user files. +test -f ../../bin/automake && test -f ../../runtest && test -d ../../t \ + || fatal_ "running from a wrong directory" + +test ! -f Makefile.am || mv Makefile.am Makefile.am~ \ + || fatal_ "failed to save Makefile.am" + +test -d ../tap-common-setup.dir && cp -fpR ../tap-common-setup.dir/* . \ + || fatal_ "couldn't get precomputed data files" + +fetch_tap_driver + +if test -f Makefile.am~; then + mv -f Makefile.am~ Makefile.am \ + || fatal_ "failed to restore Makefile.am" + echo 'TEST_LOG_DRIVER = $(srcdir)/tap-driver' >> Makefile.am \ + || fatal_ "failed to update Makefile.am" + $AUTOMAKE Makefile \ + || fatal_ "failed to remake Makefile.in" + ./config.status Makefile \ + || fatal_ "failed to remake Makefile" +fi + +: diff --git a/t/ax/tap-summary-aux.sh b/t/ax/tap-summary-aux.sh new file mode 100644 index 000000000..f0c31aa63 --- /dev/null +++ b/t/ax/tap-summary-aux.sh @@ -0,0 +1,357 @@ +#! /bin/sh +# Copyright (C) 2011-2017 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 <https://www.gnu.org/licenses/>. + +# Auxiliary script for tests on TAP support: checking testsuite summary. + +. test-init.sh + +br='============================================================================' + +case $use_colors in + yes|no) ;; + *) fatal_ "invalid \$use_colors value '$use_colors'" +esac + +fetch_tap_driver + +cat > configure.ac <<END +AC_INIT([GNU AutoTAP], [5.12], [bug-automake@gnu.org]) +AM_INIT_AUTOMAKE +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT +END + +cat > Makefile.am << 'END' +TEST_LOG_DRIVER = $(srcdir)/tap-driver +TEST_LOG_COMPILER = cat +TESTS = all.test +END + +# The following shell variables are influential for this function: +# - expect_failure +# - use_colors +do_check () +{ + case $#,$1 in + 1,--pass) expect_failure=no;; + 1,--fail) expect_failure=yes;; + *) fatal_ "invalid usage of 'do_check'";; + esac + shift + cat > summary.exp + cat all.test + if test $use_colors = yes; then + # Forced colorization should take place also with non-ANSI terminals; + # hence the "TERM=dumb" definition. + make_args='TERM=dumb AM_COLOR_TESTS=always' + else + make_args= + fi + run_make -O -e IGNORE $make_args check + if test $expect_failure = yes; then + test $am_make_rc -gt 0 || exit 1 + else + test $am_make_rc -eq 0 || exit 1 + fi + $PERL "$am_testaux_srcdir"/extract-testsuite-summary.pl stdout >summary.got \ + || fatal_ "cannot extract testsuite summary" + cat summary.exp + cat summary.got + if test $use_colors = yes; then + # Use cmp, not diff, because the files might contain binary data. + compare=cmp + else + compare=diff + fi + $compare summary.exp summary.got || exit 1 +} + +if test $use_colors = yes; then + red="$esc[0;31m" + grn="$esc[0;32m" + lgn="$esc[1;32m" + blu="$esc[1;34m" + mgn="$esc[0;35m" + brg="$esc[1m" + std="$esc[m" +else + red= grn= lgn= blu= mgn= brg= std= +fi + + success_header="\ +${grn}${br}${std} +${grn}Testsuite summary for GNU AutoTAP 5.12${std} +${grn}${br}${std}" + + success_footer=${grn}${br}${std} + + failure_header="\ +${red}${br}${std} +${red}Testsuite summary for GNU AutoTAP 5.12${std} +${red}${br}${std}" + + failure_footer="\ +${red}${br}${std} +${red}See ./test-suite.log${std} +${red}Please report to bug-automake@gnu.org${std} +${red}${br}${std}" + +$ACLOCAL +$AUTOCONF +$AUTOMAKE --add-missing + +./configure + +# 1 pass. +{ echo 1..1 && echo ok; } > all.test +do_check --pass <<END +$success_header +${brg}# TOTAL: 1${std} +${grn}# PASS: 1${std} +# SKIP: 0 +# XFAIL: 0 +# FAIL: 0 +# XPASS: 0 +# ERROR: 0 +$success_footer +END + +# 1 skip. +{ echo 1..1 && echo 'ok # SKIP'; } > all.test +do_check --pass <<END +$success_header +${brg}# TOTAL: 1${std} +# PASS: 0 +${blu}# SKIP: 1${std} +# XFAIL: 0 +# FAIL: 0 +# XPASS: 0 +# ERROR: 0 +$success_footer +END + +# 1 xfail. +{ echo 1..1 && echo 'not ok # TODO'; } > all.test +do_check --pass <<END +$success_header +${brg}# TOTAL: 1${std} +# PASS: 0 +# SKIP: 0 +${lgn}# XFAIL: 1${std} +# FAIL: 0 +# XPASS: 0 +# ERROR: 0 +$success_footer +END + +# 1 fail. +{ echo 1..1 && echo not ok; } > all.test +do_check --fail <<END +$failure_header +${brg}# TOTAL: 1${std} +# PASS: 0 +# SKIP: 0 +# XFAIL: 0 +${red}# FAIL: 1${std} +# XPASS: 0 +# ERROR: 0 +$failure_footer +END + +# 1 xpass. +{ echo 1..1 && echo 'ok # TODO'; } > all.test +do_check --fail <<END +$failure_header +${brg}# TOTAL: 1${std} +# PASS: 0 +# SKIP: 0 +# XFAIL: 0 +# FAIL: 0 +${red}# XPASS: 1${std} +# ERROR: 0 +$failure_footer +END + +# 1 hard error. +{ echo 1..1 && echo 'Bail out!'; } > all.test +do_check --fail <<END +$failure_header +${brg}# TOTAL: 1${std} +# PASS: 0 +# SKIP: 0 +# XFAIL: 0 +# FAIL: 0 +# XPASS: 0 +${mgn}# ERROR: 1${std} +$failure_footer +END + +# 3 non-failing results. +cat > all.test <<END +1..3 +ok +not ok # TODO +ok # SKIP +END +do_check --pass <<END +$success_header +${brg}# TOTAL: 3${std} +${grn}# PASS: 1${std} +${blu}# SKIP: 1${std} +${lgn}# XFAIL: 1${std} +# FAIL: 0 +# XPASS: 0 +# ERROR: 0 +$success_footer +END + +# 1 pass, 1 skip, 1 fail. +cat > all.test <<END +1..3 +ok +ok # SKIP +not ok +END +do_check --fail <<END +$failure_header +${brg}# TOTAL: 3${std} +${grn}# PASS: 1${std} +${blu}# SKIP: 1${std} +# XFAIL: 0 +${red}# FAIL: 1${std} +# XPASS: 0 +# ERROR: 0 +$failure_footer +END + +# 1 pass, 1 xfail, 1 xpass. +cat > all.test <<END +1..3 +ok +ok # TODO +not ok # TODO +END +do_check --fail <<END +$failure_header +${brg}# TOTAL: 3${std} +${grn}# PASS: 1${std} +# SKIP: 0 +${lgn}# XFAIL: 1${std} +# FAIL: 0 +${red}# XPASS: 1${std} +# ERROR: 0 +$failure_footer +END + +# 1 skip, 1 xfail, 1 error. +cat > all.test <<END +1..3 +ok # SKIP +not ok # TODO +Bail out! +END +do_check --fail <<END +$failure_header +${brg}# TOTAL: 3${std} +# PASS: 0 +${blu}# SKIP: 1${std} +${lgn}# XFAIL: 1${std} +# FAIL: 0 +# XPASS: 0 +${mgn}# ERROR: 1${std} +$failure_footer +END + +# 1 of each kind +cat > all.test <<END +1..6 +ok +not ok +ok # TODO +not ok # TODO +ok # SKIP +Bail out! +END +do_check --fail <<END +$failure_header +${brg}# TOTAL: 6${std} +${grn}# PASS: 1${std} +${blu}# SKIP: 1${std} +${lgn}# XFAIL: 1${std} +${red}# FAIL: 1${std} +${red}# XPASS: 1${std} +${mgn}# ERROR: 1${std} +$failure_footer +END + +# Prepare some common data for later. +for i in 0 1 2 3 4 5 6 7 8 9; do + for j in 0 1 2 3 4 5 6 7 8 9; do + echo "ok" + echo "not ok # TODO" + echo "ok # SKIP" + done +done > tap + +# Lots of non-failures (300 per kind). +(cat tap && cat tap && cat tap) > all.test +test $(wc -l <all.test) -eq 900 || exit 99 # Sanity check. +echo 1..900 >> all.test # Test plan. +do_check --pass <<END +$success_header +${brg}# TOTAL: 900${std} +${grn}# PASS: 300${std} +${blu}# SKIP: 300${std} +${lgn}# XFAIL: 300${std} +# FAIL: 0 +# XPASS: 0 +# ERROR: 0 +$success_footer +END + +# 1 failure and lots of non-failures means failure. +(cat tap && echo "not ok" && cat tap) > all.test +test $(wc -l <all.test) -eq 601 || exit 99 # Sanity check. +echo 1..601 >> all.test # Test plan. +do_check --fail <<END +$failure_header +${brg}# TOTAL: 601${std} +${grn}# PASS: 200${std} +${blu}# SKIP: 200${std} +${lgn}# XFAIL: 200${std} +${red}# FAIL: 1${std} +# XPASS: 0 +# ERROR: 0 +$failure_footer +END + +# 1 error and lots of non-failures means failure. +(cat tap && sed 30q tap && echo 'Bail out!') > all.test +test $(wc -l <all.test) -eq 331 || exit 99 # Sanity check. +echo 1..331 >> all.test # Test plan. +do_check --fail <<END +$failure_header +${brg}# TOTAL: 331${std} +${grn}# PASS: 110${std} +${blu}# SKIP: 110${std} +${lgn}# XFAIL: 110${std} +# FAIL: 0 +# XPASS: 0 +${mgn}# ERROR: 1${std} +$failure_footer +END + +: diff --git a/t/ax/test-defs.in b/t/ax/test-defs.in new file mode 100644 index 000000000..04d952133 --- /dev/null +++ b/t/ax/test-defs.in @@ -0,0 +1,201 @@ +# -*- shell-script -*- +# @configure_input@ +# +# Copyright (C) 1996-2017 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 <https://www.gnu.org/licenses/>. + +# Defines and minimal setup for Automake testing environment. + +# IMPORTANT NOTES AND REQUIREMENTS +# - Multiple inclusions of this file should be idempotent. +# - This code has to be 'set -e' clean. + +# See whether the current test script is expected to use TAP or not. +# Use a sensible default, while allowing the scripts to override this +# check. +if test -z "$am_test_protocol"; then + case $argv0 in + *.tap) am_test_protocol=tap;; + *) am_test_protocol=none;; + esac +fi + +am_rel_srcdir='@srcdir@' +am_top_srcdir='@abs_srcdir@' +am_top_builddir='@abs_builddir@' + +# Where testsuite-related helper scripts, data files and shell libraries +# are placed. +am_testaux_srcdir=$am_top_srcdir/t/ax +am_testaux_builddir=$am_top_builddir/t/ax + +# Support for the "installcheck" target. +case ${am_running_installcheck:=no} in + yes) + am_amdir='@amdir@' + am_automake_acdir='@automake_acdir@' + am_bindir='@bindir@' + am_datadir='@datadir@' + am_docdir='@docdir@' + am_pkgvdatadir='@pkgvdatadir@' + am_scriptdir='@scriptdir@' + am_system_acdir='@system_acdir@' + ;; + no) + am_amdir=$am_top_srcdir/lib/am + am_automake_acdir="" + am_bindir=$am_top_builddir/bin + am_datadir=$am_top_srcdir + am_docdir=$am_top_srcdir/doc + am_pkgvdatadir=$am_top_srcdir/lib + am_scriptdir=$am_top_srcdir/lib + am_system_acdir="" + ;; + *) + echo "$me: variable 'am_running_installcheck' has invalid" + "value '$am_running_installcheck'" >&2 + exit 99 + ;; +esac + +APIVERSION='@APIVERSION@' +PATH_SEPARATOR='@PATH_SEPARATOR@' + +host_alias=${host_alias-'@host_alias@'}; export host_alias +build_alias=${build_alias-'@build_alias@'}; export build_alias + +# Whether the testsuite is being run by faking the presence of a C +# compiler that doesn't grasp the '-c' and '-o' flags together. By +# default, of course, it isn't. +: "${AM_TESTSUITE_SIMULATING_NO_CC_C_O:=no}" + +# A concurrency-safe "mkdir -p" implementation. +MKDIR_P=${AM_TESTSUITE_MKDIR_P-'@MKDIR_P@'} + +# The shell we use to run our own test scripts, determined at configure +# time. It is required in the self tests, and most importantly for the +# automatic re-execution of test scripts. +AM_TEST_RUNNER_SHELL=${AM_TEST_RUNNER_SHELL-'@AM_TEST_RUNNER_SHELL@'} + +# Make sure we override the user shell. And do not read the value of +# $SHELL from the environment (think to the non-uncommon situation where +# e.g., $SHELL=/bin/tcsh). +SHELL=${AM_TESTSUITE_SHELL-'@SHELL@'}; export SHELL + +# User can override various tools used. Prefer overriding specific for +# that automake testsuite, if they are available. +AWK=${AM_TESTSUITE_AWK-${AWK-'@AWK@'}} +PERL=${AM_TESTSUITE_PERL-${PERL-'@PERL@'}} +MAKE=${AM_TESTSUITE_MAKE-${MAKE-'make'}} +YACC=${AM_TESTSUITE_YACC-${YACC-'@YACC@'}} +LEX=${AM_TESTSUITE_LEX-${LEX-'@LEX@'}} +AUTOCONF=${AM_TESTSUITE_AUTOCONF-${AUTOCONF-'@am_AUTOCONF@'}} +AUTOM4TE=${AM_TESTSUITE_AUTOM4TE-${AUTOM4TE-'@am_AUTOM4TE@'}} +AUTORECONF=${AM_TESTSUITE_AUTORECONF-${AUTORECONF-'@am_AUTORECONF@'}} +AUTOHEADER=${AM_TESTSUITE_AUTOHEADER-${AUTOHEADER-'@am_AUTOHEADER@'}} +AUTOUPDATE=${AM_TESTSUITE_AUTOUPDATE-${AUTOUPDATE-'@am_AUTOUPDATE@'}} + +# Tests which want complete control over aclocal or automake command-line +# options should use $am_original_ACLOCAL or $am_original_AUTOMAKE. The +# "test -z" tests take care not to re-initialize them if 'test-defs.sh' +# is re-sourced, as we want that file to remain really idempotent. +if test -z "$am_original_AUTOMAKE"; then + am_original_AUTOMAKE=${AM_TESTSUITE_AUTOMAKE-${AUTOMAKE-"automake-$APIVERSION"}} +fi +if test -z "$am_original_ACLOCAL"; then + am_original_ACLOCAL=${AM_TESTSUITE_ACLOCAL-${ACLOCAL-"aclocal-$APIVERSION"}} +fi + +# Use -Werror by default. Tests for which this is inappropriate should +# use -Wno-error. +# Tests which want complete control over aclocal command-line options +# should use $am_original_ACLOCAL instead. +ACLOCAL="$am_original_ACLOCAL -Werror" + +# 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. +# Tests who want complete control over automake command-line options +# should use $am_original_AUTOMAKE instead. +AUTOMAKE="$am_original_AUTOMAKE --foreign -Werror -Wall" + +# POSIX no longer requires 'egrep' and 'fgrep', +# but some hosts lack 'grep -E' and 'grep -F'. +EGREP=${AM_TESTSUITE_EGREP-'@EGREP@'} +FGREP=${AM_TESTSUITE_FGREP-'@FGREP@'} + +# Compilers and their flags. These can point to non-GNU compilers (and +# on non-Linux and non-BSD systems, they probably will). +if test $AM_TESTSUITE_SIMULATING_NO_CC_C_O = no; then + CC=${AM_TESTSUITE_CC-${CC-'@CC@'}} +else + CC=$am_testaux_builddir/cc-no-c-o +fi +CXX=${AM_TESTSUITE_CXX-${CXX-'@CXX@'}} +F77=${AM_TESTSUITE_F77-${F77-'@F77@'}} +FC=${AM_TESTSUITE_FC-${FC-'@FC@'}} +CFLAGS=${AM_TESTSUITE_CFLAGS-${CFLAGS-'@CFLAGS@'}} +CXXFLAGS=${AM_TESTSUITE_CXXFLAGS-${CXXFLAGS-'@CXXFLAGS@'}} +FCFLAGS=${AM_TESTSUITE_FCFLAGS-${FCFLAGS-'@FCFLAGS@'}} +FFLAGS=${AM_TESTSUITE_FFLAGS-${FFLAGS-'@FFLAGS@'}} +CPPFLAGS=${AM_TESTSUITE_CPPFLAGS-${CPPFLAGS-'@CPPFLAGS@'}} + +# GNU compilers and their flags. +if test $AM_TESTSUITE_SIMULATING_NO_CC_C_O = no; then + GNU_CC=${AM_TESTSUITE_GNU_CC-${GNU_CC-'@GNU_CC@'}} +else + GNU_CC=$am_testaux_builddir/cc-no-c-o +fi +GNU_CC=${AM_TESTSUITE_GNU_CC-${GNU_CC-'@GNU_CC@'}} +GNU_CXX=${AM_TESTSUITE_GNU_CXX-${GNU_CXX-'@GNU_CXX@'}} +GNU_F77=${AM_TESTSUITE_GNU_F77-${GNU_F77-'@GNU_F77@'}} +GNU_FC=${AM_TESTSUITE_GNU_FC-${GNU_FC-'@GNU_FC@'}} +GNU_FFLAGS=${AM_TESTSUITE_GNU_FFLAGS-${GNU_FFLAGS-'@GNU_FFLAGS@'}} +GNU_FCFLAGS=${AM_TESTSUITE_GNU_FCFLAGS-${GNU_FCFLAGS-'@GNU_FCFLAGS@'}} +GNU_CXXFLAGS=${AM_TESTSUITE_GNU_CXXFLAGS-${GNU_CXXFLAGS-'@GNU_CXXFLAGS@'}} +GNU_CFLAGS=${AM_TESTSUITE_GNU_CFLAGS-${GNU_CFLAGS-'@GNU_CFLAGS@'}} +GNU_GCJ=${AM_TESTSUITE_GNU_GCJ-${GNU_GCJ-'@GNU_GCJ@'}} +GNU_GCJFLAGS=${AM_TESTSUITE_GNU_GCJFLAGS-${GNU_GCJFLAGS-'@GNU_GCJFLAGS@'}} + +# No all versions of Tex support '--version', so we use a configure +# check to decide if tex is available. This decision is embodied in +# this variable. +TEX=${AM_TESTSUITE_TEX-'@TEX@'} + +# The amount we should wait after modifying files depends on the platform. +# For instance, Windows '95, '98 and ME have 2-second granularity +# and can be up to 3 seconds in the future w.r.t. the system clock. +# The creative quoting is to avoid spuriously triggering a failure in +# the maintainer checks, +sleep='sleep ''@MODIFICATION_DELAY@' + +# An old timestamp that can be given to a file, in "touch -t" format. +# The time stamp should be portable to all file systems of interest. +# Just for fun, choose the exact time of the announcement of the GNU project +# in UTC; see <https://www.gnu.org/gnu/initial-announcement.html>. +old_timestamp=198309271735.59 + +# Make our wrapper script (or installed scripts, if running under +# "installcheck") accessible by default. And avoid to uselessly +# extend $PATH multiple times if this file is sourced multiple times. +case $PATH in + $am_bindir$PATH_SEPARATOR*) ;; + *) PATH=$am_bindir$PATH_SEPARATOR$PATH;; +esac + +export PATH diff --git a/t/ax/test-init.sh b/t/ax/test-init.sh new file mode 100644 index 000000000..4311fb7c9 --- /dev/null +++ b/t/ax/test-init.sh @@ -0,0 +1,29 @@ +# -*- shell-script -*- +# +# Copyright (C) 1996-2017 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 <https://www.gnu.org/licenses/>. + +set -e + +# The variable '$required' should no longer be modified after this +# file gets sources. +required=${required-}; readonly required + +# Source the actual code for test initialization and setup. +. test-lib.sh +. am-test-lib.sh + +# Run that setup, and return control to the test script sourcing us. +am_test_setup diff --git a/t/ax/test-lib.sh b/t/ax/test-lib.sh new file mode 100644 index 000000000..5882ef052 --- /dev/null +++ b/t/ax/test-lib.sh @@ -0,0 +1,317 @@ +# -*- shell-script -*- +# +# Copyright (C) 1996-2017 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 <https://www.gnu.org/licenses/>. + +######################################################## +### IMPORTANT NOTE: keep this file 'set -e' clean. ### +######################################################## + +# Do not source several times. +test ${test_lib_sourced-no} = yes && return 0 +test_lib_sourced=yes + +# CDPATH is evil if used in non-interactive scripts (and even more +# evil if exported in the environment). +CDPATH=; unset CDPATH + +# Be more Bourne compatible. +# (Snippet inspired to configure's initialization in Autoconf 2.64) +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + setopt NO_GLOB_SUBST + # If Zsh is not started directly in POSIX-compatibility mode, it has some + # incompatibilities in the handling of $0 that conflict with our usage; + # i.e., $0 inside a file sourced with the '.' builtin is temporarily set + # to the name of the sourced file. Work around that. + # Note that a bug in some versions of Zsh prevents us from resetting $0 + # in a sourced script, so the use of $argv0. For more info see: + # <http://www.zsh.org/mla/workers/2009/msg01140.html> + # The apparently useless 'eval' here is needed by at least dash 0.5.2, + # to prevent it from bailing out with an error like: + # "Syntax error: Bad substitution". + eval 'argv0=${functrace[-1]%:*}' && test -f "$argv0" || { + echo "Cannot determine the path of running test script." >&2 + echo "Your Zsh (version $ZSH_VERSION) is probably too old." >&2 + exit 99 + } +else + argv0=$0 + # Ignore command substitution failure, for it might cause problems + # with "set -e" on some shells. + am_shell_opts=$(set -o) || : + case $am_shell_opts in *posix*) set -o posix;; esac + unset am_shell_opts +fi + +# 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 + +# The name of the current test (without the '.sh' or '.tap' suffix). +me=${argv0##*/} # Strip all directory components. +case $me in # Strip test suffix. + *.tap) me=${me%.tap};; + *.sh) me=${me%.sh} ;; + esac + +# Source extra package-specific configuration. +. test-defs.sh +# And fail hard if something went wrong. +test $? -eq 0 || exit 99 + +# We use a trap below for cleanup. This requires us to go through +# hoops to get the right exit status transported through the signal. +# Turn off errexit here so that we don't trip the bug with OSF1/Tru64 +# sh inside this function (FIXME: is this still relevant now that we +# require a POSIX shell?). +_am_exit () +{ + set +e + # See comments in the exit trap for the reason we do this. + test 77 = $1 && am__test_skipped=yes + # Extra escaping to ensure we do not call our 'exit' alias. + (\exit $1); \exit $1 +} +# Avoid interferences from the environment +am__test_skipped=no +# This alias must actually be placed before any use if 'exit' -- even +# just inside a function definition. Weird, but real. +alias exit=_am_exit + +# 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. This function and the alias below help +# to work around the issue. But be sure to use them only if actually +# needed. The repeated unset in the check below cater to the very +# unlikely case where the '_am_v' variable is set in the environment. +if unset _am_v && unset _am_v; then + : Nothing needs to be done. +else + _am_unset () + { + for _am_v + do + # Extra escaping (here and below) to ensure we do not call our + # 'unset' alias. + eval ${_am_v}=dummy && \unset ${_am_v} || return 1 + done + \unset _am_v + } + alias unset=_am_unset +fi + +## ------------------------------------ ## +## General testsuite shell functions. ## +## ------------------------------------ ## + +# Print warnings (e.g., about skipped and failed tests) to this file +# number. Override by putting, say: +# AM_TESTS_ENVIRONMENT = stderr_fileno_=9; export stderr_fileno_; +# AM_TESTS_FD_REDIRECT = 9>&2 +# in your Makefile.am. +# 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} + +# Helper functions used by "plain" tests of the Automake testsuite +# (i.e., tests that don't use any test protocol). +# TAP tests will override these functions with their TAP-enhanced +# equivalents later (see sourcing of 'tap-functions.sh' below). +# These are 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; } +# For compatibility with TAP functions. +skip_all_ () { skip_ "$@"; } + +if test $am_test_protocol = tap; then + . tap-functions.sh +fi + +## ---------------------------- ## +## Auxiliary shell functions. ## +## ---------------------------- ## + +# Tell whether we should keep the test directories around, even in +# case of success. By default, we don't. +am_keeping_testdirs () +{ + case $keep_testdirs in + ""|n|no|NO) return 1;; + *) return 0;; + esac +} + +# seq_ - print a sequence of numbers +# ---------------------------------- +# This function simulates GNU seq(1) portably. Valid usages: +# - seq LAST +# - seq FIRST LAST +# - seq FIRST INCREMENT LAST +seq_ () +{ + case $# in + 0) fatal_ "seq_: missing argument";; + 1) seq_first=1 seq_incr=1 seq_last=$1;; + 2) seq_first=$1 seq_incr=1 seq_last=$2;; + 3) seq_first=$1 seq_incr=$2 seq_last=$3;; + *) fatal_ "seq_: too many arguments";; + esac + i=$seq_first + while test $i -le $seq_last; do + echo $i + i=$(($i + $seq_incr)) + done +} + +# rm_rf_ [FILES OR DIRECTORIES ...] +# --------------------------------- +# Recursively remove the given files or directory, also handling the case +# of non-writable subdirectories. +rm_rf_ () +{ + test $# -gt 0 || return 0 + $PERL "$am_testaux_srcdir"/deltree.pl "$@" +} + +commented_sed_unindent_prog=' + /^$/b # Nothing to do for empty lines. + x # Get x<indent> into pattern space. + /^$/{ # No prior x<indent>, go prepare it. + g # Copy this 1st non-blank line into pattern space. + s/^\(['"$tab"' ]*\).*/x\1/ # Prepare x<indent> in pattern space. + } # Now: x<indent> in pattern and <line> in hold. + G # Build x<indent>\n<line> in pattern space, and + h # duplicate it into hold space. + s/\n.*$// # Restore x<indent> in pattern space, and + x # exchange with the above duplicate in hold space. + s/^x\(.*\)\n\1// # Remove leading <indent> from <line>. + s/^x.*\n// # Restore <line> when there is no leading <indent>. +' + +# 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. + +## ---------------------------------------------------------------- ## +## Create and set up of the temporary directory used by the test. ## +## Set up of the exit trap for cleanup of said directory. ## +## ---------------------------------------------------------------- ## + +# Set up the exit trap. +am_exit_trap () +{ + exit_status=$1 + set +e + cd "$am_top_builddir" + if test $am_test_protocol = tap; then + if test "$planned_" = later && test $exit_status -eq 0; then + plan_ "now" + fi + test $exit_status -eq 0 && test $tap_pass_count_ -eq $tap_count_ \ + || keep_testdirs=yes + else + # 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 + echo "$me: implicit skip turned into failure" + exit_status=78 + fi;; + esac + test $exit_status -eq 0 || keep_testdirs=yes + fi + am_keeping_testdirs || rm_rf_ $am_test_subdir + set +x + # Spurious escaping to ensure we do not call our "exit" alias. + \exit $exit_status +} + +am_set_exit_traps () +{ + trap 'am_exit_trap $?' 0 + trap "fatal_ 'caught signal SIGHUP'" 1 + trap "fatal_ 'caught signal SIGINT'" 2 + trap "fatal_ 'caught signal SIGTERM'" 15 + # Various shells seems to just ignore SIGQUIT under some circumstances, + # even if the signal is not blocked; however, if the signal is trapped, + # the trap gets correctly executed. So we also trap SIGQUIT. + # Here is a list of some shells that have been verified to exhibit the + # problematic behavior with SIGQUIT: + # - zsh 4.3.12 on Debian GNU/Linux + # - /bin/ksh and /usr/xpg4/bin/sh on Solaris 10 + # - Bash 3.2.51 on Solaris 10 and bash 4.1.5 on Debian GNU/Linux + # - AT&T ksh on Debian Gnu/Linux (deb package ksh, version 93u-1) + # OTOH, at least these shells that do *not* exhibit that behaviour: + # - modern version of the Almquist Shell (at least 0.5.5.1), on + # both Solaris and GNU/Linux + # - public domain Korn Shell, version 5.2.14, on Debian GNU/Linux + trap "fatal_ 'caught signal SIGQUIT'" 3 + # Ignore further SIGPIPE in the trap code. This is required to avoid + # a very weird issue with some shells, at least when the execution of + # the automake testsuite is driven by the 'prove' utility: if prove + # (or the make process that has spawned it) gets interrupted with + # Ctrl-C, the shell might go in a loop, continually getting a SIGPIPE, + # sometimes finally dumping core, other times hanging indefinitely. + # See also Test::Harness bug [rt.cpan.org #70855], archived at + # <https://rt.cpan.org/Ticket/Display.html?id=70855> + trap "trap '' 13; fatal_ 'caught signal SIGPIPE'" 13 +} + +am_test_setup () +{ + process_requirements $required + am_set_exit_traps + # Create and populate the temporary directory, if required. + if test x"$am_create_testdir" = x"no"; then + am_test_subdir= + else + am_setup_testdir + fi + am_extra_info + set -x + pwd +} diff --git a/t/ax/testsuite-summary-checks.sh b/t/ax/testsuite-summary-checks.sh new file mode 100644 index 000000000..0078d1ccf --- /dev/null +++ b/t/ax/testsuite-summary-checks.sh @@ -0,0 +1,102 @@ +#! /bin/sh +# Copyright (C) 2011-2017 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 <https://www.gnu.org/licenses/>. + +# Check the testsuite summary with the parallel test harness. This +# script is meant to be sourced by other test script, so that it can +# be used to check different scenarios (colorized and non-colorized +# testsuite output, packages with and without bug-report addresses, +# testsuites in subdirectories, ...) + +. test-init.sh + +case $use_colors in + yes) + AM_COLOR_TESTS=always; export AM_COLOR_TESTS + # Forced colorization should take place also with non-ANSI + # terminals; hence this setting. + TERM=dumb; export TERM + ;; + no) + ;; + *) + fatal_ "invalid use_colors='$use_colors'";; +esac + +cat > configure.ac <<END +AC_INIT([GNU AutoFoo], [7.1], [bug-automake@gnu.org]) +AM_INIT_AUTOMAKE +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT +END + +cat > Makefile.am <<'END' +TEST_EXTENSIONS = .t +T_LOG_COMPILER = $(SHELL) $(srcdir)/log-compiler +## Will be defined at runtime. +TESTS = +$(TESTS): +END + +cat > log-compiler <<'END' +#!/bin/sh +case "$1" in + pass*|*/pass*|xpass*|*/xpass*) exit 0;; + fail*|*/fail*|xfail*|*/xfail*) exit 1;; + skip*|*/skip*) exit 77;; + error*|/error*) exit 99;; + copy*|*/copy*) cat "$1";; + *) exit 99;; +esac +END + +# Quite complexish, but allow the tests in client scripts to be written +# in a "data-driven fashion". +do_check () +{ + cat > summary.exp + expect_failure=false + xfail_tests='' + tests="$*" + for t in $*; do + case $t in fail*|xpass*|error*) expect_failure=:;; esac + case $t in xfail*|xpass*) xfail_tests="$xfail_tests $t";; esac + done + run_make -O -e IGNORE check TESTS="$tests" XFAIL_TESTS="$xfail_tests" + if $expect_failure; then + test $am_make_rc -gt 0 || exit 1 + else + test $am_make_rc -eq 0 || exit 1 + fi + $PERL "$am_testaux_srcdir"/extract-testsuite-summary.pl stdout >summary.got \ + || fatal_ "cannot extract testsuite summary" + cat summary.exp + cat summary.got + if test $use_colors = yes; then + # Use cmp, not diff, because the files might contain binary data. + compare=cmp + else + compare=diff + fi + $compare summary.exp summary.got || exit 1 +} + +br='============================================================================' + +$ACLOCAL +$AUTOCONF +$AUTOMAKE --add-missing + +: diff --git a/t/ax/trivial-test-driver b/t/ax/trivial-test-driver new file mode 100644 index 000000000..5745fe3d9 --- /dev/null +++ b/t/ax/trivial-test-driver @@ -0,0 +1,102 @@ +#! /bin/sh +# Copyright (C) 2011-2017 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 <https://www.gnu.org/licenses/>. + +# +# Test driver for a very simple test protocol used by the Automake +# testsuite to check support for custom test drivers allowing for more +# test results per test script. +# +# The exit status of the wrapped script is ignored. Lines in its stdout +# and stderr beginning with 'PASS', 'FAIL', 'XFAIL', 'XPASS', 'SKIP' or +# 'ERROR' count as a test case result with the obviously-corresponding +# outcome. Every other line is ignored for what concerns the testsuite +# outcome. +# +# This script is used at least by the 'driver-custom-multitest*.test' +# tests. +# + +# Help to avoid typo-related bugs. +set -u + +## Option parsing. + +test_name=INVALID.NAME +log_file=BAD.LOG +trs_file=BAD.TRS +while test $# -gt 0; do + case $1 in + --test-name) test_name=$2; shift;; + --log-file) log_file=$2; shift;; + --trs-file) trs_file=$2; shift;; + # Ignored. + --expect-failure) shift;; + --color-tests) shift;; + --enable-hard-errors) shift;; + # Explicitly terminate option list. + --) shift; break;; + # Shouldn't happen + *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;; + esac + shift +done + +## Log file header. +{ + echo "RUN: $test_name" + echo "RUN: $test_name" | sed 's/./=/g' + echo +} > $log_file + +## Run the test script, get test cases results, display them on console. + +"$@" 2>&1 | tee -a $log_file | ( + i=0 st=0 + exec 5> $trs_file + while read line; do + result= + case $line in + PASS:*) result=PASS ;; + FAIL:*) result=FAIL ;; + XPASS:*) result=XPASS ;; + XFAIL:*) result=XFAIL ;; + SKIP:*) result=SKIP ;; + ERROR:*) result=ERROR ;; + esac + if test -n "$result"; then + case $result in FAIL|XPASS|ERROR) st=1;; esac + # Output testcase result to console. + echo "$result: $test_name" + # Register testcase outcome for the log file. + echo ":test-result: $line" >&5 + echo >&5 + fi + done + if test $st -eq 0; then + recheck=no + copy_in_global_log=no + else + recheck=yes + copy_in_global_log=yes + fi + echo ":recheck: $recheck" >&5 + echo ":copy-in-global-log: $copy_in_global_log" >&5 + exec 5>&- +) | awk '{ print $0 ", testcase " NR }' + +## And we're done. + +exit 0 |