4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 # 2005, 2006, 2007, 2008, 2009 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 # Be more Bourne compatible.
24 # (Snippet copied from configure's initialization in Autoconf 2.64)
25 DUALCASE=1; export DUALCASE # for MKS sh
26 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
29 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
30 # is contrary to our usage. Disable this feature.
31 alias -g '${1+"$@"}'='"$@"'
34 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
37 # Ensure we are running from the right directory.
39 echo "defs: not found in current directory" 1>&2
43 if test -z "$srcdir"; then
45 srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
46 test "$srcdir" = $0 && srcdir=.
49 # Ensure $srcdir is set correctly.
50 test -f "$srcdir/defs.in" || {
51 echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
55 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
57 # Make sure we override the user shell.
60 # User can override various tools used.
61 test -z "$PERL" && PERL='@PERL@'
62 test -z "$MAKE" && MAKE=make
63 test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
64 test -z "$AUTOHEADER" && AUTOHEADER="@am_AUTOHEADER@"
65 test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
66 test -z "$MISSING" && MISSING=`pwd`/../lib/missing
67 # Use -Werror because this also turns some Perl warnings into error.
68 # (Tests for which this is inappropriate should use -Wno-error.)
69 test -z "$ACLOCAL" && ACLOCAL="aclocal-@APIVERSION@ -Werror"
70 # Extra flags to pass to aclocal before all other flags added by this script.
71 ACLOCAL_TESTSUITE_FLAGS=
72 export ACLOCAL_TESTSUITE_FLAGS
74 # See how Automake should be run. We put --foreign as the default
75 # strictness to avoid having to create lots and lots of files. A test
76 # can override this by specifying a different strictness. Use -Wall
77 # -Werror by default. Tests for which this is inappropriate
78 # (e.g. when testing that a warning is enabled by a specific switch)
79 # should use -Wnone or/and -Wno-error
80 test -z "$AUTOMAKE" && AUTOMAKE="automake-@APIVERSION@ --foreign -Werror -Wall"
82 PATH="`pwd`@PATH_SEPARATOR@$PATH"
84 # Some shells forget to export modified environment variables.
85 # (See note about `export' in the Autoconf manual.)
88 for tool in : $required
90 # Check that each required tool is present.
94 # Since bison is required, we pick YACC for ./configure.
97 echo "$me: running bison --version"
98 ( bison --version ) || exit 77
101 # Do not use --version, bzip2 still tries to compress stdin.
102 echo "$me: running bzip2 --help"
103 ( bzip2 --help ) || exit 77
108 echo "$me: running $CC -?"
109 ( $CC -? ) || exit 77
112 # Exuberant Ctags will create a TAGS file even
113 # when asked for --help or --version. (Emacs's etags
114 # does not have such problem.) Use -o /dev/null
115 # to make sure we do not pollute the tests/ directory.
116 echo "$me: running etags --version -o /dev/null"
117 ( etags --version -o /dev/null ) || exit 77
120 # Use --version AND -v, because SGI Make doesn't fail on --version.
121 # Also grep for GNU because newer versions of FreeBSD make do
122 # not complain about `--version' (they seem to silently ignore it).
123 echo "$me: running $MAKE --version -v | grep GNU"
124 ( $MAKE --version -v | grep GNU ) || exit 77
127 # When gcc is required, export `CC=gcc' so that ./configure
128 # always use it. This is important only when the user
129 # has defined CC in his environment, otherwise ./configure will
130 # prefer gcc to other compilers.
133 echo "$me: running $CC --version"
134 ( $CC --version ) || exit 77
139 echo "$me: running $GCJ --version"
140 ( $GCJ --version ) || exit 77
141 ( $GCJ -v ) || exit 77
146 echo "$me: running $CXX --version"
147 ( $CXX --version ) || exit 77
152 # There is no way to ask *only* the compiler's version.
153 # This tool always wants to do something (by default
154 # it will try link *nothing* and complain it cannot find
155 # main(); funny). Use -help so it does not try linking anything.
156 echo "$me: running $CC -V -help"
157 ( $CC -V -help ) || exit 77
160 echo "$me: running makedepend -f-"
161 ( makedepend -f- ) || exit 77
164 # Make sure makeinfo understands --html.
165 echo "$me: running makeinfo --html --version"
166 ( makeinfo --html --version ) || exit 77
169 # Skip this test case if the user is root.
170 # We try to append to a read-only file to detect this.
171 priv_check_temp=priv-check.$$
172 touch $priv_check_temp || exit 1
173 chmod a-w $priv_check_temp || exit 1
174 (echo foo >> $priv_check_temp) >/dev/null 2>&1
176 rm -f $priv_check_temp
177 test $overwrite_status = 0 && exit 77
180 # Python doesn't support --version, it has -V
181 echo "$me: running python -V"
182 ( python -V ) || exit 77
185 # Skip this test case if read-only directories aren't supported
187 ro_dir_temp=ro_dir.$$
188 mkdir $ro_dir_temp || exit 1
189 chmod a-w $ro_dir_temp || exit 1
190 (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
193 test $create_status = 0 && exit 77
196 # Try the variants that are tried in check.am.
198 for r2h in $RST2HTML rst2html rst2html.py; do
199 echo "$me: running $r2h --version"
200 $r2h --version && break 2
206 # DejaGnu's runtest program. We rely on being able to specify
207 # the program on the runtest command-line. This requires
208 # DejaGnu 1.4.3 or later.
209 echo "$me: running runtest --version"
210 (runtest SOMEPROGRAM=someprogram --version) || exit 77
213 # No all versions of Tex support `--version', so we use
215 test -n "@TEX@" || exit 77
218 # Texi2dvi supports `-o' since Texinfo 4.1.
219 echo "$me: running texi2dvi -o /dev/null --version"
220 ( texi2dvi -o /dev/null --version ) || exit 77
222 # Generic case: the tool must support --version.
224 echo "$me: running $tool --version"
225 ( $tool --version ) || exit 77
231 # Always use an absolute srcdir. Otherwise symlinks made in subdirs
232 # of the test dir just won't work.
238 srcdir=`CDPATH=: && cd "$srcdir" && pwd`
242 # We use a trap below for cleanup. This requires us to go through
243 # hoops to get the right exit status transported through the signal.
244 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
245 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
246 # sh inside this function.
256 test ! -d $testSubDir || {
257 find $testSubDir -type d ! -perm -200 -exec chmod u+w {} ";"
262 sh_errexit_works=@sh_errexit_works@
263 if test "$sh_errexit_works" = yes; then
267 case $exit_status,$keep_testdirs in
269 find $testSubDir -type d ! -perm -200 -exec chmod u+w {} ";"
273 test "$signal" != 0 &&
274 echo "$me: caught signal $signal"
275 echo "$me: exit $exit_status"
278 for signal in 1 2 13 15; do
279 trap 'signal='$signal'; { Exit 1; }' $signal
284 # Copy in some files we need.
285 for file in install-sh missing depcomp; do
286 cp "$srcdir/../lib/$file" "$testSubDir/$file" || Exit 1
291 # Build appropriate environment in test directory. Eg create
292 # configure.in, touch all necessary files, etc.
293 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
294 # still produces a valid configure.ac. But then, tests running
295 # config.status really need to append AC_OUTPUT.
297 echo "AC_INIT([$me], [1.0])"
298 if test x"$parallel_tests" = x"yes"; then
299 echo "AM_INIT_AUTOMAKE([parallel-tests])"
301 echo "AM_INIT_AUTOMAKE"
303 echo "AC_CONFIG_FILES([Makefile])"
306 # Unset some MAKE... variables that may cause $MAKE to act like a
307 # recursively invoked sub-make. Any $MAKE invocation in a test is
308 # conceptually an independent invocation, not part of the main
310 unset MFLAGS MAKEFLAGS AM_MAKEFLAGS MAKELEVEL __MKLVL__ MAKE_JOBS_FIFO
311 # Unset verbosity flag.
313 # Also unset variables that will let `make -e install' divert
314 # files into unwanted directories.
316 unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
317 unset htmldir includedir infodir libdir libexecdir localedir mandir
318 unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
319 # Also unset variables that control our test driver. While not
320 # conceptually independent, they cause some changed semantics we
321 # need to control (and test for) in some of the tests to ensure
322 # backward-compatible behavior.
323 unset DISABLE_HARD_ERRORS
325 unset TEST_LOG_COMPILER
330 echo "=== Running test $0"
332 # We might need extra macros, e.g., from Libtool or Gettext.
333 # Find them on the system.
334 # Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
335 # other `-I' directories added for libtool and gettext might contain
336 # files from an old version of Automake that we don't want to use.
337 # Use `-Wno-syntax' because we do not want our test suite to fail because
338 # some third-party .m4 file is underquoted.
340 *libtool* | *gettext* )
341 aclocaldir='@prefix@/share/aclocal'
343 if test -f $aclocaldir/dirlist; then
345 <$aclocaldir/dirlist \
346 sed 's/#.*//;s/[ ][ ]*$//g' \
347 | while read dir; do test ! -d "$dir" || echo "-I $dir"; done`
352 for d in $extra_includes $aclocaldir ; do
353 test "x$d" != x-I || continue
354 if test -f "$d/libtool.m4"; then
357 if test -f "$d/gettext.m4"; then
362 *libtool* ) test $libtool_found = yes || Exit 77 ;;
363 *gettext* ) test $gettext_found = yes || Exit 77 ;;
365 # Libtool cannot cope with spaces in the build tree. Our testsuite setup
366 # cannot cope with spaces in the source tree name for Libtool and gettext
368 case $srcdir,`pwd` in
369 *\ * | *\ *) Exit 77 ;;
371 ACLOCAL="$ACLOCAL -Wno-syntax -I $srcdir/../m4 $extra_includes -I $aclocaldir"
375 testaclocaldir='@abs_top_srcdir@/m4'
377 # POSIX no longer requires 'egrep' and 'fgrep',
378 # but some hosts lack 'grep -E' and 'grep -F'.
382 # The amount we should wait after modifying files depends on the platform.
383 # For instance, Windows '95, '98 and ME have 2-second granularity
384 # and can be up to 3 seconds in the future w.r.t. the system clock.
385 sleep='sleep @MODIFICATION_DELAY@'
387 # The tests call `make -e' but we do not want $srcdir from the environment
388 # to override the definition from the Makefile.
392 # An old timestamp that can be given to a file, in "touch -t" format.
393 # The time stamp should be portable to all file systems of interest.
394 # Just for fun, choose the exact time of the announcement of the GNU project
395 # in UTC; see <http://www.gnu.org/gnu/initial-announcement.html>.
396 old_timestamp=198309271735.59
398 # is_newest FILE FILES
399 # --------------------
400 # Return false if any file in FILES is newer than FILE.
401 # Resolve ties in favor of FILE.
404 is_newest_files=`find "$@" -newer "$1"`
405 test -z "$is_newest_files"
409 # AUTOMAKE_run status [options...]
410 # --------------------------------
411 # Run Automake with OPTIONS, and fail if automake
412 # does not exit with STATUS.
418 $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$?
421 test $exitcode = $expected_exitcode || Exit 1
424 # AUTOMAKE_fails [options...]
425 # ---------------------------
426 # Run Automake with OPTIONS, and fail if automake
427 # does not exit with STATUS.
430 AUTOMAKE_run 1 ${1+"$@"}
433 # Turn on shell traces.