4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 # 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # Defines for Automake testing environment.
21 # Tom Tromey <tromey@cygnus.com>
23 # Absolutely necessary variable(s).
24 srcdir=${srcdir-'@abs_srcdir@'}
26 # Protect this file against multiple inclusion, useful for generated tests.
27 if test x"$am_skip_defs" = xyes; then
30 else # Do proper testcase setup.
32 # Be more Bourne compatible.
33 # (Snippet copied from configure's initialization in Autoconf 2.64)
34 DUALCASE=1; export DUALCASE # for MKS sh
35 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
38 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
39 # is contrary to our usage. Disable this feature.
40 alias -g '${1+"$@"}'='"$@"'
43 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
46 # Ensure we are running from the right directory.
48 echo "defs: not found in current directory" 1>&2
52 # Ensure $srcdir is set correctly.
53 test -f "$srcdir/defs.in" || {
54 echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
58 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
60 # Make sure we override the user shell.
63 # User can override various tools used.
64 test -z "$PERL" && PERL='@PERL@'
65 test -z "$MAKE" && MAKE=make
66 test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
67 test -z "$AUTOHEADER" && AUTOHEADER="@am_AUTOHEADER@"
68 test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
69 test -z "$MISSING" && MISSING=`pwd`/../lib/missing
70 # Use -Werror because this also turns some Perl warnings into error.
71 # (Tests for which this is inappropriate should use -Wno-error.)
72 test -z "$ACLOCAL" && ACLOCAL="aclocal-@APIVERSION@ -Werror"
73 # Extra flags to pass to aclocal before all other flags added by this script.
74 ACLOCAL_TESTSUITE_FLAGS=
75 export ACLOCAL_TESTSUITE_FLAGS
77 # See how Automake should be run. We put --foreign as the default
78 # strictness to avoid having to create lots and lots of files. A test
79 # can override this by specifying a different strictness. Use -Wall
80 # -Werror by default. Tests for which this is inappropriate
81 # (e.g. when testing that a warning is enabled by a specific switch)
82 # should use -Wnone or/and -Wno-error
83 test -z "$AUTOMAKE" && AUTOMAKE="automake-@APIVERSION@ --foreign -Werror -Wall"
85 PATH="`pwd`@PATH_SEPARATOR@$PATH"
87 # Some shells forget to export modified environment variables.
88 # (See note about `export' in the Autoconf manual.)
91 for tool in : $required
93 # Check that each required tool is present.
97 # Since bison is required, we pick YACC for ./configure.
100 echo "$me: running bison --version"
101 ( bison --version ) || exit 77
104 # Do not use --version, bzip2 still tries to compress stdin.
105 echo "$me: running bzip2 --help"
106 ( bzip2 --help ) || exit 77
111 echo "$me: running $CC -?"
112 ( $CC -? ) || exit 77
115 # Exuberant Ctags will create a TAGS file even
116 # when asked for --help or --version. (Emacs's etags
117 # does not have such problem.) Use -o /dev/null
118 # to make sure we do not pollute the tests/ directory.
119 echo "$me: running etags --version -o /dev/null"
120 ( etags --version -o /dev/null ) || exit 77
123 # Use --version AND -v, because SGI Make doesn't fail on --version.
124 # Also grep for GNU because newer versions of FreeBSD make do
125 # not complain about `--version' (they seem to silently ignore it).
126 echo "$me: running $MAKE --version -v | grep GNU"
127 ( $MAKE --version -v | grep GNU ) || exit 77
130 # When gcc is required, export `CC=gcc' so that ./configure
131 # always use it. This is important only when the user
132 # has defined CC in his environment, otherwise ./configure will
133 # prefer gcc to other compilers.
136 echo "$me: running $CC --version"
137 ( $CC --version ) || exit 77
142 echo "$me: running $GCJ --version"
143 ( $GCJ --version ) || exit 77
144 ( $GCJ -v ) || exit 77
149 echo "$me: running $CXX --version"
150 ( $CXX --version ) || exit 77
155 # There is no way to ask *only* the compiler's version.
156 # This tool always wants to do something (by default
157 # it will try link *nothing* and complain it cannot find
158 # main(); funny). Use -help so it does not try linking anything.
159 echo "$me: running $CC -V -help"
160 ( $CC -V -help ) || exit 77
163 echo "$me: running makedepend -f-"
164 ( makedepend -f- ) || exit 77
167 # Make sure makeinfo understands --html.
168 echo "$me: running makeinfo --html --version"
169 ( makeinfo --html --version ) || exit 77
172 # Skip this test case if the user is root.
173 # We try to append to a read-only file to detect this.
174 priv_check_temp=priv-check.$$
175 touch $priv_check_temp || exit 1
176 chmod a-w $priv_check_temp || exit 1
177 (echo foo >> $priv_check_temp) >/dev/null 2>&1
179 rm -f $priv_check_temp
180 test $overwrite_status = 0 && exit 77
183 # Skip with Devel::Cover: it cannot cope with threads.
184 test "$WANT_NO_THREADS" = yes && exit 77
187 # Python doesn't support --version, it has -V
188 echo "$me: running python -V"
189 ( python -V ) || exit 77
192 # Skip this test case if read-only directories aren't supported
194 ro_dir_temp=ro_dir.$$
195 mkdir $ro_dir_temp || exit 1
196 chmod a-w $ro_dir_temp || exit 1
197 (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
200 test $create_status = 0 && exit 77
203 # Try the variants that are tried in check.am.
205 for r2h in $RST2HTML rst2html rst2html.py; do
206 echo "$me: running $r2h --version"
207 $r2h --version && break 2
213 # DejaGnu's runtest program. We rely on being able to specify
214 # the program on the runtest command-line. This requires
215 # DejaGnu 1.4.3 or later.
216 echo "$me: running runtest --version"
217 (runtest SOMEPROGRAM=someprogram --version) || exit 77
220 # No all versions of Tex support `--version', so we use
222 test -n "@TEX@" || exit 77
225 # Texi2dvi supports `-o' since Texinfo 4.1.
226 echo "$me: running texi2dvi -o /dev/null --version"
227 ( texi2dvi -o /dev/null --version ) || exit 77
229 # Generic case: the tool must support --version.
231 echo "$me: running $tool --version"
232 ( $tool --version ) || exit 77
238 # Always use an absolute srcdir. Otherwise symlinks made in subdirs
239 # of the test dir just won't work.
245 srcdir=`CDPATH=: && cd "$srcdir" && pwd`
249 # We use a trap below for cleanup. This requires us to go through
250 # hoops to get the right exit status transported through the signal.
251 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
252 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
253 # sh inside this function.
263 test ! -d $testSubDir || {
264 find $testSubDir -type d ! -perm -200 -exec chmod u+w {} ";"
269 sh_errexit_works=@sh_errexit_works@
270 if test "$sh_errexit_works" = yes; then
274 case $exit_status,$keep_testdirs in
276 find $testSubDir -type d ! -perm -200 -exec chmod u+w {} ";"
280 test "$signal" != 0 &&
281 echo "$me: caught signal $signal"
282 echo "$me: exit $exit_status"
285 for signal in 1 2 13 15; do
286 trap 'signal='$signal'; { Exit 1; }' $signal
291 # Copy in some files we need.
292 for file in install-sh missing depcomp; do
293 cp "$srcdir/../lib/$file" "$testSubDir/$file" || Exit 1
298 # Build appropriate environment in test directory. Eg create
299 # configure.in, touch all necessary files, etc.
300 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
301 # still produces a valid configure.ac. But then, tests running
302 # config.status really need to append AC_OUTPUT.
304 echo "AC_INIT([$me], [1.0])"
305 if test x"$parallel_tests" = x"yes"; then
306 echo "AM_INIT_AUTOMAKE([parallel-tests])"
308 echo "AM_INIT_AUTOMAKE"
310 echo "AC_CONFIG_FILES([Makefile])"
313 # Unset some MAKE... variables that may cause $MAKE to act like a
314 # recursively invoked sub-make. Any $MAKE invocation in a test is
315 # conceptually an independent invocation, not part of the main
317 unset MFLAGS MAKEFLAGS AM_MAKEFLAGS MAKELEVEL __MKLVL__ MAKE_JOBS_FIFO
318 # Unset verbosity flag.
320 # Also unset variables that will let `make -e install' divert
321 # files into unwanted directories.
323 unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
324 unset htmldir includedir infodir libdir libexecdir localedir mandir
325 unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
326 # Also unset variables that control our test driver. While not
327 # conceptually independent, they cause some changed semantics we
328 # need to control (and test for) in some of the tests to ensure
329 # backward-compatible behavior.
330 unset DISABLE_HARD_ERRORS
332 unset TEST_LOG_COMPILER
337 echo "=== Running test $0"
339 # We might need extra macros, e.g., from Libtool or Gettext.
340 # Find them on the system.
341 # Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
342 # other `-I' directories added for libtool and gettext might contain
343 # files from an old version of Automake that we don't want to use.
344 # Use `-Wno-syntax' because we do not want our test suite to fail because
345 # some third-party .m4 file is underquoted.
347 *libtool* | *gettext* )
348 aclocaldir='@prefix@/share/aclocal'
350 if test -f $aclocaldir/dirlist; then
352 <$aclocaldir/dirlist \
353 sed 's/#.*//;s/[ ][ ]*$//g' \
354 | while read dir; do test ! -d "$dir" || echo "-I $dir"; done`
359 for d in $extra_includes $aclocaldir ; do
360 test "x$d" != x-I || continue
361 if test -f "$d/libtool.m4"; then
364 if test -f "$d/gettext.m4"; then
369 *libtool* ) test $libtool_found = yes || Exit 77 ;;
370 *gettext* ) test $gettext_found = yes || Exit 77 ;;
372 # Libtool cannot cope with spaces in the build tree. Our testsuite setup
373 # cannot cope with spaces in the source tree name for Libtool and gettext
375 case $srcdir,`pwd` in
376 *\ * | *\ *) Exit 77 ;;
378 ACLOCAL="$ACLOCAL -Wno-syntax -I $srcdir/../m4 $extra_includes -I $aclocaldir"
382 testaclocaldir='@abs_top_srcdir@/m4'
384 # POSIX no longer requires 'egrep' and 'fgrep',
385 # but some hosts lack 'grep -E' and 'grep -F'.
389 # The amount we should wait after modifying files depends on the platform.
390 # For instance, Windows '95, '98 and ME have 2-second granularity
391 # and can be up to 3 seconds in the future w.r.t. the system clock.
392 sleep='sleep @MODIFICATION_DELAY@'
394 # The tests call `make -e' but we do not want $srcdir from the environment
395 # to override the definition from the Makefile.
399 # An old timestamp that can be given to a file, in "touch -t" format.
400 # The time stamp should be portable to all file systems of interest.
401 # Just for fun, choose the exact time of the announcement of the GNU project
402 # in UTC; see <http://www.gnu.org/gnu/initial-announcement.html>.
403 old_timestamp=198309271735.59
405 # is_newest FILE FILES
406 # --------------------
407 # Return false if any file in FILES is newer than FILE.
408 # Resolve ties in favor of FILE.
411 is_newest_files=`find "$@" -newer "$1"`
412 test -z "$is_newest_files"
416 # AUTOMAKE_run status [options...]
417 # --------------------------------
418 # Run Automake with OPTIONS, and fail if automake
419 # does not exit with STATUS.
425 $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$?
428 test $exitcode = $expected_exitcode || Exit 1
431 # AUTOMAKE_fails [options...]
432 # ---------------------------
433 # Run Automake with OPTIONS, and fail if automake
434 # does not exit with STATUS.
437 AUTOMAKE_run 1 ${1+"$@"}
440 # Turn on shell traces.
445 fi # Proper testcase setup.