Merge branch 'maint'
[platform/upstream/automake.git] / t / ax / test-init.sh
1 # -*- shell-script -*-
2 #
3 # Copyright (C) 1996-2012 Free Software Foundation, Inc.
4 #
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)
8 # any later version.
9 #
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.
14 #
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/>.
17
18 ########################################################
19 ###  IMPORTANT NOTE: keep this file 'set -e' clean.  ###
20 ########################################################
21
22 # Enable the errexit shell flag early.
23 set -e
24
25 # The name of the current test (without the '.sh' or '.tap' suffix).
26 # Test scripts can override it if they need to (but this should
27 # be done carefully).
28 if test -z "$me"; then
29   # Strip all directory components.
30   me=${argv0##*/}
31   # Strip test suffix.
32   case $me in
33     *.tap) me=${me%.tap};;
34      *.sh) me=${me%.sh} ;;
35   esac
36 fi
37
38
39 ## --------------------- ##
40 ##  Early sanity checks. ##
41 ## --------------------- ##
42
43 # Ensure $am_top_srcdir is set correctly.
44 test -f "$am_top_srcdir/defs-static.in" || {
45    echo "$me: $am_top_srcdir/defs-static.in not found," \
46         "check \$am_top_srcdir" >&2
47    exit 99
48 }
49
50 # Ensure $am_top_builddir is set correctly.
51 test -f "$am_top_builddir/defs-static" || {
52    echo "$me: $am_top_builddir/defs-static not found," \
53         "check \$am_top_builddir" >&2
54    exit 99
55 }
56
57
58 ## ------------------ ##
59 ##  Early variables.  ##
60 ## ------------------ ##
61
62 # A single whitespace character.
63 sp=' '
64 # A tabulation character.
65 tab='   '
66 # A newline character.
67 nl='
68 '
69 # A literal escape character.  Used by test checking colored output.
70 esc='\e'
71
72 # As autoconf-generated configure scripts do, ensure that IFS
73 # is defined initially, so that saving and restoring $IFS works.
74 IFS=$sp$tab$nl
75
76
77 ## ----------------------- ##
78 ##  Early debugging info.  ##
79 ## ----------------------- ##
80
81 echo "Running from installcheck: $am_running_installcheck"
82 echo "Using TAP: $am_using_tap"
83 echo "PATH = $PATH"
84
85
86 ## ---------------------- ##
87 ##  Environment cleanup.  ##
88 ## ---------------------- ##
89
90 # Temporarily disable this, since some shells (e.g., older version
91 # of Bash) can return a non-zero exit status upon the when a non-set
92 # variable is unset.
93 set +e
94
95 # Unset some make-related variables that may cause $MAKE to act like
96 # a recursively invoked sub-make.  Any $MAKE invocation in a test is
97 # conceptually an independent invocation, not part of the main
98 # 'automake' build.
99 unset MFLAGS MAKEFLAGS AM_MAKEFLAGS MAKELEVEL
100 unset __MKLVL__ MAKE_JOBS_FIFO                     # For BSD make.
101 unset DMAKE_CHILD DMAKE_DEF_PRINTED DMAKE_MAX_JOBS # For Solaris dmake.
102 # Unset verbosity flag.
103 unset V
104 # Also unset variables that will let "make -e install" divert
105 # files into unwanted directories.
106 unset DESTDIR
107 unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
108 unset htmldir includedir infodir libdir libexecdir localedir mandir
109 unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
110 # Unset variables that might change the "make distcheck" behaviour.
111 unset DISTCHECK_CONFIGURE_FLAGS AM_DISTCHECK_CONFIGURE_FLAGS
112 # Used by install rules for info files.
113 unset AM_UPDATE_INFO_DIR
114 # The tests call "make -e" but we do not want $srcdir from the environment
115 # to override the definition from the Makefile.
116 unset srcdir
117 # Also unset variables that control our test driver.  While not
118 # conceptually independent, they cause some changed semantics we
119 # need to control (and test for) in some of the tests to ensure
120 # backward-compatible behavior.
121 unset TESTS_ENVIRONMENT AM_TESTS_ENVIRONMENT
122 unset DISABLE_HARD_ERRORS
123 unset AM_COLOR_TESTS
124 unset TESTS
125 unset XFAIL_TESTS
126 unset TEST_LOGS
127 unset TEST_SUITE_LOG
128 unset RECHECK_LOGS
129 unset VERBOSE
130 for pfx in TEST_ SH_ TAP_ ''; do
131   unset ${pfx}LOG_COMPILER
132   unset ${pfx}LOG_COMPILE # Not a typo!
133   unset ${pfx}LOG_FLAGS
134   unset AM_${pfx}LOG_FLAGS
135   unset ${pfx}LOG_DRIVER
136   unset ${pfx}LOG_DRIVER_FLAGS
137   unset AM_${pfx}LOG_DRIVER_FLAGS
138 done
139 unset pfx
140
141 # Re-enable, it had been temporarily disabled above.
142 set -e
143
144 ## ---------------------------- ##
145 ##  Auxiliary shell functions.  ##
146 ## ---------------------------- ##
147
148 # Tell whether we should keep the test directories around, even in
149 # case of success.  By default, we don't.
150 am_keeping_testdirs ()
151 {
152   case $keep_testdirs in
153      ""|n|no|NO) return 1;;
154               *) return 0;;
155   esac
156 }
157
158 # This is used in 'Exit' and in the exit trap.  See comments in the latter
159 # for more information,
160 am__test_skipped=no
161
162 # We use a trap below for cleanup.  This requires us to go through
163 # hoops to get the right exit status transported through the signal.
164 # So use "Exit STATUS" instead of "exit STATUS" inside of the tests.
165 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
166 # sh inside this function.
167 Exit ()
168 {
169   set +e
170   # See comments in the exit trap for the reason we do this.
171   test 77 = $1 && am__test_skipped=yes
172   (exit $1); exit $1
173 }
174
175 if test $am_using_tap = yes; then
176   am_funcs_file=tap-functions.sh
177 else
178   am_funcs_file=plain-functions.sh
179 fi
180
181 if test -f "$am_testauxdir/$am_funcs_file"; then
182   . "$am_testauxdir/$am_funcs_file" || {
183     echo "$me: error sourcing $am_testauxdir/$am_funcs_file" >&2
184     Exit 99
185   }
186 else
187   echo "$me: $am_testauxdir/$am_funcs_file not found" >&2
188   Exit 99
189 fi
190 unset am_funcs_file
191
192 # cross_compiling
193 # ---------------
194 # Tell whether we are cross-compiling.  This is especially useful to skip
195 # tests (or portions of them) that requires a native compiler.
196 cross_compiling ()
197 {
198   # Quoting from the autoconf manual:
199   #   ... [$host_alias and $build both] default to the result of running
200   #   config.guess, unless you specify either --build or --host.  In
201   #   this case, the default becomes the system type you specified.
202   #   If you specify both, *and they're different*, configure enters
203   #   cross compilation mode (so it doesn't run any tests that require
204   #   execution).
205   test x"$host_alias" != x && test x"$build_alias" != x"$host_alias"
206 }
207
208 # is_blocked_signal SIGNAL-NUMBER
209 # --------------------------------
210 # Return success if the given signal number is blocked in the shell,
211 # return a non-zero exit status and print a proper diagnostic otherwise.
212 is_blocked_signal ()
213 {
214   # Use perl, since trying to do this portably in the shell can be
215   # very tricky, if not downright impossible.  For reference, see:
216   # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
217   if $PERL -w -e '
218     use strict;
219     use warnings FATAL => "all";
220     use POSIX;
221     my %oldsigaction = ();
222     sigaction('"$1"', 0, \%oldsigaction);
223     exit ($oldsigaction{"HANDLER"} eq "IGNORE" ? 0 : 77);
224   '; then
225     return 0
226   elif test $? -eq 77; then
227     return 1
228   else
229     fatal_ "couldn't determine whether signal $1 is blocked"
230   fi
231 }
232
233 # AUTOMAKE_run [-e STATUS] [-d DESCRIPTION] [--] [AUTOMAKE-ARGS...]
234 # -----------------------------------------------------------------
235 # Run automake with AUTOMAKE-ARGS, and fail if it doesn't exit with
236 # STATUS.  Should be polymorphic for TAP and "plain" tests.  The
237 # DESCRIPTION, when provided, is used for console reporting, only if
238 # the TAP protocol is in use in the current test script.
239 AUTOMAKE_run ()
240 {
241   am__desc=
242   am__exp_rc=0
243   while test $# -gt 0; do
244     case $1 in
245       -d) am__desc=$2; shift;;
246       -e) am__exp_rc=$2; shift;;
247       --) shift; break;;
248        # Don't fail on unknown option: assume they (and the rest of the
249        # command line) are to be passed verbatim to automake (so stop our
250        # own option parsing).
251        *) break;;
252     esac
253     shift
254   done
255   am__got_rc=0
256   $AUTOMAKE ${1+"$@"} >stdout 2>stderr || am__got_rc=$?
257   cat stderr >&2
258   cat stdout
259   if test $am_using_tap != yes; then
260     test $am__got_rc -eq $am__exp_rc || Exit 1
261     return
262   fi
263   if test -z "$am__desc"; then
264     if test $am__got_rc -eq $am__exp_rc; then
265       am__desc="automake exited $am__got_rc"
266     else
267       am__desc="automake exited $am__got_rc, expecting $am__exp_rc"
268     fi
269   fi
270   command_ok_ "$am__desc" test $am__got_rc -eq $am__exp_rc
271 }
272
273 # AUTOMAKE_fails [-d DESCRIPTION] [OPTIONS...]
274 # --------------------------------------------
275 # Run automake with OPTIONS, and fail if doesn't exit with status 1.
276 # Should be polymorphic for TAP and "plain" tests.  The DESCRIPTION,
277 # when provided, is used for console reporting, only if the TAP
278 # protocol is in use in the current test script.
279 AUTOMAKE_fails ()
280 {
281   AUTOMAKE_run -e 1 ${1+"$@"}
282 }
283
284 # extract_configure_help { --OPTION | VARIABLE-NAME } [FILES]
285 # -----------------------------------------------------------
286 # Use this to extract from the output of "./configure --help" (or similar)
287 # the description or help message associated to the given --OPTION or
288 # VARIABLE-NAME.
289 extract_configure_help ()
290 {
291   am__opt_re='' am__var_re=''
292   case $1 in
293     --*'=')   am__opt_re="^  $1";;
294     --*'[=]') am__opt_re='^  '$(printf '%s\n' "$1" | sed 's/...$//')'\[=';;
295     --*)      am__opt_re="^  $1( .*|$)";;
296       *)      am__var_re="^  $1( .*|$)";;
297   esac
298   shift
299   if test x"$am__opt_re" != x; then
300     LC_ALL=C awk '
301       /'"$am__opt_re"'/        { print; do_print = 1; next; }
302       /^$/                     { do_print = 0; next }
303       /^  --/                  { do_print = 0; next }
304       (do_print == 1)          { print }
305     ' ${1+"$@"}
306   else
307     LC_ALL=C awk '
308       /'"$am__var_re"'/        { print; do_print = 1; next; }
309       /^$/                     { do_print = 0; next }
310       /^  [A-Z][A-Z0-9_]* /    { do_print = 0; next }
311       /^  [A-Z][A-Z0-9_]*$/    { do_print = 0; next }
312       (do_print == 1)          { print }
313     ' ${1+"$@"}
314   fi
315 }
316
317 # grep_configure_help { --OPTION | VARIABLE-NAME } REGEXP
318 # -------------------------------------------------------
319 # Grep the section of "./configure --help" output associated with either
320 # --OPTION or VARIABLE-NAME for the given *extended* regular expression.
321 grep_configure_help ()
322 {
323   ./configure --help > am--all-help \
324     || { cat am--all-help; Exit 1; }
325   cat am--all-help
326   extract_configure_help "$1" am--all-help > am--our-help \
327     || { cat am--our-help; Exit 1; }
328   cat am--our-help
329   $EGREP "$2" am--our-help || Exit 1
330 }
331
332 # using_gmake
333 # -----------
334 # Return success if $MAKE is GNU make, return failure otherwise.
335 # Caches the result for speed reasons.
336 using_gmake ()
337 {
338   case $am__using_gmake in
339     yes)
340       return 0;;
341     no)
342       return 1;;
343     '')
344       # Use --version AND -v, because SGI Make doesn't fail on --version.
345       # Also grep for GNU because newer versions of FreeBSD make do
346       # not complain about --version (they seem to silently ignore it).
347       if $MAKE --version -v | grep GNU; then
348         am__using_gmake=yes
349         return 0
350       else
351         am__using_gmake=no
352         return 1
353       fi;;
354     *)
355       fatal_ "invalid value for \$am__using_gmake: '$am__using_gmake'";;
356   esac
357 }
358 am__using_gmake="" # Avoid interferences from the environment.
359
360 # make_can_chain_suffix_rules
361 # ---------------------------
362 # Return 0 if $MAKE is a make implementation that can chain suffix rules
363 # automatically, return 1 otherwise.  Caches the result for speed reasons.
364 make_can_chain_suffix_rules ()
365 {
366   if test -z "$am__can_chain_suffix_rules"; then
367     if using_gmake; then
368       am__can_chain_suffix_rules=yes
369       return 0
370     else
371       mkdir am__chain.dir$$
372       cd am__chain.dir$$
373       unindent > Makefile << 'END'
374         .SUFFIXES: .u .v .w
375         .u.v: ; cp $< $@
376         .v.w: ; cp $< $@
377 END
378       echo make can chain suffix rules > foo.u
379       if $MAKE foo.w && diff foo.u foo.w; then
380         am__can_chain_suffix_rules=yes
381       else
382         am__can_chain_suffix_rules=no
383       fi
384       cd ..
385       rm -rf am__chain.dir$$
386     fi
387   fi
388   case $am__can_chain_suffix_rules in
389     yes) return 0;;
390      no) return 1;;
391       *) fatal_ "make_can_chain_suffix_rules: internal error";;
392   esac
393 }
394 am__can_chain_suffix_rules="" # Avoid interferences from the environment.
395
396 # useless_vpath_rebuild
397 # ---------------------
398 # Tell whether $MAKE suffers of the bug triggering automake bug#7884.
399 # For example, this happens with FreeBSD make, since in a VPATH build
400 # it tends to rebuilt files for which there is an explicit or even just
401 # a suffix rule, even if said files are already available in the VPATH
402 # directory.
403 useless_vpath_rebuild ()
404 {
405   if test -z "$am__useless_vpath_rebuild"; then
406     if using_gmake; then
407       am__useless_vpath_rebuild=no
408       return 1
409     fi
410     mkdir am__vpath.dir$$
411     cd am__vpath.dir$$
412     touch foo.a foo.b bar baz
413     mkdir build
414     cd build
415     unindent > Makefile << 'END'
416         .SUFFIXES: .a .b
417         VPATH = ..
418         all: foo.b baz
419         .PHONY: all
420         .a.b: ; cp $< $@
421         baz: bar ; cp ../baz bar
422 END
423     if $MAKE all && test ! -f foo.b && test ! -f bar; then
424       am__useless_vpath_rebuild=no
425     else
426       am__useless_vpath_rebuild=yes
427     fi
428     cd ../..
429     rm -rf am__vpath.dir$$
430   fi
431   case $am__useless_vpath_rebuild in
432     yes) return 0;;
433      no) return 1;;
434      "") ;;
435       *) fatal_ "no_useless_builddir_remake: internal error";;
436   esac
437 }
438 am__useless_vpath_rebuild=""
439
440 yl_distcheck () { useless_vpath_rebuild || $MAKE distcheck ${1+"$@"}; }
441
442 # seq_ - print a sequence of numbers
443 # ----------------------------------
444 # This function simulates GNU seq(1) portably.  Valid usages:
445 #  - seq LAST
446 #  - seq FIRST LAST
447 #  - seq FIRST INCREMENT LAST
448 seq_ ()
449 {
450   case $# in
451     0) fatal_ "seq_: missing argument";;
452     1) seq_first=1  seq_incr=1  seq_last=$1;;
453     2) seq_first=$1 seq_incr=1  seq_last=$2;;
454     3) seq_first=$1 seq_incr=$2 seq_last=$3;;
455     *) fatal_ "seq_: too many arguments";;
456   esac
457   i=$seq_first
458   while test $i -le $seq_last; do
459     echo $i
460     i=$(($i + $seq_incr))
461   done
462 }
463
464 # rm_rf_ [FILES OR DIRECTORIES ...]
465 # ---------------------------------
466 # Recursively remove the given files or directory, also handling the case
467 # of non-writable subdirectories.
468 rm_rf_ ()
469 {
470   test $# -gt 0 || return 0
471   # Ignore failures in find, we are only interested in failures of the
472   # final rm.
473   find "$@" -type d ! -perm -700 -exec chmod u+rwx {} \; || :
474   rm -rf "$@"
475 }
476
477 # count_test_results total=N pass=N fail=N xpass=N xfail=N skip=N error=N
478 # -----------------------------------------------------------------------
479 # Check that a testsuite run driven by the parallel-tests harness has
480 # had the specified numbers of test results (specified by kind).
481 # This function assumes that the output of "make check" or "make recheck"
482 # has been saved in the 'stdout' file in the current directory, and its
483 # log in the 'test-suite.log' file.
484 count_test_results ()
485 {
486   # Use a subshell so that we won't pollute the script namespace.
487   (
488     # TODO: Do proper checks on the arguments?
489     total=ERR pass=ERR fail=ERR xpass=ERR xfail=ERR skip=ERR error=ERR
490     eval "$@"
491     # For debugging.
492     $EGREP -i '(total|x?pass|x?fail|skip|error)' stdout || :
493     rc=0
494     # Avoid spurious failures with shells with "overly sensible"
495     # errexit shell flag, such as e.g., Solaris /bin/sh.
496     set +e
497     test $(grep -c '^PASS:'  stdout) -eq $pass  || rc=1
498     test $(grep -c '^XFAIL:' stdout) -eq $xfail || rc=1
499     test $(grep -c '^SKIP:'  stdout) -eq $skip  || rc=1
500     test $(grep -c '^FAIL:'  stdout) -eq $fail  || rc=1
501     test $(grep -c '^XPASS:' stdout) -eq $xpass || rc=1
502     test $(grep -c '^ERROR:' stdout) -eq $error || rc=1
503     grep "^# TOTAL:  *$total$" stdout || rc=1
504     grep "^# PASS:  *$pass$"   stdout || rc=1
505     grep "^# XFAIL:  *$xfail$" stdout || rc=1
506     grep "^# SKIP:  *$skip$"   stdout || rc=1
507     grep "^# FAIL:  *$fail$"   stdout || rc=1
508     grep "^# XPASS:  *$xpass$" stdout || rc=1
509     grep "^# ERROR:  *$error$" stdout || rc=1
510     test $rc -eq 0
511   )
512 }
513
514 commented_sed_unindent_prog='
515   /^$/b                    # Nothing to do for empty lines.
516   x                        # Get x<indent> into pattern space.
517   /^$/{                    # No prior x<indent>, go prepare it.
518     g                      # Copy this 1st non-blank line into pattern space.
519     s/^\(['"$tab"' ]*\).*/x\1/   # Prepare x<indent> in pattern space.
520   }                        # Now: x<indent> in pattern and <line> in hold.
521   G                        # Build x<indent>\n<line> in pattern space, and
522   h                        # duplicate it into hold space.
523   s/\n.*$//                # Restore x<indent> in pattern space, and
524   x                        # exchange with the above duplicate in hold space.
525   s/^x\(.*\)\n\1//         # Remove leading <indent> from <line>.
526   s/^x.*\n//               # Restore <line> when there is no leading <indent>.
527 '
528
529 # unindent [input files...]
530 # -------------------------
531 # Remove the "proper" amount of leading whitespace from the given files,
532 # and output the result on stdout.  That amount is determined by looking
533 # at the leading whitespace of the first non-blank line in the input
534 # files.  If no input file is specified, standard input is implied.
535 unindent ()
536 {
537   if test x"$sed_unindent_prog" = x; then
538     sed_unindent_prog=$(printf '%s\n' "$commented_sed_unindent_prog" \
539                           | sed -e "s/  *# .*//")
540   fi
541   sed "$sed_unindent_prog" ${1+"$@"}
542 }
543 sed_unindent_prog="" # Avoid interferences from the environment.
544
545 # get_shell_script SCRIPT-NAME
546 # -----------------------------
547 # Fetch an Automake-provided shell script from the 'lib/' directory into
548 # the current directory, and, if the '$am_test_prefer_config_shell'
549 # variable is set to "yes", modify its shebang line to use $SHELL instead
550 # of /bin/sh.
551 get_shell_script ()
552 {
553   test ! -f "$1" || rm -f "$1" || return 99
554   if test x"$am_test_prefer_config_shell" = x"yes"; then
555     sed "1s|#!.*|#! $SHELL|" "$am_scriptdir/$1" > "$1" \
556      && chmod a+x "$1" \
557      || return 99
558   else
559     cp -f "$am_scriptdir/$1" . || return 99
560   fi
561   sed 10q "$1" # For debugging.
562 }
563
564 # require_xsi SHELL
565 # -----------------
566 # Skip the test if the given shell fails to support common XSI constructs.
567 require_xsi ()
568 {
569   test $# -eq 1 || fatal_ "require_xsi needs exactly one argument"
570   echo "$me: trying some XSI constructs with $1"
571   $1 -c "$xsi_shell_code" || skip_all_ "$1 lacks XSI features"
572 }
573 # Shell code supposed to work only with XSI shells.  Keep this in sync
574 # with libtool.m4:_LT_CHECK_SHELL_FEATURES.
575 xsi_shell_code='
576   _lt_dummy="a/b/c"
577   test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
578       = c,a/b,b/c, \
579     && eval '\''test $(( 1 + 1 )) -eq 2 \
580     && test "${#_lt_dummy}" -eq 5'\'
581
582 # fetch_tap_driver
583 # ----------------
584 # Fetch the Automake-provided TAP driver from the 'lib/' directory into
585 # the current directory, and edit its shebang line so that it will be
586 # run with the perl interpreter determined at configure time.
587 fetch_tap_driver ()
588 {
589   # TODO: we should devise a way to make the shell TAP driver tested also
590   # TODO: with /bin/sh, for better coverage.
591   case $am_tap_implementation in
592     perl)
593       $PERL -MTAP::Parser -e 1 \
594         || skip_all_ "cannot import TAP::Parser perl module"
595       sed "1s|#!.*|#! $PERL -w|" "$am_scriptdir"/tap-driver.pl >tap-driver
596       ;;
597     shell)
598       AM_TAP_AWK=$AWK; export AM_TAP_AWK
599       sed "1s|#!.*|#! $SHELL|" "$am_scriptdir"/tap-driver.sh >tap-driver
600       ;;
601     *)
602       fatal_ "invalid \$am_tap_implementation '$am_tap_implementation'" ;;
603   esac \
604     && chmod a+x tap-driver \
605     || framework_failure_ "couldn't fetch $am_tap_implementation TAP driver"
606   sed 10q tap-driver # For debugging.
607 }
608 # The shell/awk implementation of the TAP driver is still mostly dummy, so
609 # use the perl implementation by default for the moment.
610 am_tap_implementation=${am_tap_implementation-shell}
611
612 # Usage: require_compiler_ {cc|c++|fortran|fortran77}
613 require_compiler_ ()
614 {
615   case $# in
616     0) fatal_ "require_compiler_: missing argument";;
617     1) ;;
618     *) fatal_ "require_compiler_: too many arguments";;
619   esac
620   case $1 in
621     cc)
622       am__comp_lang="C"
623       am__comp_var=CC
624       am__comp_flag_vars='CFLAGS CPPFLAGS'
625       ;;
626     c++)
627       am__comp_lang="C++"
628       am__comp_var=CXX
629       am__comp_flag_vars='CXXFLAGS CPPFLAGS'
630       ;;
631     fortran)
632       am__comp_lang="Fortran"
633       am__comp_var=FC
634       am__comp_flag_vars='FCFLAGS'
635       ;;
636     fortran77)
637       am__comp_lang="Fortran 77"
638       am__comp_var=F77
639       am__comp_flag_vars='FFLAGS'
640       ;;
641   esac
642   shift
643   eval "am__comp_prog=\${$am__comp_var}" \
644     || fatal_ "expanding \${$am__comp_var} in require_compiler_"
645   case $am__comp_prog in
646     "")
647       fatal_ "botched configuration: \$$am__comp_var is empty";;
648     false)
649       skip_all_ "no $am__comp_lang compiler available";;
650     autodetect|autodetected)
651       # Let the ./configure commands in the test script try to determine
652       # these automatically.
653       unset $am__comp_var $am__comp_flag_vars;;
654     *)
655       # Pre-set these for the ./configure commands in the test script.
656       export $am__comp_var $am__comp_flag_vars;;
657   esac
658   # Delete private variables.
659   unset am__comp_lang am__comp_prog am__comp_var am__comp_flag_vars
660 }
661
662 ## ----------------------------------------------------------- ##
663 ##  Checks for required tools, and additional setups (if any)  ##
664 ##  required by them.                                          ##
665 ## ----------------------------------------------------------- ##
666
667 # Performance tests must be enabled explicitly.
668 case $argv0 in
669   */perf/*)
670     case $AM_TESTSUITE_PERF in
671       [yY]|[yY]es|1) ;;
672       *) skip_ "performance tests not explicitly enabled" ;;
673     esac
674     ;;
675 esac
676
677 # Look for (and maybe set up) required tools and/or system features; skip
678 # the current test if they are not found.
679 for tool in : $required
680 do
681   # Check that each required tool is present.
682   case $tool in
683     :) ;;
684     cc|c++|fortran|fortran77)
685       require_compiler_ $tool;;
686     xsi-lib-shell)
687       if test x"$am_test_prefer_config_shell" = x"yes"; then
688         require_xsi "$SHELL"
689       else
690         require_xsi "/bin/sh"
691       fi
692       ;;
693     bzip2)
694       # Do not use --version, older versions bzip2 still tries to compress
695       # stdin.
696       echo "$me: running bzip2 --help"
697       bzip2 --help \
698         || skip_all_ "required program 'bzip2' not available"
699       ;;
700     cl)
701       CC=cl
702       # Don't export CFLAGS, as that could have been initialized to only
703       # work with the C compiler detected at configure time.  If the user
704       # wants CFLAGS to also influence 'cl', he can still export CFLAGS
705       # in the environment "by hand" before calling the testsuite.
706       export CC CPPFLAGS
707       echo "$me: running $CC -?"
708       $CC -? || skip_all_ "Microsoft C compiler '$CC' not available"
709       ;;
710     etags)
711       # Exuberant Ctags will create a TAGS file even
712       # when asked for --help or --version.  (Emacs's etags
713       # does not have such problem.)  Use -o /dev/null
714       # to make sure we do not pollute the build directory.
715       echo "$me: running etags --version -o /dev/null"
716       etags --version -o /dev/null \
717         || skip_all_ "required program 'etags' not available"
718       ;;
719     GNUmake)
720       for make_ in "$MAKE" gmake gnumake :; do
721         MAKE=$make_ am__using_gmake=''
722         test "$MAKE" =  : && break
723         echo "$me: determine whether $MAKE is GNU make"
724         using_gmake && break
725         : For shells with busted 'set -e'.
726       done
727       test "$MAKE" = : && skip_all_ "this test requires GNU make"
728       export MAKE
729       unset make_
730       ;;
731     gcj)
732       GCJ=$GNU_GCJ GCJFLAGS=$GNU_GCJFLAGS; export GCJ GCJFLAGS
733       test "$GCJ" = false && skip_all_ "GNU Java compiler unavailable"
734       : For shells with busted 'set -e'.
735       ;;
736     gcc)
737       CC=$GNU_CC CFLAGS=$GNU_CFLAGS; export CC CFLAGS CPPFLAGS
738       test "$CC" = false && skip_all_ "GNU C compiler unavailable"
739       : For shells with busted 'set -e'.
740       ;;
741     g++)
742       CXX=$GNU_CXX CXXFLAGS=$GNU_CXXFLAGS; export CXX CXXFLAGS CPPFLAGS
743       test "$CXX" = false && skip_all_ "GNU C++ compiler unavailable"
744       : For shells with busted 'set -e'.
745       ;;
746     gfortran)
747       FC=$GNU_FC FCFLAGS=$GNU_FCFLAGS; export FC FCFLAGS
748       test "$FC" = false && skip_all_ "GNU Fortran compiler unavailable"
749       case " $required " in
750         *\ g77\ *) ;;
751         *) F77=$FC FFLAGS=$FCFLAGS; export F77 FFLAGS;;
752       esac
753       ;;
754     g77)
755       F77=$GNU_F77 FFLAGS=$GNU_FFLAGS; export F77 FFLAGS
756       test "$F77" = false && skip_all_ "GNU Fortran 77 compiler unavailable"
757       case " $required " in
758         *\ gfortran\ *) ;;
759         *) FC=$F77 FCFLAGS=$FFLAGS; export FC FCFLAGS;;
760       esac
761       ;;
762     grep-nonprint)
763       # Check that grep can parse nonprinting characters correctly.
764       # BSD 'grep' works from a pipe, but not a seekable file.
765       # GNU or BSD 'grep -a' works on files, but is not portable.
766       case $(echo "$esc" | grep .)$(echo "$esc" | grep "$esc") in
767         "$esc$esc") ;;
768         *) skip_ "grep can't handle nonprinting characters correctly";;
769       esac
770       ;;
771     javac)
772       # The Java compiler from JDK 1.5 (and presumably earlier versions)
773       # cannot handle the '-version' option by itself: it bails out
774       # telling that source files are missing.  Adding also the '-help'
775       # option seems to solve the problem.
776       echo "$me: running javac -version -help"
777       javac -version -help || skip_all_ "Sun Java compiler not available"
778       ;;
779     java)
780       # See the comments above about 'javac' for why we use also '-help'.
781       echo "$me: running java -version -help"
782       java -version -help || skip_all_ "Sun Java interpreter not found"
783       ;;
784     lib)
785       AR=lib
786       export AR
787       # Attempting to create an empty archive will actually not
788       # create the archive, but lib will output its version.
789       echo "$me: running $AR -out:defstest.lib"
790       $AR -out:defstest.lib \
791         || skip_all_ "Microsoft 'lib' utility not available"
792       ;;
793     makedepend)
794       echo "$me: running makedepend -f-"
795       makedepend -f- \
796         || skip_all_ "required program 'makedepend' not available"
797       ;;
798     mingw)
799       uname_s=$(uname -s || echo UNKNOWN)
800       echo "$me: system name: $uname_s"
801       case $uname_s in
802         MINGW*) ;;
803         *) skip_all_ "this test requires MSYS in MinGW mode" ;;
804       esac
805       unset uname_s
806       ;;
807     non-root)
808       # Skip this test case if the user is root.
809       # We try to append to a read-only file to detect this.
810       priv_check_temp=priv-check.$$
811       touch $priv_check_temp && chmod a-w $priv_check_temp \
812         || framework_failure_ "creating unwritable file $priv_check_temp"
813       # Not a useless use of subshell: lesser shells like Solaris /bin/sh
814       # can exit if a builtin fails.
815       overwrite_status=0
816       (echo foo >> $priv_check_temp) || overwrite_status=$?
817       rm -f $priv_check_temp
818       if test $overwrite_status -eq 0; then
819         skip_all_ "cannot drop file write permissions"
820       fi
821       unset priv_check_temp overwrite_status
822       ;;
823     perl-threads)
824       if test "$WANT_NO_THREADS" = "yes"; then
825         skip_all_ "Devel::Cover cannot cope with threads"
826       fi
827       ;;
828     native)
829       # Don't use "&&" here, to avoid a bug of 'set -e' present in
830       # some (even relatively recent) versions of the BSD shell.
831       # We add the dummy "else" branch for extra safety.
832       ! cross_compiling || skip_all_ "doesn't work in cross-compile mode"
833       ;;
834     python)
835       # Python doesn't support --version, it has -V
836       echo "$me: running python -V"
837       python -V || skip_all_ "python interpreter not available"
838       ;;
839     ro-dir)
840       # Skip this test case if read-only directories aren't supported
841       # (e.g., under DOS.)
842       ro_dir_temp=ro_dir.$$
843       mkdir $ro_dir_temp && chmod a-w $ro_dir_temp \
844         || framework_failure_ "creating unwritable directory $ro_dir_temp"
845       # Not a useless use of subshell: lesser shells like Solaris /bin/sh
846       # can exit if a builtin fails.
847       create_status=0
848       (: > $ro_dir_temp/probe) || create_status=$?
849       rm -rf $ro_dir_temp
850       if test $create_status -eq 0; then
851         skip_all_ "cannot drop directory write permissions"
852       fi
853       unset ro_dir_temp create_status
854       ;;
855     runtest)
856       # DejaGnu's runtest program. We rely on being able to specify
857       # the program on the runtest command-line. This requires
858       # DejaGnu 1.4.3 or later.
859       echo "$me: running runtest SOMEPROGRAM=someprogram --version"
860       runtest SOMEPROGRAM=someprogram --version \
861         || skip_all_ "DejaGnu is not available"
862       ;;
863     tex)
864       # No all versions of Tex support '--version', so we use
865       # a configure check.
866       if test -z "$TEX"; then
867         skip_all_ "TeX is required, but it wasn't found by configure"
868       fi
869       ;;
870     lex)
871       test x"$LEX" = x"false" && skip_all_ "lex not found or disabled"
872       export LEX
873       ;;
874     yacc)
875       test x"$YACC" = x"false" && skip_all_ "yacc not found or disabled"
876       export YACC
877       ;;
878     flex)
879       LEX=flex; export LEX
880       echo "$me: running flex --version"
881       flex --version || skip_all_ "required program 'flex' not available"
882       ;;
883     bison)
884       YACC='bison -y'; export YACC
885       echo "$me: running bison --version"
886       bison --version || skip_all_ "required program 'bison' not available"
887       ;;
888     *)
889       # Generic case: the tool must support --version.
890       echo "$me: running $tool --version"
891       # It is not likely but possible that $tool is a special builtin,
892       # in which case the shell is allowed to exit after an error.  So
893       # we need the subshell here.  Also, some tools, like Sun cscope,
894       # can be interactive without redirection.
895       ($tool --version) </dev/null \
896         || skip_all_ "required program '$tool' not available"
897       ;;
898   esac
899 done
900
901 # Using just $am_top_builddir for the check here is ok, since the
902 # further temporary subdirectory where the test will be run is
903 # ensured not to contain any whitespace character.
904 case $am_top_builddir in
905   *\ *|*\       *)
906     case " $required " in
907       *' libtool '* | *' libtoolize '* )
908         skip_all_ "libtool has problems with spaces in builddir name";;
909     esac
910     ;;
911 esac
912
913 # This test is necessary, although Automake's configure script bails out
914 # when $srcdir contains spaces.  This is because $am_top_srcdir is in not
915 # configure-time $srcdir, but is instead configure-time $abs_srcdir, and
916 # that is allowed to contain spaces.
917 case $am_top_srcdir in
918   *\ * |*\      *)
919     case " $required " in
920       *' libtool '* | *' libtoolize '* | *' gettext '* )
921         skip_all_ "spaces in srcdir name: libtool/gettext tests won't work";;
922    esac
923    ;;
924 esac
925
926 # We might need extra macros, e.g., from Libtool or Gettext.
927 case " $required " in *\ libtool*) . ./t/libtool-macros.dir/get.sh;; esac
928 case " $required " in *\ gettext*) . ./t/gettext-macros.dir/get.sh;; esac
929
930
931 ## ---------------------------------------------------------------- ##
932 ##  Create and set up of the temporary directory used by the test.  ##
933 ##  Set up of the exit trap for cleanup of said directory.          ##
934 ## ---------------------------------------------------------------- ##
935
936 # This might be used in testcases checking distribution-related features.
937 # Test scripts are free to override this if they need to.
938 distdir=$me-1.0
939
940 # Set up the exit trap.
941 trap 'exit_status=$?
942   set +e
943   cd "$am_top_builddir"
944   if test $am_using_tap = yes; then
945     if test "$planned_" = later && test $exit_status -eq 0; then
946       plan_ "now"
947     fi
948     test $exit_status -eq 0 && test $tap_pass_count_ -eq $tap_count_ \
949       || keep_testdirs=yes
950   else
951     # This is to ensure that a test script does give a SKIP outcome just
952     # because a command in it happens to exit with status 77.  This
953     # behaviour, while from time to time useful to developers, is not
954     # meant to be enabled by default, as it could cause spurious failures
955     # in the wild.  Thus it will be enabled only when the variable
956     # "am_explicit_skips" is set to a "true" value.
957     case $am_explicit_skips in
958       [yY]|[yY]es|1)
959         if test $exit_status -eq 77 && test $am__test_skipped != yes; then
960           echo "$me: implicit skip turned into failure"
961           exit_status=78
962         fi;;
963     esac
964     test $exit_status -eq 0 || keep_testdirs=yes
965   fi
966   am_keeping_testdirs || rm_rf_ $testSubDir
967   set +x
968   echo "$me: exit $exit_status"
969   exit $exit_status
970 ' 0
971 trap "fatal_ 'caught signal SIGHUP'" 1
972 trap "fatal_ 'caught signal SIGINT'" 2
973 trap "fatal_ 'caught signal SIGTERM'" 15
974 # Various shells seems to just ignore SIGQUIT under some circumstances,
975 # even if the signal is not blocked; however, if the signal it trapped,
976 # the trap gets correctly executed.  So we also trap SIGQUIT.
977 # Here is a list of some shells that have been verified to exhibit the
978 # problematic behavior with SIGQUIT:
979 #  - zsh 4.3.12 on Debian GNU/Linux
980 #  - /bin/ksh and /usr/xpg4/bin/sh on Solaris 10
981 #  - Bash 3.2.51 on Solaris 10 and bash 4.1.5 on Debian GNU/Linux
982 #  - AT&T ksh on Debian Gnu/Linux (deb package ksh, version 93u-1)
983 # OTOH, at least these shells that do *not* exhibit that behaviour:
984 #  - modern version of the Almquist Shell (at least 0.5.5.1), on
985 #    both Solaris and GNU/Linux
986 #  - Solaris 10 /bin/sh
987 #  - public domain Korn Shell, version 5.2.14, on Debian GNU/Linux
988 trap "fatal_ 'caught signal SIGQUIT'" 3
989 # Ignore further SIGPIPE in the trap code.  This is required to avoid
990 # a very weird issue with some shells, at least when the execution of
991 # the automake testsuite is driven by the 'prove' utility: if prove
992 # (or the make process that has spawned it) gets interrupted with
993 # Ctrl-C, the shell might go in a loop, continually getting a SIGPIPE,
994 # sometimes finally dumping core, other times hanging indefinitely.
995 # See also Test::Harness bug [rt.cpan.org #70855], archived at
996 # <https://rt.cpan.org/Ticket/Display.html?id=70855>
997 trap "trap '' 13; fatal_ 'caught signal SIGPIPE'" 13
998
999 # Create and populate the temporary directory, if and as required.
1000 if test x"$am_create_testdir" = x"no"; then
1001   testSubDir=
1002 else
1003   # The subdirectory where the current test script will run and write its
1004   # temporary/data files.  This will be created shortly, and will be removed
1005   # by the cleanup trap below if the test passes.  If the test doesn't pass,
1006   # this directory will be kept, to facilitate debugging.
1007   testSubDir=t/$me.dir
1008   test ! -d $testSubDir || rm_rf_ $testSubDir \
1009     || framework_failure_ "removing old test subdirectory"
1010   test -d t || mkdir t
1011   mkdir $testSubDir \
1012     || framework_failure_ "creating test subdirectory"
1013   # The trailing './'ris to avoid CDPATH issues.
1014   cd ./$testSubDir \
1015     || framework_failure_ "cannot chdir into test subdirectory"
1016   if test x"$am_create_testdir" != x"empty"; then
1017     cp "$am_scriptdir"/install-sh "$am_scriptdir"/missing \
1018        "$am_scriptdir"/depcomp . \
1019       || framework_failure_ "fetching common files from $am_scriptdir"
1020     # Build appropriate environment in test directory.  E.g., create
1021     # configure.ac, touch all necessary files, etc.  Don't use AC_OUTPUT,
1022     # but AC_CONFIG_FILES so that appending still produces a valid
1023     # configure.ac.  But then, tests running config.status really need
1024     # to append AC_OUTPUT.
1025     {
1026       echo "AC_INIT([$me], [1.0])"
1027       if test x"$am_serial_tests" = x"yes"; then
1028         echo "AM_INIT_AUTOMAKE([serial-tests])"
1029       else
1030         echo "AM_INIT_AUTOMAKE"
1031       fi
1032       echo "AC_CONFIG_FILES([Makefile])"
1033     } >configure.ac || framework_failure_ "creating configure.ac skeleton"
1034   fi
1035 fi
1036
1037
1038 ## ---------------- ##
1039 ##  Ready to go...  ##
1040 ## ---------------- ##
1041
1042 set -x
1043 pwd