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 Bourne compatible.
24 # (Snippet copied from configure's initialization in Autoconf 2.59c.)
25 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
28 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
29 # is contrary to our usage. Disable this feature.
30 alias -g '${1+"$@"}'='"$@"'
32 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
34 BIN_SH=xpg4; export BIN_SH # for Tru64
35 DUALCASE=1; export DUALCASE # for MKS sh
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
106 # Exuberant Ctags will create a TAGS file even
107 # when asked for --help or --version. (Emacs's etags
108 # does not have such problem.) Use -o /dev/null
109 # to make sure we do not pollute the tests/ directory.
110 echo "$me: running etags --version -o /dev/null"
111 ( etags --version -o /dev/null ) || exit 77
114 # Use --version AND -v, because SGI Make doesn't fail on --version.
115 # Also grep for GNU because newer versions of FreeBSD make do
116 # not complain about `--version' (they seem to silently ignore it).
117 echo "$me: running $MAKE --version -v | grep GNU"
118 ( $MAKE --version -v | grep GNU ) || exit 77
121 # When gcc is required, export `CC=gcc' so that ./configure
122 # always use it. This is important only when the user
123 # has defined CC in his environment, otherwise ./configure will
124 # prefer gcc to other compilers.
127 echo "$me: running $CC --version"
128 ( $CC --version ) || exit 77
133 echo "$me: running $GCJ --version"
134 ( $GCJ --version ) || exit 77
135 ( $GCJ -v ) || exit 77
140 echo "$me: running $CXX --version"
141 ( $CXX --version ) || exit 77
146 # There is no way to ask *only* the compiler's version.
147 # This tool always wants to do something (by default
148 # it will try link *nothing* and complain it cannot find
149 # main(); funny). Use -help so it does not try linking anything.
150 echo "$me: running $CC -V -help"
151 ( $CC -V -help ) || exit 77
154 echo "$me: running makedepend -f-"
155 ( makedepend -f- ) || exit 77
158 # Make sure makeinfo understands --html.
159 echo "$me: running makeinfo --html --version"
160 ( makeinfo --html --version ) || exit 77
163 # Skip this test case if the user is root.
164 # We try to append to a read-only file to detect this.
165 priv_check_temp=priv-check.$$
166 touch $priv_check_temp || exit 1
167 chmod a-w $priv_check_temp || exit 1
168 (echo foo >> $priv_check_temp) >/dev/null 2>&1
170 rm -f $priv_check_temp
171 test $overwrite_status = 0 && exit 77
174 # Python doesn't support --version, it has -V
175 echo "$me: running python -V"
176 ( python -V ) || exit 77
179 # Skip this test case if read-only directories aren't supported
181 ro_dir_temp=ro_dir.$$
182 mkdir $ro_dir_temp || exit 1
183 chmod a-w $ro_dir_temp || exit 1
184 (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
187 test $create_status = 0 && exit 77
190 # Try the variants that are tried in check.am.
192 for r2h in $RST2HTML rst2html rst2html.py; do
193 echo "$me: running $r2h --version"
194 $r2h --version && break 2
200 # DejaGnu's runtest program. We rely on being able to specify
201 # the program on the runtest command-line. This requires
202 # DejaGnu 1.4.3 or later.
203 echo "$me: running runtest --version"
204 (runtest SOMEPROGRAM=someprogram --version) || exit 77
207 # No all versions of Tex support `--version', so we use
209 test -n "@TEX@" || exit 77
212 # Texi2dvi supports `-o' since Texinfo 4.1.
213 echo "$me: running texi2dvi -o /dev/null --version"
214 ( texi2dvi -o /dev/null --version ) || exit 77
216 # Generic case: the tool must support --version.
218 echo "$me: running $tool --version"
219 ( $tool --version ) || exit 77
225 # Always use an absolute srcdir. Otherwise symlinks made in subdirs
226 # of the test dir just won't work.
232 srcdir=`CDPATH=: && cd "$srcdir" && pwd`
236 # We use a trap below for cleanup. This requires us to go through
237 # hoops to get the right exit status transported through the signal.
238 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
239 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
240 # sh inside this function.
250 chmod -R u+rwx $testSubDir > /dev/null 2>&1
251 rm -rf $testSubDir > /dev/null 2>&1
254 sh_errexit_works=@sh_errexit_works@
255 if test "$sh_errexit_works" = yes; then
258 case $exit_status,$keep_testdirs in
260 chmod -R a+rwx $testSubDir > /dev/null 2>&1
261 rm -rf "$testSubDir" ;;
263 test "$signal" != 0 &&
264 echo "$as_me: caught signal $signal"
265 echo "$as_me: exit $exit_status"
268 for signal in 1 2 13 15; do
269 trap 'signal='$signal'; { Exit 1; }' $signal
274 # Copy in some files we need.
275 for file in install-sh missing depcomp; do
276 cp "$srcdir/../lib/$file" "$testSubDir/$file" || Exit 1
281 # Build appropriate environment in test directory. Eg create
282 # configure.in, touch all necessary files, etc.
283 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
284 # still produces a valid configure.ac. But then, tests running
285 # config.status really need to append AC_OUTPUT.
286 cat > configure.in << END
287 AC_INIT([$me], [1.0])
289 AC_CONFIG_FILES([Makefile])
292 # Unset some MAKE... variables that may cause $MAKE to act like a
293 # recursively invoked sub-make. Any $MAKE invocation in a test is
294 # conceptually an independent invocation, not part of the main
300 # Unset verbosity flag.
302 # Also unset variables that control our test driver. While not
303 # conceptually independent, they cause some changed semantics we
304 # need to control (and test for) in some of the tests to ensure
305 # backward-compatible behavior.
306 unset DISABLE_HARD_ERRORS
312 echo "=== Running test $0"
314 # We might need extra macros, e.g., from Libtool or Gettext.
315 # Find them on the system.
316 # Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
317 # other `-I' directories added for libtool and gettext might contain
318 # files from an old version of Automake that we don't want to use.
319 # Use `-Wno-syntax' because we do not want our test suite to fail because
320 # some third-party .m4 file is underquoted.
322 *libtool* | *gettext* )
323 aclocaldir='@prefix@/share/aclocal'
325 if test -f $aclocaldir/dirlist; then
327 <$aclocaldir/dirlist \
328 sed 's/#.*//;s/[ ][ ]*$//g' \
329 | while read dir; do test ! -d "$dir" || echo "-I $dir"; done`
334 for d in $extra_includes $aclocaldir ; do
335 test "x$d" != x-I || continue
336 if test -f "$d/libtool.m4"; then
339 if test -f "$d/gettext.m4"; then
344 *libtool* ) test $libtool_found = yes || Exit 77 ;;
345 *gettext* ) test $gettext_found = yes || Exit 77 ;;
347 # Libtool cannot cope with spaces in the build tree. Our testsuite setup
348 # cannot cope with spaces in the source tree name for Libtool and gettext
350 case $srcdir,`pwd` in
351 *\ * | *\ *) Exit 77 ;;
353 ACLOCAL="$ACLOCAL -Wno-syntax -I $srcdir/../m4 $extra_includes -I $aclocaldir"
357 testaclocaldir='@abs_top_srcdir@/m4'
359 # POSIX no longer requires 'egrep' and 'fgrep',
360 # but some hosts lack 'grep -E' and 'grep -F'.
364 # The amount we should wait after modifying files depends on the platform.
365 # For instance, Windows '95, '98 and ME have 2-second granularity
366 # and can be up to 3 seconds in the future w.r.t. the system clock.
367 sleep='sleep @MODIFICATION_DELAY@'
369 # The tests call `make -e' but we do not want $srcdir from the environment
370 # to override the definition from the Makefile.
374 # An old timestamp that can be given to a file, in "touch -t" format.
375 # The time stamp should be portable to all file systems of interest.
376 # Just for fun, choose the exact time of the announcement of the GNU project
377 # in UTC; see <http://www.gnu.org/gnu/initial-announcement.html>.
378 old_timestamp=198309271735.59
380 # is_newest FILE FILES
381 # --------------------
382 # Return false if any file in FILES is newer than FILE.
383 # Resolve ties in favor of FILE.
386 is_newest_files=`find "$@" -newer "$1"`
387 test -z "$is_newest_files"
391 # AUTOMAKE_run status [options...]
392 # --------------------------------
393 # Run Automake with OPTIONS, and fail if automake
394 # does not exit with STATUS.
400 $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$?
403 test $exitcode = $expected_exitcode || Exit 1
406 # AUTOMAKE_fails [options...]
407 # ---------------------------
408 # Run Automake with OPTIONS, and fail if automake
409 # does not exit with STATUS.
412 AUTOMAKE_run 1 ${1+"$@"}
415 # Turn on shell traces.