4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 # 2005, 2006, 2007, 2008 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 3, 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 srcdir is not set, then we are not running from `make check', be verbose.
44 if test -z "$srcdir"; then
47 srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
48 test "$srcdir" = $0 && srcdir=.
51 # Ensure $srcdir is set correctly.
52 test -f "$srcdir/defs.in" || {
53 echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
57 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
59 # See how redirections should work. User can set VERBOSE to see all
61 test -z "$VERBOSE" && {
65 # Make sure we override the user shell.
68 # User can override various tools used.
69 test -z "$PERL" && PERL='@PERL@'
70 test -z "$MAKE" && MAKE=make
71 test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
72 test -z "$AUTOHEADER" && AUTOHEADER="@am_AUTOHEADER@"
73 test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
74 test -z "$MISSING" && MISSING=`pwd`/../lib/missing
75 # Use -Werror because this also turns some Perl warnings into error.
76 # (Tests for which this is inappropriate should use -Wno-error.)
77 test -z "$ACLOCAL" && ACLOCAL="aclocal-@APIVERSION@ -Werror"
78 # Extra flags to pass to aclocal before all other flags added by this script.
79 ACLOCAL_TESTSUITE_FLAGS=
80 export ACLOCAL_TESTSUITE_FLAGS
82 # See how Automake should be run. We put --foreign as the default
83 # strictness to avoid having to create lots and lots of files. A test
84 # can override this by specifying a different strictness. Use -Wall
85 # -Werror by default. Tests for which this is inappropriate
86 # (e.g. when testing that a warning is enabled by a specific switch)
87 # should use -Wnone or/and -Wno-error
88 test -z "$AUTOMAKE" && AUTOMAKE="automake-@APIVERSION@ --foreign -Werror -Wall"
90 PATH="`pwd`@PATH_SEPARATOR@$PATH"
92 # Some shells forget to export modified environment variables.
93 # (See note about `export' in the Autoconf manual.)
96 for tool in : $required
98 # Check that each required tool is present.
102 # Since bison is required, we pick YACC for ./configure.
105 echo "$me: running bison --version"
106 ( bison --version ) || exit 77
109 # Do not use --version, bzip2 still tries to compress stdin.
110 echo "$me: running bzip2 --help"
111 ( bzip2 --help ) || exit 77
114 # Exuberant Ctags will create a TAGS file even
115 # when asked for --help or --version. (Emacs's etags
116 # does not have such problem.) Use -o /dev/null
117 # to make sure we do not pollute the tests/ directory.
118 echo "$me: running etags --version -o /dev/null"
119 ( etags --version -o /dev/null ) || exit 77
122 # Use --version AND -v, because SGI Make doesn't fail on --version.
123 # Also grep for GNU because newer versions of FreeBSD make do
124 # not complain about `--version' (they seem to silently ignore it).
125 echo "$me: running $MAKE --version -v | grep GNU"
126 ( $MAKE --version -v | grep GNU ) || exit 77
129 # When gcc is required, export `CC=gcc' so that ./configure
130 # always use it. This is important only when the user
131 # has defined CC in his environment, otherwise ./configure will
132 # prefer gcc to other compilers.
135 echo "$me: running $CC --version"
136 ( $CC --version ) || exit 77
141 echo "$me: running $GCJ --version"
142 ( $GCJ --version ) || exit 77
143 ( $GCJ -v ) || exit 77
148 echo "$me: running $CXX --version"
149 ( $CXX --version ) || exit 77
154 # There is no way to ask *only* the compiler's version.
155 # This tool always wants to do something (by default
156 # it will try link *nothing* and complain it cannot find
157 # main(); funny). Use -help so it does not try linking anything.
158 echo "$me: running $CC -V -help"
159 ( $CC -V -help ) || exit 77
162 echo "$me: running makedepend -f-"
163 ( makedepend -f- ) || exit 77
166 # Make sure makeinfo understands --html.
167 echo "$me: running makeinfo --html --version"
168 ( makeinfo --html --version ) || exit 77
171 # Skip this test case if the user is root.
172 # We try to append to a read-only file to detect this.
173 priv_check_temp=priv-check.$$
174 touch $priv_check_temp || exit 1
175 chmod a-w $priv_check_temp || exit 1
176 (echo foo >> $priv_check_temp) >/dev/null 2>&1
178 rm -f $priv_check_temp
179 test $overwrite_status = 0 && exit 77
182 # Python doesn't support --version, it has -V
183 echo "$me: running python -V"
184 ( python -V ) || exit 77
187 # Skip this test case if read-only directories aren't supported
189 ro_dir_temp=ro_dir.$$
190 mkdir $ro_dir_temp || exit 1
191 chmod a-w $ro_dir_temp || exit 1
192 (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
195 test $create_status = 0 && exit 77
198 # DejaGnu's runtest program. We rely on being able to specify
199 # the program on the runtest command-line. This requires
200 # DejaGnu 1.4.3 or later.
201 echo "$me: running runtest --version"
202 (runtest SOMEPROGRAM=someprogram --version) || exit 77
205 # No all versions of Tex support `--version', so we use
207 test -n "@TEX@" || exit 77
210 # Texi2dvi supports `-o' since Texinfo 4.1.
211 echo "$me: running texi2dvi -o /dev/null --version"
212 ( texi2dvi -o /dev/null --version ) || exit 77
214 # Generic case: the tool must support --version.
216 echo "$me: running $tool --version"
217 ( $tool --version ) || exit 77
223 # Always use an absolute srcdir. Otherwise symlinks made in subdirs
224 # of the test dir just won't work.
230 srcdir=`CDPATH=: && cd "$srcdir" && pwd`
234 # We use a trap below for cleanup. This requires us to go through
235 # hoops to get the right exit status transported through the signal.
236 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
237 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
238 # sh inside this function.
248 chmod -R u+rwx $testSubDir > /dev/null 2>&1
249 rm -rf $testSubDir > /dev/null 2>&1
254 case $exit_status,$keep_testdirs in
256 chmod -R a+rwx $testSubDir > /dev/null 2>&1
257 rm -rf "$testSubDir" ;;
259 test "$signal" != 0 &&
260 echo "$as_me: caught signal $signal"
261 echo "$as_me: exit $exit_status"
264 for signal in 1 2 13 15; do
265 trap 'signal='$signal'; { Exit 1; }' $signal
269 # Copy in some files we need.
270 for file in install-sh missing depcomp; do
271 cp "$srcdir/../lib/$file" "$testSubDir/$file" || Exit 1
276 # Build appropriate environment in test directory. Eg create
277 # configure.in, touch all necessary files, etc.
278 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
279 # still produces a valid configure.ac. But then, tests running
280 # config.status really need to append AC_OUTPUT.
281 cat > configure.in << END
282 AC_INIT([$me], [1.0])
284 AC_CONFIG_FILES([Makefile])
287 # Unset some MAKE... variables that may cause $MAKE to act like a
288 # recursively invoked sub-make. Any $MAKE invocation in a test is
289 # conceptually an independent invocation, not part of the main
296 echo "=== Running test $0"
298 # We might need extra macros, e.g., from Libtool or Gettext.
299 # Find them on the system.
300 # Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
301 # other `-I' directories added for libtool and gettext might contain
302 # files from an old version of Automake that we don't want to use.
303 # Use `-Wno-syntax' because we do not want our test suite to fail because
304 # some third-party .m4 file is underquoted.
306 *libtool* | *gettext* )
307 aclocaldir='@prefix@/share/aclocal'
309 if test -f $aclocaldir/dirlist; then
311 <$aclocaldir/dirlist \
312 sed -ne 's/#.*//;s/[ ][ ]*$//g;s/..*/ -I &/p' |
318 for d in $extra_includes $aclocaldir ; do
319 test "x$d" != x-I || continue
320 if test -f "$d/libtool.m4"; then
323 if test -f "$d/gettext.m4"; then
328 *libtool* ) test $libtool_found = yes || Exit 77 ;;
329 *gettext* ) test $gettext_found = yes || Exit 77 ;;
331 # Libtool cannot cope with spaces in the build tree. Our testsuite setup
332 # cannot cope with spaces in the source tree name for Libtool and gettext
334 case $srcdir,`pwd` in
335 *\ * | *\ *) Exit 77 ;;
337 ACLOCAL="$ACLOCAL -Wno-syntax -I $srcdir/../m4 $extra_includes -I $aclocaldir"
341 testaclocaldir='@abs_top_srcdir@/m4'
343 # POSIX no longer requires 'egrep' and 'fgrep',
344 # but some hosts lack 'grep -E' and 'grep -F'.
348 # The amount we should wait after modifying files depends on the platform.
349 # For instance, Windows '95, '98 and ME have 2-second granularity
350 # and can be up to 3 seconds in the future w.r.t. the system clock.
351 sleep='sleep @MODIFICATION_DELAY@'
353 # The tests call `make -e' but we do not want $srcdir from the environment
354 # to override the definition from the Makefile.
358 # An old timestamp that can be given to a file, in "touch -t" format.
359 # The time stamp should be portable to all file systems of interest.
360 # Just for fun, choose the exact time of the announcement of the GNU project
361 # in UTC; see <http://www.gnu.org/gnu/initial-announcement.html>.
362 old_timestamp=198309271735.59
364 # is_newest FILE FILES
365 # --------------------
366 # Return false if any file in FILES is newer than FILE.
367 # Resolve ties in favor of FILE.
370 is_newest_files=`find "$@" -newer "$1"`
371 test -z "$is_newest_files"
375 # AUTOMAKE_run status [options...]
376 # --------------------------------
377 # Run Automake with OPTIONS, and fail if automake
378 # does not exit with STATUS.
384 $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$?
387 test $exitcode = $expected_exitcode || Exit 1
390 # AUTOMAKE_fails [options...]
391 # ---------------------------
392 # Run Automake with OPTIONS, and fail if automake
393 # does not exit with STATUS.
396 AUTOMAKE_run 1 ${1+"$@"}
399 # Turn on shell traces when VERBOSE is set.
400 if test -n "$VERBOSE"; then