summaryrefslogtreecommitdiff
path: root/tests/defs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/defs')
-rw-r--r--tests/defs199
1 files changed, 137 insertions, 62 deletions
diff --git a/tests/defs b/tests/defs
index 47d8c8992..5494625b0 100644
--- a/tests/defs
+++ b/tests/defs
@@ -17,6 +17,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# IMPORTANT NOTE: This file should execute correctly with any system's
+# /bin/sh shell, and not only with configure-time detected $CONFIG_SHELL,
+# until differently and explicitly specified.
+
+
## -------------------------------------------------------- ##
## Source static setup and definitions for the testsuite. ##
## -------------------------------------------------------- ##
@@ -42,9 +48,9 @@ if test -z "$me"; then
|| { echo "$argv0: failed to define \$me" >&2; exit 99; }
fi
-## ---------------------------------------- ##
-## Sanity checks and environment cleanup. ##
-## ---------------------------------------- ##
+## ---------------------- ##
+## Early sanity checks. ##
+## ---------------------- ##
# A single whitespace character.
sp=' '
@@ -70,6 +76,48 @@ test -f "$testbuilddir/defs-static" || {
exit 99
}
+# Ensure we can find ourselves.
+test -f "$0" || {
+ echo "$me: unable to find myself: $0" >&2
+ exit 1
+}
+
+
+## ------------------------------------ ##
+## Ensure we run with a proper shell. ##
+## ------------------------------------ ##
+
+# Make sure we run with the shell detected at configure time (unless
+# the user forbids it).
+case ${AM_TESTS_REEXEC-yes} in
+ n|no|false|0)
+ ;;
+ *)
+ AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+ # Cannot simply do `opts=$-', since the content of $- is not
+ # portable among different shells. So try to propagate only
+ # the portable and interesting options.
+ case $- in
+ *x*v*|*v*x) opts=-vx;;
+ *v*) opts=-v;;
+ *x*) opts=-x;;
+ *) opts=;;
+ esac
+ echo $me: exec $SHELL $opts "$0" "$*"
+ exec $SHELL $opts "$0" ${1+"$@"}
+ echo "$me: failed to re-execute with $SHELL" >&2
+ exit 99
+ ;;
+esac
+
+# NOTE: From this point on, we can assume this file is being executed
+# by the configure-time detected $CONFIG_SHELL.
+
+
+## ---------------------- ##
+## Environment cleanup. ##
+## ---------------------- ##
+
# Unset some MAKE... variables that may cause $MAKE to act like a
# recursively invoked sub-make. Any $MAKE invocation in a test is
# conceptually an independent invocation, not part of the main
@@ -103,6 +151,10 @@ unset VERBOSE
## Auxiliary shell functions. ##
## ---------------------------- ##
+# This is used in `Exit' and in the exit trap. See comments in the latter
+# for more information,
+am__test_skipped=no
+
# We use a trap below for cleanup. This requires us to go through
# hoops to get the right exit status transported through the signal.
# So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
@@ -111,8 +163,9 @@ unset VERBOSE
Exit ()
{
set +e
- (exit $1)
- exit $1
+ # See comments in the exit trap for the reason we do this.
+ test 77 = $1 && am__test_skipped=yes
+ (exit $1); exit $1
}
# Print warnings (e.g., about skipped and failed tests) to this file
@@ -135,7 +188,7 @@ framework_failure_ () { warn_ "$me: set-up failure: $@"; Exit 99; }
# tests (or portions of them) that requires a native compiler.
cross_compiling ()
{
- test x"$host_alias" != x
+ test x"$host_alias" != x && test x"$build_alias" != x"$host_alias"
}
# is_newest FILE FILES
@@ -199,6 +252,7 @@ using_gmake ()
Exit 99;;
esac
}
+am__using_gmake="" # Avoid interferences from the environment.
commented_sed_unindent_prog='
/^$/b # Nothing to do for empty lines.
@@ -255,24 +309,31 @@ do
# Check that each required tool is present.
case $tool in
:) ;;
- cc|c++|fortran|fortran77)
- echo "$me: dummy requirement '$tool', no check done"
- ;;
+ cc)
+ test "$CC" = false && skip_ "no C compiler available";;
+ c++)
+ test "$CXX" = false && skip_ "no C++ compiler available";;
+ fortran)
+ test "$FC" = false && skip_ "no Fortran compiler available";;
+ fortran77)
+ test "$F77" = false && skip_ "no Fortran 77 compiler available";;
bzip2)
# Do not use --version, bzip2 still tries to compress stdin.
echo "$me: running bzip2 --help"
- bzip2 --help || exit 77
+ bzip2 --help \
+ || skip_ "required program \`bzip2' not available"
;;
cl)
CC=cl
export CC
echo "$me: running $CC -?"
- $CC -? || exit 77
+ $CC -? || skip_ "Microsoft C compiler \`$CC' not available"
;;
cscope)
# Sun cscope is interactive without redirection.
echo "$me: running cscope --version </dev/null"
- cscope --version </dev/null || exit 77
+ cscope --version </dev/null \
+ || skip_ "required program \`cscope' not available"
;;
etags)
# Exuberant Ctags will create a TAGS file even
@@ -280,11 +341,19 @@ do
# does not have such problem.) Use -o /dev/null
# to make sure we do not pollute the tests/ directory.
echo "$me: running etags --version -o /dev/null"
- etags --version -o /dev/null || exit 77
+ etags --version -o /dev/null \
+ || skip_ "required program \`etags' not available"
;;
GNUmake)
- echo "$me: determine if $MAKE is GNU make"
- using_gmake || exit 77
+ for make_ in "$MAKE" gmake gnumake :; do
+ MAKE=$make_ am__using_gmake=''
+ test "$MAKE" = : && break
+ echo "$me: determine whether $MAKE is GNU make"
+ using_gmake && break
+ done
+ test "$MAKE" = : && skip_ "this test requires GNU make"
+ export MAKE
+ unset make_
;;
gcc)
# When gcc is required, export `CC=gcc' so that ./configure
@@ -294,25 +363,25 @@ do
CC=${am__tool_prefix}gcc
export CC
echo "$me: running $CC --version"
- $CC --version || exit 77
+ $CC --version || skip_ "GNU C compiler not available"
echo "$me: running $CC -v"
- $CC -v || exit 77
+ $CC -v || skip_ "botched installation for GNU C compiler"
;;
gcj)
GCJ=${am__tool_prefix}gcj
export GCJ
echo "$me: running $GCJ --version"
- $GCJ --version || exit 77
+ $GCJ --version || skip_ "GNU Java compiler not available"
echo "$me: running $GCJ -v"
- $GCJ -v || exit 77
+ $GCJ -v || skip_ "botched installation for GNU Java compiler"
;;
g++)
CXX=${am__tool_prefix}g++
export CXX
echo "$me: running $CXX --version"
- $CXX --version || exit 77
+ $CXX --version || skip_ "GNU C++ compiler not available"
echo "$me: running $CXX -v"
- $CXX -v || exit 77
+ $CXX -v || skip_ "botched installation for GNU C++ compiler"
;;
gfortran)
FC=${am__tool_prefix}gfortran
@@ -346,7 +415,7 @@ do
# it will try link *nothing* and complain it cannot find
# main(); funny). Use -help so it does not try linking anything.
echo "$me: running $CC -V -help"
- $CC -V -help || exit 77
+ $CC -V -help || skip_ "Intel C compiler \`$CC' not available"
;;
javac)
# The Java compiler from JDK 1.5 (and presumably earlier versions)
@@ -354,16 +423,19 @@ do
# telling that source files are missing. Adding also the `-help'
# option seems to solve the problem.
echo "$me: running javac -version -help"
- javac -version -help || exit 77
+ javac -version -help || skip_ "Sun Java compiler not available"
;;
makedepend)
echo "$me: running makedepend -f-"
- makedepend -f- || exit 77
+ makedepend -f- \
+ || skip_ "required program \`makedepend' not available"
;;
makeinfo-html)
- # Make sure makeinfo understands --html.
+ # Make sure we have makeinfo, and it understands `--html'.
echo "$me: running makeinfo --html --version"
- makeinfo --html --version || exit 77
+ makeinfo --html --version \
+ || skip_ "cannot find a makeinfo program that groks the" \
+ "\`--html' option"
;;
non-root)
# Skip this test case if the user is root.
@@ -375,15 +447,13 @@ do
overwrite_status=$?
rm -f $priv_check_temp
if test $overwrite_status -eq 0; then
- echo "$me: cannot drop file write permissions" >&2
- exit 77
+ skip_ "cannot drop file write permissions"
fi
unset priv_check_temp overwrite_status
;;
perl-threads)
if test "$WANT_NO_THREADS" = "yes"; then
- echo "$me: skip with Devel::Cover: cannot cope with threads" >&2
- exit 77
+ skip_ "Devel::Cover cannot cope with threads"
fi
;;
native)
@@ -392,7 +462,7 @@ do
python)
# Python doesn't support --version, it has -V
echo "$me: running python -V"
- python -V || exit 77
+ python -V || skip_ "python interpreter not available"
;;
ro-dir)
# Skip this test case if read-only directories aren't supported
@@ -404,8 +474,7 @@ do
create_status=$?
rm -rf $ro_dir_temp
if test $create_status -eq 0; then
- echo "$me: cannot drop directory write permissions" >&2
- exit 77
+ skip_ "cannot drop directory write permissions"
fi
unset ro_dir_temp create_status
;;
@@ -416,8 +485,7 @@ do
echo "$me: running $r2h --version"
$r2h --version && break 2
done
- echo "$me: no proper rst2html program found" >&2
- exit 77
+ skip_ "no proper rst2html program found"
done
unset r2h
;;
@@ -426,20 +494,21 @@ do
# the program on the runtest command-line. This requires
# DejaGnu 1.4.3 or later.
echo "$me: running runtest SOMEPROGRAM=someprogram --version"
- runtest SOMEPROGRAM=someprogram --version || exit 77
+ runtest SOMEPROGRAM=someprogram --version \
+ || skip_ "DejaGnu is not available"
;;
tex)
# No all versions of Tex support `--version', so we use
# a configure check.
if test -z "$TEX"; then
- echo "$me: TeX is required, but it wasn't found by configure" >&2
- exit 77
+ skip_ "TeX is required, but it wasn't found by configure"
fi
;;
texi2dvi-o)
# Texi2dvi supports `-o' since Texinfo 4.1.
echo "$me: running texi2dvi -o /dev/null --version"
- texi2dvi -o /dev/null --version || exit 77
+ texi2dvi -o /dev/null --version \
+ || skip_ "required program \`texi2dvi' not available"
;;
xsi-shell)
# Try some XSI features.
@@ -449,7 +518,8 @@ do
test "${_am_dummy##*/},${_am_dummy%/*},${_am_dummy#??}"${_am_dummy%"$_am_dummy"}, \
= c,a/b,b/c, \
&& eval 'test $(( 1 + 1 )) -eq 2 \
- && test "${#_am_dummy}" -eq 5' ) || exit 77
+ && test "${#_am_dummy}" -eq 5' ) \
+ || skip_ "the shell lacks some required XSI features"
;;
flex|lex)
# Since flex is required, we pick LEX for ./configure.
@@ -459,19 +529,15 @@ do
flex --version || exit 77
;;
yacc)
- if test x"$YACC" = x"no"; then
- # The user has explicitly told he doesn't want a yacc program
- # to be used.
- echo "$me: \$YACC is \"no\", skipping test" >&2
- exit 77
- elif test -z "$YACC"; then
+ test "$YACC" = false && skip_ "no Yacc program available"
+ if test -z "$YACC"; then
# The user hasn't explicitly specified any yacc program in the
# environment, so we try to use bison, skipping the test if it's
# not found.
YACC='bison -y'
export YACC
echo "$me: running bison --version"
- bison --version || exit 77
+ bison --version || skip_ "required program \`bison' not available"
fi
;;
*)
@@ -480,7 +546,7 @@ do
# It is not likely but possible that $tool is a special builtin,
# in which case the shell is allowed to exit after an error.
# So, please leave the subshell here.
- ( $tool --version ) || exit 77
+ ($tool --version) || skip_ "required program \`$tool' not available"
;;
esac
done
@@ -492,10 +558,7 @@ case $testbuilddir in
*\ *|*\ *)
case " $required " in
*' libtool '* | *' libtoolize '* )
- echo "$me: libtool/libtoolized cannot cope correctly" >&2
- echo "$me: with spaces in the build tree" >&2
- exit 77
- ;;
+ skip_ "libtool has problems with spaces in builddir name";;
esac
;;
esac
@@ -508,10 +571,7 @@ case $testsrcdir in
*\ * |*\ *)
case " $required " in
*' libtool '* | *' libtoolize '* | *' gettext '* )
- echo "$me: our testsuite setup cannot cope correctly with spaces" >&2
- echo "$me: in the source tree for libtool/gettext tests" >&2
- exit 77
- ;;
+ skip_ "spaces in srcdir name: libtool/gettext tests won't work";;
esac
;;
esac
@@ -548,16 +608,18 @@ case " $required " in
case " $required " in
*' libtool '*|*' libtoolize '*)
if test $libtool_found != yes; then
- echo "$me: libtool/libtoolize is required, but libtool.m4 wasn't" >&2
- echo "$me: found in directories $aclocaldir $extra_includes" >&2
- exit 77
+ # Write more diagnostic to the log file than to the console.
+ echo "$me: \`libtool.m4' wasn't found in directories" \
+ "$aclocaldir $extra_includes"
+ skip_ "libtool m4 macros won't be found by aclocal"
fi
;;
*' gettext '*)
if test $gettext_found != yes; then
- echo "$me: gettext is required, but gettext.m4 wasn't found" >&2
- echo "$me: in directories $aclocaldir $extra_includes" >&2
- exit 77
+ # Write more diagnostic to the log file than to the console.
+ echo "$me: \`gettext.m4' wasn't found in directories" \
+ "$aclocaldir $extra_includes"
+ skip_ "gettext m4 macros won't be found by aclocal"
fi
;;
esac
@@ -595,6 +657,19 @@ if test "$sh_errexit_works" = yes; then
trap 'exit_status=$?
set +e
cd "$testbuilddir"
+ # This is to ensure that a test script does give a SKIP outcome just
+ # because a command in it happens to exit with status 77. This
+ # behaviour, while from time to time useful to developers, is not
+ # meant to be enabled by default, as it could cause spurious failures
+ # in the wild. Thus it will be enabled only when the variable
+ # "am_explicit_skips" is set to a "true" value.
+ case $am_explicit_skips in
+ [yY]|[yY]es|1)
+ if test $exit_status -eq 77 && test $am__test_skipped != yes; then
+ exit_status=78
+ fi
+ ;;
+ esac
case $exit_status,$keep_testdirs in
0,)
find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";"