autoconf/tests/tools.m4
Akim Demaille 54c26866f9 * tests/tools.m4 (syntax.sh): The logic of the previous patch was
twisted.  Fix it so that it performs what claims the entry below.
From Nicolas Joly.
2000-02-21 12:57:47 +00:00

134 lines
2.9 KiB
Plaintext

# -*- autoconf -*-
cat <<EOF
Autoheader, autoupdate...
EOF
## -------------------------------------------------------- ##
## Check that the shell scripts are syntactically correct. ##
## -------------------------------------------------------- ##
# We use `/bin/sh -n script' to check that there are no syntax errors
# in the scripts. Although incredible, there are /bin/sh that go into
# endless loops with `-n', e.g., SunOS's:
#
# $ uname -a
# SunOS ondine 4.1.3 2 sun4m unknown
# $ cat endless.sh
# while false
# do
# :
# done
# exit 0
# $ time sh endless.sh
# sh endless.sh 0,02s user 0,03s system 78% cpu 0,064 total
# $ time sh -nx endless.sh
# ^Csh -nx endless.sh 3,67s user 0,03s system 63% cpu 5,868 total
#
# So before using `/bin/sh -n' to check our scripts, we first check
# that `/bin/sh -n' is not broken to death.
AT_SETUP(Syntax of the scripts)
# A script that never returns. We don't care that it never returns,
# broken /bin/sh loop equally with `false', but it makes it easier to
# test the robusteness in a good environment: just remove the `-n'.
AT_DATA(endless.sh,
[[while true
do
:
done
]])
# A script in charge of testing `/bin/sh -n'.
AT_DATA(syntax.sh,
[[(/bin/sh -n endless.sh) &
sleep 2
if kill $! >/dev/null 2>&1; then
# We managed to kill the child, which means that we probably
# can't trust `/bin/sh -n', hence the test failed.
exit 1
fi
]])
if /bin/sh ./syntax.sh; then
AT_CHECK([/bin/sh -n ../autoconf], 0)
AT_CHECK([/bin/sh -n ../autoreconf], 0)
AT_CHECK([/bin/sh -n ../autoupdate], 0)
AT_CHECK([/bin/sh -n ../autoreconf], 0)
AT_CHECK([/bin/sh -n ../ifnames], 0)
fi
AT_CLEANUP
## ---------- ##
## AH_DEFUN. ##
## ---------- ##
# We check that both the AH_DEFUN given in auxiliary files and in
# `configure.in' function properly.
AT_SETUP(AH_DEFUN)
AT_DATA(configure.in,
[[AC_INCLUDE(actest.m4)
AH_DEFUN(AC_ANAKIN,
[AH_TEMPLATE(Anakin, [The future Darth Vador?])])
AC_INIT
AC_TATOOINE
AC_ANAKIN
AC_CONFIG_HEADERS(config.h:config.hin)
AC_OUTPUT
]])
# Checking `autoheader'.
AT_CHECK([../autoheader -m .. -l $at_srcdir], 0)
AT_CHECK([cat config.hin], 0,
[/* config.hin. Generated automatically from configure.in by autoheader. */
/* The future Darth Vador? */
#undef Anakin
/* The planet where Luke was raised. */
#undef Tatooine
])
AT_CLEANUP(config.hin)
## ------------ ##
## autoupdate. ##
## ------------ ##
# Check that AC_LINK_FILES and AC_OUTPUT are properly updated.
# actest.m4 AU_ defines OSBOLETE to UPDATED.
AT_SETUP(autoupdate)
AT_DATA(configure.in,
[[AC_INIT
dnl The doc says 27 is a valid fubar.
fubar=27
AC_OUTPUT(Makefile, echo $fubar, fubar=$fubar)
]])
# Checking `autoupdate'.
AT_CHECK([../autoupdate -m .. -l $at_srcdir -<configure.in], 0,
[[AC_INIT
dnl The doc says 27 is a valid fubar.
fubar=27
AC_CONFIG_FILES(Makefile)
AC_CONFIG_COMMANDS(default, [echo $fubar], [fubar=$fubar])
AC_OUTPUT
]], ignore)
AT_CLEANUP