tests: split test libs into "generic" and "automake-specific"
[platform/upstream/automake.git] / t / ax / am-test-lib.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 # A literal escape character.  Used by test checking colored output.
23 esc='\e'
24
25 # This might be used in testcases checking distribution-related features.
26 # Test scripts are free to override this if they need to.
27 distdir=$me-1.0
28
29 ## ---------------------- ##
30 ##  Environment cleanup.  ##
31 ## ---------------------- ##
32
33 # Temporarily disable this, since some shells (e.g., older version
34 # of Bash) can return a non-zero exit status upon the when a non-set
35 # variable is unset.
36 set +e
37
38 # Unset some make-related variables that may cause $MAKE to act like
39 # a recursively invoked sub-make.  Any $MAKE invocation in a test is
40 # conceptually an independent invocation, not part of the main
41 # 'automake' build.
42 unset MFLAGS MAKEFLAGS AM_MAKEFLAGS MAKELEVEL
43 unset __MKLVL__ MAKE_JOBS_FIFO                     # For BSD make.
44 unset DMAKE_CHILD DMAKE_DEF_PRINTED DMAKE_MAX_JOBS # For Solaris dmake.
45 # Unset verbosity flag.
46 unset V
47 # Also unset variables that will let "make -e install" divert
48 # files into unwanted directories.
49 unset DESTDIR
50 unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
51 unset htmldir includedir infodir libdir libexecdir localedir mandir
52 unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
53 # Unset variables that might change the "make distcheck" behaviour.
54 unset DISTCHECK_CONFIGURE_FLAGS AM_DISTCHECK_CONFIGURE_FLAGS
55 # Used by install rules for info files.
56 unset AM_UPDATE_INFO_DIR
57 # The tests call "make -e" but we do not want $srcdir from the environment
58 # to override the definition from the Makefile.
59 unset srcdir
60 # Also unset variables that control our test driver.  While not
61 # conceptually independent, they cause some changed semantics we
62 # need to control (and test for) in some of the tests to ensure
63 # backward-compatible behavior.
64 unset TESTS_ENVIRONMENT AM_TESTS_ENVIRONMENT
65 unset DISABLE_HARD_ERRORS
66 unset AM_COLOR_TESTS
67 unset TESTS
68 unset XFAIL_TESTS
69 unset TEST_LOGS
70 unset TEST_SUITE_LOG
71 unset RECHECK_LOGS
72 unset VERBOSE
73 for pfx in TEST_ SH_ TAP_ ''; do
74   unset ${pfx}LOG_COMPILER
75   unset ${pfx}LOG_COMPILE # Not a typo!
76   unset ${pfx}LOG_FLAGS
77   unset AM_${pfx}LOG_FLAGS
78   unset ${pfx}LOG_DRIVER
79   unset ${pfx}LOG_DRIVER_FLAGS
80   unset AM_${pfx}LOG_DRIVER_FLAGS
81 done
82 unset pfx
83
84 # Re-enable, it had been temporarily disabled above.
85 set -e
86
87 # cross_compiling
88 # ---------------
89 # Tell whether we are cross-compiling.  This is especially useful to skip
90 # tests (or portions of them) that requires a native compiler.
91 cross_compiling ()
92 {
93   # Quoting from the autoconf manual:
94   #   ... [$host_alias and $build both] default to the result of running
95   #   config.guess, unless you specify either --build or --host.  In
96   #   this case, the default becomes the system type you specified.
97   #   If you specify both, *and they're different*, configure enters
98   #   cross compilation mode (so it doesn't run any tests that require
99   #   execution).
100   test x"$host_alias" != x && test x"$build_alias" != x"$host_alias"
101 }
102
103 # is_blocked_signal SIGNAL-NUMBER
104 # --------------------------------
105 # Return success if the given signal number is blocked in the shell,
106 # return a non-zero exit status and print a proper diagnostic otherwise.
107 is_blocked_signal ()
108 {
109   # Use perl, since trying to do this portably in the shell can be
110   # very tricky, if not downright impossible.  For reference, see:
111   # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
112   if $PERL -w -e '
113     use strict;
114     use warnings FATAL => "all";
115     use POSIX;
116     my %oldsigaction = ();
117     sigaction('"$1"', 0, \%oldsigaction);
118     exit ($oldsigaction{"HANDLER"} eq "IGNORE" ? 0 : 77);
119   '; then
120     return 0
121   elif test $? -eq 77; then
122     return 1
123   else
124     fatal_ "couldn't determine whether signal $1 is blocked"
125   fi
126 }
127
128 # AUTOMAKE_run [-e STATUS] [-d DESCRIPTION] [--] [AUTOMAKE-ARGS...]
129 # -----------------------------------------------------------------
130 # Run automake with AUTOMAKE-ARGS, and fail if it doesn't exit with
131 # STATUS.  Should be polymorphic for TAP and "plain" tests.  The
132 # DESCRIPTION, when provided, is used for console reporting, only if
133 # the TAP protocol is in use in the current test script.
134 AUTOMAKE_run ()
135 {
136   am__desc=
137   am__exp_rc=0
138   while test $# -gt 0; do
139     case $1 in
140       -d) am__desc=$2; shift;;
141       -e) am__exp_rc=$2; shift;;
142       --) shift; break;;
143        # Don't fail on unknown option: assume they (and the rest of the
144        # command line) are to be passed verbatim to automake (so stop our
145        # own option parsing).
146        *) break;;
147     esac
148     shift
149   done
150   am__got_rc=0
151   $AUTOMAKE ${1+"$@"} >stdout 2>stderr || am__got_rc=$?
152   cat stderr >&2
153   cat stdout
154   if test $am_using_tap != yes; then
155     test $am__got_rc -eq $am__exp_rc || exit 1
156     return
157   fi
158   if test -z "$am__desc"; then
159     if test $am__got_rc -eq $am__exp_rc; then
160       am__desc="automake exited $am__got_rc"
161     else
162       am__desc="automake exited $am__got_rc, expecting $am__exp_rc"
163     fi
164   fi
165   command_ok_ "$am__desc" test $am__got_rc -eq $am__exp_rc
166 }
167
168 # AUTOMAKE_fails [-d DESCRIPTION] [OPTIONS...]
169 # --------------------------------------------
170 # Run automake with OPTIONS, and fail if doesn't exit with status 1.
171 # Should be polymorphic for TAP and "plain" tests.  The DESCRIPTION,
172 # when provided, is used for console reporting, only if the TAP
173 # protocol is in use in the current test script.
174 AUTOMAKE_fails ()
175 {
176   AUTOMAKE_run -e 1 ${1+"$@"}
177 }
178
179 # extract_configure_help { --OPTION | VARIABLE-NAME } [FILES]
180 # -----------------------------------------------------------
181 # Use this to extract from the output of "./configure --help" (or similar)
182 # the description or help message associated to the given --OPTION or
183 # VARIABLE-NAME.
184 extract_configure_help ()
185 {
186   am__opt_re='' am__var_re=''
187   case $1 in
188     --*'=')   am__opt_re="^  $1";;
189     --*'[=]') am__opt_re='^  '$(printf '%s\n' "$1" | sed 's/...$//')'\[=';;
190     --*)      am__opt_re="^  $1( .*|$)";;
191       *)      am__var_re="^  $1( .*|$)";;
192   esac
193   shift
194   if test x"$am__opt_re" != x; then
195     LC_ALL=C awk '
196       /'"$am__opt_re"'/        { print; do_print = 1; next; }
197       /^$/                     { do_print = 0; next }
198       /^  --/                  { do_print = 0; next }
199       (do_print == 1)          { print }
200     ' ${1+"$@"}
201   else
202     LC_ALL=C awk '
203       /'"$am__var_re"'/        { print; do_print = 1; next; }
204       /^$/                     { do_print = 0; next }
205       /^  [A-Z][A-Z0-9_]* /    { do_print = 0; next }
206       /^  [A-Z][A-Z0-9_]*$/    { do_print = 0; next }
207       (do_print == 1)          { print }
208     ' ${1+"$@"}
209   fi
210 }
211
212 # grep_configure_help { --OPTION | VARIABLE-NAME } REGEXP
213 # -------------------------------------------------------
214 # Grep the section of "./configure --help" output associated with either
215 # --OPTION or VARIABLE-NAME for the given *extended* regular expression.
216 grep_configure_help ()
217 {
218   ./configure --help > am--all-help \
219     || { cat am--all-help; exit 1; }
220   cat am--all-help
221   extract_configure_help "$1" am--all-help > am--our-help \
222     || { cat am--our-help; exit 1; }
223   cat am--our-help
224   $EGREP "$2" am--our-help || exit 1
225 }
226
227 # using_gmake
228 # -----------
229 # Return success if $MAKE is GNU make, return failure otherwise.
230 # Caches the result for speed reasons.
231 using_gmake ()
232 {
233   case $am__using_gmake in
234     yes)
235       return 0;;
236     no)
237       return 1;;
238     '')
239       # Use --version AND -v, because SGI Make doesn't fail on --version.
240       # Also grep for GNU because newer versions of FreeBSD make do
241       # not complain about --version (they seem to silently ignore it).
242       if $MAKE --version -v | grep GNU; then
243         am__using_gmake=yes
244         return 0
245       else
246         am__using_gmake=no
247         return 1
248       fi;;
249     *)
250       fatal_ "invalid value for \$am__using_gmake: '$am__using_gmake'";;
251   esac
252 }
253 am__using_gmake="" # Avoid interferences from the environment.
254
255 # make_can_chain_suffix_rules
256 # ---------------------------
257 # Return 0 if $MAKE is a make implementation that can chain suffix rules
258 # automatically, return 1 otherwise.  Caches the result for speed reasons.
259 make_can_chain_suffix_rules ()
260 {
261   if test -z "$am__can_chain_suffix_rules"; then
262     if using_gmake; then
263       am__can_chain_suffix_rules=yes
264       return 0
265     else
266       mkdir am__chain.dir$$
267       cd am__chain.dir$$
268       unindent > Makefile << 'END'
269         .SUFFIXES: .u .v .w
270         .u.v: ; cp $< $@
271         .v.w: ; cp $< $@
272 END
273       echo make can chain suffix rules > foo.u
274       if $MAKE foo.w && diff foo.u foo.w; then
275         am__can_chain_suffix_rules=yes
276       else
277         am__can_chain_suffix_rules=no
278       fi
279       cd ..
280       rm -rf am__chain.dir$$
281     fi
282   fi
283   case $am__can_chain_suffix_rules in
284     yes) return 0;;
285      no) return 1;;
286       *) fatal_ "make_can_chain_suffix_rules: internal error";;
287   esac
288 }
289 am__can_chain_suffix_rules="" # Avoid interferences from the environment.
290
291 # useless_vpath_rebuild
292 # ---------------------
293 # Tell whether $MAKE suffers of the bug triggering automake bug#7884.
294 # For example, this happens with FreeBSD make, since in a VPATH build
295 # it tends to rebuilt files for which there is an explicit or even just
296 # a suffix rule, even if said files are already available in the VPATH
297 # directory.
298 useless_vpath_rebuild ()
299 {
300   if test -z "$am__useless_vpath_rebuild"; then
301     if using_gmake; then
302       am__useless_vpath_rebuild=no
303       return 1
304     fi
305     mkdir am__vpath.dir$$
306     cd am__vpath.dir$$
307     touch foo.a foo.b bar baz
308     mkdir build
309     cd build
310     unindent > Makefile << 'END'
311         .SUFFIXES: .a .b
312         VPATH = ..
313         all: foo.b baz
314         .PHONY: all
315         .a.b: ; cp $< $@
316         baz: bar ; cp ../baz bar
317 END
318     if $MAKE all && test ! -e foo.b && test ! -e bar; then
319       am__useless_vpath_rebuild=no
320     else
321       am__useless_vpath_rebuild=yes
322     fi
323     cd ../..
324     rm -rf am__vpath.dir$$
325   fi
326   case $am__useless_vpath_rebuild in
327     yes) return 0;;
328      no) return 1;;
329      "") ;;
330       *) fatal_ "no_useless_builddir_remake: internal error";;
331   esac
332 }
333 am__useless_vpath_rebuild=""
334
335 yl_distcheck () { useless_vpath_rebuild || $MAKE distcheck ${1+"$@"}; }
336
337 # count_test_results total=N pass=N fail=N xpass=N xfail=N skip=N error=N
338 # -----------------------------------------------------------------------
339 # Check that a testsuite run driven by the parallel-tests harness has
340 # had the specified numbers of test results (specified by kind).
341 # This function assumes that the output of "make check" or "make recheck"
342 # has been saved in the 'stdout' file in the current directory, and its
343 # log in the 'test-suite.log' file.
344 count_test_results ()
345 {
346   # Use a subshell so that we won't pollute the script namespace.
347   (
348     # TODO: Do proper checks on the arguments?
349     total=ERR pass=ERR fail=ERR xpass=ERR xfail=ERR skip=ERR error=ERR
350     eval "$@"
351     # For debugging.
352     $EGREP -i '(total|x?pass|x?fail|skip|error)' stdout || :
353     rc=0
354     # Avoid spurious failures with shells with "overly sensible"
355     # errexit shell flag, such as e.g., Solaris /bin/sh.
356     set +e
357     test $(grep -c '^PASS:'  stdout) -eq $pass  || rc=1
358     test $(grep -c '^XFAIL:' stdout) -eq $xfail || rc=1
359     test $(grep -c '^SKIP:'  stdout) -eq $skip  || rc=1
360     test $(grep -c '^FAIL:'  stdout) -eq $fail  || rc=1
361     test $(grep -c '^XPASS:' stdout) -eq $xpass || rc=1
362     test $(grep -c '^ERROR:' stdout) -eq $error || rc=1
363     grep "^# TOTAL:  *$total$" stdout || rc=1
364     grep "^# PASS:  *$pass$"   stdout || rc=1
365     grep "^# XFAIL:  *$xfail$" stdout || rc=1
366     grep "^# SKIP:  *$skip$"   stdout || rc=1
367     grep "^# FAIL:  *$fail$"   stdout || rc=1
368     grep "^# XPASS:  *$xpass$" stdout || rc=1
369     grep "^# ERROR:  *$error$" stdout || rc=1
370     test $rc -eq 0
371   )
372 }
373
374 # get_shell_script SCRIPT-NAME
375 # -----------------------------
376 # Fetch an Automake-provided shell script from the 'lib/' directory into
377 # the current directory, and, if the '$am_test_prefer_config_shell'
378 # variable is set to "yes", modify its shebang line to use $SHELL instead
379 # of /bin/sh.
380 get_shell_script ()
381 {
382   test ! -f "$1" || rm -f "$1" || return 99
383   if test x"$am_test_prefer_config_shell" = x"yes"; then
384     sed "1s|#!.*|#! $SHELL|" "$am_scriptdir/$1" > "$1" \
385      && chmod a+x "$1" \
386      || return 99
387   else
388     cp -f "$am_scriptdir/$1" . || return 99
389   fi
390   sed 10q "$1" # For debugging.
391 }
392
393 # require_xsi SHELL
394 # -----------------
395 # Skip the test if the given shell fails to support common XSI constructs.
396 require_xsi ()
397 {
398   test $# -eq 1 || fatal_ "require_xsi needs exactly one argument"
399   echo "$me: trying some XSI constructs with $1"
400   $1 -c "$xsi_shell_code" || skip_all_ "$1 lacks XSI features"
401 }
402 # Shell code supposed to work only with XSI shells.  Keep this in sync
403 # with libtool.m4:_LT_CHECK_SHELL_FEATURES.
404 xsi_shell_code='
405   _lt_dummy="a/b/c"
406   test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
407       = c,a/b,b/c, \
408     && eval '\''test $(( 1 + 1 )) -eq 2 \
409     && test "${#_lt_dummy}" -eq 5'\'
410
411 # fetch_tap_driver
412 # ----------------
413 # Fetch the Automake-provided TAP driver from the 'lib/' directory into
414 # the current directory, and edit its shebang line so that it will be
415 # run with the perl interpreter determined at configure time.
416 fetch_tap_driver ()
417 {
418   # TODO: we should devise a way to make the shell TAP driver tested also
419   # TODO: with /bin/sh, for better coverage.
420   case $am_tap_implementation in
421     # Extra quoting required to avoid maintainer-check spurious failures.
422    'perl')
423       $PERL -MTAP::Parser -e 1 \
424         || skip_all_ "cannot import TAP::Parser perl module"
425       sed "1s|#!.*|#! $PERL -w|" "$am_scriptdir"/tap-driver.pl >tap-driver
426       ;;
427     shell)
428       AM_TAP_AWK=$AWK; export AM_TAP_AWK
429       sed "1s|#!.*|#! $SHELL|" "$am_scriptdir"/tap-driver.sh >tap-driver
430       ;;
431     *)
432       fatal_ "invalid \$am_tap_implementation '$am_tap_implementation'" ;;
433   esac \
434     && chmod a+x tap-driver \
435     || framework_failure_ "couldn't fetch $am_tap_implementation TAP driver"
436   sed 10q tap-driver # For debugging.
437 }
438 # The shell/awk implementation of the TAP driver is still mostly dummy, so
439 # use the perl implementation by default for the moment.
440 am_tap_implementation=${am_tap_implementation-shell}
441
442 # Usage: require_compiler_ {cc|c++|fortran|fortran77}
443 require_compiler_ ()
444 {
445   case $# in
446     0) fatal_ "require_compiler_: missing argument";;
447     1) ;;
448     *) fatal_ "require_compiler_: too many arguments";;
449   esac
450   case $1 in
451     cc)
452       am__comp_lang="C"
453       am__comp_var=CC
454       am__comp_flag_vars='CFLAGS CPPFLAGS'
455       ;;
456     c++)
457       am__comp_lang="C++"
458       am__comp_var=CXX
459       am__comp_flag_vars='CXXFLAGS CPPFLAGS'
460       ;;
461     fortran)
462       am__comp_lang="Fortran"
463       am__comp_var=FC
464       am__comp_flag_vars='FCFLAGS'
465       ;;
466     fortran77)
467       am__comp_lang="Fortran 77"
468       am__comp_var=F77
469       am__comp_flag_vars='FFLAGS'
470       ;;
471   esac
472   shift
473   eval "am__comp_prog=\${$am__comp_var}" \
474     || fatal_ "expanding \${$am__comp_var} in require_compiler_"
475   case $am__comp_prog in
476     "")
477       fatal_ "botched configuration: \$$am__comp_var is empty";;
478     false)
479       skip_all_ "no $am__comp_lang compiler available";;
480     autodetect|autodetected)
481       # Let the ./configure commands in the test script try to determine
482       # these automatically.
483       unset $am__comp_var $am__comp_flag_vars;;
484     *)
485       # Pre-set these for the ./configure commands in the test script.
486       export $am__comp_var $am__comp_flag_vars;;
487   esac
488   # Delete private variables.
489   unset am__comp_lang am__comp_prog am__comp_var am__comp_flag_vars
490 }
491
492 ## ----------------------------------------------------------- ##
493 ##  Checks for required tools, and additional setups (if any)  ##
494 ##  required by them.                                          ##
495 ## ----------------------------------------------------------- ##
496
497 require_tool ()
498 {
499   am_tool=$1
500   case $1 in
501     cc|c++|fortran|fortran77)
502       require_compiler_ $1;;
503     xsi-lib-shell)
504       if test x"$am_test_prefer_config_shell" = x"yes"; then
505         require_xsi "$SHELL"
506       else
507         require_xsi "/bin/sh"
508       fi
509       ;;
510     bzip2)
511       # Do not use --version, older versions bzip2 still tries to compress
512       # stdin.
513       echo "$me: running bzip2 --help"
514       bzip2 --help \
515         || skip_all_ "required program 'bzip2' not available"
516       ;;
517     cl)
518       CC=cl
519       # Don't export CFLAGS, as that could have been initialized to only
520       # work with the C compiler detected at configure time.  If the user
521       # wants CFLAGS to also influence 'cl', he can still export CFLAGS
522       # in the environment "by hand" before calling the testsuite.
523       export CC CPPFLAGS
524       echo "$me: running $CC -?"
525       $CC -? || skip_all_ "Microsoft C compiler '$CC' not available"
526       ;;
527     etags)
528       # Exuberant Ctags will create a TAGS file even
529       # when asked for --help or --version.  (Emacs's etags
530       # does not have such problem.)  Use -o /dev/null
531       # to make sure we do not pollute the build directory.
532       echo "$me: running etags --version -o /dev/null"
533       etags --version -o /dev/null \
534         || skip_all_ "required program 'etags' not available"
535       ;;
536     GNUmake)
537       for make_ in "$MAKE" gmake gnumake :; do
538         MAKE=$make_ am__using_gmake=''
539         test "$MAKE" =  : && break
540         echo "$me: determine whether $MAKE is GNU make"
541         using_gmake && break
542         : For shells with busted 'set -e'.
543       done
544       test "$MAKE" = : && skip_all_ "this test requires GNU make"
545       export MAKE
546       unset make_
547       ;;
548     gcj)
549       GCJ=$GNU_GCJ GCJFLAGS=$GNU_GCJFLAGS; export GCJ GCJFLAGS
550       test "$GCJ" = false && skip_all_ "GNU Java compiler unavailable"
551       : For shells with busted 'set -e'.
552       ;;
553     gcc)
554       CC=$GNU_CC CFLAGS=$GNU_CFLAGS; export CC CFLAGS CPPFLAGS
555       test "$CC" = false && skip_all_ "GNU C compiler unavailable"
556       : For shells with busted 'set -e'.
557       ;;
558     g++)
559       CXX=$GNU_CXX CXXFLAGS=$GNU_CXXFLAGS; export CXX CXXFLAGS CPPFLAGS
560       test "$CXX" = false && skip_all_ "GNU C++ compiler unavailable"
561       : For shells with busted 'set -e'.
562       ;;
563     gfortran)
564       FC=$GNU_FC FCFLAGS=$GNU_FCFLAGS; export FC FCFLAGS
565       test "$FC" = false && skip_all_ "GNU Fortran compiler unavailable"
566       case " $required " in
567         *\ g77\ *) ;;
568         *) F77=$FC FFLAGS=$FCFLAGS; export F77 FFLAGS;;
569       esac
570       ;;
571     g77)
572       F77=$GNU_F77 FFLAGS=$GNU_FFLAGS; export F77 FFLAGS
573       test "$F77" = false && skip_all_ "GNU Fortran 77 compiler unavailable"
574       case " $required " in
575         *\ gfortran\ *) ;;
576         *) FC=$F77 FCFLAGS=$FFLAGS; export FC FCFLAGS;;
577       esac
578       ;;
579     grep-nonprint)
580       # Check that grep can parse nonprinting characters correctly.
581       # BSD 'grep' works from a pipe, but not a seekable file.
582       # GNU or BSD 'grep -a' works on files, but is not portable.
583       case $(echo "$esc" | grep .)$(echo "$esc" | grep "$esc") in
584         "$esc$esc") ;;
585         *) skip_ "grep can't handle nonprinting characters correctly";;
586       esac
587       ;;
588     javac)
589       # The Java compiler from JDK 1.5 (and presumably earlier versions)
590       # cannot handle the '-version' option by itself: it bails out
591       # telling that source files are missing.  Adding also the '-help'
592       # option seems to solve the problem.
593       echo "$me: running javac -version -help"
594       javac -version -help || skip_all_ "Sun Java compiler not available"
595       ;;
596     java)
597       # See the comments above about 'javac' for why we use also '-help'.
598       echo "$me: running java -version -help"
599       java -version -help || skip_all_ "Sun Java interpreter not found"
600       ;;
601     lib)
602       AR=lib
603       export AR
604       # Attempting to create an empty archive will actually not
605       # create the archive, but lib will output its version.
606       echo "$me: running $AR -out:defstest.lib"
607       $AR -out:defstest.lib \
608         || skip_all_ "Microsoft 'lib' utility not available"
609       ;;
610     makedepend)
611       echo "$me: running makedepend -f-"
612       makedepend -f- \
613         || skip_all_ "required program 'makedepend' not available"
614       ;;
615     makeinfo-html)
616       # Make sure we have makeinfo, and it understands '--html'.
617       echo "$me: running makeinfo --html --version"
618       makeinfo --html --version \
619         || skip_all_ "cannot find a makeinfo program that groks" \
620                      "the '--html' option"
621       ;;
622     mingw)
623       uname_s=$(uname -s || echo UNKNOWN)
624       echo "$me: system name: $uname_s"
625       case $uname_s in
626         MINGW*) ;;
627         *) skip_all_ "this test requires MSYS in MinGW mode" ;;
628       esac
629       unset uname_s
630       ;;
631     non-root)
632       # Skip this test case if the user is root.
633       # We try to append to a read-only file to detect this.
634       priv_check_temp=priv-check.$$
635       touch $priv_check_temp && chmod a-w $priv_check_temp \
636         || framework_failure_ "creating unwritable file $priv_check_temp"
637       # Not a useless use of subshell: lesser shells might bail
638       # out if a builtin fails.
639       overwrite_status=0
640       (echo foo >> $priv_check_temp) || overwrite_status=$?
641       rm -f $priv_check_temp
642       if test $overwrite_status -eq 0; then
643         skip_all_ "cannot drop file write permissions"
644       fi
645       unset priv_check_temp overwrite_status
646       ;;
647     # Extra quoting required to avoid maintainer-check spurious failures.
648     'perl-threads')
649       if test "$WANT_NO_THREADS" = "yes"; then
650         skip_all_ "Devel::Cover cannot cope with threads"
651       fi
652       ;;
653     native)
654       # Don't use "&&" here, to avoid a bug of 'set -e' present in
655       # some (even relatively recent) versions of the BSD shell.
656       # We add the dummy "else" branch for extra safety.
657       ! cross_compiling || skip_all_ "doesn't work in cross-compile mode"
658       ;;
659     python)
660       # Python doesn't support --version, it has -V
661       echo "$me: running python -V"
662       python -V || skip_all_ "python interpreter not available"
663       ;;
664     ro-dir)
665       # Skip this test case if read-only directories aren't supported
666       # (e.g., under DOS.)
667       ro_dir_temp=ro_dir.$$
668       mkdir $ro_dir_temp && chmod a-w $ro_dir_temp \
669         || framework_failure_ "creating unwritable directory $ro_dir_temp"
670       # Not a useless use of subshell: lesser shells might bail
671       # out if a builtin fails.
672       create_status=0
673       (: > $ro_dir_temp/probe) || create_status=$?
674       rm -rf $ro_dir_temp
675       if test $create_status -eq 0; then
676         skip_all_ "cannot drop directory write permissions"
677       fi
678       unset ro_dir_temp create_status
679       ;;
680     runtest)
681       # DejaGnu's runtest program. We rely on being able to specify
682       # the program on the runtest command-line. This requires
683       # DejaGnu 1.4.3 or later.
684       echo "$me: running runtest SOMEPROGRAM=someprogram --version"
685       runtest SOMEPROGRAM=someprogram --version \
686         || skip_all_ "DejaGnu is not available"
687       ;;
688     tex)
689       # No all versions of Tex support '--version', so we use
690       # a configure check.
691       if test -z "$TEX"; then
692         skip_all_ "TeX is required, but it wasn't found by configure"
693       fi
694       ;;
695     texi2dvi-o)
696       # Texi2dvi supports '-o' since Texinfo 4.1.
697       echo "$me: running texi2dvi -o /dev/null --version"
698       texi2dvi -o /dev/null --version \
699         || skip_all_ "required program 'texi2dvi' not available"
700       ;;
701     lex)
702       test x"$LEX" = x"false" && skip_all_ "lex not found or disabled"
703       export LEX
704       ;;
705     yacc)
706       test x"$YACC" = x"false" && skip_all_ "yacc not found or disabled"
707       export YACC
708       ;;
709     flex)
710       LEX=flex; export LEX
711       echo "$me: running flex --version"
712       flex --version || skip_all_ "required program 'flex' not available"
713       ;;
714     bison)
715       YACC='bison -y'; export YACC
716       echo "$me: running bison --version"
717       bison --version || skip_all_ "required program 'bison' not available"
718       ;;
719     *)
720       # Generic case: the tool must support --version.
721       echo "$me: running $1 --version"
722       # It is not likely but possible that the required tool is a special
723       # builtin, in which case the shell is allowed to exit after an error.
724       # So we need the subshell here.  Also, some tools, like Sun cscope,
725       # can be interactive without redirection.
726       ($1 --version) </dev/null \
727         || skip_all_ "required program '$1' not available"
728       ;;
729   esac
730 }
731
732 process_requirements ()
733 {
734   # Look for (and maybe set up) required tools and/or system features;
735   # skip the current test if they are not found.
736   for am_tool in $*; do
737     require_tool $am_tool
738   done
739   unset am_tool
740   # We might need extra macros, e.g., from Libtool or Gettext.
741   case " $required " in
742     *\ libtool*) . ./t/libtool-macros.dir/get.sh;;
743   esac
744   case " $required " in
745     *\ gettext*) . ./t/gettext-macros.dir/get.sh;;
746   esac
747 }
748
749 ## ---------------------------------------------------------------- ##
750 ##  Create and set up of the temporary directory used by the test.  ##
751 ## ---------------------------------------------------------------- ##
752
753 am_setup_testdir ()
754 {
755   # The subdirectory where the current test script will run and write its
756   # temporary/data files.  This will be created shortly, and will be removed
757   # by the cleanup trap below if the test passes.  If the test doesn't pass,
758   # this directory will be kept, to facilitate debugging.
759   am_test_subdir=${argv0#$am_rel_srcdir/}
760   case $am_test_subdir in
761     */*) am_test_subdir=${am_test_subdir%/*}/$me.dir;;
762       *) am_test_subdir=$me.dir;;
763   esac
764   test ! -e $am_test_subdir || rm_rf_ $am_test_subdir \
765     || framework_failure_ "removing old test subdirectory"
766   $MKDIR_P $am_test_subdir \
767     || framework_failure_ "creating test subdirectory"
768   cd $am_test_subdir \
769     || framework_failure_ "cannot chdir into test subdirectory"
770   if test x"$am_create_testdir" != x"empty"; then
771     cp "$am_scriptdir"/install-sh "$am_scriptdir"/missing \
772        "$am_scriptdir"/depcomp . \
773       || framework_failure_ "fetching common files from $am_scriptdir"
774     # Build appropriate environment in test directory.  E.g., create
775     # configure.ac, touch all necessary files, etc.  Don't use AC_OUTPUT,
776     # but AC_CONFIG_FILES so that appending still produces a valid
777     # configure.ac.  But then, tests running config.status really need
778     # to append AC_OUTPUT.
779     {
780       echo "AC_INIT([$me], [1.0])"
781       if test x"$am_serial_tests" = x"yes"; then
782         echo "AM_INIT_AUTOMAKE"
783       else
784         echo "AM_INIT_AUTOMAKE([parallel-tests])"
785       fi
786       echo "AC_CONFIG_FILES([Makefile])"
787     } >configure.ac || framework_failure_ "creating configure.ac skeleton"
788   fi
789 }
790
791 am_extra_info ()
792 {
793   echo "Running from installcheck: $am_running_installcheck"
794   echo "Using TAP: $am_using_tap"
795   echo "PATH = $PATH"
796 }