3 # Copyright (C) 1996-2012 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 ########################################################
19 ### IMPORTANT NOTE: keep this file 'set -e' clean. ###
20 ########################################################
22 # NOTE: This file should execute correctly with any system's /bin/sh
23 # shell, and not only with configure-time detected $AM_TEST_RUNNER_SHELL,
24 # *until differently and explicitly specified*.
26 ## -------------------------------------------------------- ##
27 ## Source static setup and definitions for the testsuite. ##
28 ## -------------------------------------------------------- ##
30 # Ensure we are running from the right directory.
31 test -f ./defs-static || {
32 echo "$0: ./defs-static: not found in current directory" >&2
36 # Source the shell sanitization and variables' definitions.
37 . ./defs-static || exit 99
39 # Enable the errexit shell flag early.
42 # The name of the current test (without the '.sh' or '.tap' suffix).
43 # Test scripts can override it if they need to (but this should
44 # be done carefully, and *before* including ./defs).
45 if test -z "$me"; then
46 # Guard against failure to spawn sed (seen on MSYS), or empty $argv0.
47 me=`echo "$argv0" | sed -e 's,.*[\\/],,;s/\.sh$//;s/\.tap$//'` \
49 || { echo "$argv0: failed to define \$me" >&2; exit 99; }
52 ## ---------------------- ##
53 ## Early sanity checks. ##
54 ## ---------------------- ##
56 # A single whitespace character.
58 # A tabulation character.
60 # A newline character.
64 # As autoconf-generated configure scripts do, ensure that IFS
65 # is defined initially, so that saving and restoring $IFS works.
68 # Ensure $am_top_srcdir is set correctly.
69 test -f "$am_top_srcdir/defs-static.in" || {
70 echo "$me: $am_top_srcdir/defs-static.in not found," \
71 "check \$am_top_srcdir" >&2
75 # Ensure $am_top_builddir is set correctly.
76 test -f "$am_top_builddir/defs-static" || {
77 echo "$me: $am_top_builddir/defs-static not found," \
78 "check \$am_top_builddir" >&2
83 ## ------------------------------------ ##
84 ## Ensure we run with a proper shell. ##
85 ## ------------------------------------ ##
87 # Make sure we run with the shell detected at configure time (unless
88 # the user forbids it).
89 case ${AM_TESTS_REEXEC-yes} in
93 # Ensure we can find ourselves.
94 if test ! -f "$0"; then
95 echo "$me: unable to find myself: $0" >&2
98 AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
99 # Cannot simply do "opts=$-", since the content of $- is not
100 # portable among different shells. So try to propagate only
101 # the portable and interesting options.
103 *x*v*|*v*x) opts=-vx;;
108 echo $me: exec $AM_TEST_RUNNER_SHELL $opts "$0" "$*"
109 exec $AM_TEST_RUNNER_SHELL $opts "$0" ${1+"$@"} || {
110 echo "$me: failed to re-execute with $AM_TEST_RUNNER_SHELL" >&2
116 # NOTE: From this point on, we can assume this file is being executed
117 # by the configure-time detected $AM_TEST_RUNNER_SHELL.
120 ## ----------------------- ##
121 ## Early debugging info. ##
122 ## ----------------------- ##
124 echo "Running from installcheck: $am_running_installcheck"
125 echo "Using TAP: $am_using_tap"
129 ## ---------------------- ##
130 ## Environment cleanup. ##
131 ## ---------------------- ##
133 # Temporarily disable this, since some shells (e.g., older version
134 # of Bash) can return a non-zero exit status upon the when a non-set
138 # Unset some make-related variables that may cause $MAKE to act like
139 # a recursively invoked sub-make. Any $MAKE invocation in a test is
140 # conceptually an independent invocation, not part of the main
142 unset MFLAGS MAKEFLAGS AM_MAKEFLAGS MAKELEVEL
143 unset __MKLVL__ MAKE_JOBS_FIFO # For BSD make.
144 unset DMAKE_CHILD DMAKE_DEF_PRINTED DMAKE_MAX_JOBS # For Solaris dmake.
145 # Unset verbosity flag.
147 # Also unset variables that will let "make -e install" divert
148 # files into unwanted directories.
150 unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
151 unset htmldir includedir infodir libdir libexecdir localedir mandir
152 unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
153 # Unset variables that might change the "make distcheck" behaviour.
154 unset DISTCHECK_CONFIGURE_FLAGS AM_DISTCHECK_CONFIGURE_FLAGS
155 # Used by install rules for info files.
156 unset AM_UPDATE_INFO_DIR
157 # The tests call "make -e" but we do not want $srcdir from the environment
158 # to override the definition from the Makefile.
160 # Also unset variables that control our test driver. While not
161 # conceptually independent, they cause some changed semantics we
162 # need to control (and test for) in some of the tests to ensure
163 # backward-compatible behavior.
164 unset TESTS_ENVIRONMENT AM_TESTS_ENVIRONMENT
165 unset DISABLE_HARD_ERRORS
173 for pfx in TEST_ SH_ TAP_ ''; do
174 unset ${pfx}LOG_COMPILER
175 unset ${pfx}LOG_COMPILE # Not a typo!
176 unset ${pfx}LOG_FLAGS
177 unset AM_${pfx}LOG_FLAGS
178 unset ${pfx}LOG_DRIVER
179 unset ${pfx}LOG_DRIVER_FLAGS
180 unset AM_${pfx}LOG_DRIVER_FLAGS
184 # Re-enable, it had been temporarily disabled above.
187 ## ---------------------------- ##
188 ## Auxiliary shell functions. ##
189 ## ---------------------------- ##
191 # Tell whether we should keep the test directories around, even in
192 # case of success. By default, we don't.
193 am_keeping_testdirs ()
195 case $keep_testdirs in
196 ""|n|no|NO) return 1;;
201 # This is used in 'Exit' and in the exit trap. See comments in the latter
202 # for more information,
205 # We use a trap below for cleanup. This requires us to go through
206 # hoops to get the right exit status transported through the signal.
207 # So use "Exit STATUS" instead of "exit STATUS" inside of the tests.
208 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
209 # sh inside this function.
213 # See comments in the exit trap for the reason we do this.
214 test 77 = $1 && am__test_skipped=yes
218 if test $am_using_tap = yes; then
219 am_funcs_file=tap-functions.sh
221 am_funcs_file=plain-functions.sh
224 if test -f "$am_testauxdir/$am_funcs_file"; then
225 . "$am_testauxdir/$am_funcs_file" || {
226 echo "$me: error sourcing $am_testauxdir/$am_funcs_file" >&2
230 echo "$me: $am_testauxdir/$am_funcs_file not found" >&2
237 # Tell whether we are cross-compiling. This is especially useful to skip
238 # tests (or portions of them) that requires a native compiler.
241 # Quoting from the autoconf manual:
242 # ... [$host_alias and $build both] default to the result of running
243 # config.guess, unless you specify either --build or --host. In
244 # this case, the default becomes the system type you specified.
245 # If you specify both, *and they're different*, configure enters
246 # cross compilation mode (so it doesn't run any tests that require
248 test x"$host_alias" != x && test x"$build_alias" != x"$host_alias"
251 # is_newest FILE FILES
252 # --------------------
253 # Return false if any file in FILES is newer than FILE.
254 # Resolve ties in favor of FILE.
257 is_newest_files=`find "$@" -prune -newer "$1"`
258 test -z "$is_newest_files"
261 # is_blocked_signal SIGNAL-NUMBER
262 # --------------------------------
263 # Return success if the given signal number is blocked in the shell,
264 # return a non-zero exit status and print a proper diagnostic otherwise.
267 # Use perl, since trying to do this portably in the shell can be
268 # very tricky, if not downright impossible. For reference, see:
269 # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
272 use warnings FATAL => "all";
274 my %oldsigaction = ();
275 sigaction('"$1"', 0, \%oldsigaction);
276 exit ($oldsigaction{"HANDLER"} eq "IGNORE" ? 0 : 77);
279 elif test $? -eq 77; then
282 fatal_ "couldn't determine whether signal $1 is blocked"
286 # AUTOMAKE_run [-e STATUS] [-d DESCRIPTION] [--] [AUTOMAKE-ARGS...]
287 # -----------------------------------------------------------------
288 # Run automake with AUTOMAKE-ARGS, and fail if it doesn't exit with
289 # STATUS. Should be polymorphic for TAP and "plain" tests. The
290 # DESCRIPTION, when provided, is used for console reporting, only if
291 # the TAP protocol is in use in the current test script.
296 while test $# -gt 0; do
298 -d) am__desc=$2; shift;;
299 -e) am__exp_rc=$2; shift;;
301 # Don't fail on unknown option: assume they (and the rest of the
302 # command line) are to be passed verbatim to automake (so stop our
303 # own option parsing).
309 $AUTOMAKE ${1+"$@"} >stdout 2>stderr || am__got_rc=$?
312 if test $am_using_tap != yes; then
313 test $am__got_rc -eq $am__exp_rc || Exit 1
316 if test -z "$am__desc"; then
317 if test $am__got_rc -eq $am__exp_rc; then
318 am__desc="automake exited $am__got_rc"
320 am__desc="automake exited $am__got_rc, expecting $am__exp_rc"
323 command_ok_ "$am__desc" test $am__got_rc -eq $am__exp_rc
326 # AUTOMAKE_fails [-d DESCRIPTION] [OPTIONS...]
327 # --------------------------------------------
328 # Run automake with OPTIONS, and fail if doesn't exit with status 1.
329 # Should be polymorphic for TAP and "plain" tests. The DESCRIPTION,
330 # when provided, is used for console reporting, only if the TAP
331 # protocol is in use in the current test script.
334 AUTOMAKE_run -e 1 ${1+"$@"}
337 # extract_configure_help { --OPTION | VARIABLE-NAME } [FILES]
338 # -----------------------------------------------------------
339 # Use this to extract from the output of "./configure --help" (or similar)
340 # the description or help message associated to the given --OPTION or
342 extract_configure_help ()
344 am__opt_re='' am__var_re=''
346 --*'=') am__opt_re="^ $1";;
347 --*'[=]') am__opt_re='^ '`printf '%s\n' "$1" | sed 's/...$//'`'\[=';;
348 --*) am__opt_re="^ $1( .*|$)";;
349 *) am__var_re="^ $1( .*|$)";;
352 if test x"$am__opt_re" != x; then
354 /'"$am__opt_re"'/ { print; do_print = 1; next; }
355 /^$/ { do_print = 0; next }
356 /^ --/ { do_print = 0; next }
357 (do_print == 1) { print }
361 /'"$am__var_re"'/ { print; do_print = 1; next; }
362 /^$/ { do_print = 0; next }
363 /^ [A-Z][A-Z0-9_]* / { do_print = 0; next }
364 /^ [A-Z][A-Z0-9_]*$/ { do_print = 0; next }
365 (do_print == 1) { print }
370 # grep_configure_help { --OPTION | VARIABLE-NAME } REGEXP
371 # -------------------------------------------------------
372 # Grep the section of "./configure --help" output associated with either
373 # --OPTION or VARIABLE-NAME for the given *extended* regular expression.
374 grep_configure_help ()
376 ./configure --help > am--all-help \
377 || { cat am--all-help; Exit 1; }
379 extract_configure_help "$1" am--all-help > am--our-help \
380 || { cat am--our-help; Exit 1; }
382 $EGREP "$2" am--our-help || Exit 1
387 # Return success if $MAKE is GNU make, return failure otherwise.
388 # Caches the result for speed reasons.
391 case $am__using_gmake in
397 # Use --version AND -v, because SGI Make doesn't fail on --version.
398 # Also grep for GNU because newer versions of FreeBSD make do
399 # not complain about --version (they seem to silently ignore it).
400 if $MAKE --version -v | grep GNU; then
408 fatal_ "invalid value for \$am__using_gmake: '$am__using_gmake'";;
411 am__using_gmake="" # Avoid interferences from the environment.
413 # make_can_chain_suffix_rules
414 # ---------------------------
415 # Return 0 if $MAKE is a make implementation that can chain suffix rules
416 # automatically, return 1 otherwise. Caches the result for speed reasons.
417 make_can_chain_suffix_rules ()
419 if test -z "$am__can_chain_suffix_rules"; then
421 am__can_chain_suffix_rules=yes
424 mkdir am__chain.dir$$
426 unindent > Makefile << 'END'
431 echo make can chain suffix rules > foo.u
432 if $MAKE foo.w && diff foo.u foo.w; then
433 am__can_chain_suffix_rules=yes
435 am__can_chain_suffix_rules=no
438 rm -rf am__chain.dir$$
441 case $am__can_chain_suffix_rules in
444 *) fatal_ "make_can_chain_suffix_rules: internal error";;
447 am__can_chain_suffix_rules="" # Avoid interferences from the environment.
449 # useless_vpath_rebuild
450 # ---------------------
451 # Tell whether $MAKE suffers of the bug triggering automake bug#7884.
452 # For example, this happens with FreeBSD make, since in a VPATH build
453 # it tends to rebuilt files for which there is an explicit or even just
454 # a suffix rule, even if said files are already available in the VPATH
456 useless_vpath_rebuild ()
458 if test -z "$am__useless_vpath_rebuild"; then
460 am__useless_vpath_rebuild=no
463 mkdir am__vpath.dir$$
465 touch foo.a foo.b bar baz
468 unindent > Makefile << 'END'
474 baz: bar ; cp ../baz bar
476 if $MAKE all && test ! -f foo.b && test ! -f bar; then
477 am__useless_vpath_rebuild=no
479 am__useless_vpath_rebuild=yes
482 rm -rf am__vpath.dir$$
484 case $am__useless_vpath_rebuild in
488 *) fatal_ "no_useless_builddir_remake: internal error";;
491 am__useless_vpath_rebuild=""
493 yl_distcheck () { useless_vpath_rebuild || $MAKE distcheck ${1+"$@"}; }
495 # seq_ - print a sequence of numbers
496 # ----------------------------------
497 # This function simulates GNU seq(1) portably. Valid usages:
500 # - seq FIRST INCREMENT LAST
504 0) fatal_ "seq_: missing argument";;
505 1) seq_first=1 seq_incr=1 seq_last=$1;;
506 2) seq_first=$1 seq_incr=1 seq_last=$2;;
507 3) seq_first=$1 seq_incr=$2 seq_last=$3;;
508 *) fatal_ "seq_: too many arguments";;
510 # Try to avoid forks if possible.
511 case "$BASH_VERSION" in
513 : Not bash, or a too old bash version. ;;
515 # Use eval to protect dumber shells from parsing errors.
516 eval 'for ((i = seq_first; i <= seq_last; i += seq_incr)); do
521 # Else, use GNU seq if available.
523 # Otherwise revert to a slower loop using expr(1).
525 while test $i -le $seq_last; do
527 i=`expr $i + $seq_incr`
531 # rm_rf_ [FILES OR DIRECTORIES ...]
532 # ---------------------------------
533 # Recursively remove the given files or directory, also handling the case
534 # of non-writable subdirectories.
537 test $# -gt 0 || return 0
538 # Ignore failures in find, we are only interested in failures of the
540 find "$@" -type d ! -perm -700 -exec chmod u+rwx {} \; || :
544 # count_test_results total=N pass=N fail=N xpass=N xfail=N skip=N error=N
545 # -----------------------------------------------------------------------
546 # Check that a testsuite run driven by the parallel-tests harness has
547 # had the specified numbers of test results (specified by kind).
548 # This function assumes that the output of "make check" or "make recheck"
549 # has been saved in the 'stdout' file in the current directory, and its
550 # log in the 'test-suite.log' file.
551 count_test_results ()
553 # Use a subshell so that we won't pollute the script namespace.
555 # TODO: Do proper checks on the arguments?
556 total=ERR pass=ERR fail=ERR xpass=ERR xfail=ERR skip=ERR error=ERR
559 $EGREP -i '(total|x?pass|x?fail|skip|error)' stdout || :
561 # Avoid spurious failures with shells with "overly sensible"
562 # errexit shell flag, such as e.g., Solaris /bin/sh.
564 test `grep -c '^PASS:' stdout` -eq $pass || rc=1
565 test `grep -c '^XFAIL:' stdout` -eq $xfail || rc=1
566 test `grep -c '^SKIP:' stdout` -eq $skip || rc=1
567 test `grep -c '^FAIL:' stdout` -eq $fail || rc=1
568 test `grep -c '^XPASS:' stdout` -eq $xpass || rc=1
569 test `grep -c '^ERROR:' stdout` -eq $error || rc=1
570 grep "^# TOTAL: *$total$" stdout || rc=1
571 grep "^# PASS: *$pass$" stdout || rc=1
572 grep "^# XFAIL: *$xfail$" stdout || rc=1
573 grep "^# SKIP: *$skip$" stdout || rc=1
574 grep "^# FAIL: *$fail$" stdout || rc=1
575 grep "^# XPASS: *$xpass$" stdout || rc=1
576 grep "^# ERROR: *$error$" stdout || rc=1
581 commented_sed_unindent_prog='
582 /^$/b # Nothing to do for empty lines.
583 x # Get x<indent> into pattern space.
584 /^$/{ # No prior x<indent>, go prepare it.
585 g # Copy this 1st non-blank line into pattern space.
586 s/^\(['"$tab"' ]*\).*/x\1/ # Prepare x<indent> in pattern space.
587 } # Now: x<indent> in pattern and <line> in hold.
588 G # Build x<indent>\n<line> in pattern space, and
589 h # duplicate it into hold space.
590 s/\n.*$// # Restore x<indent> in pattern space, and
591 x # exchange with the above duplicate in hold space.
592 s/^x\(.*\)\n\1// # Remove leading <indent> from <line>.
593 s/^x.*\n// # Restore <line> when there is no leading <indent>.
596 # unindent [input files...]
597 # -------------------------
598 # Remove the "proper" amount of leading whitespace from the given files,
599 # and output the result on stdout. That amount is determined by looking
600 # at the leading whitespace of the first non-blank line in the input
601 # files. If no input file is specified, standard input is implied.
604 if test x"$sed_unindent_prog" = x; then
605 sed_unindent_prog=`printf '%s\n' "$commented_sed_unindent_prog" | sed -e "s/ *# .*//"`
607 sed "$sed_unindent_prog" ${1+"$@"}
609 sed_unindent_prog="" # Avoid interferences from the environment.
611 # get_shell_script SCRIPT-NAME
612 # -----------------------------
613 # Fetch an Automake-provided shell script from the 'lib/' directory into
614 # the current directory, and, if the '$am_test_prefer_config_shell'
615 # variable is set to "yes", modify its shebang line to use $SHELL instead
619 test ! -f "$1" || rm -f "$1" || return 99
620 if test x"$am_test_prefer_config_shell" = x"yes"; then
621 sed "1s|#!.*|#! $SHELL|" "$am_scriptdir/$1" > "$1" \
625 cp -f "$am_scriptdir/$1" . || return 99
627 sed 10q "$1" # For debugging.
632 # Skip the test if the given shell fails to support common XSI constructs.
635 test $# -eq 1 || fatal_ "require_xsi needs exactly one argument"
636 echo "$me: trying some XSI constructs with $1"
637 $1 -c "$xsi_shell_code" || skip_all_ "$1 lacks XSI features"
639 # Shell code supposed to work only with XSI shells. Keep this in sync
640 # with libtool.m4:_LT_CHECK_SHELL_FEATURES.
643 test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
645 && eval '\''test $(( 1 + 1 )) -eq 2 \
646 && test "${#_lt_dummy}" -eq 5'\'
650 # Fetch the Automake-provided TAP driver from the 'lib/' directory into
651 # the current directory, and edit its shebang line so that it will be
652 # run with the perl interpreter determined at configure time.
655 # TODO: we should devise a way to make the shell TAP driver tested also
656 # TODO: with /bin/sh, for better coverage.
657 case $am_tap_implementation in
659 $PERL -MTAP::Parser -e 1 \
660 || skip_all_ "cannot import TAP::Parser perl module"
661 sed "1s|#!.*|#! $PERL -w|" "$am_scriptdir"/tap-driver.pl >tap-driver
664 AM_TAP_AWK=$AWK; export AM_TAP_AWK
665 sed "1s|#!.*|#! $SHELL|" "$am_scriptdir"/tap-driver.sh >tap-driver
668 fatal_ "invalid \$am_tap_implementation '$am_tap_implementation'" ;;
670 && chmod a+x tap-driver \
671 || framework_failure_ "couldn't fetch $am_tap_implementation TAP driver"
672 sed 10q tap-driver # For debugging.
674 # The shell/awk implementation of the TAP driver is still mostly dummy, so
675 # use the perl implementation by default for the moment.
676 am_tap_implementation=${am_tap_implementation-shell}
678 # Usage: require_compiler_ {cc|c++|fortran|fortran77}
682 0) fatal_ "require_compiler_: missing argument";;
684 *) fatal_ "require_compiler_: too many arguments";;
690 am__comp_flag_vars='CFLAGS CPPFLAGS'
695 am__comp_flag_vars='CXXFLAGS CPPFLAGS'
698 am__comp_lang="Fortran"
700 am__comp_flag_vars='FCFLAGS'
703 am__comp_lang="Fortran 77"
705 am__comp_flag_vars='FFLAGS'
709 eval "am__comp_prog=\${$am__comp_var}" \
710 || fatal_ "expanding \${$am__comp_var} in require_compiler_"
711 case $am__comp_prog in
713 fatal_ "botched configuration: \$$am__comp_var is empty";;
715 skip_all_ "no $am__comp_lang compiler available";;
716 autodetect|autodetected)
717 # Let the ./configure commands in the test script try to determine
718 # these automatically.
719 unset $am__comp_var $am__comp_flag_vars;;
721 # Pre-set these for the ./configure commands in the test script.
722 export $am__comp_var $am__comp_flag_vars;;
724 # Delete private variables.
725 unset am__comp_lang am__comp_prog am__comp_var am__comp_flag_vars
728 ## ----------------------------------------------------------- ##
729 ## Checks for required tools, and additional setups (if any) ##
730 ## required by them. ##
731 ## ----------------------------------------------------------- ##
733 # Performance tests must be enabled explicitly.
736 case $AM_TESTSUITE_PERF in
738 *) skip_ "performance tests not explicitly enabled" ;;
743 # Look for (and maybe set up) required tools and/or system features; skip
744 # the current test if they are not found.
745 for tool in : $required
747 # Check that each required tool is present.
750 cc|c++|fortran|fortran77)
751 require_compiler_ $tool;;
753 if test x"$am_test_prefer_config_shell" = x"yes"; then
756 require_xsi "/bin/sh"
760 # Do not use --version, older versions bzip2 still tries to compress
762 echo "$me: running bzip2 --help"
764 || skip_all_ "required program 'bzip2' not available"
768 # Don't export CFLAGS, as that could have been initialized to only
769 # work with the C compiler detected at configure time. If the user
770 # wants CFLAGS to also influence 'cl', he can still export CFLAGS
771 # in the environment "by hand" before calling the testsuite.
773 echo "$me: running $CC -?"
774 $CC -? || skip_all_ "Microsoft C compiler '$CC' not available"
777 # Exuberant Ctags will create a TAGS file even
778 # when asked for --help or --version. (Emacs's etags
779 # does not have such problem.) Use -o /dev/null
780 # to make sure we do not pollute the build directory.
781 echo "$me: running etags --version -o /dev/null"
782 etags --version -o /dev/null \
783 || skip_all_ "required program 'etags' not available"
786 for make_ in "$MAKE" gmake gnumake :; do
787 MAKE=$make_ am__using_gmake=''
788 test "$MAKE" = : && break
789 echo "$me: determine whether $MAKE is GNU make"
790 # Don't use "&&" here, or a bug of 'set -e' present in some
791 # versions of the BSD shell will be triggered. We add the
792 # dummy "else" branch for extra safety.
793 if using_gmake; then break; else :; fi
795 test "$MAKE" = : && skip_all_ "this test requires GNU make"
800 GCJ=$GNU_GCJ GCJFLAGS=$GNU_GCJFLAGS; export GCJ GCJFLAGS
801 test "$GCJ" = false && skip_all_ "GNU Java compiler unavailable"
802 : For shells with busted 'set -e'.
805 CC=$GNU_CC CFLAGS=$GNU_CFLAGS; export CC CFLAGS CPPFLAGS
806 test "$CC" = false && skip_all_ "GNU C compiler unavailable"
807 : For shells with busted 'set -e'.
810 CXX=$GNU_CXX CXXFLAGS=$GNU_CXXFLAGS; export CXX CXXFLAGS CPPFLAGS
811 test "$CXX" = false && skip_all_ "GNU C++ compiler unavailable"
812 : For shells with busted 'set -e'.
815 FC=$GNU_FC FCFLAGS=$GNU_FCFLAGS; export FC FCFLAGS
816 test "$FC" = false && skip_all_ "GNU Fortran compiler unavailable"
817 case " $required " in
819 *) F77=$FC FFLAGS=$FCFLAGS; export F77 FFLAGS;;
823 F77=$GNU_F77 FFLAGS=$GNU_FFLAGS; export F77 FFLAGS
824 test "$F77" = false && skip_all_ "GNU Fortran 77 compiler unavailable"
825 case " $required " in
827 *) FC=$F77 FCFLAGS=$FFLAGS; export FC FCFLAGS;;
831 # The Java compiler from JDK 1.5 (and presumably earlier versions)
832 # cannot handle the '-version' option by itself: it bails out
833 # telling that source files are missing. Adding also the '-help'
834 # option seems to solve the problem.
835 echo "$me: running javac -version -help"
836 javac -version -help || skip_all_ "Sun Java compiler not available"
839 # See the comments above about 'javac' for why we use also '-help'.
840 echo "$me: running java -version -help"
841 java -version -help || skip_all_ "Sun Java interpreter not found"
846 # Attempting to create an empty archive will actually not
847 # create the archive, but lib will output its version.
848 echo "$me: running $AR -out:defstest.lib"
849 $AR -out:defstest.lib \
850 || skip_all_ "Microsoft 'lib' utility not available"
853 echo "$me: running makedepend -f-"
855 || skip_all_ "required program 'makedepend' not available"
858 # Make sure we have makeinfo, and it understands '--html'.
859 echo "$me: running makeinfo --html --version"
860 makeinfo --html --version \
861 || skip_all_ "cannot find a makeinfo program that groks" \
862 "the '--html' option"
865 uname_s=`uname -s || echo UNKNOWN`
866 echo "$me: system name: $uname_s"
869 *) skip_all_ "this test requires MSYS in MinGW mode" ;;
873 # Skip this test case if the user is root.
874 # We try to append to a read-only file to detect this.
875 priv_check_temp=priv-check.$$
876 touch $priv_check_temp && chmod a-w $priv_check_temp \
877 || framework_failure_ "creating unwritable file $priv_check_temp"
878 # Not a useless use of subshell: lesser shells like Solaris /bin/sh
879 # can exit if a builtin fails.
881 (echo foo >> $priv_check_temp) || overwrite_status=$?
882 rm -f $priv_check_temp
883 if test $overwrite_status -eq 0; then
884 skip_all_ "cannot drop file write permissions"
886 unset priv_check_temp overwrite_status
889 if test "$WANT_NO_THREADS" = "yes"; then
890 skip_all_ "Devel::Cover cannot cope with threads"
894 # Don't use "&&" here, to avoid a bug of 'set -e' present in
895 # some (even relatively recent) versions of the BSD shell.
896 # We add the dummy "else" branch for extra safety.
897 if cross_compiling; then
898 skip_all_ "doesn't work in cross-compile mode"
902 # Python doesn't support --version, it has -V
903 echo "$me: running python -V"
904 python -V || skip_all_ "python interpreter not available"
907 # Skip this test case if read-only directories aren't supported
909 ro_dir_temp=ro_dir.$$
910 mkdir $ro_dir_temp && chmod a-w $ro_dir_temp \
911 || framework_failure_ "creating unwritable directory $ro_dir_temp"
912 # Not a useless use of subshell: lesser shells like Solaris /bin/sh
913 # can exit if a builtin fails.
915 (: > $ro_dir_temp/probe) || create_status=$?
917 if test $create_status -eq 0; then
918 skip_all_ "cannot drop directory write permissions"
920 unset ro_dir_temp create_status
923 # DejaGnu's runtest program. We rely on being able to specify
924 # the program on the runtest command-line. This requires
925 # DejaGnu 1.4.3 or later.
926 echo "$me: running runtest SOMEPROGRAM=someprogram --version"
927 runtest SOMEPROGRAM=someprogram --version \
928 || skip_all_ "DejaGnu is not available"
931 # No all versions of Tex support '--version', so we use
933 if test -z "$TEX"; then
934 skip_all_ "TeX is required, but it wasn't found by configure"
938 # Texi2dvi supports '-o' since Texinfo 4.1.
939 echo "$me: running texi2dvi -o /dev/null --version"
940 texi2dvi -o /dev/null --version \
941 || skip_all_ "required program 'texi2dvi' not available"
944 test x"$LEX" = x"false" && skip_all_ "lex not found or disabled"
948 test x"$YACC" = x"false" && skip_all_ "yacc not found or disabled"
953 echo "$me: running flex --version"
954 flex --version || skip_all_ "required program 'flex' not available"
957 YACC='bison -y'; export YACC
958 echo "$me: running bison --version"
959 bison --version || skip_all_ "required program 'bison' not available"
962 # Generic case: the tool must support --version.
963 echo "$me: running $tool --version"
964 # It is not likely but possible that $tool is a special builtin,
965 # in which case the shell is allowed to exit after an error. So
966 # we need the subshell here. Also, some tools, like Sun cscope,
967 # can be interactive without redirection.
968 ($tool --version) </dev/null \
969 || skip_all_ "required program '$tool' not available"
974 # Using just $am_top_builddir for the check here is ok, since the
975 # further temporary subdirectory where the test will be run is
976 # ensured not to contain any whitespace character.
977 case $am_top_builddir in
979 case " $required " in
980 *' libtool '* | *' libtoolize '* )
981 skip_all_ "libtool has problems with spaces in builddir name";;
986 # This test is necessary, although Automake's configure script bails out
987 # when $srcdir contains spaces. This is because $am_top_srcdir is in not
988 # configure-time $srcdir, but is instead configure-time $abs_srcdir, and
989 # that is allowed to contain spaces.
990 case $am_top_srcdir in
992 case " $required " in
993 *' libtool '* | *' libtoolize '* | *' gettext '* )
994 skip_all_ "spaces in srcdir name: libtool/gettext tests won't work";;
999 # We might need extra macros, e.g., from Libtool or Gettext.
1000 case " $required " in *\ libtool*) . ./t/libtool-macros.dir/get.sh;; esac
1001 case " $required " in *\ gettext*) . ./t/gettext-macros.dir/get.sh;; esac
1004 ## ---------------------------------------------------------------- ##
1005 ## Create and set up of the temporary directory used by the test. ##
1006 ## Set up of the exit trap for cleanup of said directory. ##
1007 ## ---------------------------------------------------------------- ##
1009 # This might be used in testcases checking distribution-related features.
1010 # Test scripts are free to override this if they need to.
1013 # Set up the exit trap.
1014 trap 'exit_status=$?
1016 cd "$am_top_builddir"
1017 if test $am_using_tap = yes; then
1018 if test "$planned_" = later && test $exit_status -eq 0; then
1021 test $exit_status -eq 0 && test $tap_pass_count_ -eq $tap_count_ \
1022 || keep_testdirs=yes
1024 # This is to ensure that a test script does give a SKIP outcome just
1025 # because a command in it happens to exit with status 77. This
1026 # behaviour, while from time to time useful to developers, is not
1027 # meant to be enabled by default, as it could cause spurious failures
1028 # in the wild. Thus it will be enabled only when the variable
1029 # "am_explicit_skips" is set to a "true" value.
1030 case $am_explicit_skips in
1032 if test $exit_status -eq 77 && test $am__test_skipped != yes; then
1033 echo "$me: implicit skip turned into failure"
1037 test $exit_status -eq 0 || keep_testdirs=yes
1039 am_keeping_testdirs || rm_rf_ $testSubDir
1041 echo "$me: exit $exit_status"
1044 trap "fatal_ 'caught signal SIGHUP'" 1
1045 trap "fatal_ 'caught signal SIGINT'" 2
1046 trap "fatal_ 'caught signal SIGTERM'" 15
1047 # Various shells seems to just ignore SIGQUIT under some circumstances,
1048 # even if the signal is not blocked; however, if the signal it trapped,
1049 # the trap gets correctly executed. So we also trap SIGQUIT.
1050 # Here is a list of some shells that have been verified to exhibit the
1051 # problematic behavior with SIGQUIT:
1052 # - zsh 4.3.12 on Debian GNU/Linux
1053 # - /bin/ksh and /usr/xpg4/bin/sh on Solaris 10
1054 # - Bash 3.2.51 on Solaris 10 and bash 4.1.5 on Debian GNU/Linux
1055 # - AT&T ksh on Debian Gnu/Linux (deb package ksh, version 93u-1)
1056 # OTOH, at least these shells that do *not* exhibit that behaviour:
1057 # - modern version of the Almquist Shell (at least 0.5.5.1), on
1058 # both Solaris and GNU/Linux
1059 # - Solaris 10 /bin/sh
1060 # - public domain Korn Shell, version 5.2.14, on Debian GNU/Linux
1061 trap "fatal_ 'caught signal SIGQUIT'" 3
1062 # Ignore further SIGPIPE in the trap code. This is required to avoid
1063 # a very weird issue with some shells, at least when the execution of
1064 # the automake testsuite is driven by the 'prove' utility: if prove
1065 # (or the make process that has spawned it) gets interrupted with
1066 # Ctrl-C, the shell might go in a loop, continually getting a SIGPIPE,
1067 # sometimes finally dumping core, other times hanging indefinitely.
1068 # See also Test::Harness bug [rt.cpan.org #70855], archived at
1069 # <https://rt.cpan.org/Ticket/Display.html?id=70855>
1070 trap "trap '' 13; fatal_ 'caught signal SIGPIPE'" 13
1072 # Create and populate the temporary directory, if and as required.
1073 if test x"$am_create_testdir" = x"no"; then
1076 # The subdirectory where the current test script will run and write its
1077 # temporary/data files. This will be created shortly, and will be removed
1078 # by the cleanup trap below if the test passes. If the test doesn't pass,
1079 # this directory will be kept, to facilitate debugging.
1080 testSubDir=t/$me.dir
1081 test ! -d $testSubDir || rm_rf_ $testSubDir \
1082 || framework_failure_ "removing old test subdirectory"
1083 test -d t || mkdir t
1085 || framework_failure_ "creating test subdirectory"
1086 # The trailing './'ris to avoid CDPATH issues.
1088 || framework_failure_ "cannot chdir into test subdirectory"
1089 if test x"$am_create_testdir" != x"empty"; then
1090 cp "$am_scriptdir"/install-sh "$am_scriptdir"/missing \
1091 "$am_scriptdir"/depcomp . \
1092 || framework_failure_ "fetching common files from $am_scriptdir"
1093 # Build appropriate environment in test directory. E.g., create
1094 # configure.ac, touch all necessary files, etc. Don't use AC_OUTPUT,
1095 # but AC_CONFIG_FILES so that appending still produces a valid
1096 # configure.ac. But then, tests running config.status really need
1097 # to append AC_OUTPUT.
1099 echo "AC_INIT([$me], [1.0])"
1100 if test x"$am_serial_tests" = x"yes"; then
1101 echo "AM_INIT_AUTOMAKE([serial-tests])"
1103 echo "AM_INIT_AUTOMAKE"
1105 echo "AC_CONFIG_FILES([Makefile])"
1106 } >configure.ac || framework_failure_ "creating configure.ac skeleton"
1111 ## ---------------- ##
1112 ## Ready to go... ##
1113 ## ---------------- ##