4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 # 2005, 2006, 2007, 2008, 2009, 2011 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 # A single whitespace character.
39 # A tabulation character.
41 # A newline character.
45 # As autoconf-generated configure scripts do, ensure that IFS
46 # is defined initially, so that saving and restoring $IFS works.
49 # Ensure we are running from the right directory.
51 echo "defs: not found in current directory" 1>&2
55 if test -z "$srcdir"; then
57 srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
58 test "$srcdir" = $0 && srcdir=.
61 # Ensure $srcdir is set correctly.
62 test -f "$srcdir/defs.in" || {
63 echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
67 # The name of the current test (without the `.test' suffix).
68 # Test scripts can override it if they need to (but this should
69 # be done carefully, and *before* including ./defs).
70 if test -z "$me"; then
71 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
72 elif env | grep '^me=' >/dev/null; then
73 echo "$0: variable \`me' is set in the environment: this is unsafe" >&2
77 # Check that the environment is properly sanitized.
78 for var in required parallel_tests; do
79 if env | grep "^$var=" >/dev/null; then
80 echo "$me: variable \`$var' is set in the environment:" \
87 # This might be used in testcases checking distribution-related features.
88 # Test scripts are free to override this if they need to.
91 APIVERSION='@APIVERSION@'
92 PATH_SEPARATOR='@PATH_SEPARATOR@'
94 # Make sure we override the user shell.
97 # User can override various tools used.
98 MAKE=${AM_TESTSUITE_MAKE-${MAKE-'make'}}
99 test -z "$PERL" && PERL='@PERL@'
100 test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
101 test -z "$AUTOM4TE" && AUTOM4TE="@am_AUTOM4TE@"
102 test -z "$AUTORECONF" && AUTORECONF="@am_AUTORECONF@"
103 test -z "$AUTOHEADER" && AUTOHEADER="@am_AUTOHEADER@"
104 test -z "$AUTOUPDATE" && AUTOUPDATE="@am_AUTOUPDATE@"
105 test -z "$MISSING" && MISSING=`pwd`/../lib/missing
107 # This is a hack to seamlessly support the infamous "autoconf wrappers",
108 # that might dispatch different autoconf versions depending on the name
109 # of the input files and/or the command-line options used. See:
110 # <http://lists.gnu.org/archive/html/automake/2011-12/msg00039.html>
111 # FIXME: in the long run, the better fix will be to convert our testsuite
112 # to use `configure.ac' instead of `configure.in' as autoconf input.
113 AUTOCONF="$AUTOCONF -B /no/such/dir"
114 AUTOM4TE="$AUTOM4TE -B /no/such/dir"
115 AUTORECONF="$AUTORECONF -B /no/such/dir"
117 # Use -Werror because this also turns some Perl warnings into error.
118 # (Tests for which this is inappropriate should use -Wno-error.)
119 test -z "$ACLOCAL" && ACLOCAL="aclocal-$APIVERSION -Werror"
121 # See how Automake should be run. We put --foreign as the default
122 # strictness to avoid having to create lots and lots of files. A test
123 # can override this by specifying a different strictness. Use -Wall
124 # -Werror by default. Tests for which this is inappropriate
125 # (e.g. when testing that a warning is enabled by a specific switch)
126 # should use -Wnone or/and -Wno-error
127 test -z "$AUTOMAKE" && AUTOMAKE="automake-$APIVERSION --foreign -Werror -Wall"
129 PATH="`pwd`$PATH_SEPARATOR$PATH"
131 # Some shells forget to export modified environment variables.
132 # (See note about `export' in the Autoconf manual.)
135 # We use a trap below for cleanup. This requires us to go through
136 # hoops to get the right exit status transported through the signal.
137 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
138 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
139 # sh inside this function.
147 # Print warnings (e.g., about skipped and failed tests) to this file
148 # number. Override by putting, say:
149 # stderr_fileno_=9; export stderr_fileno_; exec 9>&2;
150 # in the definition of AM_TESTS_ENVIRONMENT.
151 # This is useful when using automake's parallel tests mode, to print the
152 # reason for skip/failure to console, rather than to the *.log files.
153 : ${stderr_fileno_=2}
155 # Copied from Gnulib's `tests/init.sh'.
156 warn_ () { echo "$@" 1>&$stderr_fileno_; }
157 fail_ () { warn_ "$me: failed test: $@"; Exit 1; }
158 skip_ () { warn_ "$me: skipped test: $@"; Exit 77; }
159 fatal_ () { warn_ "$me: hard error: $@"; Exit 99; }
160 framework_failure_ () { warn_ "$me: set-up failure: $@"; Exit 99; }
164 # Tell whether we are cross-compiling. This is especially useful to skip
165 # tests (or portions of them) that requires a native compiler.
168 test x"$host_alias" != x
171 # So that we can force the use of correct gcc, g++ etc., consistently
172 # with cross-compilation settings.
173 if cross_compiling; then
174 am__tool_prefix="$host_alias-"
179 for tool in : $required
181 # Check that each required tool is present.
185 # Since bison is required, we pick YACC for ./configure.
188 echo "$me: running bison --version"
189 ( bison --version ) || exit 77
192 # Since flex is required, we pick LEX for ./configure.
195 echo "$me: running flex --version"
196 flex --version || exit 77
198 cc|c++|fortran|fortran77)
199 echo "$me: dummy requirement '$tool', no check done"
202 # Do not use --version, bzip2 still tries to compress stdin.
203 echo "$me: running bzip2 --help"
204 ( bzip2 --help ) || exit 77
209 echo "$me: running $CC -?"
210 ( $CC -? ) || exit 77
213 # Exuberant Ctags will create a TAGS file even
214 # when asked for --help or --version. (Emacs's etags
215 # does not have such problem.) Use -o /dev/null
216 # to make sure we do not pollute the tests/ directory.
217 echo "$me: running etags --version -o /dev/null"
218 ( etags --version -o /dev/null ) || exit 77
221 # Use --version AND -v, because SGI Make doesn't fail on --version.
222 # Also grep for GNU because newer versions of FreeBSD make do
223 # not complain about `--version' (they seem to silently ignore it).
224 echo "$me: running $MAKE --version -v | grep GNU"
225 ( $MAKE --version -v | grep GNU ) || exit 77
228 # When gcc is required, export `CC=gcc' so that ./configure
229 # always use it. This is important only when the user
230 # has defined CC in his environment, otherwise ./configure will
231 # prefer gcc to other compilers.
232 CC=${am__tool_prefix}gcc
234 echo "$me: running $CC --version"
235 ( $CC --version ) || exit 77
238 GCJ=${am__tool_prefix}gcj
240 echo "$me: running $GCJ --version"
241 ( $GCJ --version ) || exit 77
242 ( $GCJ -v ) || exit 77
245 CXX=${am__tool_prefix}g++
247 echo "$me: running $CXX --version"
248 ( $CXX --version ) || exit 77
251 FC=${am__tool_prefix}gfortran
253 echo "$me: running $FC --version"
254 $FC --version || skip_ "GNU Fortran compiler not available"
255 echo "$me: running $FC -v"
256 $FC -v || skip_ "botched installation for GNU Fortran compiler"
257 case " $required " in
259 *) F77=$FC; export F77;;
263 F77=${am__tool_prefix}g77
265 echo "$me: running $F77 --version"
266 $F77 --version || skip_ "GNU Fortran 77 compiler not available"
267 echo "$me: running $F77 -v"
268 $F77 -v || skip_ "botched installation for GNU Fortran 77 compiler"
269 case " $required " in
271 *) FC=$F77; export FC;;
277 # There is no way to ask *only* the compiler's version.
278 # This tool always wants to do something (by default
279 # it will try link *nothing* and complain it cannot find
280 # main(); funny). Use -help so it does not try linking anything.
281 echo "$me: running $CC -V -help"
282 ( $CC -V -help ) || exit 77
285 # The Java compiler from JDK 1.5 (and presumably earlier versions)
286 # cannot handle the `-version' option by itself: it bails out
287 # telling that source files are missing. Adding also the `-help'
288 # option seems to solve the problem.
289 echo "$me: running javac -version -help"
290 javac -version -help || exit 77
295 # Attempting to create an empty archive will actually not
296 # create the archive, but lib will output its version.
297 echo "$me: running $AR -out:defstest.lib"
298 $AR -out:defstest.lib || skip_ "Microsoft \`lib' utility not available"
301 echo "$me: running makedepend -f-"
302 ( makedepend -f- ) || exit 77
305 # Make sure makeinfo understands --html.
306 echo "$me: running makeinfo --html --version"
307 ( makeinfo --html --version ) || exit 77
310 # Skip this test case if the user is root.
311 # We try to append to a read-only file to detect this.
312 priv_check_temp=priv-check.$$
313 touch $priv_check_temp || exit 1
314 chmod a-w $priv_check_temp || exit 1
315 (echo foo >> $priv_check_temp) >/dev/null 2>&1
317 rm -f $priv_check_temp
318 test $overwrite_status = 0 && exit 77
321 cross_compiling && skip_ "doesn't work in cross-compile mode"
324 # Python doesn't support --version, it has -V
325 echo "$me: running python -V"
326 ( python -V ) || exit 77
329 # Skip this test case if read-only directories aren't supported
331 ro_dir_temp=ro_dir.$$
332 mkdir $ro_dir_temp || exit 1
333 chmod a-w $ro_dir_temp || exit 1
334 (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
337 test $create_status = 0 && exit 77
340 # Try the variants that are tried in check.am.
342 for r2h in $RST2HTML rst2html rst2html.py; do
343 echo "$me: running $r2h --version"
344 $r2h --version && break 2
350 # DejaGnu's runtest program. We rely on being able to specify
351 # the program on the runtest command-line. This requires
352 # DejaGnu 1.4.3 or later.
353 echo "$me: running runtest --version"
354 (runtest SOMEPROGRAM=someprogram --version) || exit 77
357 # No all versions of Tex support `--version', so we use
359 test -n "@TEX@" || exit 77
362 # Texi2dvi supports `-o' since Texinfo 4.1.
363 echo "$me: running texi2dvi -o /dev/null --version"
364 ( texi2dvi -o /dev/null --version ) || exit 77
367 # Try some XSI features.
368 echo "$me: trying some XSI constructs"
370 test "${_am_dummy##*/},${_am_dummy%/*},${_am_dummy#??}"${_am_dummy%"$_am_dummy"}, \
372 && eval 'test $(( 1 + 1 )) -eq 2 \
373 && test "${#_am_dummy}" -eq 5' ) || exit 77
375 # Generic case: the tool must support --version.
377 echo "$me: running $tool --version"
378 ( $tool --version ) || exit 77
384 # Always use an absolute srcdir. Otherwise symlinks made in subdirs
385 # of the test dir just won't work.
391 srcdir=`CDPATH=: && cd "$srcdir" && pwd`
397 test ! -d $testSubDir || {
398 find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";"
403 sh_errexit_works=@sh_errexit_works@
404 if test "$sh_errexit_works" = yes; then
408 case $exit_status,$keep_testdirs in
410 find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";"
414 test "$signal" != 0 &&
415 echo "$me: caught signal $signal"
416 echo "$me: exit $exit_status"
419 for signal in 1 2 13 15; do
420 trap 'signal='$signal'; { Exit 1; }' $signal
425 # Copy in some files we need.
426 for file in install-sh missing depcomp; do
427 cp "$srcdir/../lib/$file" "$testSubDir/$file" || Exit 1
432 # Build appropriate environment in test directory. Eg create
433 # configure.in, touch all necessary files, etc.
434 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
435 # still produces a valid configure.ac. But then, tests running
436 # config.status really need to append AC_OUTPUT.
438 echo "AC_INIT([$me], [1.0])"
439 if test x"$parallel_tests" = x"yes"; then
440 echo "AM_INIT_AUTOMAKE([parallel-tests])"
442 echo "AM_INIT_AUTOMAKE"
444 echo "AC_CONFIG_FILES([Makefile])"
447 # Unset some make-related variables that may cause $MAKE to act like
448 # a recursively invoked sub-make. Any $MAKE invocation in a test is
449 # conceptually an independent invocation, not part of the main
451 unset MFLAGS MAKEFLAGS AM_MAKEFLAGS MAKELEVEL
452 unset __MKLVL__ MAKE_JOBS_FIFO # For BSD make.
453 unset DMAKE_CHILD DMAKE_DEF_PRINTED DMAKE_MAX_JOBS # For Solaris dmake.
454 # Unset verbosity flag.
456 # Also unset variables that will let `make -e install' divert
457 # files into unwanted directories.
459 unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
460 unset htmldir includedir infodir libdir libexecdir localedir mandir
461 unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
462 # Unset variables that might change the "make distcheck" behaviour.
463 unset DISTCHECK_CONFIGURE_FLAGS AM_DISTCHECK_CONFIGURE_FLAGS
464 # Also unset variables that control our test driver. While not
465 # conceptually independent, they cause some changed semantics we
466 # need to control (and test for) in some of the tests to ensure
467 # backward-compatible behavior.
468 unset TESTS_ENVIRONMENT AM_TESTS_ENVIRONMENT
469 unset DISABLE_HARD_ERRORS
472 unset TEST_LOG_COMPILER
477 echo "=== Running test $0"
479 # We might need extra macros, e.g., from Libtool or Gettext.
480 case " $required " in *\ libtool*) . ../libtool-macros.dir/get.sh;; esac
481 case " $required " in *\ gettext*) . ../gettext-macros.dir/get.sh;; esac
483 testaclocaldir='@abs_top_srcdir@/m4'
485 # POSIX no longer requires 'egrep' and 'fgrep',
486 # but some hosts lack 'grep -E' and 'grep -F'.
490 # The amount we should wait after modifying files depends on the platform.
491 # For instance, Windows '95, '98 and ME have 2-second granularity
492 # and can be up to 3 seconds in the future w.r.t. the system clock.
493 sleep='sleep @MODIFICATION_DELAY@'
495 # The tests call `make -e' but we do not want $srcdir from the environment
496 # to override the definition from the Makefile.
500 # An old timestamp that can be given to a file, in "touch -t" format.
501 # The time stamp should be portable to all file systems of interest.
502 # Just for fun, choose the exact time of the announcement of the GNU project
503 # in UTC; see <http://www.gnu.org/gnu/initial-announcement.html>.
504 old_timestamp=198309271735.59
506 # is_newest FILE FILES
507 # --------------------
508 # Return false if any file in FILES is newer than FILE.
509 # Resolve ties in favor of FILE.
512 is_newest_files=`find "$@" -prune -newer "$1"`
513 test -z "$is_newest_files"
518 # Return success if $MAKE is GNU make, return failure otherwise.
519 # Caches the result for speed reasons.
522 case $am__using_gmake in
528 # Use --version AND -v, because SGI Make doesn't fail on --version.
529 # Also grep for GNU because newer versions of FreeBSD make do
530 # not complain about `--version' (they seem to silently ignore it).
531 if $MAKE --version -v | grep GNU; then
539 fatal_ "invalid value for \$am__using_gmake: '$am__using_gmake'";;
542 am__using_gmake="" # Avoid interferences from the environment.
544 # AUTOMAKE_run status [options...]
545 # --------------------------------
546 # Run Automake with OPTIONS, and fail if automake
547 # does not exit with STATUS.
553 $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$?
556 test $exitcode = $expected_exitcode || Exit 1
559 # AUTOMAKE_fails [options...]
560 # ---------------------------
561 # Run Automake with OPTIONS, and fail if automake
562 # does not exit with STATUS.
565 AUTOMAKE_run 1 ${1+"$@"}
568 commented_sed_unindent_prog='
569 /^$/b # Nothing to do for empty lines.
570 x # Get x<indent> into pattern space.
571 /^$/{ # No prior x<indent>, go prepare it.
572 g # Copy this 1st non-blank line into pattern space.
573 s/^\(['"$tab"' ]*\).*/x\1/ # Prepare x<indent> in pattern space.
574 } # Now: x<indent> in pattern and <line> in hold.
575 G # Build x<indent>\n<line> in pattern space, and
576 h # duplicate it into hold space.
577 s/\n.*$// # Restore x<indent> in pattern space, and
578 x # exchange with the above duplicate in hold space.
579 s/^x\(.*\)\n\1// # Remove leading <indent> from <line>.
580 s/^x.*\n// # Restore <line> when there is no leading <indent>.
583 # unindent [input files...]
584 # -------------------------
585 # Remove the "proper" amount of leading whitespace from the given files,
586 # and output the result on stdout. That amount is determined by looking
587 # at the leading whitespace of the first non-blank line in the input
588 # files. If no input file is specified, standard input is implied.
591 if test x"$sed_unindent_prog" = x; then
592 sed_unindent_prog=`printf '%s\n' "$commented_sed_unindent_prog" | sed -e "s/ *# .*//"`
594 sed "$sed_unindent_prog" ${1+"$@"}
596 sed_unindent_prog="" # Avoid interferences from the environment.
598 # Turn on shell traces.