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