summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2012-04-25 03:06:27 +0000
committer <>2015-01-30 17:22:32 +0000
commit55d1d2c339bc5f935f6d8d702e98b7bd5d968e9d (patch)
tree50ef475ac4188cd7eb705e81ca6c2b8f4e0a7d6c /tests
downloadautoconf-tarball-master.tar.gz
Imported from /home/lorry/working-area/delta_autoconf-tarball/autoconf-2.69.tar.xz.HEADautoconf-2.69master
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am227
-rw-r--r--tests/Makefile.in643
-rw-r--r--tests/acautoheader.at0
-rw-r--r--tests/acautoupdate.at0
-rw-r--r--tests/acc.at34
-rw-r--r--tests/acfortran.at32
-rw-r--r--tests/acfunctions.at43
-rw-r--r--tests/acgeneral.at34
-rw-r--r--tests/acgo.at15
-rw-r--r--tests/acheaders.at26
-rw-r--r--tests/aclang.at16
-rw-r--r--tests/aclibs.at15
-rw-r--r--tests/acprograms.at27
-rw-r--r--tests/acspecific.at28
-rw-r--r--tests/acstatus.at15
-rw-r--r--tests/actypes.at42
-rw-r--r--tests/atlocal.in48
-rw-r--r--tests/autoscan.at47
-rw-r--r--tests/autotest.at1955
-rw-r--r--tests/base.at710
-rw-r--r--tests/c.at418
-rw-r--r--tests/compile.at465
-rw-r--r--tests/erlang.at134
-rw-r--r--tests/foreign.at140
-rw-r--r--tests/fortran.at1164
-rw-r--r--tests/go.at33
-rw-r--r--tests/local.at527
-rw-r--r--tests/m4sh.at1957
-rw-r--r--tests/m4sugar.at2140
-rwxr-xr-xtests/mktests.sh236
-rw-r--r--tests/mktests.stamp0
-rw-r--r--tests/semantics.at746
-rw-r--r--tests/statesave.m443
-rw-r--r--tests/suite.at79
-rw-r--r--tests/tools.at1337
-rw-r--r--tests/torture.at1835
-rw-r--r--tests/wrapper.as41
37 files changed, 15252 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..c946773
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,227 @@
+## Make Autoconf tests.
+
+# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# We don't actually distribute the built testsuite or package.m4, since one
+# only needs m4 to build them, and m4 is required to install Autoconf.
+# But if you are borrowing from this file for setting up autotest in your
+# project, remember to distribute both testsuite and package.m4.
+EXTRA_DIST = $(TESTSUITE_AT) local.at mktests.sh \
+ atlocal.in wrapper.as statesave.m4
+
+# Running the uninstalled scripts. Build them upon `all', for the manpages.
+noinst_SCRIPTS = $(wrappers)
+DISTCLEANFILES = atconfig atlocal $(TESTSUITE)
+MAINTAINERCLEANFILES = Makefile.in
+
+# Import the dependencies on Autotest and M4sh.
+include ../lib/freeze.mk
+
+
+## ------------ ##
+## package.m4. ##
+## ------------ ##
+
+# The `:;' works around a redirected compound command bash exit status bug.
+package.m4: Makefile
+ :;{ \
+ echo '# Signature of the current package.' && \
+ echo 'm4_define([AT_PACKAGE_NAME], [$(PACKAGE_NAME)])' && \
+ echo 'm4_define([AT_PACKAGE_TARNAME], [$(PACKAGE_TARNAME)])' && \
+ echo 'm4_define([AT_PACKAGE_VERSION], [$(PACKAGE_VERSION)])' && \
+ echo 'm4_define([AT_PACKAGE_STRING], [$(PACKAGE_STRING)])' && \
+ echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])' && \
+ echo 'm4_define([AT_PACKAGE_URL], [$(PACKAGE_URL)])'; \
+ } > $@-t
+ mv $@-t $@
+
+
+
+## ---------- ##
+## Wrappers. ##
+## ---------- ##
+
+wrappers = autoconf autoheader autom4te autoreconf autoscan autoupdate ifnames
+CLEANFILES = wrapper.in $(wrappers) package.m4
+
+wrapper.in: $(srcdir)/wrapper.as $(m4sh_m4f_dependencies)
+ $(MY_AUTOM4TE) --language=M4sh $(srcdir)/wrapper.as -o $@
+
+edit = sed \
+ -e 's|@wrap_program[@]|$@|g' \
+ -e 's|@abs_top_srcdir[@]|@abs_top_srcdir@|g' \
+ -e 's|@abs_top_builddir[@]|@abs_top_builddir@|g' \
+ -e "s|@configure_input[@]|Generated from $$input.|g"
+
+$(wrappers): wrapper.in
+ rm -f $@ $@.tmp
+ input=wrapper.in; \
+ $(edit) wrapper.in >$@.tmp
+ chmod +x $@.tmp
+ chmod a-w $@.tmp
+ mv -f $@.tmp $@
+
+
+
+## ------------ ##
+## Test suite. ##
+## ------------ ##
+
+TESTSUITE_GENERATED_AT = \
+ $(srcdir)/aclang.at \
+ $(srcdir)/acc.at \
+ $(srcdir)/acfortran.at \
+ $(srcdir)/acgo.at \
+ $(srcdir)/acgeneral.at \
+ $(srcdir)/acstatus.at \
+ $(srcdir)/acautoheader.at \
+ $(srcdir)/acautoupdate.at \
+ $(srcdir)/acspecific.at \
+ $(srcdir)/acfunctions.at \
+ $(srcdir)/acheaders.at \
+ $(srcdir)/actypes.at \
+ $(srcdir)/aclibs.at \
+ $(srcdir)/acprograms.at
+
+TESTSUITE_HAND_AT = \
+ suite.at \
+ m4sugar.at m4sh.at autotest.at \
+ base.at tools.at torture.at \
+ compile.at c.at erlang.at fortran.at go.at \
+ semantics.at \
+ autoscan.at \
+ foreign.at
+
+TESTSUITE_AT = $(TESTSUITE_GENERATED_AT) $(TESTSUITE_HAND_AT)
+TESTSUITE = ./testsuite
+
+# Run the non installed autom4te.
+# Don't use AUTOM4TE since `make alpha' makes it unavailable although
+# we are allowed to use it (since we ship it).
+AUTOTEST = $(MY_AUTOM4TE) --language=autotest
+$(TESTSUITE): package.m4 \
+ local.at \
+ $(TESTSUITE_AT) \
+ $(autotest_m4f_dependencies)
+ cd $(top_builddir)/lib/autotest && $(MAKE) $(AM_MAKEFLAGS) autotest.m4f
+ $(AUTOTEST) -I . -I $(srcdir) suite.at -o $@.tmp
+ mv $@.tmp $@
+
+atconfig: $(top_builddir)/config.status
+ cd $(top_builddir) && ./config.status tests/$@
+
+# Avoid a race condition that would make parallel "distclean" fail.
+# The rule in clean-local tests for existence of $(TESTSUITE), and
+# if found, attempts to run it. But the distclean-generic rule may
+# be running in parallel, and it removes $(DISTCLEANFILES) which
+# includes $(TESTSUITE). This is the Automake rule, plus our
+# dependency, and we silence the warning from 'automake -Wall' by
+# hiding the dependency behind a variable.
+# TODO - fix this if newer automake accommodates the dependency.
+distclean_generic = distclean-generic
+$(distclean_generic): clean-local
+
+clean-local:
+ test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
+ rm -f *.tmp
+ rm -f -r autom4te.cache
+
+check-local: atconfig atlocal $(TESTSUITE)
+ $(SHELL) $(TESTSUITE) $(TESTSUITEFLAGS)
+
+# Run the test suite on the *installed* tree.
+installcheck-local: atconfig atlocal $(TESTSUITE)
+ $(SHELL) $(TESTSUITE) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS)
+
+
+
+## ------------------ ##
+## Maintainer rules. ##
+## ------------------ ##
+
+MAINTAINERCLEANFILES += $(TESTSUITE_GENERATED_AT)
+
+## Producing the test files.
+
+# The files which contain macros we check for syntax. Use $(top_srcdir)
+# for the benefit of non-GNU make. Fix the names in the rule below
+# where we `cd' to $srcdir.
+autoconfdir = $(top_srcdir)/lib/autoconf
+AUTOCONF_FILES = $(autoconfdir)/general.m4 \
+ $(autoconfdir)/status.m4 \
+ $(autoconfdir)/autoheader.m4 \
+ $(autoconfdir)/autoupdate.m4 \
+ $(autoconfdir)/specific.m4 \
+ $(autoconfdir)/functions.m4 \
+ $(autoconfdir)/lang.m4 \
+ $(autoconfdir)/c.m4 \
+ $(autoconfdir)/erlang.m4 \
+ $(autoconfdir)/fortran.m4 \
+ $(autoconfdir)/go.m4 \
+ $(autoconfdir)/headers.m4 \
+ $(autoconfdir)/libs.m4 \
+ $(autoconfdir)/types.m4 \
+ $(autoconfdir)/programs.m4
+
+$(TESTSUITE_GENERATED_AT): mktests.stamp
+## Recover from the removal of $@
+ @if test -f $@; then :; else \
+ rm -f mktests.stamp; \
+ $(MAKE) $(AM_MAKEFLAGS) mktests.stamp; \
+ fi
+
+mktests.stamp : mktests.sh $(AUTOCONF_FILES)
+ @rm -f mktests.tmp
+ @touch mktests.tmp
+ cd $(srcdir) && ./mktests.sh \
+ `echo " "$(AUTOCONF_FILES) | sed 's, [^ ]*/, ../lib/autoconf/,g'`
+ @mv -f mktests.tmp $@
+
+## Distribute the stamp file, since we distribute the generated files.
+EXTRA_DIST += mktests.stamp
+CLEANFILES += mktests.tmp
+MAINTAINERCLEANFILES += mktests.stamp
+
+## maintainer-check ##
+
+# These cannot be run in parallel.
+maintainer-check:
+ $(MAKE) $(AM_MAKEFLAGS) maintainer-check-posix
+ $(MAKE) $(AM_MAKEFLAGS) maintainer-check-c++
+
+# The hairy heredoc is more robust than using echo.
+CLEANFILES += expr
+expr:
+ :;{ \
+ echo '#! $(SHELL)'; \
+ echo 'result=`$(EXPR) "$$@"`'; \
+ echo 'estatus=$$?'; \
+ echo 'cat <<EOF'; \
+ echo '$${result:-0}'; \
+ echo 'EOF'; \
+ echo 'exit $$estatus'; \
+ } > $@-t
+ chmod +x $@-t
+ mv $@-t $@
+
+# Try the test suite with more severe environments.
+maintainer-check-posix: expr
+ POSIXLY_CORRECT=yes $(MAKE) $(AM_MAKEFLAGS) check
+ rm expr
+
+# Try using G++ as a C compiler.
+maintainer-check-c++:
+ CC=g++ $(MAKE) $(AM_MAKEFLAGS) check
diff --git a/tests/Makefile.in b/tests/Makefile.in
new file mode 100644
index 0000000..3460771
--- /dev/null
+++ b/tests/Makefile.in
@@ -0,0 +1,643 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Freeze M4 files.
+
+# Copyright (C) 2002, 2004, 2006-2012 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+DIST_COMMON = $(srcdir)/../lib/freeze.mk $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in $(srcdir)/atlocal.in
+subdir = tests
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
+ $(top_srcdir)/m4/m4.m4 $(top_srcdir)/m4/make-case.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES = atlocal
+CONFIG_CLEAN_VPATH_FILES =
+SCRIPTS = $(noinst_SCRIPTS)
+SOURCES =
+DIST_SOURCES =
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMACS = @EMACS@
+EMACSLOADPATH = @EMACSLOADPATH@
+EXPR = @EXPR@
+GREP = @GREP@
+HELP2MAN = @HELP2MAN@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+M4 = @M4@
+M4_DEBUGFILE = @M4_DEBUGFILE@
+M4_GNU = @M4_GNU@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PERL_FLOCK = @PERL_FLOCK@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TEST_EMACS = @TEST_EMACS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_cv_dir_trailing_space = @ac_cv_dir_trailing_space@
+ac_cv_sh_n_works = @ac_cv_sh_n_works@
+ac_cv_unsupported_fs_chars = @ac_cv_unsupported_fs_chars@
+am__leading_dot = @am__leading_dot@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+lispdir = @lispdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+# We don't actually distribute the built testsuite or package.m4, since one
+# only needs m4 to build them, and m4 is required to install Autoconf.
+# But if you are borrowing from this file for setting up autotest in your
+# project, remember to distribute both testsuite and package.m4.
+EXTRA_DIST = $(TESTSUITE_AT) local.at mktests.sh atlocal.in wrapper.as \
+ statesave.m4 mktests.stamp
+
+# Running the uninstalled scripts. Build them upon `all', for the manpages.
+noinst_SCRIPTS = $(wrappers)
+DISTCLEANFILES = atconfig atlocal $(TESTSUITE)
+MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE_GENERATED_AT) \
+ mktests.stamp
+SUFFIXES = .m4 .m4f
+AUTOM4TE_CFG = $(top_builddir)/lib/autom4te.cfg
+
+# Do not use AUTOM4TE here, since maint.mk (my-distcheck)
+# checks if we are independent of Autoconf by defining AUTOM4TE (and
+# others) to `false'. Autoconf provides autom4te, so that doesn't
+# apply to us.
+MY_AUTOM4TE = \
+ autom4te_perllibdir='$(top_srcdir)'/lib \
+ AUTOM4TE_CFG='$(AUTOM4TE_CFG)' $(top_builddir)/bin/autom4te \
+ -B '$(top_builddir)'/lib -B '$(top_srcdir)'/lib # keep ` '
+
+
+# Factor the dependencies between all the frozen files.
+# Some day we should explain to Automake how to use autom4te to compute
+# the dependencies...
+src_libdir = $(top_srcdir)/lib
+build_libdir = $(top_builddir)/lib
+m4f_dependencies = $(top_builddir)/bin/autom4te $(AUTOM4TE_CFG)
+m4sugar_m4f_dependencies = \
+ $(m4f_dependencies) \
+ $(src_libdir)/m4sugar/m4sugar.m4 \
+ $(build_libdir)/m4sugar/version.m4
+
+m4sh_m4f_dependencies = \
+ $(m4sugar_m4f_dependencies) \
+ $(src_libdir)/m4sugar/m4sh.m4
+
+autotest_m4f_dependencies = \
+ $(m4sh_m4f_dependencies) \
+ $(src_libdir)/autotest/autotest.m4 \
+ $(src_libdir)/autotest/general.m4 \
+ $(src_libdir)/autotest/specific.m4
+
+autoconf_m4f_dependencies = \
+ $(m4sh_m4f_dependencies) \
+ $(src_libdir)/autoconf/autoscan.m4 \
+ $(src_libdir)/autoconf/general.m4 \
+ $(src_libdir)/autoconf/autoheader.m4 \
+ $(src_libdir)/autoconf/autoupdate.m4 \
+ $(src_libdir)/autoconf/autotest.m4 \
+ $(src_libdir)/autoconf/status.m4 \
+ $(src_libdir)/autoconf/oldnames.m4 \
+ $(src_libdir)/autoconf/specific.m4 \
+ $(src_libdir)/autoconf/lang.m4 \
+ $(src_libdir)/autoconf/c.m4 \
+ $(src_libdir)/autoconf/fortran.m4 \
+ $(src_libdir)/autoconf/erlang.m4 \
+ $(src_libdir)/autoconf/go.m4 \
+ $(src_libdir)/autoconf/functions.m4 \
+ $(src_libdir)/autoconf/headers.m4 \
+ $(src_libdir)/autoconf/types.m4 \
+ $(src_libdir)/autoconf/libs.m4 \
+ $(src_libdir)/autoconf/programs.m4 \
+ $(src_libdir)/autoconf/autoconf.m4
+
+ETAGS_FOR_M4 = \
+ --lang=none \
+ --regex='/\(m4_define\|define\)(\[\([^]]*\)\]/\2/'
+
+ETAGS_FOR_M4SUGAR = \
+ $(ETAGS_FOR_M4) \
+ --regex='/m4_defun(\[\([^]]*\)\]/\1/'
+
+ETAGS_FOR_AUTOCONF = \
+ $(ETAGS_FOR_M4SUGAR) \
+ --regex='/\(A[CU]_DEFUN\|AU_ALIAS\)(\[\([^]]*\)\]/\2/' \
+ --regex='/AN_\(FUNCTION\|HEADER\|IDENTIFIER\|LIBRARY\|MAKEVAR\|PROGRAM\)(\[\([^]]*\)\]/\2/'
+
+wrappers = autoconf autoheader autom4te autoreconf autoscan autoupdate ifnames
+
+# The hairy heredoc is more robust than using echo.
+CLEANFILES = wrapper.in $(wrappers) package.m4 mktests.tmp expr
+edit = sed \
+ -e 's|@wrap_program[@]|$@|g' \
+ -e 's|@abs_top_srcdir[@]|@abs_top_srcdir@|g' \
+ -e 's|@abs_top_builddir[@]|@abs_top_builddir@|g' \
+ -e "s|@configure_input[@]|Generated from $$input.|g"
+
+TESTSUITE_GENERATED_AT = \
+ $(srcdir)/aclang.at \
+ $(srcdir)/acc.at \
+ $(srcdir)/acfortran.at \
+ $(srcdir)/acgo.at \
+ $(srcdir)/acgeneral.at \
+ $(srcdir)/acstatus.at \
+ $(srcdir)/acautoheader.at \
+ $(srcdir)/acautoupdate.at \
+ $(srcdir)/acspecific.at \
+ $(srcdir)/acfunctions.at \
+ $(srcdir)/acheaders.at \
+ $(srcdir)/actypes.at \
+ $(srcdir)/aclibs.at \
+ $(srcdir)/acprograms.at
+
+TESTSUITE_HAND_AT = \
+ suite.at \
+ m4sugar.at m4sh.at autotest.at \
+ base.at tools.at torture.at \
+ compile.at c.at erlang.at fortran.at go.at \
+ semantics.at \
+ autoscan.at \
+ foreign.at
+
+TESTSUITE_AT = $(TESTSUITE_GENERATED_AT) $(TESTSUITE_HAND_AT)
+TESTSUITE = ./testsuite
+
+# Run the non installed autom4te.
+# Don't use AUTOM4TE since `make alpha' makes it unavailable although
+# we are allowed to use it (since we ship it).
+AUTOTEST = $(MY_AUTOM4TE) --language=autotest
+
+# Avoid a race condition that would make parallel "distclean" fail.
+# The rule in clean-local tests for existence of $(TESTSUITE), and
+# if found, attempts to run it. But the distclean-generic rule may
+# be running in parallel, and it removes $(DISTCLEANFILES) which
+# includes $(TESTSUITE). This is the Automake rule, plus our
+# dependency, and we silence the warning from 'automake -Wall' by
+# hiding the dependency behind a variable.
+# TODO - fix this if newer automake accommodates the dependency.
+distclean_generic = distclean-generic
+
+# The files which contain macros we check for syntax. Use $(top_srcdir)
+# for the benefit of non-GNU make. Fix the names in the rule below
+# where we `cd' to $srcdir.
+autoconfdir = $(top_srcdir)/lib/autoconf
+AUTOCONF_FILES = $(autoconfdir)/general.m4 \
+ $(autoconfdir)/status.m4 \
+ $(autoconfdir)/autoheader.m4 \
+ $(autoconfdir)/autoupdate.m4 \
+ $(autoconfdir)/specific.m4 \
+ $(autoconfdir)/functions.m4 \
+ $(autoconfdir)/lang.m4 \
+ $(autoconfdir)/c.m4 \
+ $(autoconfdir)/erlang.m4 \
+ $(autoconfdir)/fortran.m4 \
+ $(autoconfdir)/go.m4 \
+ $(autoconfdir)/headers.m4 \
+ $(autoconfdir)/libs.m4 \
+ $(autoconfdir)/types.m4 \
+ $(autoconfdir)/programs.m4
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .m4 .m4f
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/../lib/freeze.mk $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu tests/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+atlocal: $(top_builddir)/config.status $(srcdir)/atlocal.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-local
+check: check-am
+all-am: Makefile $(SCRIPTS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+clean: clean-am
+
+clean-am: clean-generic clean-local mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am: installcheck-local
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: all all-am check check-am check-local clean clean-generic \
+ clean-local distclean distclean-generic distdir dvi dvi-am \
+ html html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installcheck-local installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am
+
+$(AUTOM4TE_CFG): $(top_srcdir)/lib/autom4te.in
+ cd $(top_builddir)/lib && $(MAKE) $(AM_MAKEFLAGS) autom4te.cfg
+
+# When processing the file with diversion disabled, there must be no
+# output but comments and empty lines.
+# If freezing produces output, something went wrong: a bad `divert',
+# or an improper paren etc.
+# It may happen that the output does not end with an end of line, hence
+# force an end of line when reporting errors.
+.m4.m4f:
+ $(MY_AUTOM4TE) \
+ --language=$* \
+ --freeze \
+ --output=$@
+
+# For parallel builds.
+$(build_libdir)/m4sugar/version.m4:
+ cd $(build_libdir)/m4sugar && $(MAKE) $(AM_MAKEFLAGS) version.m4
+
+check-forbidden-patterns:
+ @if (cd $(srcdir) && \
+ $(GREP) $(forbidden_patterns) $(forbidden_patterns_files)) \
+ >forbidden.log; then \
+ echo "ERROR: forbidden patterns were found:" >&2; \
+ sed "s|^|$*.m4: |" <forbidden.log >&2; \
+ echo >&2; \
+ exit 1; \
+ else \
+ rm -f forbidden.log; \
+ fi
+
+# Import the dependencies on Autotest and M4sh.
+
+# The `:;' works around a redirected compound command bash exit status bug.
+package.m4: Makefile
+ :;{ \
+ echo '# Signature of the current package.' && \
+ echo 'm4_define([AT_PACKAGE_NAME], [$(PACKAGE_NAME)])' && \
+ echo 'm4_define([AT_PACKAGE_TARNAME], [$(PACKAGE_TARNAME)])' && \
+ echo 'm4_define([AT_PACKAGE_VERSION], [$(PACKAGE_VERSION)])' && \
+ echo 'm4_define([AT_PACKAGE_STRING], [$(PACKAGE_STRING)])' && \
+ echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])' && \
+ echo 'm4_define([AT_PACKAGE_URL], [$(PACKAGE_URL)])'; \
+ } > $@-t
+ mv $@-t $@
+
+wrapper.in: $(srcdir)/wrapper.as $(m4sh_m4f_dependencies)
+ $(MY_AUTOM4TE) --language=M4sh $(srcdir)/wrapper.as -o $@
+
+$(wrappers): wrapper.in
+ rm -f $@ $@.tmp
+ input=wrapper.in; \
+ $(edit) wrapper.in >$@.tmp
+ chmod +x $@.tmp
+ chmod a-w $@.tmp
+ mv -f $@.tmp $@
+$(TESTSUITE): package.m4 \
+ local.at \
+ $(TESTSUITE_AT) \
+ $(autotest_m4f_dependencies)
+ cd $(top_builddir)/lib/autotest && $(MAKE) $(AM_MAKEFLAGS) autotest.m4f
+ $(AUTOTEST) -I . -I $(srcdir) suite.at -o $@.tmp
+ mv $@.tmp $@
+
+atconfig: $(top_builddir)/config.status
+ cd $(top_builddir) && ./config.status tests/$@
+$(distclean_generic): clean-local
+
+clean-local:
+ test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
+ rm -f *.tmp
+ rm -f -r autom4te.cache
+
+check-local: atconfig atlocal $(TESTSUITE)
+ $(SHELL) $(TESTSUITE) $(TESTSUITEFLAGS)
+
+# Run the test suite on the *installed* tree.
+installcheck-local: atconfig atlocal $(TESTSUITE)
+ $(SHELL) $(TESTSUITE) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS)
+
+$(TESTSUITE_GENERATED_AT): mktests.stamp
+ @if test -f $@; then :; else \
+ rm -f mktests.stamp; \
+ $(MAKE) $(AM_MAKEFLAGS) mktests.stamp; \
+ fi
+
+mktests.stamp : mktests.sh $(AUTOCONF_FILES)
+ @rm -f mktests.tmp
+ @touch mktests.tmp
+ cd $(srcdir) && ./mktests.sh \
+ `echo " "$(AUTOCONF_FILES) | sed 's, [^ ]*/, ../lib/autoconf/,g'`
+ @mv -f mktests.tmp $@
+
+# These cannot be run in parallel.
+maintainer-check:
+ $(MAKE) $(AM_MAKEFLAGS) maintainer-check-posix
+ $(MAKE) $(AM_MAKEFLAGS) maintainer-check-c++
+expr:
+ :;{ \
+ echo '#! $(SHELL)'; \
+ echo 'result=`$(EXPR) "$$@"`'; \
+ echo 'estatus=$$?'; \
+ echo 'cat <<EOF'; \
+ echo '$${result:-0}'; \
+ echo 'EOF'; \
+ echo 'exit $$estatus'; \
+ } > $@-t
+ chmod +x $@-t
+ mv $@-t $@
+
+# Try the test suite with more severe environments.
+maintainer-check-posix: expr
+ POSIXLY_CORRECT=yes $(MAKE) $(AM_MAKEFLAGS) check
+ rm expr
+
+# Try using G++ as a C compiler.
+maintainer-check-c++:
+ CC=g++ $(MAKE) $(AM_MAKEFLAGS) check
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tests/acautoheader.at b/tests/acautoheader.at
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/acautoheader.at
diff --git a/tests/acautoupdate.at b/tests/acautoupdate.at
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/acautoupdate.at
diff --git a/tests/acc.at b/tests/acc.at
new file mode 100644
index 0000000..a4a6cff
--- /dev/null
+++ b/tests/acc.at
@@ -0,0 +1,34 @@
+# Generated by mktests.sh. -*- Autotest -*-
+
+## --------------------- ##
+## Do not edit by hand. ##
+## --------------------- ##
+
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# 2010 Free Software Foundation, Inc.
+
+AT_BANNER([Testing autoconf/c macros.])
+
+# Modern macros.
+AT_CHECK_MACRO([AC_C_BACKSLASH_A])
+AT_CHECK_MACRO([AC_C_BIGENDIAN])
+AT_CHECK_MACRO([AC_C_CHAR_UNSIGNED])
+AT_CHECK_MACRO([AC_C_FLEXIBLE_ARRAY_MEMBER])
+AT_CHECK_MACRO([AC_C_INLINE])
+AT_CHECK_MACRO([AC_C_PROTOTYPES])
+AT_CHECK_MACRO([AC_C_RESTRICT])
+AT_CHECK_MACRO([AC_C_STRINGIZE])
+AT_CHECK_MACRO([AC_C_TYPEOF])
+AT_CHECK_MACRO([AC_C_VARARRAYS])
+AT_CHECK_MACRO([AC_OPENMP])
+AT_CHECK_MACRO([AC_PROG_CC_C89])
+AT_CHECK_MACRO([AC_PROG_CC_C99])
+AT_CHECK_MACRO([AC_PROG_CC_C_O])
+AT_CHECK_MACRO([AC_PROG_CC_STDC])
+AT_CHECK_MACRO([AC_PROG_CPP_WERROR])
+AT_CHECK_MACRO([AC_PROG_GCC_TRADITIONAL])
+
+# Obsolete macros.
+AT_CHECK_AU_MACRO([AC_LANG_C])
+AT_CHECK_AU_MACRO([AC_LANG_CPLUSPLUS])
+AT_CHECK_AU_MACRO([AC_LANG_OBJC])
diff --git a/tests/acfortran.at b/tests/acfortran.at
new file mode 100644
index 0000000..e6eaedf
--- /dev/null
+++ b/tests/acfortran.at
@@ -0,0 +1,32 @@
+# Generated by mktests.sh. -*- Autotest -*-
+
+## --------------------- ##
+## Do not edit by hand. ##
+## --------------------- ##
+
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# 2010 Free Software Foundation, Inc.
+
+AT_BANNER([Testing autoconf/fortran macros.])
+
+# Modern macros.
+AT_CHECK_MACRO([AC_F77_IMPLICIT_NONE])
+AT_CHECK_MACRO([AC_F77_MAIN])
+AT_CHECK_MACRO([AC_F77_WRAPPERS])
+AT_CHECK_MACRO([AC_FC_CHECK_BOUNDS])
+AT_CHECK_MACRO([AC_FC_FIXEDFORM])
+AT_CHECK_MACRO([AC_FC_FREEFORM])
+AT_CHECK_MACRO([AC_FC_IMPLICIT_NONE])
+AT_CHECK_MACRO([AC_FC_LINE_LENGTH])
+AT_CHECK_MACRO([AC_FC_MAIN])
+AT_CHECK_MACRO([AC_FC_MODULE_EXTENSION])
+AT_CHECK_MACRO([AC_FC_MODULE_FLAG])
+AT_CHECK_MACRO([AC_FC_MODULE_OUTPUT_FLAG])
+AT_CHECK_MACRO([AC_FC_PP_DEFINE])
+AT_CHECK_MACRO([AC_FC_WRAPPERS])
+AT_CHECK_MACRO([AC_PROG_F77_C_O])
+AT_CHECK_MACRO([AC_PROG_FC_C_O])
+
+# Obsolete macros.
+AT_CHECK_AU_MACRO([AC_F77_NAME_MANGLING])
+AT_CHECK_AU_MACRO([AC_LANG_FORTRAN77])
diff --git a/tests/acfunctions.at b/tests/acfunctions.at
new file mode 100644
index 0000000..a78c234
--- /dev/null
+++ b/tests/acfunctions.at
@@ -0,0 +1,43 @@
+# Generated by mktests.sh. -*- Autotest -*-
+
+## --------------------- ##
+## Do not edit by hand. ##
+## --------------------- ##
+
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# 2010 Free Software Foundation, Inc.
+
+AT_BANNER([Testing autoconf/functions macros.])
+
+# Modern macros.
+AT_CHECK_MACRO([AC_CHECK_FUNCS_ONCE])
+AT_CHECK_MACRO([AC_FUNC_CHOWN])
+AT_CHECK_MACRO([AC_FUNC_CLOSEDIR_VOID])
+AT_CHECK_MACRO([AC_FUNC_ERROR_AT_LINE])
+AT_CHECK_MACRO([AC_FUNC_FNMATCH])
+AT_CHECK_MACRO([AC_FUNC_FORK])
+AT_CHECK_MACRO([AC_FUNC_FSEEKO])
+AT_CHECK_MACRO([AC_FUNC_GETGROUPS])
+AT_CHECK_MACRO([AC_FUNC_GETMNTENT])
+AT_CHECK_MACRO([AC_FUNC_GETPGRP])
+AT_CHECK_MACRO([AC_FUNC_LSTAT])
+AT_CHECK_MACRO([AC_FUNC_MALLOC])
+AT_CHECK_MACRO([AC_FUNC_MBRTOWC])
+AT_CHECK_MACRO([AC_FUNC_MEMCMP])
+AT_CHECK_MACRO([AC_FUNC_MKTIME])
+AT_CHECK_MACRO([AC_FUNC_MMAP])
+AT_CHECK_MACRO([AC_FUNC_OBSTACK])
+AT_CHECK_MACRO([AC_FUNC_REALLOC])
+AT_CHECK_MACRO([AC_FUNC_SELECT_ARGTYPES])
+AT_CHECK_MACRO([AC_FUNC_SETPGRP])
+AT_CHECK_MACRO([AC_FUNC_STAT])
+AT_CHECK_MACRO([AC_FUNC_STRCOLL])
+AT_CHECK_MACRO([AC_FUNC_STRERROR_R])
+AT_CHECK_MACRO([AC_FUNC_STRFTIME])
+AT_CHECK_MACRO([AC_FUNC_STRNLEN])
+AT_CHECK_MACRO([AC_FUNC_STRTOD])
+AT_CHECK_MACRO([AC_FUNC_STRTOLD])
+AT_CHECK_MACRO([AC_FUNC_UTIME_NULL])
+AT_CHECK_MACRO([AC_FUNC_VPRINTF])
+
+# Obsolete macros.
diff --git a/tests/acgeneral.at b/tests/acgeneral.at
new file mode 100644
index 0000000..64ec531
--- /dev/null
+++ b/tests/acgeneral.at
@@ -0,0 +1,34 @@
+# Generated by mktests.sh. -*- Autotest -*-
+
+## --------------------- ##
+## Do not edit by hand. ##
+## --------------------- ##
+
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# 2010 Free Software Foundation, Inc.
+
+AT_BANNER([Testing autoconf/general macros.])
+
+# Modern macros.
+AT_CHECK_MACRO([AC_ARG_ENABLE])
+AT_CHECK_MACRO([AC_ARG_PROGRAM])
+AT_CHECK_MACRO([AC_ARG_WITH])
+AT_CHECK_MACRO([AC_CHECK_DECLS_ONCE])
+AT_CHECK_MACRO([AC_EGREP_CPP])
+AT_CHECK_MACRO([AC_EGREP_HEADER])
+AT_CHECK_MACRO([AC_LIBOBJ])
+AT_CHECK_MACRO([AC_LIBSOURCES])
+AT_CHECK_MACRO([AC_PREFIX_DEFAULT])
+
+# Obsolete macros.
+AT_CHECK_AU_MACRO([AC_CHECKING])
+AT_CHECK_AU_MACRO([AC_COMPILE_CHECK])
+AT_CHECK_AU_MACRO([AC_ENABLE])
+AT_CHECK_AU_MACRO([AC_FOREACH])
+AT_CHECK_AU_MACRO([AC_MSG_RESULT_UNQUOTED])
+AT_CHECK_AU_MACRO([AC_TRY_COMPILE])
+AT_CHECK_AU_MACRO([AC_TRY_CPP])
+AT_CHECK_AU_MACRO([AC_TRY_LINK])
+AT_CHECK_AU_MACRO([AC_TRY_RUN])
+AT_CHECK_AU_MACRO([AC_VALIDATE_CACHED_SYSTEM_TUPLE])
+AT_CHECK_AU_MACRO([AC_WITH])
diff --git a/tests/acgo.at b/tests/acgo.at
new file mode 100644
index 0000000..a1380c2
--- /dev/null
+++ b/tests/acgo.at
@@ -0,0 +1,15 @@
+# Generated by mktests.sh. -*- Autotest -*-
+
+## --------------------- ##
+## Do not edit by hand. ##
+## --------------------- ##
+
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# 2010 Free Software Foundation, Inc.
+
+AT_BANNER([Testing autoconf/go macros.])
+
+# Modern macros.
+
+# Obsolete macros.
+AT_CHECK_AU_MACRO([AC_LANG_GO])
diff --git a/tests/acheaders.at b/tests/acheaders.at
new file mode 100644
index 0000000..0bc71ab
--- /dev/null
+++ b/tests/acheaders.at
@@ -0,0 +1,26 @@
+# Generated by mktests.sh. -*- Autotest -*-
+
+## --------------------- ##
+## Do not edit by hand. ##
+## --------------------- ##
+
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# 2010 Free Software Foundation, Inc.
+
+AT_BANNER([Testing autoconf/headers macros.])
+
+# Modern macros.
+AT_CHECK_MACRO([AC_CHECK_HEADERS_ONCE])
+AT_CHECK_MACRO([AC_CHECK_HEADER_STDBOOL])
+AT_CHECK_MACRO([AC_HEADER_ASSERT])
+AT_CHECK_MACRO([AC_HEADER_MAJOR])
+AT_CHECK_MACRO([AC_HEADER_RESOLV])
+AT_CHECK_MACRO([AC_HEADER_STAT])
+AT_CHECK_MACRO([AC_HEADER_STDBOOL])
+AT_CHECK_MACRO([AC_HEADER_TIOCGWINSZ])
+
+# Obsolete macros.
+AT_CHECK_AU_MACRO([AC_DIR_HEADER])
+AT_CHECK_AU_MACRO([AC_MEMORY_H])
+AT_CHECK_AU_MACRO([AC_UNISTD_H])
+AT_CHECK_AU_MACRO([AC_USG])
diff --git a/tests/aclang.at b/tests/aclang.at
new file mode 100644
index 0000000..978b5eb
--- /dev/null
+++ b/tests/aclang.at
@@ -0,0 +1,16 @@
+# Generated by mktests.sh. -*- Autotest -*-
+
+## --------------------- ##
+## Do not edit by hand. ##
+## --------------------- ##
+
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# 2010 Free Software Foundation, Inc.
+
+AT_BANNER([Testing autoconf/lang macros.])
+
+# Modern macros.
+AT_CHECK_MACRO([AC_NO_EXECUTABLES])
+AT_CHECK_MACRO([AC_REQUIRE_CPP])
+
+# Obsolete macros.
diff --git a/tests/aclibs.at b/tests/aclibs.at
new file mode 100644
index 0000000..b4a9274
--- /dev/null
+++ b/tests/aclibs.at
@@ -0,0 +1,15 @@
+# Generated by mktests.sh. -*- Autotest -*-
+
+## --------------------- ##
+## Do not edit by hand. ##
+## --------------------- ##
+
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# 2010 Free Software Foundation, Inc.
+
+AT_BANNER([Testing autoconf/libs macros.])
+
+# Modern macros.
+
+# Obsolete macros.
+AT_CHECK_AU_MACRO([AC_HAVE_LIBRARY])
diff --git a/tests/acprograms.at b/tests/acprograms.at
new file mode 100644
index 0000000..6fd2463
--- /dev/null
+++ b/tests/acprograms.at
@@ -0,0 +1,27 @@
+# Generated by mktests.sh. -*- Autotest -*-
+
+## --------------------- ##
+## Do not edit by hand. ##
+## --------------------- ##
+
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# 2010 Free Software Foundation, Inc.
+
+AT_BANNER([Testing autoconf/programs macros.])
+
+# Modern macros.
+AT_CHECK_MACRO([AC_PROG_AWK])
+AT_CHECK_MACRO([AC_PROG_FGREP])
+AT_CHECK_MACRO([AC_PROG_INSTALL])
+AT_CHECK_MACRO([AC_PROG_LEX])
+AT_CHECK_MACRO([AC_PROG_LN_S])
+AT_CHECK_MACRO([AC_PROG_MAKE_SET])
+AT_CHECK_MACRO([AC_PROG_MKDIR_P])
+AT_CHECK_MACRO([AC_PROG_RANLIB])
+AT_CHECK_MACRO([AC_PROG_SED])
+AT_CHECK_MACRO([AC_PROG_YACC])
+
+# Obsolete macros.
+AT_CHECK_AU_MACRO([AC_CHECK_TOOL_PREFIX])
+AT_CHECK_AU_MACRO([AC_DECL_YYTEXT])
+AT_CHECK_AU_MACRO([AC_RSH])
diff --git a/tests/acspecific.at b/tests/acspecific.at
new file mode 100644
index 0000000..fbf533a
--- /dev/null
+++ b/tests/acspecific.at
@@ -0,0 +1,28 @@
+# Generated by mktests.sh. -*- Autotest -*-
+
+## --------------------- ##
+## Do not edit by hand. ##
+## --------------------- ##
+
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# 2010 Free Software Foundation, Inc.
+
+AT_BANNER([Testing autoconf/specific macros.])
+
+# Modern macros.
+AT_CHECK_MACRO([AC_SYS_INTERPRETER])
+AT_CHECK_MACRO([AC_SYS_LARGEFILE])
+AT_CHECK_MACRO([AC_SYS_LONG_FILE_NAMES])
+AT_CHECK_MACRO([AC_SYS_POSIX_TERMIOS])
+
+# Obsolete macros.
+AT_CHECK_AU_MACRO([AC_AIX])
+AT_CHECK_AU_MACRO([AC_ARG_ARRAY])
+AT_CHECK_AU_MACRO([AC_DECL_SYS_SIGLIST])
+AT_CHECK_AU_MACRO([AC_DYNIX_SEQ])
+AT_CHECK_AU_MACRO([AC_HAVE_POUNDBANG])
+AT_CHECK_AU_MACRO([AC_IRIX_SUN])
+AT_CHECK_AU_MACRO([AC_ISC_POSIX])
+AT_CHECK_AU_MACRO([AC_MINIX])
+AT_CHECK_AU_MACRO([AC_SCO_INTL])
+AT_CHECK_AU_MACRO([AC_XENIX_DIR])
diff --git a/tests/acstatus.at b/tests/acstatus.at
new file mode 100644
index 0000000..37c96cf
--- /dev/null
+++ b/tests/acstatus.at
@@ -0,0 +1,15 @@
+# Generated by mktests.sh. -*- Autotest -*-
+
+## --------------------- ##
+## Do not edit by hand. ##
+## --------------------- ##
+
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# 2010 Free Software Foundation, Inc.
+
+AT_BANNER([Testing autoconf/status macros.])
+
+# Modern macros.
+
+# Obsolete macros.
+AT_CHECK_AU_MACRO([AC_OUTPUT_COMMANDS])
diff --git a/tests/actypes.at b/tests/actypes.at
new file mode 100644
index 0000000..babec18
--- /dev/null
+++ b/tests/actypes.at
@@ -0,0 +1,42 @@
+# Generated by mktests.sh. -*- Autotest -*-
+
+## --------------------- ##
+## Do not edit by hand. ##
+## --------------------- ##
+
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# 2010 Free Software Foundation, Inc.
+
+AT_BANNER([Testing autoconf/types macros.])
+
+# Modern macros.
+AT_CHECK_MACRO([AC_STRUCT_DIRENT_D_INO])
+AT_CHECK_MACRO([AC_STRUCT_DIRENT_D_TYPE])
+AT_CHECK_MACRO([AC_STRUCT_ST_BLOCKS])
+AT_CHECK_MACRO([AC_STRUCT_TIMEZONE])
+AT_CHECK_MACRO([AC_TYPE_INT16_T])
+AT_CHECK_MACRO([AC_TYPE_INT32_T])
+AT_CHECK_MACRO([AC_TYPE_INT64_T])
+AT_CHECK_MACRO([AC_TYPE_INT8_T])
+AT_CHECK_MACRO([AC_TYPE_INTMAX_T])
+AT_CHECK_MACRO([AC_TYPE_INTPTR_T])
+AT_CHECK_MACRO([AC_TYPE_LONG_DOUBLE])
+AT_CHECK_MACRO([AC_TYPE_LONG_DOUBLE_WIDER])
+AT_CHECK_MACRO([AC_TYPE_MODE_T])
+AT_CHECK_MACRO([AC_TYPE_OFF_T])
+AT_CHECK_MACRO([AC_TYPE_SSIZE_T])
+AT_CHECK_MACRO([AC_TYPE_UINT16_T])
+AT_CHECK_MACRO([AC_TYPE_UINT32_T])
+AT_CHECK_MACRO([AC_TYPE_UINT64_T])
+AT_CHECK_MACRO([AC_TYPE_UINT8_T])
+AT_CHECK_MACRO([AC_TYPE_UINTMAX_T])
+AT_CHECK_MACRO([AC_TYPE_UINTPTR_T])
+
+# Obsolete macros.
+AT_CHECK_AU_MACRO([AC_C_LONG_DOUBLE])
+AT_CHECK_AU_MACRO([AC_INT_16_BITS])
+AT_CHECK_AU_MACRO([AC_LONG_64_BITS])
+AT_CHECK_AU_MACRO([AC_STRUCT_ST_BLKSIZE])
+AT_CHECK_AU_MACRO([AC_STRUCT_ST_RDEV])
+AT_CHECK_AU_MACRO([AC_TYPE_SIGNAL])
+AT_CHECK_AU_MACRO([AM_TYPE_PTRDIFF_T])
diff --git a/tests/atlocal.in b/tests/atlocal.in
new file mode 100644
index 0000000..bf29d1c
--- /dev/null
+++ b/tests/atlocal.in
@@ -0,0 +1,48 @@
+# -*- shell-script -*-
+# @configure_input@
+# Configurable variable values for Autoconf test suite.
+
+# Copyright (C) 2000-2001, 2005, 2008-2012 Free Software Foundation,
+# Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+PERL='@PERL@'
+GREP='@GREP@'
+EGREP='@EGREP@'
+SED='@SED@'
+
+# We need to know if sh -n is ok.
+ac_cv_sh_n_works='@ac_cv_sh_n_works@'
+
+# Check whether the underlying system can manage some unusual
+# symbols in file names.
+if test -z '@ac_cv_unsupported_fs_chars@'; then
+ func_sanitize_file_name () { echo "$@"; }
+else
+ func_sanitize_file_name () { echo "$@" | tr -d '@ac_cv_unsupported_fs_chars@'; }
+fi
+
+# Can we create directories with trailing whitespace in their names?
+ac_cv_dir_trailing_space='@ac_cv_dir_trailing_space@'
+if test "$ac_cv_dir_trailing_space" = yes; then
+ func_sanitize_dir_name () { echo "$@"; }
+else
+ func_sanitize_dir_name () { echo "$@" | sed 's/ *$//'; }
+fi
+
+# AUTOM4TE might be set in the environment. Override it here so that
+# direct aclocal invocations also use it.
+AUTOM4TE=autom4te
+export AUTOM4TE
diff --git a/tests/autoscan.at b/tests/autoscan.at
new file mode 100644
index 0000000..0130997
--- /dev/null
+++ b/tests/autoscan.at
@@ -0,0 +1,47 @@
+# -*- Autotest -*-
+
+AT_BANNER([Autoscan.])
+
+# Copyright (C) 2005, 2009-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([autoscan])
+
+AT_DATA([Makefile.am],
+[[SUBDIRS = subpkg
+]])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PREREQ(2.59)
+AM_INIT_AUTOMAKE(foreign)
+AC_CONFIG_SUBDIRS(subpkg)
+AC_CONFIG_FILES(Makefile)
+AC_OUTPUT
+]])
+
+mkdir subpkg
+
+AT_DATA([subpkg/Makefile.am], [])
+AT_DATA([subpkg/configure.ac],
+[[AC_INIT
+AM_INIT_AUTOMAKE(foreign)
+AC_CONFIG_FILES(Makefile)
+AC_OUTPUT
+]])
+AT_CHECK([autoscan])
+AT_CHECK([grep subpkg/Makefile configure.scan], [1], [], [ignore])
+
+AT_CLEANUP
diff --git a/tests/autotest.at b/tests/autotest.at
new file mode 100644
index 0000000..b56d3f8
--- /dev/null
+++ b/tests/autotest.at
@@ -0,0 +1,1955 @@
+# -*- Autotest -*-
+
+AT_BANNER([Autotest.])
+
+# Copyright (C) 2004-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+# AT_DATA_AUTOTEST(FILE-NAME, CONTENTS)
+# -------------------------------------
+# Escape the invalid tokens with @&t@.
+m4_define([AT_DATA_AUTOTEST],
+[AT_DATA([$1],
+[m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\|AS\|AT\)\(_\)\|\(d\)\(nl\)],
+ [\1\3\5@&t@\2\4\6])])])
+
+
+# AT_CHECK_AT_PREP(NAME, SUITE-CODE, [STATUS = 0], [STDOUT], [STDERR],
+# [DIR = .])
+# --------------------------------------------------------------------
+# Create a new testsuite named NAME that runs a minimal Autotest test suite,
+# SUITE-CODE. Do not use `testsuite' for NAME, or the log file it generates
+# will overwrite the log that the Autoconf test produces when managing
+# this test case. STATUS, STDOUT, and STDERR pass directly to the AT_CHECK
+# that compiles the testsuite. DIR can specify a particular subdirectory
+# where the testsuite should live.
+m4_define([AT_CHECK_AT_PREP],
+[AT_KEYWORDS([autotest])dnl
+dnl overquote AT_dir, to make it easier to use
+m4_pushdef([AT_dir], m4_ifval([$6], [[[$6]]], [.]))dnl
+dnl
+AT_CAPTURE_FILE(AT_dir[/$1.log])dnl
+dnl
+AT_DATA_AUTOTEST(AT_dir[/package.m4],
+[[m4_define([AT_PACKAGE_NAME], [GNU Nonsense])
+m4_define([AT_PACKAGE_TARNAME], [nonsense])
+m4_define([AT_PACKAGE_VERSION], [1.0])
+m4_define([AT_PACKAGE_STRING], [GNU Nonsense 1.0])
+m4_define([AT_PACKAGE_BUGREPORT], [bug-autoconf@gnu.org])
+]])
+dnl
+AT_DATA_AUTOTEST(AT_dir[/$1.at], [$2])
+AT_CHECK([cat >m4_default([$6], [.])/atconfig <<EOF
+at_testdir=m4_default([$6], [.])
+abs_builddir='`pwd`'
+at_srcdir=.
+abs_srcdir='`pwd`'
+at_top_srcdir=.
+abs_top_srcdir='`pwd`'
+at_top_build_prefix=
+abs_top_builddir='`pwd`'
+EOF])
+m4_ifval([$6], [(cd AT_dir])
+AT_CHECK_AUTOM4TE([--language=autotest -o $1 $1.at], [$3], [$4], [$5])
+m4_ifval([$6], [)])
+m4_popdef([AT_dir])dnl
+]) # AT_CHECK_AT_PREP
+
+# AT_CHECK_AT(TITLE, SUITE-CODE, [XFAIL-CONDITION], [STATUS = 0],
+# [STDOUT = ignore], STDERR, [PRE-TEST-CODE],
+# [POST-TEST-CODE], [SUITE-ARGS])
+# ---------------------------------------------------------------
+# Create a new test named TITLE that runs a minimal Autotest test suite,
+# SUITE-CODE with additional SUITE-ARGS, once without and once with
+# '-v -x' added. Call AT_XFAIL_IF with XFAIL-CONDITION. Pass STDERR
+# directly to the AT_CHECK that calls the minimal test suite, STDOUT to
+# the AT_CHECK without '-v -x'; ignore stdout for the latter.
+# Run PRE-TEST-CODE at the top level after the micro-suite is created, but
+# before it is run, and POST-TEST-CODE after the micro-suite has been run.
+m4_define([AT_CHECK_AT],
+[AT_SETUP([$1])
+AT_XFAIL_IF([$3])
+AT_CHECK_AT_PREP([micro-suite], [$2])
+$7
+AT_CHECK([$CONFIG_SHELL ./micro-suite $9], m4_default([$4], 0),
+ m4_default([$5], [ignore]), [$6])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -v -x $9], m4_default([$4], 0),
+ [ignore], [$6])
+$8
+AT_CLEANUP
+])# AT_CHECK_AT
+
+# AT_CHECK_AT_TEST(TITLE, SUITE-SNIPPET, ...)
+# -------------------------------------------
+# Wrapper for AT_CHECK_AT that surrounds SUITE-SNIPPET with a boilerplate
+# AT_INIT, AT_SETUP, and AT_CLEANUP and passes other arguments verbatim.
+m4_define([AT_CHECK_AT_TEST],
+[AT_CHECK_AT([$1],
+[[
+AT_INIT([artificial test suite])
+AT_SETUP([my only test])
+$2
+AT_CLEANUP
+]], m4_shift2($@))]) # AT_CHECK_AT_TEST
+
+# AT_CHECK_AT_SYNTAX(TITLE, SUITE, MESSAGE)
+# -----------------------------------------
+# Create a test named TITLE that tries compiling SUITE with syntax
+# errors with autotest. Expect a failed compilation, and grep for
+# MESSAGE occurring within the error output.
+m4_define([AT_CHECK_AT_SYNTAX],
+[AT_SETUP([$1])
+AT_CHECK_AT_PREP([micro-suite], [$2], [1], [], [stderr])
+AT_CHECK([grep '$3' stderr], [0], [ignore])
+AT_CLEANUP
+])# AT_CHECK_AT_SYNTAX
+
+
+# AT_NO_CMDSUBST
+# --------------
+m4_define([AT_NO_CMDSUBST],
+[if (eval 'foo=$(echo bar) && test "$foo" = bar') >/dev/null 2>&1; then ]dnl
+[false; else :; fi])
+
+# AT_CHECK_EGREP(PATTERN, STATUS, COUNT)
+# --------------------------------------
+# Run grep -E, counting how many times PATTERN occurs in the file 'stdout',
+# and expecting exit STATUS and output COUNT.
+m4_define([AT_CHECK_EGREP],
+[AT_CHECK([$EGREP -c '$1' stdout], [$2], [$3
+], [ignore])
+])
+
+
+## -------------- ##
+## AT_COPYRIGHT. ##
+## -------------- ##
+
+# Ensure the FSF notice as well as the user-provided one are present
+# in the head of the testsuite as well as the --version output.
+
+AT_CHECK_AT([AT@&t@_COPYRIGHT],
+[[AT_INIT([Testing AT@&t@_COPYRIGHT])
+AT_COPYRIGHT([[This is just a test notice, not a real one, so let's avoid
+words that may be matched by scanners for legal things,
+causing extra work for distributors.
+Multi-line values should be supported.
+]])
+]], [], [], [stdout], [], [], [
+AT_CHECK([grep 'Copyright.*Free Software Foundation' stdout], [], [ignore])
+AT_CHECK([grep 'This is just a test notice' stdout], [], [ignore])
+AT_CHECK([sed 50q micro-suite | grep 'Copyright.*Free Software Foundation'],
+ [], [ignore])
+AT_CHECK([sed 50q micro-suite | grep 'This is just a test notice'],
+ [], [ignore])],
+[--version])
+
+
+## --------- ##
+## AT_DATA. ##
+## --------- ##
+
+AT_CHECK_AT_TEST([AT@&t@_DATA], [
+AT_CHECK([test -f file1], [1])
+AT_DATA([file1])
+AT_CHECK([test -f file1 && test ! -s file1])
+AT_CHECK([echo hi > file1])
+AT_DATA([file1], [[]])
+AT_CHECK([test -f file1 && test ! -s file1])
+file=file2
+AT_DATA([$file], [[$file
+]])
+AT_CHECK([echo '$file' > file3])
+AT_CHECK([cmp file2 file3])
+])
+
+
+## ------------------ ##
+## Empty test suite. ##
+## ------------------ ##
+
+# This is not a sensible thing to do, but the user should not get an unhelpful
+# error message.
+AT_CHECK_AT([Empty test suite],
+[[AT_INIT([empty test suite])
+]])
+
+AT_CHECK_AT([Banner-only test suite],
+[[AT_INIT([empty test suite])
+AT_BANNER([banner])
+]])
+
+# Next level of emptiness.
+AT_CHECK_AT_TEST([Empty test], [])
+
+# And finally, an empty check should not cause a syntax error.
+AT_CHECK_AT_TEST([Empty check], [AT_CHECK])
+
+# Check for sensible error messages for common bugs.
+AT_CHECK_AT_SYNTAX([AT@&t@_SETUP without AT@&t@_INIT],
+[[AT_SETUP([only test])
+AT_CHECK([:])
+AT_CLEANUP
+]], [AT@&t@_SETUP: missing AT@&t@_INIT detected])
+
+AT_CHECK_AT_SYNTAX([AT@&t@_BANNER without AT@&t@_INIT],
+[[AT_BANNER([just a banner])
+]], [AT@&t@_BANNER: missing AT@&t@_INIT detected])
+
+AT_CHECK_AT_SYNTAX([AT@&t@_CLEANUP without AT@&t@_INIT],
+[[AT_CLEANUP
+]], [AT@&t@_CLEANUP: missing AT@&t@_INIT detected])
+
+AT_CHECK_AT_SYNTAX([Missing AT@&t@_CLEANUP],
+[[AT_INIT([incomplete test suite])
+AT_SETUP([only test])
+AT_CHECK([:])
+]], [missing AT@&t@_CLEANUP detected])
+
+AT_CHECK_AT_SYNTAX([AT@&t@_FAIL_IF without AT@&t@_SETUP],
+[[AT_INIT([incomplete test suite])
+AT_FAIL_IF([:])
+]], [AT@&t@_FAIL_IF: missing AT@&t@_SETUP detected])
+
+AT_CHECK_AT_SYNTAX([AT@&t@_SKIP_IF without AT@&t@_SETUP],
+[[AT_INIT([incomplete test suite])
+AT_SKIP_IF([:])
+]], [AT@&t@_SKIP_IF: missing AT@&t@_SETUP detected])
+
+AT_CHECK_AT_SYNTAX([AT@&t@_CHECK without AT@&t@_SETUP],
+[[AT_INIT([incomplete test suite])
+AT_CHECK([:])
+]], [AT@&t@_CHECK: missing AT@&t@_SETUP detected])
+
+AT_CHECK_AT_SYNTAX([AT@&t@_DATA without AT@&t@_SETUP],
+[[AT_INIT([incomplete test suite])
+AT_DATA([file])
+]], [AT@&t@_DATA: missing AT@&t@_SETUP detected])
+
+AT_CHECK_AT_SYNTAX([AT@&t@_XFAIL_IF without AT@&t@_SETUP],
+[[AT_INIT([incomplete test suite])
+AT_XFAIL_IF([:])
+]], [AT@&t@_XFAIL_IF: missing AT@&t@_SETUP detected])
+
+AT_CHECK_AT_SYNTAX([AT@&t@_KEYWORDS without AT@&t@_SETUP],
+[[AT_INIT([incomplete test suite])
+AT_KEYWORDS([keyword])
+]], [AT@&t@_KEYWORDS: missing AT@&t@_SETUP detected])
+
+AT_CHECK_AT_SYNTAX([AT@&t@_CLEANUP without AT@&t@_SETUP],
+[[AT_INIT([incomplete test suite])
+AT_CLEANUP
+]], [AT@&t@_CLEANUP: missing AT@&t@_SETUP detected])
+
+AT_CHECK_AT_SYNTAX([AT@&t@_BANNER inside AT@&t@_SETUP],
+[[AT_INIT([incomplete test suite])
+AT_SETUP([only test])
+AT_BANNER([banner])
+AT_CHECK([:])
+AT_CLEANUP
+]], [AT@&t@_BANNER: nested AT@&t@_SETUP detected])
+
+AT_CHECK_AT_SYNTAX([AT@&t@_SETUP inside AT@&t@_SETUP],
+[[AT_INIT([incomplete test suite])
+AT_SETUP([only test])
+ AT_SETUP([nested test])
+ AT_CHECK([:])
+ AT_CLEANUP
+AT_CHECK([:])
+AT_CLEANUP
+]], [AT@&t@_SETUP: nested AT@&t@_SETUP detected])
+
+AT_CHECK_AT_SYNTAX([Multiple AT@&t@_INIT],
+[[AT_INIT([[suite, take one]])
+AT_INIT([repeat])
+]], [AT@&t@_INIT: invoked multiple times])
+
+# Check for tested programs. autoconf should only appear once.
+AT_CHECK_AT([Tested programs],
+[[AT_INIT([programs test suite])
+AT_TESTED([autoconf autom4te])
+AT_TESTED([autoconf])
+]], [], [], [], [], [],
+[AT_CHECK([[sed -n 's|.*/\([^ /]* --version\)|\1|p' micro-suite.log]], [],
+[[autoconf --version
+autom4te --version
+]])])
+
+AT_CHECK_AT([Startup error messages],
+[[AT_INIT([[suite]])
+AT_SETUP([only test])
+AT_CHECK([:])
+AT_CLEANUP
+]], [], [], [], [], [],
+[AT_CHECK([sed -n '/exec AS_MESSAGE_LOG_FD/q; />&AS_MESSAGE_LOG_FD/p' < micro-suite])])
+
+## ----------------- ##
+## Status handling. ##
+## ----------------- ##
+
+AT_CHECK_AT_TEST([Truth],
+ [AT_CHECK([:], 0, [], [])])
+
+AT_CHECK_AT_TEST([Fallacy],
+ [AT_CHECK([false], [], [], [])],
+ [], [1], [], [ignore], [],
+ [AT_CHECK([grep failed micro-suite.log], [], [ignore])])
+
+AT_CHECK_AT_TEST([Skip],
+ [AT_CHECK([echo output; echo irrelevant >&2; exit 77], 0, [mismatch], [])],
+ [], [], [], [], [],
+ [AT_CHECK([grep skipped micro-suite.log], [], [ignore])])
+
+AT_CHECK_AT_TEST([Hard fail],
+ [AT_CHECK([exit 99])
+ AT_CLEANUP
+ AT_SETUP([another test])
+ AT_XFAIL_IF([:])
+ AT_CHECK([exit 99])],
+ [], [1], [], [ignore], [],
+ [AT_CHECK([grep '2 failed unexpectedly' micro-suite.log], [], [ignore])
+ AT_CHECK([grep '^[[12]].*ok' micro-suite.log], [1])])
+
+AT_CHECK_AT_TEST([AT@&t@_FAIL_IF],
+ [AT_FAIL_IF([:])
+ AT_CLEANUP
+ AT_SETUP
+ AT_FAIL_IF([false])
+ AT_CLEANUP
+ AT_SETUP
+ AT_FAIL_IF([test x = y])
+ AT_CLEANUP
+ AT_SETUP
+ AT_FAIL_IF([bah])
+ AT_CLEANUP
+ AT_SETUP
+ AT_FAIL_IF([test x = x])
+ AT_CLEANUP
+ AT_SETUP
+ AT_FAIL_IF([test $foo = x])],
+ [], [1], [stdout], [ignore], [],
+ [AT_CHECK([grep '1 5 failed' stdout], [], [ignore], [ignore])])
+
+AT_CHECK_AT_TEST([AT@&t@_SKIP_IF],
+ [AT_SKIP_IF([:])
+ AT_CLEANUP
+ AT_SETUP
+ AT_SKIP_IF([false])
+ AT_CLEANUP
+ AT_SETUP
+ AT_SKIP_IF([test x = y])
+ AT_CLEANUP
+ AT_SETUP
+ AT_SKIP_IF([bah])
+ AT_CLEANUP
+ AT_SETUP
+ AT_SKIP_IF([test x = x])
+ AT_CLEANUP
+ AT_SETUP
+ AT_SKIP_IF([test $foo = x])],
+ [], [], [], [], [],
+ [AT_CHECK([grep '2.*skipped' micro-suite.log], [], [ignore], [ignore])])
+
+AT_CHECK_AT_TEST([Syntax error],
+ [AT_CHECK([:])
+ AT_CLEANUP
+ AT_SETUP([syntax])
+ AT_CHECK([if])
+ AT_CLEANUP
+ AT_SETUP([another test])
+ AT_CHECK([:])],
+ [], [0], [], [], [],
+ [dnl Until we can find a way to avoid catastrophic failure (ash) or
+ dnl lack of failure (zsh), skip the rest of this test on such shells.
+ echo 'if' > syntax
+ AT_CHECK([${CONFIG_SHELL-$SHELL} -c 'case `. ./syntax; echo $?` in
+ 0|"") exit 77;;
+ esac'], [0], [ignore], [ignore])
+ AT_CHECK([$CONFIG_SHELL ./micro-suite], [1], [ignore], [stderr])
+ AT_CHECK([grep "unable to parse test group: 2" stderr], [0], [ignore])],
+ [1 3])
+
+AT_CHECK_AT_TEST([errexit],
+ [AT_CHECK([false])
+ AT_CLEANUP
+ AT_SETUP([test that should not be run])
+ AT_CHECK([:])
+ AT_CLEANUP
+ AT_SETUP([xpassing test])
+ AT_XFAIL_IF([:])
+ AT_CHECK([:])
+ AT_CLEANUP
+ AT_SETUP([another test that should not be run])
+ AT_CHECK([:])
+ AT_CLEANUP
+ AT_SETUP([skipping test])
+ AT_CHECK([exit 77])
+ AT_CLEANUP
+ AT_SETUP([xfailing test])
+ AT_XFAIL_IF([:])
+ AT_CHECK([false])
+ AT_CLEANUP
+ AT_SETUP([a test that should be run])
+ AT_CLEANUP
+ AT_SETUP([hard failure])
+ AT_XFAIL_IF([:])
+ AT_CHECK([exit 99])
+ AT_CLEANUP
+ AT_SETUP([yet another test that should not be run])],
+ [], [1], [stdout], [stderr], [],
+ [AT_CHECK([test -f micro-suite.log], [1])
+ touch micro-suite.log # shut up AT_CAPTURE_FILE.
+ AT_CHECK([grep "should not be run" stdout], [1])
+ AT_CHECK([grep "1 .* inhibited subsequent" stderr], [], [ignore])
+ AT_CHECK([$CONFIG_SHELL ./micro-suite --errexit 3-], [1], [stdout], [stderr])
+ AT_CHECK([grep "should not be run" stdout], [1])
+ AT_CHECK([grep "1 .* inhibited subsequent" stderr], [], [ignore])
+ AT_CHECK([$CONFIG_SHELL ./micro-suite --errexit 5-], [1], [stdout], [stderr])
+ AT_CHECK([grep "should be run" stdout], [0], [ignore])
+ AT_CHECK([grep "should not be run" stdout], [1])
+ AT_CHECK([grep "inhibited subsequent" stderr], [], [ignore])],
+ [--errexit])
+
+
+AT_CHECK_AT_TEST([at_status],
+ [AT_CHECK([exit $mystatus], [$expected], [], [],
+ [AT_CHECK([echo run-if-fail: $at_status], [], [ignore])],
+ [AT_CHECK([echo run-if-pass: $at_status], [], [ignore])])
+ AT_CLEANUP
+ AT_SETUP([test with nested checks])
+ AT_CHECK([exit $mystatus], [$expected], [], [],
+ [AT_CHECK([exit $mystatus], [$expected], [], [],
+ [AT_CHECK([echo inner run-if-fail: $at_status], [],
+ [ignore])])])],
+ [], [], [stdout], [],
+[], [
+AT_CHECK([grep 'inner run-if-fail: 42' stdout], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -x -v 1 mystatus=0 expected=0], [], [stdout])
+AT_CHECK([grep 'run-if-pass: 0' stdout], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -x -v 1 mystatus=42 expected=0], [], [stdout])
+AT_CHECK([grep 'run-if-fail: 42' stdout], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -x -v 1 mystatus=0 expected=42], [], [stdout])
+AT_CHECK([grep 'run-if-fail: 0' stdout], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -x -v 1 mystatus=42 expected=42], [], [stdout])
+AT_CHECK([grep 'run-if-pass: 42' stdout], [], [ignore])
+],
+[-v mystatus=42 expected=1
+])
+
+
+AT_CHECK_AT_TEST([AT@&t@_CHECK execution environment],
+ [dnl The first test should fail, so we enter RUN-IF-FAIL.
+ AT_CHECK([test "$state" != before], [], [], [],
+ [state=run-if-fail
+ AT_CHECK([:]) dnl need this so we do not bail out at this point.
+ ])
+ dnl This should pass, so we enter RUN-IF-PASS.
+ AT_CHECK([test "$state" = run-if-fail], [], [], [], [],
+ [state=run-if-pass])
+ AT_CHECK([test "$state" = run-if-pass])
+ dnl However, COMMANDS are run inside a subshell, so do not change state.
+ AT_CHECK([state=broken; false], [], [], [],
+ [AT_CHECK([test "$state" = run-if-pass])])
+ AT_CHECK([state=broken], [], [], [], [],
+ [AT_CHECK([test "$state" = run-if-pass])])
+ ],
+ [], [], [], [], [], [], [state=before])
+
+
+AT_CHECK_AT_TEST([unquoted output],
+ [m4_define([backtick], [`])
+ a=a
+ AT_CHECK_UNQUOTED([echo 'a"b backtick`'], [],
+ [${a}"`echo 'b '`\`\backtick]m4_newline)],
+ [], [], [], [], [AT_KEYWORDS([AT@&t@_CHECK_UNQUOTED])])
+
+AT_CHECK_AT_TEST([Trace output],
+ [AT_CHECK([echo some longer longer longer command piped | ]dnl
+ [sed 's,into some other longer longer longer command,,'],
+ [], [some longer longer longer command piped
+])])
+
+AT_CHECK_AT([Logging],
+ [[AT_INIT([artificial test suite])
+ dnl intentionally write failing tests, to see what gets logged
+ AT_SETUP([one])
+ AT_CHECK([echo magicstring01], [1], [ignore])
+ AT_CLEANUP
+ AT_SETUP([two])
+ AT_CHECK([echo magicstring02 >&2], [1], [], [ignore])
+ AT_CLEANUP
+ AT_SETUP([three])
+ AT_CHECK([echo magicstring03], [1], [ignore-nolog])
+ AT_CLEANUP
+ AT_SETUP([four])
+ AT_CHECK([echo magicstring04 >&2], [1], [], [ignore-nolog])
+ AT_CLEANUP
+ AT_SETUP([five])
+ AT_CHECK([echo magicstring05], [1], [stdout])
+ AT_CLEANUP
+ AT_SETUP([six])
+ AT_CHECK([echo magicstring06 >&2], [1], [], [stderr])
+ AT_CLEANUP
+ AT_SETUP([seven])
+ AT_CHECK([echo magicstring07], [1], [stdout-nolog])
+ AT_CLEANUP
+ AT_SETUP([eight])
+ AT_CHECK([echo magicstring08 >&2], [1], [], [stderr-nolog])
+ AT_CLEANUP
+ AT_SETUP([nine])
+ echo magicstring09 > expout
+ AT_CHECK([echo magicstring09], [1], [expout])
+ AT_CLEANUP
+ AT_SETUP([ten])
+ echo magicstring10 > experr
+ AT_CHECK([echo magicstring10 >&2], [1], [], [experr])
+ AT_CLEANUP
+]], [], [1], [], [ignore], [],
+ [AT_CHECK([$CONFIG_SHELL ./micro-suite], [1], [ignore-nolog], [ignore-nolog])
+ AT_CHECK([grep '^magicstring' micro-suite.log], [],
+[[magicstring01
+magicstring02
+magicstring05
+magicstring06
+]])])
+
+
+AT_CHECK_AT([Binary output],
+ [[AT_INIT([artificial test suite])
+ AT_SETUP([pass: no trailing newline])
+ AT_CHECK([printf short], [0], [stdout-nolog])
+ AT_CHECK([cat stdout], [0], [[short]])
+ AT_CLEANUP
+ AT_SETUP([pass: non-printing characters])
+ AT_CHECK([printf '\1\n' >&2], [0], [], [stderr-nolog])
+ printf '\1\n' > expout
+ AT_CHECK([cat stderr], [0], [expout])
+ AT_CLEANUP
+ AT_SETUP([pass: long lines])
+ # 5000 bytes in str
+ str=..........
+ str=$str$str$str$str$str$str$str$str$str$str
+ str=$str$str$str$str$str$str$str$str$str$str
+ str=$str$str$str$str$str
+ AT_CHECK_UNQUOTED([echo $str], [0], [[$str]m4_newline])
+ AT_CLEANUP
+ AT_SETUP([fail: no trailing newline])
+ AT_CHECK([printf short], [0], [stdout-nolog])
+ AT_CHECK([cat stdout], [0], [[long]])
+ AT_CLEANUP
+ AT_SETUP([fail: non-printing characters])
+ AT_CHECK([printf '\1\n' >&2], [0], [], [stderr-nolog])
+ printf '\2\n' > expout
+ AT_CHECK([cat stderr], [0], [expout])
+ AT_CLEANUP
+ AT_SETUP([fail: long lines])
+ # 5000 bytes in str
+ str=..........
+ str=$str$str$str$str$str$str$str$str$str$str
+ str=$str$str$str$str$str$str$str$str$str$str
+ str=$str$str$str$str$str
+ AT_CHECK_UNQUOTED([echo x$str], [0], [[${str}x]m4_newline])
+ AT_CLEANUP
+]], [], [0], [], [], [],
+ [AT_CHECK([$CONFIG_SHELL ./micro-suite 4], [1], [ignore], [ignore])
+ AT_CHECK([$CONFIG_SHELL ./micro-suite 5], [1], [ignore], [ignore])
+ AT_CHECK([$CONFIG_SHELL ./micro-suite 6], [1], [ignore], [ignore])], [1-3])
+
+
+AT_CHECK_AT_TEST([Cleanup],
+ [AT_CHECK([test ! -f cleanup.success && test ! -f cleanup.failure])
+ AT_XFAIL_IF([$xfail])
+ AT_CHECK_UNQUOTED([exit $value], [ignore], [$output],
+ [], [touch cleanup.failure], [touch cleanup.success])],
+ [], [], [], [],
+ [AT_KEYWORDS([AT@&t@_CHECK_UNQUOTED])
+ output=; export output],
+ [AT_CHECK([test -d micro-suite.dir/1])
+ AT_CHECK([test -f micro-suite.dir/1/cleanup.success])
+ AT_CHECK([test ! -f micro-suite.dir/1/cleanup.failure])
+
+ AT_CHECK([$CONFIG_SHELL ./micro-suite -d xfail=false value=1], [], [ignore])
+ AT_CHECK([test -f micro-suite.dir/1/cleanup.success])
+ AT_CHECK([test ! -f micro-suite.dir/1/cleanup.failure])
+
+ AT_CHECK([$CONFIG_SHELL ./micro-suite xfail=: value=0],
+ [1], [ignore], [ignore])
+ AT_CHECK([test -f micro-suite.dir/1/cleanup.success])
+ AT_CHECK([test ! -f micro-suite.dir/1/cleanup.failure])
+
+ AT_CHECK([$CONFIG_SHELL ./micro-suite -d xfail=false value=1 output=mismatch],
+ [1], [ignore], [ignore])
+ AT_CHECK([test ! -f micro-suite.dir/1/cleanup.success])
+ AT_CHECK([test -f micro-suite.dir/1/cleanup.failure])
+
+ AT_CHECK([$CONFIG_SHELL ./micro-suite -d xfail=false value=77], [], [ignore])
+ AT_CHECK([test ! -f micro-suite.dir/1/cleanup.success])
+ AT_CHECK([test ! -f micro-suite.dir/1/cleanup.failure])
+
+ AT_CHECK([$CONFIG_SHELL ./micro-suite -d xfail=false value=99],
+ [1], [ignore], [ignore])
+ AT_CHECK([test ! -f micro-suite.dir/1/cleanup.success])
+ AT_CHECK([test ! -f micro-suite.dir/1/cleanup.failure])
+ ], [-d xfail=false value=0])
+
+## ----------------------------------------------------- ##
+## Newlines and command substitutions in test commands. ##
+## ----------------------------------------------------- ##
+
+AT_CHECK_AT_TEST([Literal multiline command],
+ [AT_CHECK([echo Auto'
+'conf], 0, [Auto
+conf
+], [])])
+
+AT_CHECK_AT_TEST([Multiline parameter expansion],
+ [FOO='one
+two'
+ AT_CHECK([echo "$FOO"], 0, [one
+two
+], [])])
+
+AT_CHECK_AT_TEST([Backquote command substitution],
+ [AT_CHECK([echo `echo hi`], 0, [hi
+], [])])
+
+
+AT_CHECK_AT_TEST([Multiline backquote command substitution],
+ [AT_DATA([myfile],[foo
+bar
+])
+ AT_CHECK([echo "`cat myfile`"], 0, [foo
+bar
+], [])])
+
+AT_CHECK_AT_TEST([Parenthetical command substitution],
+ [AT_CHECK([echo $(echo hi)], 0, [hi
+], [])],
+ [AT_NO_CMDSUBST])
+
+AT_CHECK_AT_TEST([Multiline parenthetical command substitution],
+ [AT_DATA([myfile],[foo
+bar
+])
+ AT_CHECK([echo "$(cat myfile)"], 0, [foo
+bar
+], [])],
+ [AT_NO_CMDSUBST])
+
+
+AT_CHECK_AT_TEST([Shell comment in command],
+ [my_echo=echo
+ AT_CHECK([$my_echo one [#] two], [], [one
+])])
+
+
+## ------------------------- ##
+## ${...} in test commands. ##
+## ------------------------- ##
+
+# If this invalid parameter expansion capsizes the test suite, the entire
+# AT_SETUP ... AT_CLEANUP subshell will exit, and the commands it runs will
+# appear to have succeeded. Therefore, we verify a failing test case.
+
+AT_CHECK_AT_TEST([Invalid brace-enclosed parameter expansion],
+ [AT_CHECK([echo '${=invalid}'], 0, [wrong])], [false], 1, ignore, ignore)
+
+
+## ---------------------------- ##
+## M4 macros in test commands. ##
+## ---------------------------- ##
+
+AT_CHECK_AT_TEST([Multiline command from M4 expansion],
+ [m4_define([GNU], ['foo
+bar'])
+ AT_CHECK([echo GNU], 0, [foo
+bar
+], [])])
+
+AT_CHECK_AT_TEST([Double-M4-quoted command],
+ [m4_define([GNU], ['foo
+bar'])
+ AT_CHECK([[echo GNU]], 0, [[GNU
+]], [])])
+
+
+AT_CHECK_AT_TEST([Metacharacters in command from M4 expansion],
+ [m4_define([GNU], [\"`])
+ AT_CHECK([echo '\"`' [GNU] 'GNU'], 0, [GNU [G][NU] [\"`
+]], [])])
+
+
+## -------------------------------------- ##
+## Backslash-<newline> in test commands. ##
+## -------------------------------------- ##
+
+AT_CHECK_AT_TEST([BS-newline in command],
+ [AT_CHECK([echo Auto"\
+"conf], 0, [Autoconf
+], [])])
+
+AT_CHECK_AT_TEST([^BS-newline in command],
+ [AT_CHECK([\
+echo GNU], 0, [GNU
+], [])])
+
+AT_CHECK_AT_TEST([BSx641-newline in command],
+ [AT_CHECK([printf '%s\n' Auto"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+"conf], 0, [Auto\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\conf
+], [])])
+
+AT_CHECK_AT_TEST([BS-BS-newline in command],
+ [AT_CHECK([printf '%s\n' Auto"\\
+"conf], 0, [Auto\
+conf
+], [])])
+
+# A `^BS-BS-newline in command' test will run a command named `\'. No, thanks.
+
+AT_CHECK_AT_TEST([BSx640-newline in command],
+ [AT_CHECK([printf '%s\n' Auto"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+"conf], 0, [Auto\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+conf
+], [])])
+
+# This command has both escaped and unescaped newlines.
+AT_CHECK_AT_TEST([Newline-CODE-BS-newline in command],
+ [AT_CHECK([printf '%s\n' Auto'
+'co\
+nf], 0, [Auto
+conf
+], [])])
+
+AT_CHECK_AT_TEST([Single-quote-BS-newline in command],
+ [AT_CHECK([printf '%s\n' Auto'\
+'conf], 0, [Auto\
+conf
+], [])])
+
+AT_CHECK_AT_TEST([Single-quote-newline-BS-newline in command],
+ [AT_CHECK([printf '%s\n' Auto'
+\
+'conf], 0, [Auto
+\
+conf
+], [])])
+
+
+## ----------------- ##
+## Input from stdin. ##
+## ----------------- ##
+
+AT_SETUP([Input from stdin])
+
+AT_CHECK_AT_PREP([micro-suite],
+[[AT_INIT
+AT_SETUP([please enter hello<RETURN><EOF>])
+AT_CHECK([cat], [], [hello
+])
+AT_CLEANUP
+]])
+
+AT_CHECK([echo hello | $CONFIG_SHELL ./micro-suite], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite </dev/null], [1], [ignore], [ignore])
+
+AT_CLEANUP
+
+
+## ------------------------------- ##
+## Funny characters in test names. ##
+## ------------------------------- ##
+
+# AT_CHECK_AT_TITLE(TITLE, TITLE-TO-TEST, EXPANDED-TITLE-TO-TEST,
+# [XFAIL-CONDITION], [COLUMN = 53])
+# ---------------------------------------------------------------
+# Create a new test named TITLE that runs an Autotest test suite
+# comprised of a trivial test named TITLE-TO-TEST, which expands
+# to EXPANDED-TITLE-TO-TEST. XFAIL-CONDITION passes verbatim to
+# AT_CHECK_AT. Verify that `ok' prints at COLUMN.
+m4_define([AT_CHECK_AT_TITLE],
+[AT_CHECK_AT([$1],
+[[
+m4_define([macro_name], [[macro_expanded]])
+m4_define([macro_expanded], [[macro_overexpanded]])
+m4_define([macro_backquote], [`])
+m4_define([macro_single_quote], ['])
+m4_define([macro_double_quote], ["])
+]]dnl restore font-lock: "
+[[m4_define([macro_backslash], [\])
+m4_define([macro_echo], [$][1])
+AT_INIT([artificial test suite])
+AT_SETUP([$2])
+AT_CHECK([:])
+AT_CLEANUP
+]], [$4], [], [], [], [],
+dnl This sed script checks for two things - that the output is properly
+dnl expanded, and that the 'ok' starts on the right column.
+[AT_KEYWORDS([m4@&t@_expand])
+AT_CHECK([[$CONFIG_SHELL ./micro-suite |
+ sed -n '/^ 1:/{
+h
+s/[^:]*: \(.*[^ ]\)[ ]*ok.*/\1/p
+x
+s/^.\{]]]m4_default($5, 53)[[[\}ok.*/ok/p
+}']],,
+[[$3
+ok
+]])
+dnl This sed script checks for two things - that -v output doesn't have
+dnl an empty $at_srcdir expansion, and that the 'testing ...' line
+dnl contains the test group title.
+AT_CHECK([[$CONFIG_SHELL ./micro-suite -v |
+ sed -n 's/.*testing \(.*\) \.\.\./\1/p; /^\/micro-suite\.at:/p']],,
+[[$3
+]])
+AT_CHECK([[$CONFIG_SHELL ./micro-suite -l |
+ sed -n 's/.*[0-9]: [^ ][^ ]*[ ][ ]*\(.*[^ ]\)[ ]*/\1/p']],,
+[[$3
+]])
+AT_CHECK([[sed -n 's/[^.]*\. \(.*\) ([^)]*): ok.*/\1/p' micro-suite.log]],,
+[[$3
+]])
+])])
+
+m4_define([AT_CHECK_AT_TITLE_CHAR],
+[AT_CHECK_AT_TITLE([$1 in a test title], [A $2 in my name],
+ [A ]m4_ifval([$3], [[$3]], [[$2]])[ in my name], $4, $5)])
+
+AT_CHECK_AT_TITLE_CHAR([Backquote], [`])
+AT_CHECK_AT_TITLE_CHAR([Single-quote], ['])
+AT_CHECK_AT_TITLE_CHAR([Double-quote], ["])
+dnl restore font-lock: "
+AT_CHECK_AT_TITLE_CHAR([Backslash], [\])
+AT_CHECK_AT_TITLE_CHAR([Brackets], [[[]]], [[]])
+AT_CHECK_AT_TITLE_CHAR([Left bracket], [@<:@], [@<:@])
+AT_CHECK_AT_TITLE_CHAR([Right bracket], [@:>@], [@:>@])
+AT_CHECK_AT_TITLE_CHAR([Quoted pound], [[#]], [#])
+AT_CHECK_AT_TITLE_CHAR([Pound], [#])
+AT_CHECK_AT_TITLE_CHAR([Quoted comma], [[,]], [,])
+AT_CHECK_AT_TITLE_CHAR([Comma], [,])
+dnl this test also hits quadrigraphs for ()
+AT_CHECK_AT_TITLE_CHAR([Parentheses], [(@{:@)@:}@], [(())])
+AT_CHECK_AT_TITLE_CHAR([Left paren], [[(]], [(])
+AT_CHECK_AT_TITLE_CHAR([Right paren], [[)]], [)])
+
+AT_CHECK_AT_TITLE_CHAR([Quoted Macro], [[macro_name]], [macro_name])
+AT_CHECK_AT_TITLE_CHAR([Macro], [macro_name], [macro_expanded])
+AT_CHECK_AT_TITLE_CHAR([Macro with backquote], [macro_backquote], [`])
+AT_CHECK_AT_TITLE_CHAR([Macro with single-quote], [macro_single_quote], ['])
+AT_CHECK_AT_TITLE_CHAR([Macro with double-quote], [macro_double_quote], ["])
+dnl restore font-lock: "
+AT_CHECK_AT_TITLE_CHAR([Macro with backslash], [macro_backslash], [\])
+AT_CHECK_AT_TITLE_CHAR([Macro echoing macro], [macro_echo([macro_name])],
+ [macro_expanded])
+AT_CHECK_AT_TITLE_CHAR([Macro echoing single-quote], [macro_echo(['])], ['])
+AT_CHECK_AT_TITLE_CHAR([Long test title], [0123456789012345678901234567890123])
+AT_CHECK_AT_TITLE_CHAR([Longer test title],
+ [01234567890123456789012345678901234], [], [], [54])
+
+
+## ----------------------- ##
+## Long test source lines. ##
+## ----------------------- ##
+
+# Create a test file that has more than 99 words in a line, for Solaris awk.
+# While at that, try out the limit of 2000 bytes in a text file line.
+
+AT_CHECK_AT_TEST([Long test source lines],
+[m4_for([nnn], [1], [999], [], [: ])
+AT_CHECK([:])
+], [], [], [], [ignore], [],
+[AT_CHECK([$CONFIG_SHELL ./micro-suite -k skipalltests], [], [ignore], [ignore])
+])
+
+
+## ---------------- ##
+## Huge testsuite. ##
+## ---------------- ##
+
+# Ensure we don't hit line length limits with large test suites.
+
+AT_CHECK_AT_TEST([Huge testsuite],
+[m4_for([nnn], [1], [1999], [],
+[AT_CLEANUP
+AT_SETUP([test ]nnn)
+])
+], [], [], [], [ignore], [], [], [1999])
+
+
+## ----------------- ##
+## Debugging a test. ##
+## ----------------- ##
+
+AT_CHECK_AT_TEST([Debugging a successful test],
+ [AT_CHECK([:])], [], [], [], [ignore], [],
+[# Without options, when all tests pass, no test directory should exist.
+AT_CHECK([test -d micro-suite.dir/1 && exit 42
+ $CONFIG_SHELL ./micro-suite -d 1], [], [ignore], [ignore])
+# Running with -d should leave a reproducible test group.
+# Also, running the test script from the test group locks the
+# directory from removal on some platforms; the script should still be
+# able to run even if rmdir fails.
+AT_CHECK([(cd micro-suite.dir/1 && ./run)], [], [ignore], [ignore])
+# Running a debugging script implies -d.
+AT_CHECK([(cd micro-suite.dir/1 && ./run)], [], [ignore], [ignore])
+])
+
+AT_CHECK_AT_TEST([Debugging script and environment],
+ [AT_CHECK([test "$MY_VAR" = pass || exit 42])],
+ [], [1], [], [ignore], [], [
+# Changing environment outside of debugging script is not preserved.
+AT_CHECK([(cd micro-suite.dir/1 && MY_VAR=pass ./run)],
+ [0], [ignore], [ignore])
+AT_CHECK([(cd micro-suite.dir/1 && ./run)],
+ [1], [ignore], [ignore])
+# Changing environment as argument to debugging script is preserved.
+AT_CHECK([(cd micro-suite.dir/1; ./run MY_VAR=pass)],
+ [0], [ignore], [ignore])
+AT_CHECK([(cd micro-suite.dir/1; ./run)],
+ [0], [ignore], [ignore])
+])
+
+# The run script must still be valid when shell metacharacters are passed
+# in via an environment option.
+AT_CHECK_AT_TEST([Debugging a failed test],
+ [AT_CHECK([test "$MY_VAR" = "one space" || exit 42])],
+ [], [1], [], [ignore], [], [
+AT_CHECK([(cd micro-suite.dir/1 && ./run MY_VAR='two spaces')],
+ [1], [ignore], [ignore])
+AT_CHECK([(cd micro-suite.dir/1 && ./run MY_VAR='one space')],
+ [0], [ignore], [ignore])
+])
+
+
+# Setting default variable values via atlocal.
+AT_CHECK_AT_TEST([Using atlocal],
+ [AT_CHECK([test "x$MY_VAR" = "xodd; 'string" || exit 42])],
+ [], [1], [ignore], [ignore], [], [
+dnl check that command line can set variable
+AT_CHECK([$CONFIG_SHELL ./micro-suite MY_VAR="odd; 'string"], [0], [ignore])
+dnl check that command line overrides environment
+AT_CHECK([MY_VAR="odd; 'string" $CONFIG_SHELL ./micro-suite MY_VAR=unset],
+ [1], [ignore], [ignore])
+dnl check that atlocal can give it a default
+AT_CHECK([cat <<EOF >atlocal
+MY_VAR="odd; 'string"
+export MY_VAR
+dnl Also populate enough of atlocal to do what atconfig normally does.
+at_testdir=.
+abs_builddir='`pwd`'
+at_srcdir=.
+abs_srcdir='`pwd`'
+at_top_srcdir=.
+abs_top_srcdir='`pwd`'
+at_top_build_prefix=
+abs_top_builddir='`pwd`'
+EOF
+])
+AT_CHECK([$CONFIG_SHELL ./micro-suite], [0], [ignore])
+dnl check that atlocal overrides environment
+AT_CHECK([MY_VAR=unset $CONFIG_SHELL ./micro-suite], [0], [ignore])
+dnl check that command line overrides atlocal
+AT_CHECK([$CONFIG_SHELL ./micro-suite MY_VAR=], [1], [ignore], [ignore])
+dnl check that syntax error is detected
+AT_CHECK([$CONFIG_SHELL ./micro-suite =], [1], [], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite 1=2], [1], [], [ignore], [ignore])
+])
+
+
+# Controlling where the testsuite is run.
+AT_CHECK_AT_TEST([Choosing where testsuite is run],
+ [AT_CHECK([:])], [], [], [], [], [], [
+dnl AT_CHECK_AT_TEST tests the default of running in `.'.
+AT_CHECK([$CONFIG_SHELL ./micro-suite --clean])
+AT_CHECK([test -f micro-suite.log], [1])
+AT_CHECK([test -d micro-suite.dir], [1])
+AT_CHECK([mkdir sub1 sub2])
+dnl check specifying a different relative path to run in.
+AT_CHECK([$CONFIG_SHELL ./micro-suite -C sub1], [0], [ignore], [])
+AT_CHECK([test -f micro-suite.log], [1])
+AT_CHECK([test -f sub1/micro-suite.log], [0])
+AT_CHECK([test -d micro-suite.dir], [1])
+AT_CHECK([test -d sub1/micro-suite.dir], [0])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -C sub1 --clean])
+AT_CHECK([test -f sub1/micro-suite.log], [1])
+AT_CHECK([test -d sub1/micro-suite.dir], [1])
+dnl check specifying an absolute path to run in.
+AT_CHECK([$CONFIG_SHELL ./micro-suite --directory="`pwd`/sub2"],
+ [0], [ignore], [])
+AT_CHECK([test -f micro-suite.log], [1])
+AT_CHECK([test -f sub2/micro-suite.log], [0])
+AT_CHECK([$CONFIG_SHELL ./micro-suite --clean --directory="`pwd`/sub2"])
+AT_CHECK([test -f sub2/micro-suite.log], [1])
+AT_CHECK([test -f sub2/micro-suite.dir], [1])
+dnl check for failure detection with bad, missing, or empty directory.
+AT_CHECK([$CONFIG_SHELL ./micro-suite -C nonesuch || exit 1], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -C ''], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -C - || exit 1], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -C], [1], [ignore], [ignore])
+dnl check that --help overrides bad directory selection.
+AT_CHECK([$CONFIG_SHELL ./micro-suite -C nonesuch --help], [0], [ignore], [])
+])
+
+
+# --recheck.
+AT_CHECK_AT_TEST([recheck],
+ [AT_CHECK([:])
+ AT_CLEANUP
+ AT_SETUP([failing test])
+ AT_CHECK([exit 1])
+ AT_CLEANUP
+ AT_SETUP([xpassing test])
+ AT_XFAIL_IF([:])
+ AT_CHECK([:])
+ AT_CLEANUP
+ AT_SETUP([xfailing test])
+ AT_XFAIL_IF([:])
+ AT_CHECK([exit 1])
+], [], [], [], [], [], [
+AT_CHECK([$CONFIG_SHELL ./micro-suite --recheck], [0], [stdout])
+AT_CHECK([grep "0 tests were successful" stdout], [0], [ignore])
+
+AT_CHECK([$CONFIG_SHELL ./micro-suite], [1], [ignore], [ignore])
+AT_CHECK([grep 'only test' micro-suite.log], [0], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite --recheck], [1], [ignore], [ignore])
+AT_CHECK([grep 'only test' micro-suite.log], [1])
+AT_CHECK([grep 'xfailing' micro-suite.log], [1])
+AT_CHECK([grep 'failing test' micro-suite.log], [0], [ignore])
+AT_CHECK([grep 'xpassing test' micro-suite.log], [0], [ignore])
+
+AT_CHECK([$CONFIG_SHELL ./micro-suite --clean], [0])
+AT_CHECK([test -f micro-suite.log], [1])
+
+dnl check specifying a different relative path to run in.
+AT_CHECK([mkdir sub1])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -C sub1], [1], [ignore], [ignore])
+AT_CHECK([test -f micro-suite.log], [1])
+AT_CHECK([test -f sub1/micro-suite.log], [0])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -C sub1 --recheck --list], [0], [stdout])
+AT_CHECK([grep 'only test' stdout], [1])
+AT_CHECK([grep 'xfailing test' stdout], [1])
+AT_CHECK([grep 'failing test' stdout], [0], [ignore])
+AT_CHECK([grep 'xpassing test' stdout], [0], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -C sub1 --recheck], [1], [ignore],
+ [ignore])
+AT_CHECK([grep 'failing test' sub1/micro-suite.log], [0], [ignore])
+AT_CHECK([grep 'xpassing test' sub1/micro-suite.log], [0], [ignore])
+], [1 4])
+
+
+## -------- ##
+## Banners. ##
+## -------- ##
+AT_SETUP([Banners])
+
+AT_CHECK_AT_PREP([b],
+[[AT_INIT
+AT_SETUP(zero)# 1
+AT_CHECK(:)
+AT_CLEANUP
+
+AT_BANNER([first])
+AT_SETUP(one a)# 2
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(one b)# 3
+AT_CHECK(:)
+AT_CLEANUP
+
+AT_BANNER()
+AT_SETUP(two a)# 4
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(two b)# 5
+AT_CHECK(:)
+AT_CLEANUP
+
+AT_BANNER([second])
+AT_SETUP(three a)# 6
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(three b)# 7
+AT_CHECK(:)
+AT_CLEANUP
+]])
+
+# AT_CHECK_BANNERS(TESTSUITE-OPTIONS, PATTERN1, COUNT1, PATTERN2, COUNT2)
+m4_define([AT_CHECK_BANNERS],
+[AT_CHECK([$CONFIG_SHELL ./b $1], [], [stdout])
+AT_CHECK_EGREP([$2], m4_if([$3], [0], [1], [0]), [$3])
+AT_CHECK_EGREP([$4], m4_if([$5], [0], [1], [0]), [$5])
+])
+
+AT_CHECK_BANNERS([], [first], [1], [second], [1])
+AT_CHECK_BANNERS([-k zero], [first], [0], [second], [0])
+AT_CHECK_BANNERS([1], [first], [0], [second], [0])
+AT_CHECK_BANNERS([-2], [first], [1], [second], [0])
+AT_CHECK_BANNERS([-3], [first], [1], [second], [0])
+AT_CHECK_BANNERS([-k one], [first], [1], [second], [0])
+AT_CHECK_BANNERS([3-4], [first], [1], [second], [0])
+dnl There should be an empty line separating the first category from the
+dnl unnamed one.
+AT_CHECK([sed -n '/one b/,/two a/p' stdout | grep '^$'], [0], [ignore])
+AT_CHECK_BANNERS([3-6], [first], [1], [second], [1])
+AT_CHECK_BANNERS([4-6], [first], [0], [second], [1])
+AT_CHECK_BANNERS([3-], [first], [1], [second], [1])
+AT_CHECK_BANNERS([-k a], [first], [1], [second], [1])
+AT_CHECK_BANNERS([4], [first], [0], [second], [0])
+AT_CHECK_BANNERS([4-], [first], [0], [second], [1])
+AT_CHECK_BANNERS([-k two], [first], [0], [second], [0])
+AT_CHECK_BANNERS([1 4], [first], [0], [second], [0])
+AT_CHECK_BANNERS([-k three], [first], [0], [second], [1])
+AT_CHECK_BANNERS([5], [first], [0], [second], [0])
+AT_CHECK_BANNERS([5-], [first], [0], [second], [1])
+AT_CLEANUP
+
+
+## --------- ##
+## Keywords. ##
+## --------- ##
+AT_SETUP([Keywords and ranges])
+
+AT_CHECK_AT_PREP([k],
+[[AT_INIT
+AT_SETUP(none) # 01
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(first) # 02
+AT_KEYWORDS(key1)
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(second) # 03
+AT_KEYWORDS(key2)
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(both) # 04
+AT_KEYWORDS([key1 key2])
+AT_KEYWORDS([m4_echo([Key1])])
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test5) # 05
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test6) # 06
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test7) # 07
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test8) # 08
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test9) # 09
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test10) # 10
+AT_CHECK(:)
+AT_CLEANUP
+]])
+dnl check that AT_KEYWORDS does not duplicate words
+AT_CHECK([grep -i 'key1.*key1' k], [1])
+dnl check that -k requires an argument
+AT_CHECK([$CONFIG_SHELL ./k -k], [1], [], [ignore])
+
+# AT_CHECK_KEYS(TESTSUITE-OPTIONS, PATTERN1, COUNT1, PATTERN2, COUNT2)
+m4_define([AT_CHECK_KEYS],
+[AT_CHECK([$CONFIG_SHELL ./k $1], 0, [stdout])
+AT_CHECK_EGREP([$2], 0, [$3])
+AT_CHECK_EGREP([$4], 1, [$5])
+])
+
+AT_CHECK_KEYS([-k key1], [first|both], [2], [none|second], [0])
+AT_CHECK_KEYS([-k key2], [second|both], [2], [none|first], [0])
+AT_CHECK_KEYS([-k key1,key2], [both], [1], [none|first|second], [0])
+AT_CHECK_KEYS([-k key1 -k key2], [first|second|both], [3], [none], [0])
+AT_CHECK_KEYS([-k '!key1'], [none|second], [2], [first|both], [0])
+AT_CHECK_KEYS([-k '!key2'], [none|first], [2], [second|both], [0])
+AT_CHECK_KEYS([-k '!key1,key2'], [second], [1], [none|first|both], [0])
+AT_CHECK_KEYS([-k 'key1,!key2'], [first], [1], [none|second|both], [0])
+AT_CHECK_KEYS([-k '!key1,!key2'], [none], [1], [first|second|both], [0])
+AT_CHECK_KEYS([-k '!key1' -k KEY2], [none|second|both], [3], [first], [0])
+AT_CHECK_KEYS([-k key1 -k '!key2'], [none|first|both], [3], [second], [0])
+AT_CHECK_KEYS([-k '!KEY1' -k '!key2'], [none|first|second], [3], [both], [0])
+
+AT_CHECK_KEYS([-k none], [none], [1], [first|second|both], [0])
+AT_CHECK_KEYS([-k key1,both], [both], [1], [none|first|second], [0])
+AT_CHECK_KEYS([-k key1 -k both], [first|both], [2], [none|second], [0])
+AT_CHECK_KEYS([-k none,first], [successful], [1], [none|first|second|both], [0])
+AT_CHECK_KEYS([-k none,first,second,both], [successful], [1], [none|first|second|both], [0])
+AT_CHECK_KEYS([-k !none,first], [first], [1], [none|second|both], [0])
+
+AT_CHECK_KEYS([-k '.*eco.*'], [second], [1], [none|first|both], [0])
+AT_CHECK_KEYS([-k 'ECO'], [successful], [1], [none|first|second|both], [0])
+AT_CHECK_KEYS([-k '.*eco'], [successful], [1], [none|first|second|both], [0])
+AT_CHECK_KEYS([-k 'eco.*'], [successful], [1], [none|first|second|both], [0])
+AT_CHECK_KEYS([-k 'fir.*'], [first], [1], [none|second|both], [0])
+
+AT_CHECK_KEYS([1-2], [none|first], [2], [second|both], [0])
+AT_CHECK_KEYS([01-002 08], [none|first], [2], [second|both], [0])
+AT_CHECK_KEYS([1-3 2-1], [none|first|second], [3], [both], [0])
+AT_CHECK_KEYS([-3], [none|first|second], [3], [both], [0])
+AT_CHECK_KEYS([4-], [both], [1], [none|first|second], [0])
+AT_CHECK_KEYS([010], [test10], [1], [none|first|second|both], [0])
+AT_CHECK_KEYS([-k second 4-], [second|both], [2], [none|first], [0])
+
+AT_CHECK([$CONFIG_SHELL ./k 0], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 0-], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k -0], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 11], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 11-], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 1-011], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k -k nonexistent], [0], [ignore])
+
+AT_CHECK_KEYS([--list -k nonexistent], [KEYWORDS], [1], [first|second|both], [0])
+AT_CHECK_KEYS([--list 1], [none], [1], [first|second|both], [0])
+AT_CHECK_KEYS([--list 01], [none], [1], [first|second|both], [0])
+AT_CHECK_KEYS([--list -k none -k first], [none|first], [2], [second|both], [0])
+AT_CLEANUP
+
+
+## ----------------- ##
+## Keyword wrapping. ##
+## ----------------- ##
+AT_SETUP([Keyword wrapping])
+
+AT_CHECK_AT_PREP([k],
+[[AT_INIT
+AT_SETUP([test])
+AT_KEYWORDS([a1 b1 c1 d1 e1 f1 g1 h1 i1 j1 k1 l1 m1 n1 o1 p1 q1 r1 s1 t1])
+AT_KEYWORDS([u1 v1 w1 x1 y1 z1])
+AT_KEYWORDS([a b c d e f g h i j k l m n o p q r s t u v w x y z])
+AT_CLEANUP
+AT_SETUP([test with long keywords])
+AT_KEYWORDS(
+[this-is-a-long-keyword-that-cannot-be-wrapped-so-we-exceed-the-length-limit-here])
+# surrounded by short ones
+AT_KEYWORDS([s])
+AT_KEYWORDS(
+[another-very-long-keyword-that-hits-the-line-length-limit-bla-bla-bla-bla])
+AT_KEYWORDS([t])
+AT_CLEANUP
+]])
+
+AT_CHECK_KEYS([-l], [.{80}], [1], [.{87}], [0])
+
+AT_CLEANUP
+
+
+## ------------- ##
+## AT_ARG_OPTION ##
+## ------------- ##
+
+AT_CHECK_AT([AT@&t@_ARG_OPTION],
+[[
+AT_INIT([artificial test suite])
+AT_ARG_OPTION([frob fro fr f],
+ [AS_HELP_STRING([-f, --frob], [frobnicate the test run])],
+ [frob=$at_optarg], [frob=default])
+AT_ARG_OPTION([opt-with-hyphen],
+ [AS_HELP_STRING([--opt-with-hyphen], [option name with hypen])])
+AT_ARG_OPTION([ping],
+ [AS_HELP_STRING([--ping], [ping on every encounter])],
+ [echo ping])
+AT_SETUP([test argument handling])
+AT_CHECK([test "$frob" = "$FROB"])
+AT_CHECK([test "$at_arg_frob" = "$FROB_ARG"])
+AT_CLEANUP
+AT_SETUP([test hyphen normalization])
+AT_CHECK([test "$at_arg_opt_with_hyphen" = "$expected"])
+AT_CLEANUP
+]],
+[], [], [stdout], [], [],
+[# We already invoked --help.
+AT_CHECK([grep ' -f, --frob.*frobnicate' stdout], [], [ignore])
+for args in \
+ '1 FROB=default FROB_ARG=false' \
+ '1 -f FROB=: FROB_ARG=:' \
+ '1 --fr FROB=: FROB_ARG=:' \
+ '1 --fro FROB=: FROB_ARG=:' \
+ '1 --frob FROB=: FROB_ARG=:' \
+ '1 --no-f FROB=false FROB_ARG=false' \
+ '1 --no-fr FROB=false FROB_ARG=false' \
+ '1 --no-fro FROB=false FROB_ARG=false' \
+ '1 --no-frob FROB=false FROB_ARG=false' \
+ '2 expected=false' \
+ '2 --opt-with-hyphen expected=:' \
+ '2 --no-opt-with-hyphen expected=false'
+do
+ AT_CHECK([$CONFIG_SHELL ./micro-suite -x $args], [], [ignore])
+done
+AT_CHECK([$CONFIG_SHELL ./micro-suite 2 --ping --no-ping --ping expected=false],
+ [], [stdout])
+AT_CHECK([grep -c ping stdout], [], [[3
+]])
+], [--help])
+
+
+## ----------------- ##
+## AT_ARG_OPTION_ARG ##
+## ----------------- ##
+
+AT_CHECK_AT([AT@&t@_ARG_OPTION_ARG],
+[[
+AT_INIT([artificial test suite])
+AT_ARG_OPTION_ARG([frob fro fr f],
+ [AS_HELP_STRING([-f, --frob=FOO], [frobnicate FOO])],
+ [frob=$at_optarg], [frob=default])
+AT_ARG_OPTION_ARG([opt-with-hyphen],
+ [AS_HELP_STRING([--opt-with-hyphen=ARG],
+ [option name with hypen])])
+AT_ARG_OPTION_ARG([ping],
+ [AS_HELP_STRING([--ping], [ping on every encounter])],
+ [echo ping])
+AT_SETUP([test argument handling])
+AT_CHECK([test "$frob" = "$FROB"])
+AT_CHECK([test "$at_arg_frob" = "$FROB_ARG"])
+AT_CLEANUP
+AT_SETUP([test hyphen normalization])
+AT_CHECK([test "$at_arg_opt_with_hyphen" = "$expected"])
+AT_CLEANUP
+]],
+[], [], [stdout], [], [],
+[# We already invoked --help.
+AT_CHECK([grep ' -f, --frob.*frobnicate' stdout], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -x --frob], [1], [ignore], [stderr])
+AT_CHECK([grep 'requires an argument' stderr], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -x --no-frob], [1], [ignore], [stderr])
+AT_CHECK([grep 'invalid option' stderr], [], [ignore])
+for args in \
+ '1 FROB=default FROB_ARG=' \
+ '1 -f bar FROB=bar FROB_ARG=bar' \
+ '1 --fr bar FROB=bar FROB_ARG=bar' \
+ '1 --fro bar FROB=bar FROB_ARG=bar' \
+ '1 --frob bar FROB=bar FROB_ARG=bar' \
+ '1 -f=bar FROB=bar FROB_ARG=bar' \
+ '1 --fr=bar FROB=bar FROB_ARG=bar' \
+ '1 --fro=bar FROB=bar FROB_ARG=bar' \
+ '1 --frob=bar FROB=bar FROB_ARG=bar' \
+ '2 expected=' \
+ '2 --opt-with-hyphen=baz expected=baz'
+do
+ AT_CHECK([$CONFIG_SHELL ./micro-suite -x $args], [], [ignore])
+done
+AT_CHECK([$CONFIG_SHELL ./micro-suite 2 --ping=1 --ping=2 expected=],
+ [], [stdout])
+AT_CHECK([grep -c ping stdout], [], [[2
+]])
+], [--help])
+
+
+m4_define([AT_SKIP_PARALLEL_TESTS],
+[# Per BUGS, we have not yet figured out how to run parallel tests cleanly
+# under dash and some ksh variants. For now, only run this test under
+# limited conditions; help is appreciated in widening this test base.
+AT_SKIP_IF([${CONFIG_SHELL-$SHELL} -c 'test -z "${BASH_VERSION+set}]]dnl
+[[${ZSH_VERSION+set}${TEST_PARALLEL_AUTOTEST+set}"'])
+# The parallel scheduler requires mkfifo and job control to work.
+AT_CHECK([mkfifo fifo || exit 77])
+AT_CHECK([${CONFIG_SHELL-$SHELL} -c '(set -m && set +m) || exit 77'],
+ [], [], [ignore])
+])
+
+
+## ----------------------- ##
+## parallel test execution ##
+## ----------------------- ##
+
+AT_SETUP([parallel test execution])
+
+# This test tries to ensure that -j runs tests in parallel.
+# Such a test is inherently racy, because there are no real-time
+# guarantees about scheduling delays. So we try to minimize
+# the chance to lose the race.
+
+# The time needed for a micro-suite consisting of NTESTS tests each
+# sleeping for a second is estimated by
+# startup + ntests * (serial_overhead + 1 / njobs)
+#
+# in absence of major scheduling delays. This leads to side conditions:
+# - NTESTS should be high, so the STARTUP time is small compared to the
+# test run time, and scheduling delays can even out; it should not be
+# too high, to not slow down the testsuite unnecessarily,
+# - the number of concurrent jobs NJOBS should not be too low, so the
+# race is not lost so easily; it should not be too high, to avoid fork
+# failures on tightly limited systems. 4 seems a good compromise
+# here, considering that Autotest spawns several other processes.
+# - STARTUP is assumed to be the same for parallel and serial runs, so
+# the latter can estimate the former.
+# - To avoid unportable output from time measurement commands, spawn
+# both a parallel and a serial testsuite run; check that the former
+# completes before the latter has completed a fraction SERIAL_NTESTS
+# of the tests (the serial run is executed in a subdirectory), plus
+# some additional time to allow for compensation of SERIAL_OVERHEAD.
+# - when adding this time to the serial test execution, an initial delay
+# SERIAL_DELAY of the serial test helps to avoid unreliable scheduling
+# due to the startup burst of the suites.
+
+dnl total number of tests.
+m4_define([AT_PARALLEL_NTESTS], [16])
+dnl number of jobs to run in parallel.
+m4_define([AT_PARALLEL_NJOBS], [4])
+dnl number of tests to run serially, as comparison.
+m4_define([AT_PARALLEL_SERIAL_NTESTS],
+ m4_eval(AT_PARALLEL_NTESTS / AT_PARALLEL_NJOBS))
+dnl initial delay of serial run, to compensate for SERIAL_OVERHEAD.
+dnl This corresponds to 0.67 s of overhead per test.
+m4_define([AT_PARALLEL_SERIAL_DELAY],
+ m4_eval((AT_PARALLEL_NTESTS - AT_PARALLEL_SERIAL_NTESTS + 1) * 2 / 3))
+
+
+AT_CHECK_AT_PREP([micro-suite],
+[[AT_INIT([suite to test parallel execution])
+m4_for([count], [1], ]]AT_PARALLEL_NTESTS[[, [],
+ [AT_SETUP([test number count])
+ AT_CHECK([sleep 1])
+ AT_CLEANUP
+])
+]])
+
+# Even if parallel jobs are not supported, the command line must work.
+AT_CHECK([$CONFIG_SHELL ./micro-suite --help | grep " --jobs"], [0], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -j2foo], [1], [], [stderr])
+AT_CHECK([grep 'non-numeric argument' stderr], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite --jobs=foo], [1], [], [stderr])
+AT_CHECK([grep 'non-numeric argument' stderr], [], [ignore])
+
+AT_SKIP_PARALLEL_TESTS
+
+# Ensure that all tests run, and lines are not split.
+AT_CHECK([$CONFIG_SHELL ./micro-suite -j[]AT_PARALLEL_NJOBS], [], [stdout])
+AT_CHECK([grep -c '^.\{53\}ok' stdout], [], [AT_PARALLEL_NTESTS
+])
+# Running one test with -j should produce correctly formatted output:
+AT_CHECK([$CONFIG_SHELL ./micro-suite -j 3], [], [stdout])
+AT_CHECK([grep -c '^.\{53\}ok' stdout], [], [1
+])
+# Specifying more jobs than tests should not hang:
+AT_CHECK([$CONFIG_SHELL ./micro-suite -j3 3], [], [stdout])
+AT_CHECK([grep -c '^.\{53\}ok' stdout], [], [1
+])
+# Not even with zero tests:
+AT_CHECK([$CONFIG_SHELL ./micro-suite -j -k nomatch], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -j3 -k nomatch], [], [ignore])
+
+mkdir serial
+
+# Unfortunately, the return value of wait is unreliable,
+# so we check that kill fails.
+AT_CHECK([$CONFIG_SHELL ./micro-suite --jobs=[]AT_PARALLEL_NJOBS & ]dnl
+ [sleep AT_PARALLEL_SERIAL_DELAY && ]dnl
+ [cd serial && $CONFIG_SHELL ../micro-suite -AT_PARALLEL_SERIAL_NTESTS >/dev/null && ]dnl
+ [{ kill $! && exit 1; :; }], [], [stdout], [ignore])
+AT_CHECK([grep -c '^.\{53\}ok' stdout], [], [AT_PARALLEL_NTESTS
+])
+AT_CHECK([grep 'AT_PARALLEL_NTESTS tests' stdout], [], [ignore])
+
+AT_CLEANUP
+
+AT_CHECK_AT_TEST([parallel truth],
+ [AT_CHECK([:], 0, [], [])],
+ [], [], [], [], [AT_SKIP_PARALLEL_TESTS],
+ [], [-j])
+
+AT_CHECK_AT_TEST([parallel fallacy],
+ [AT_CHECK([false], [], [], [])],
+ [], [1], [], [ignore], [AT_SKIP_PARALLEL_TESTS],
+ [AT_CHECK([grep failed micro-suite.log], [], [ignore])], [-j])
+
+AT_CHECK_AT_TEST([parallel skip],
+ [AT_CHECK([echo output; echo irrelevant >&2; exit 77], 0, [mismatch], [])],
+ [], [], [], [], [AT_SKIP_PARALLEL_TESTS],
+ [AT_CHECK([grep skipped micro-suite.log], [], [ignore])], [-j])
+
+AT_CHECK_AT_TEST([parallel syntax error],
+ [AT_CHECK([:])
+ AT_CLEANUP
+ AT_SETUP([syntax])
+ AT_CHECK([if])
+ AT_CLEANUP
+ AT_SETUP([another test])
+ AT_CHECK([:])],
+ [], [0], [], [], [AT_SKIP_PARALLEL_TESTS],
+ [dnl Until we can find a way to avoid catastrophic failure (ash) or
+ dnl lack of failure (zsh), skip the rest of this test on such shells.
+ echo 'if' > syntax
+ AT_CHECK([${CONFIG_SHELL-$SHELL} -c 'case `. ./syntax; echo $?` in
+ 0|"") exit 77;;
+ esac'], [0], [ignore], [ignore])
+ AT_CHECK([$CONFIG_SHELL ./micro-suite -j], [1], [ignore], [stderr])
+ AT_CHECK([grep "unable to parse test group: 2" stderr], [0], [ignore])],
+ [-j2 1 3])
+
+AT_CHECK_AT_TEST([parallel errexit],
+ [AT_CHECK([false])
+ AT_CLEANUP
+ AT_SETUP([barrier test])
+ AT_CHECK([sleep 4])
+ AT_CLEANUP
+ AT_SETUP([test that should not be run])
+ AT_CHECK([:])],
+ [], [1], [stdout], [stderr], [AT_SKIP_PARALLEL_TESTS],
+ [AT_CHECK([test -f micro-suite.log], [1])
+ touch micro-suite.log # shut up AT_CAPTURE_FILE.
+ AT_CHECK([grep "should not be run" stdout], [1])
+ AT_CHECK([grep "[[12]] .* inhibited subsequent" stderr], [], [ignore])],
+ [-j2 --errexit])
+
+
+AT_SETUP([parallel autotest and signal handling])
+
+AT_SKIP_PARALLEL_TESTS
+
+# Goals:
+# (1) interrupt `./testsuite -jN'
+# (2) interrupt `make check TESTSUITEFLAGS=-jN'
+# (3) no trailing verbose/trace output
+# (4) exit status should be 128+signal
+
+AT_DATA([atlocal],
+[[suite_pid=$$
+export suite_pid
+]])
+
+AT_CHECK_AT_PREP([micro-suite],
+[[AT_INIT([suite to test parallel execution])
+AT_SETUP([test number 1])
+AT_CHECK([sleep 2])
+AT_CLEANUP
+AT_SETUP([test number 2])
+AT_CHECK([sleep 1])
+AT_CLEANUP
+AT_SETUP([test number 3])
+AT_CHECK([sleep 1])
+AT_CLEANUP
+AT_SETUP([killer test])
+AT_CHECK([kill -$signal $suite_pid])
+AT_CLEANUP
+m4_for([count], [5], [7], [],
+ [AT_SETUP([test number count])
+ AT_CHECK([sleep 1])
+ AT_CLEANUP
+])
+]])
+
+AT_DATA([Makefile.in],
+[[@SET_MAKE@
+SHELL = @SHELL@
+TESTSUITE = ./micro-suite
+check:
+ $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
+.PHONY: check
+]])
+
+AT_CHECK([$CONFIG_SHELL $abs_top_builddir/config.status --file=Makefile:Makefile.in],
+ [], [ignore])
+
+# Test INT and TERM.
+for signal in 2 15; do
+ export signal
+ AS_VAR_ARITH([expected_status], [128 + $signal])
+
+ # Sequential case.
+ AT_CHECK([$CONFIG_SHELL ./micro-suite], [$expected_status],
+ [ignore], [stderr])
+ # Both stderr and the log should contain the notification about the signal.
+ AT_CHECK([grep 'bailing out' stderr], [], [ignore])
+ AT_CHECK([grep 'bailing out' micro-suite.log], [], [ignore])
+ # There should be no junk job status output.
+ AT_CHECK([[grep '[iI]nterrupt[ ]' stderr]], [1])
+
+ # Parallel case.
+ AT_CHECK([$CONFIG_SHELL ./micro-suite --jobs=3], [$expected_status],
+ [ignore], [stderr])
+ AT_CHECK([grep 'bailing out' stderr], [], [ignore])
+ AT_CHECK([grep 'bailing out' micro-suite.log], [], [ignore])
+ # We'd like to check this here, too, but some shells do not allow to
+ # turn off job control.
+ # AT_CHECK([[grep '[iI]nterrupt[ ]' stderr]], [1])
+
+ # Ditto with `make' in the loop.
+ : "${MAKE=make}"
+ unset MAKEFLAGS
+ # Need to eliminate outer TESTSUITEFLAGS here.
+ # Need to normalize exit status here: some make implementations
+ # exit 1 (BSD make), some exit 2 (GNU make).
+ AT_CHECK([$MAKE check TESTSUITEFLAGS=; ]dnl
+ [case $? in 1|2) exit 1;; *) exit $?;; esac],
+ [1], [ignore], [stderr])
+ AT_CHECK([grep 'bailing out' stderr], [], [ignore])
+ AT_CHECK([grep 'bailing out' micro-suite.log], [], [ignore])
+ # Ditto, parallel case.
+ AT_CHECK([$MAKE check TESTSUITEFLAGS=--jobs=3; ]dnl
+ [case $? in 1|2) exit 1;; *) exit $?;; esac],
+ [1], [ignore], [stderr])
+ AT_CHECK([grep 'bailing out' stderr], [], [ignore])
+ AT_CHECK([grep 'bailing out' micro-suite.log], [], [ignore])
+done
+
+
+# Test PIPE.
+# The most important part here is that things should not hang, nor
+# get out of hand. OTOH, if the shell sets the default handler to
+# ignore PIPE (pdksh, dash), there is little we can do about having the
+# test run; it's only the output that won't be there. So all we check
+# for is that, if test 7 didn't run serially, then it shouldn't be
+# run in the parallel case either; the intermediate tests serve as
+# parallel barrier.
+# Note that stderr may contain "Broken pipe" errors.
+AT_CHECK([($CONFIG_SHELL ./micro-suite -d -3 5-; echo $? >status) | sed 5q],
+ [], [stdout], [stderr])
+AT_CHECK([grep '5.*ok' stdout], [1])
+# Apparently some shells don't get around to creating 'status' any more.
+# And ksh93 on FreeBSD uses 256 + 13 instead of 128 + 13
+AT_CHECK([test ! -s status || grep 141 status || grep 269 status],
+ [], [ignore])
+AT_CHECK([if test -f micro-suite.dir/7/micro-suite.log; then ]dnl
+ [ echo "shell ignores SIGPIPE" > sigpipe-stamp ]dnl
+ [else :; fi])
+
+AT_CHECK([$CONFIG_SHELL ./micro-suite -d -3 5- --jobs=2 | sed 5q], [], [stdout], [ignore])
+AT_CHECK([grep '5.*ok' stdout], [1])
+AT_CHECK([test -s sigpipe-stamp || test ! -f micro-suite.dir/7/micro-suite.log], [0])
+
+AT_CLEANUP
+
+
+# Avoid running into a regression when mkfifo does not work.
+AT_CHECK_AT_TEST([parallel args but non-working mkfifo],
+[AT_CHECK([:])
+AT_CLEANUP
+AT_SETUP([second test])
+AT_CHECK([:])
+],
+[], [], [stdout], [stderr],
+[AT_SKIP_PARALLEL_TESTS
+mkdir bin
+cat >bin/mkfifo <<\EOF
+#! /bin/sh
+exit 1
+EOF
+chmod +x bin/mkfifo
+PATH=`pwd`/bin:$PATH
+export PATH
+],
+[AT_CHECK([grep 'second test' stdout], [], [ignore])
+], [--jobs])
+
+
+# --color
+AT_CHECK_AT_TEST([colored test results],
+ [AT_CHECK([:])
+ AT_CLEANUP
+ AT_SETUP([fail])
+ AT_CHECK([exit 1])
+ AT_CLEANUP
+ AT_SETUP([xpass])
+ AT_XFAIL_IF([:])
+ AT_CHECK([:])
+ AT_CLEANUP
+ AT_SETUP([xfail])
+ AT_XFAIL_IF([:])
+ AT_CHECK([exit 1])
+ AT_CLEANUP
+ AT_SETUP([skip])
+ AT_CHECK([exit 77])
+ AT_CLEANUP
+ AT_SETUP([hardfail])
+ AT_XFAIL_IF([:])
+ AT_CHECK([exit 99])
+], [], [], [], [], [], [
+
+TERM=ansi
+export TERM
+
+red=`printf '\033@<:@0;31m'`
+grn=`printf '\033@<:@0;32m'`
+lgn=`printf '\033@<:@1;32m'`
+blu=`printf '\033@<:@1;34m'`
+std=`printf '\033@<:@m'`
+
+# Check that grep can parse nonprinting characters.
+# BSD 'grep' works from a pipe, but not a seekable file.
+# GNU or BSD 'grep -a' works on files, but is not portable.
+AT_CHECK([case `echo "$std" | grep .` in #'' restore font-lock
+ $std) :;;
+ *) exit 77;;
+ esac], [], [ignore], [],
+ [echo "grep can't parse nonprinting characters" >&2])
+
+if echo 'ab*c' | grep -F 'ab*c' >/dev/null 2>&1; then
+ FGREP="grep -F"
+else
+ FGREP=fgrep
+fi
+
+# No color.
+AT_CHECK([$CONFIG_SHELL ./micro-suite], [1], [stdout], [stderr])
+for color in "$red" "$grn" "$lgn" "$blu"; do
+ AT_CHECK([cat stdout stderr | $FGREP "$color"], [1])
+done
+
+# Color of test group results.
+AT_CHECK([$CONFIG_SHELL ./micro-suite --color=always], [1], [stdout], [stderr])
+AT_CHECK([cat stdout | grep " only " | $FGREP "$grn"], [], [ignore])
+AT_CHECK([cat stdout | grep " fail " | $FGREP "$red"], [], [ignore])
+AT_CHECK([cat stdout | grep " xfail " | $FGREP "$lgn"], [], [ignore])
+AT_CHECK([cat stdout | grep " xpass " | $FGREP "$red"], [], [ignore])
+AT_CHECK([cat stdout | grep " skip " | $FGREP "$blu"], [], [ignore])
+AT_CHECK([cat stdout | grep " hardfail " | $FGREP "$red"], [], [ignore])
+AT_CHECK([cat stderr | grep ERROR | $FGREP "$red"], [], [ignore])
+
+# The summary is green if all tests were successful, light green if all
+# behaved as expected, and red otherwise.
+AT_CHECK([$CONFIG_SHELL ./micro-suite --color=always 1 -k skip],
+ [0], [stdout])
+AT_CHECK([cat stdout | grep 'test.*successful' | $FGREP "$grn"],
+ [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite --color=always 1 -k xfail -k skip],
+ [0], [stdout])
+AT_CHECK([cat stdout | grep 'as expected' | $FGREP "$lgn"], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite --color=always -k fail],
+ [1], [ignore], [stderr])
+AT_CHECK([cat stderr | grep ERROR | $FGREP "$red"], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite --color=always -k xpass],
+ [1], [ignore], [stderr])
+AT_CHECK([cat stderr | grep ERROR | $FGREP "$red"], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite --color=always -k hardfail],
+ [1], [ignore], [stderr])
+AT_CHECK([cat stderr | grep ERROR | $FGREP "$red"], [], [ignore])
+# Reset color on verbose output.
+printf %s\\n "$std"
+], [1])
+
+
+## ------------------- ##
+## srcdir propagation. ##
+## ------------------- ##
+
+AT_SETUP([srcdir propagation])
+
+mkdir pkg vpath-outside vpath-abs
+mkdir pkg/t pkg/vpath-inside
+AT_DATA([pkg/a])
+AT_DATA([pkg/t/b])
+
+AT_DATA([pkg/configure.ac], [[AC_INIT
+AC_CONFIG_TESTDIR([t])
+AC_OUTPUT
+]])
+cp "$abs_top_srcdir/build-aux/install-sh" pkg
+
+cd pkg
+AT_CHECK_AUTOCONF
+cd ..
+
+AT_CHECK_AT_PREP([suite],
+[[AT_INIT([suite to check srcdir])
+AT_SETUP([my only test])
+AT_CHECK([test -f "$top_srcdir"/a && test -f "$srcdir"/b])
+AT_CLEANUP
+]], [], [], [], [pkg/t])
+
+rm -f pkg/t/atconfig
+
+# Build directory totally outside source directory.
+cd vpath-outside
+AT_CHECK([../pkg/configure $configure_options], [0], [ignore])
+cd t
+AT_CHECK([../../pkg/t/suite], [0], [ignore])
+AT_CHECK([../../pkg/t/suite -v], [0], [stdout])
+AT_CHECK([grep '^\.\./\.\./pkg/t/suite.at' stdout], [0], [ignore])
+cd ../..
+
+# Build directory totally outside source directory (absolute).
+my_srcdir=`pwd`/pkg
+cd vpath-abs
+AT_CHECK(["$my_srcdir"/configure $configure_options], [0], [ignore])
+cd t
+AT_CHECK(["$my_srcdir"/t/suite], [0], [ignore])
+AT_CHECK(["$my_srcdir"/t/suite -v], [0], [stdout])
+AT_CHECK([grep '..*/t/suite.at' stdout], [0], [ignore])
+cd ../..
+
+# Build directory as subdirectory of source directory.
+cd pkg/vpath-inside
+AT_CHECK([../configure $configure_options], [0], [ignore])
+cd t
+AT_CHECK([../../t/suite], [0], [ignore])
+AT_CHECK([../../t/suite -v], [0], [stdout])
+AT_CHECK([grep '^\.\./\.\./t/suite.at' stdout], [0], [ignore])
+cd ../../..
+
+# Build directory as parent of source directory.
+AT_CHECK([pkg/configure $configure_options], [0], [ignore])
+cd t
+AT_CHECK([../pkg/t/suite], [0], [ignore])
+AT_CHECK([../pkg/t/suite -v], [0], [stdout])
+AT_CHECK([grep '^\.\./pkg/t/suite.at' stdout], [0], [ignore])
+cd ..
+
+# Build directory as source directory.
+cd pkg
+AT_CHECK_CONFIGURE
+cd t
+AT_CHECK([./suite], [0], [ignore])
+AT_CHECK([./suite -v], [0], [stdout])
+AT_CHECK([grep '^\./suite.at' stdout], [0], [ignore])
+cd ../..
+
+AT_CLEANUP
+
+
+## ------------------------------ ##
+## whitespace in absolute testdir ##
+## ------------------------------ ##
+
+AT_SETUP([whitespace in absolute testdir])
+
+dir='dir with whitespace'
+mkdir "$dir"
+cd "$dir"
+wd=`pwd`
+
+AT_DATA([a])
+AT_CHECK_AT_PREP([suite],
+[[AT_INIT([suite to check srcdir])
+AT_SETUP([my only test])
+AT_CHECK([test -f "$top_srcdir"/a])
+AT_CLEANUP
+]])
+AT_CHECK([top_srcdir=$wd ./suite], [0], [ignore])
+AT_CHECK([top_srcdir=$wd ./suite -d], [0], [ignore])
+AT_CHECK([cd suite.dir/1 && ./run top_srcdir="$wd"], [0], [ignore], [ignore])
+AT_CLEANUP
+
+
+## ------------------ ##
+## unusual file names ##
+## ------------------ ##
+
+AT_SETUP([unusual file names])
+
+AT_DATA_AUTOTEST([d@&t@nl.at],
+[[AT_SETUP([test one])
+m4_pattern_allow([^dnl$])
+AT_CHECK([test "]m4_dquote(AT_LINE)[" = dn[]l.at:3])
+AT_CLEANUP
+]])
+
+mkdir sub
+AT_DATA_AUTOTEST([sub/"two spaces".at],
+[[AT_SETUP([test two])
+AT_CHECK([test "]m4_dquote(AT_LINE)[" = "two spaces.at:2"])
+AT_CLEANUP
+]])
+
+AT_CHECK_AT_PREP([suite],
+[[AT_INIT([suite to check included file names])
+m4_include([d][nl.at])
+m4_include([sub/two spaces.at])
+]])
+AT_CHECK([$CONFIG_SHELL ./suite], [0], [stdout])
+AT_CHECK([grep 'two spaces' suite.log], [1])
+AT_CLEANUP
+
+
+## ------------------------- ##
+## Erlang EUnit unit tests. ##
+## ------------------------- ##
+
+AT_SETUP([Erlang Eunit unit tests])
+AT_KEYWORDS([Erlang])
+
+mkdir s t
+AT_DATA([configure.ac], [[AC_INIT
+AC_ERLANG_PATH_ERL([no])
+AC_ERLANG_PATH_ERLC([no])
+if test "$ERL" = "no" || test "$ERLC" = "no"; then
+ HAVE_ERLANG=no
+ HAVE_EUNIT=no
+else
+ HAVE_ERLANG=yes
+ AC_ERLANG_CHECK_LIB([eunit], [HAVE_EUNIT=yes], [HAVE_EUNIT=no])
+fi
+AC_SUBST([HAVE_ERLANG])
+AC_SUBST([HAVE_EUNIT])
+
+AC_CONFIG_TESTDIR([t])
+AC_CONFIG_FILES([s/compile], [chmod +x s/compile])
+AC_CONFIG_FILES([erlang.conf])
+AC_OUTPUT
+]])
+
+# File to pass info back to us
+AT_DATA([erlang.conf.in],
+[[HAVE_ERLANG=@HAVE_ERLANG@
+HAVE_EUNIT=@HAVE_EUNIT@
+]])
+
+# Erlang module to test:
+AT_DATA([s/testme.erl],
+[[-module(testme).
+-export([foo/1]).
+foo(1) -> one;
+foo(2) -> two;
+foo(_) -> other.
+]])
+
+# Corresponding Eunit unit test module:
+AT_DATA([s/testme_tests.erl],
+[[-module(testme_tests).
+-include_lib("eunit/include/eunit.hrl").
+foo_one_test() -> ?assertEqual(one, testme:foo(1)).
+foo_two_test() -> ?assertEqual(two, testme:foo(2)).
+foo_other_test() -> ?assertEqual(other, testme:foo(42)).
+]])
+
+# Compilation script:
+AT_DATA([s/compile.in],
+[["@ERLC@" -b beam testme.erl testme_tests.erl
+]])
+
+AT_CHECK_AT_PREP([suite],
+[[AT_INIT([suite to check EUnit integration])
+AT_SETUP([my only test])
+AT_CHECK_EUNIT([my_testsuite], [{module, testme}],
+ [-pa "${abs_top_builddir}/s"])
+AT_CLEANUP
+]], [], [], [], [t])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+. ./erlang.conf
+
+AT_CHECK([grep '^ERL='\''.*'\' t/atconfig], [], [ignore])
+AT_CHECK([grep '^ERLC='\''.*'\' t/atconfig], [], [ignore])
+AT_CHECK([grep '^ERLCFLAGS='\''.*'\' t/atconfig], [], [ignore])
+
+if test "$HAVE_ERLANG" = yes && test "$HAVE_EUNIT" = yes; then
+ AT_CHECK([cd s && $CONFIG_SHELL ./compile])
+fi
+
+AT_CHECK([cd t && $CONFIG_SHELL ./suite], [], [ignore])
+
+if test "$HAVE_EUNIT" = yes; then
+ AT_CHECK([grep 1.*successful t/suite.log], [], [ignore])
+ AT_CHECK([grep skipped t/suite.log], [1], [ignore])
+else
+ AT_CHECK([grep 1.*skipped t/suite.log], [], [ignore])
+ AT_CHECK([grep 0.*successful t/suite.log], [], [ignore])
+fi
+
+AT_CLEANUP
diff --git a/tests/base.at b/tests/base.at
new file mode 100644
index 0000000..7979413
--- /dev/null
+++ b/tests/base.at
@@ -0,0 +1,710 @@
+# -*- Autotest -*-
+
+AT_BANNER([Autoconf base layer.])
+
+# Copyright (C) 2000-2001, 2003, 2005-2012 Free Software Foundation,
+# Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+## ------------------------------- ##
+## AC_REQUIRE: topological sort.. ##
+## ------------------------------- ##
+
+# Check that dependencies are always properly honored.
+
+AT_SETUP([AC_REQUIRE: topological sort])
+AT_KEYWORDS([m4@&t@_require])
+
+AT_DATA([configure.ac],
+[[define([REQUIRE_AND_CHECK],
+[AC_REQUIRE([$1])
+test -z "$m4@&t@_translit([$1], [A-Z], [a-z])" && AS_EXIT(1)])
+
+AC_DEFUN([TEST1],
+[REQUIRE_AND_CHECK([TEST2a])
+REQUIRE_AND_CHECK([TEST2b])
+test1=set])
+
+AC_DEFUN([TEST2a],
+[test2a=set])
+
+AC_DEFUN([TEST2b],
+[REQUIRE_AND_CHECK([TEST3])
+test2b=set])
+
+AC_DEFUN([TEST3],
+[REQUIRE_AND_CHECK([TEST2a])
+test3=set])
+
+AS@&t@_INIT
+
+TEST1
+test -z "$test1" &&
+ AC_MSG_ERROR([\$test1 is empty])
+AS_EXIT(0)
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+## --------------------------- ##
+## AC_REQUIRE: error message. ##
+## --------------------------- ##
+
+# Check that the message mentions AC_DEFUN, not m4_defun.
+
+AT_SETUP([AC_REQUIRE: error message])
+AT_KEYWORDS([m4@&t@_require])
+AT_DATA([configure.ac],
+[[AC_REQUIRE([AC_PROG_CC])
+]])
+
+AT_CHECK_AUTOCONF([], [1], [],
+[[configure.ac:1: error: AC_REQUIRE(AC_PROG_CC): cannot be used outside of an AC_DEFUN'd macro
+configure.ac:1: the top level
+autom4te: m4 failed with exit status: 1
+]])
+AT_CLEANUP
+
+
+## ----------------------------------------------- ##
+## AC_REQUIRE and AC_DEFUN_ONCE: Require, expand. ##
+## ----------------------------------------------- ##
+
+AT_SETUP([AC_REQUIRE & AC_DEFUN_ONCE: [Require, expand]])
+AT_KEYWORDS([m4@&t@_require m4@&t@_require_once])
+
+AT_DATA([configure.ac],
+[[AC_DEFUN([TEST],
+[AC_REQUIRE([MULTI_TEST])
+AC_REQUIRE([SINGLE_TEST])])
+
+AC_DEFUN([MULTI_TEST],
+[multi_test=".$multi_test"])
+
+AC_DEFUN_ONCE([SINGLE_TEST],
+[single_test=".$single_test"])
+
+AS@&t@_INIT
+
+TEST
+TEST
+MULTI_TEST
+MULTI_TEST
+SINGLE_TEST
+SINGLE_TEST
+
+case $multi_test:$single_test in
+ ...:. ) AS_EXIT(0);;
+ ...:* ) AC_MSG_ERROR([DEFUN_ONCE is broken]);;
+ *:. ) AC_MSG_ERROR([DEFUN is broken (Wow, congrats!)]);;
+esac
+]])
+
+AT_CHECK_AUTOCONF([], 0, [])
+
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+
+## ----------------------------------------------- ##
+## AC_REQUIRE and AC_DEFUN_ONCE: Expand, require. ##
+## ----------------------------------------------- ##
+
+AT_SETUP([AC_REQUIRE & AC_DEFUN_ONCE: [Expand, require]])
+AT_KEYWORDS([m4@&t@_require m4@&t@_require_once])
+
+AT_DATA([configure.ac],
+[[AC_DEFUN([TEST],
+[AC_REQUIRE([MULTI_TEST])
+AC_REQUIRE([SINGLE_TEST])])
+
+AC_DEFUN([MULTI_TEST],
+[multi_test=".$multi_test"])
+
+AC_DEFUN_ONCE([SINGLE_TEST],
+[single_test=".$single_test"])
+
+AS@&t@_INIT
+
+MULTI_TEST
+MULTI_TEST
+SINGLE_TEST
+SINGLE_TEST
+TEST
+TEST
+
+case $multi_test:$single_test in
+ ..:. ) AS_EXIT(0);;
+ ..:* ) AC_MSG_ERROR([DEFUN_ONCE is broken]);;
+ *:. ) AC_MSG_ERROR([DEFUN is broken (Wow, congrats!)]);;
+ * ) AC_MSG_ERROR([received `$multi_test:$single_test']);;
+esac
+]])
+
+AT_CHECK_AUTOCONF([], 0, [])
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+
+## ------------------------- ##
+## AC_REQUIRE & AC_PROVIDE. ##
+## ------------------------- ##
+
+AT_SETUP([AC_REQUIRE & AC_PROVIDE])
+AT_KEYWORDS([m4@&t@_require])
+
+AT_DATA([configure.ac],
+[[AC_DEFUN([TEST],
+[AC_REQUIRE([INNER_TEST])])
+
+AC_DEFUN([INNER_TEST],
+[inner_test=".$inner_test"])
+
+AS@&t@_INIT
+
+AC_PROVIDE([INNER_TEST])
+TEST
+
+case $inner_test in
+ "" ) AS_EXIT(0);;
+ * ) AC_MSG_ERROR([received `$inner_test']);;
+esac
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+## -------- ##
+## AC_INIT. ##
+## -------- ##
+
+# Make sure AC_INIT sets PACKAGE_TARNAME properly.
+
+AT_SETUP([AC_INIT])
+
+AT_DATA([configure.ac],
+[[AC_INIT([GNU fu], [1.0], [bug-fu@gnu.org])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([-q])
+
+# Ensure we get the expected definition:
+AT_CHECK([grep "^PACKAGE_TARNAME='fu'\$" configure], [], [ignore])
+
+AT_CLEANUP
+
+
+## ------------------------------------- ##
+## AC_INIT with unusual version strings. ##
+## ------------------------------------- ##
+
+AT_SETUP([AC_INIT with unusual version strings])
+
+AT_DATA([configure.ac],
+[[AC_INIT([GNU String++ with spaces (foo)],
+ [2.48++ (2010-07-03)], [[http://example.com/?a=b&c=d#e]], [clisp])
+AC_OUTPUT
+]])
+
+if echo 'ab*c' | grep -F 'ab*c' >/dev/null 2>&1; then
+ FGREP="grep -F"
+else
+ FGREP=fgrep
+fi
+
+AT_CHECK_AUTOCONF([-Werror])
+AT_CHECK_CONFIGURE([-q])
+AT_CHECK_CONFIGURE([--help], [], [stdout])
+AT_CHECK([[$FGREP 'com/?a=b&c=d#e' stdout]], [], [ignore])
+AT_CHECK_CONFIGURE([--version], [], [stdout])
+AT_CHECK([$FGREP 'GNU String++ with spaces (foo)' stdout], [], [ignore])
+AT_CHECK([$FGREP '2.48++ (2010-07-03)' stdout], [], [ignore])
+
+AT_CHECK([./config.status --help], [], [stdout])
+AT_CHECK([[$FGREP 'com/?a=b&c=d#e' stdout]], [], [ignore])
+AT_CHECK([./config.status --version], [], [stdout])
+AT_CHECK([$FGREP 'GNU String++ with spaces (foo)' stdout], [], [ignore])
+AT_CHECK([$FGREP '2.48++ (2010-07-03)' stdout], [], [ignore])
+
+AT_DATA([configure.ac],
+[[AC_INIT([GNU "String++"],
+ [2.48], [http://example.com/], [clisp])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
+AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore])
+
+AT_DATA([configure.ac],
+[[AC_INIT([GNU String++],
+ ['codename' 2.48], [http://example.com/], [clisp])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
+AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore])
+
+AT_DATA([configure.ac],
+[[AC_INIT([GNU
+String++], [2.48], [http://example.com/], [clisp])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
+AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore])
+
+AT_CLEANUP
+
+
+## -------------- ##
+## AC_COPYRIGHT. ##
+## -------------- ##
+
+# Ensure the FSF notice as well as the user-provided one are present
+# in the head of the testsuite as well as the --version output.
+
+AT_SETUP([AC@&t@_COPYRIGHT])
+
+AT_DATA([configure.ac],
+[[AC_INIT([GNU fu], [1.0])
+AC_COPYRIGHT([[This is just a test notice, not a real one, so let's avoid
+words that may be matched by scanners for legal things,
+causing extra work for distributors.
+Multi-line values should be supported.
+]])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([--version], [], [stdout])
+AT_CHECK([grep 'Copyright.*Free Software Foundation' stdout], [], [ignore])
+AT_CHECK([grep 'This is just a test notice' stdout], [], [ignore])
+AT_CHECK([sed -ne 50q -e '/Copyright/{' -e N -e N -e N -e N -e 's/#//g' ]dnl
+ [ -e 's/\n//g' -e p -e '}' configure ]dnl
+ [ | grep 'Copyright.*Free Software Foundation'],
+ [], [ignore])
+AT_CHECK([sed 50q configure | grep 'This is just a test notice'], [], [ignore])
+
+AT_CLEANUP
+
+
+## ---------------- ##
+## AC_CACHE_CHECK. ##
+## ---------------- ##
+
+# Make sure AC_CACHE_CHECK is silent with -q.
+# Also make sure we warn about cache id's not named with `_cv_'.
+
+AT_SETUP([AC_CACHE_CHECK])
+AT_KEYWORDS([CONFIG_SITE])
+
+# Don't let a config.site file affect this test.
+AS_UNSET([CONFIG_SITE])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+# m4_define([ac_nothing], [ac_cv_absolutely_nothing])
+AC_CACHE_CHECK([for nothing],
+ [ac_nothing],
+ [ac_nothing=found])
+
+AC_MSG_CHECKING([for some other variable])
+commands_to_set_it_was_run=false
+AC_CACHE_VAL([my_cv_variable], [
+# FOO
+commands_to_set_it_was_run=true
+my_cv_variable=true
+])
+AC_MSG_RESULT([$my_cv_variable])
+
+# Ensure that the result is available at this point.
+if test ${my_cv_variable+set} != set; then
+ AC_MSG_ERROR([AC@&@&t@t@_CACHE_VAL did not ensure that the cache variable was set])
+fi
+
+# AC_CACHE_SAVE should be enough here, no need for AC_OUTPUT.
+AC_CACHE_SAVE
+]])
+
+AT_CHECK_AUTOCONF([], [], [], [stderr])
+AT_CHECK([grep 'must contain _cv_ to be cached' stderr], [], [ignore])
+
+# Do not warn about defines:
+sed 's/^# m4_define/m4_define/' configure.ac > t
+mv -f t configure.ac
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([-q])
+
+sed '/m4_define/d; s/ac_nothing/ac_cv_nothing/' configure.ac > t
+mv -f t configure.ac
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([-q])
+
+# Print a message saying that the result was cached, iff it was cached.
+AT_CHECK_CONFIGURE([], [], [stdout])
+AT_CHECK([grep 'cached' stdout], [1])
+AT_CHECK_CONFIGURE([my_cv_variable='yes it is set'], [], [stdout])
+AT_CHECK([grep 'cached.*yes it is set' stdout], [], [ignore])
+
+# --cache-file is honored and has caching semantics.
+AT_CHECK_CONFIGURE([--cache-file=foobar.cache], [], [stdout])
+AT_CHECK([grep 'cached' stdout], [1])
+AT_CHECK([test ! -f config.cache])
+AT_CHECK([grep 'my_cv_variable.*true' foobar.cache], [], [ignore])
+AT_CHECK_CONFIGURE([--cache-file=foobar.cache], [], [stdout])
+AT_CHECK([grep 'some other variable.*cached.*true' stdout], [], [ignore])
+
+# A setting on the command line overrides the cache.
+AT_CHECK_CONFIGURE([--cache-file=foobar.cache my_cv_variable='override'], [], [stdout])
+AT_CHECK([grep 'cached.*override' stdout], [], [ignore])
+AT_CHECK([grep 'my_cv_variable.*override' foobar.cache], [], [ignore])
+
+# Values containing braces need special internal treatment.
+AT_CHECK_CONFIGURE([-C ac_cv_nothing='{' my_cv_variable='contains } brace'],
+ [], [stdout])
+AT_CHECK([grep 'ac_cv_nothing.*{' config.cache], [], [ignore])
+AT_CHECK([grep 'my_cv_variable.*contains } brace' config.cache], [], [ignore])
+AT_CHECK_CONFIGURE([-C], [], [stdout])
+AT_CHECK([grep 'nothing.*{' stdout], [], [ignore])
+AT_CHECK([grep 'some other variable.*contains } brace' stdout], [], [ignore])
+rm -f config.cache
+
+# Diagnose common side-effects that are errors in COMMANDS-TO-SET-IT:
+sed 's/^# FOO/AC_DEFINE([some-define], [1], [oooh.])/' configure.ac > t
+mv -f t configure.ac
+AT_CHECK_AUTOCONF([], [], [], [stderr])
+AT_CHECK([grep 'suspicious.*AC_DEFINE' stderr], [], [ignore])
+
+sed 's/^AC_DEFINE.*/AC_SUBST([some_substitution], [oooh.])/' configure.ac > t
+mv -f t configure.ac
+AT_CHECK_AUTOCONF([], [], [], [stderr])
+AT_CHECK([grep 'suspicious.*AC_SUBST' stderr], [], [ignore])
+
+# Ensure the examples from the manual work as intended.
+# Taken from autoconf.texi:Caching Results
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_DEFUN([AC_SHELL_TRUE],
+[AC_CACHE_CHECK([whether true(1) works], [my_cv_shell_true_works],
+ [my_cv_shell_true_works=no
+ (true) 2>/dev/null && my_cv_shell_true_works=yes
+ if test "x$my_cv_shell_true_works" = xyes; then
+ AC_DEFINE([TRUE_WORKS], [1],
+ [Define if `true(1)' works properly.])
+ fi])
+])
+AC_SHELL_TRUE
+]])
+AT_CHECK_AUTOCONF([-Werror], [1], [], [stderr])
+AT_CHECK([grep 'suspicious.*AC_DEFINE' stderr], [], [ignore])
+
+# Taken from autoconf.texi:Caching Results
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_DEFUN([AC_SHELL_TRUE],
+[AC_CACHE_CHECK([whether true(1) works], [my_cv_shell_true_works],
+ [my_cv_shell_true_works=no
+ (true) 2>/dev/null && my_cv_shell_true_works=yes])
+ if test "x$my_cv_shell_true_works" = xyes; then
+ AC_DEFINE([TRUE_WORKS], [1],
+ [Define if `true(1)' works properly.])
+ fi
+])
+AC_SHELL_TRUE
+AC_OUTPUT
+]])
+AT_CHECK_AUTOCONF([-Werror])
+AT_CHECK_CONFIGURE([-C], [], [stdout])
+AT_CHECK([grep my_cv_shell_true_works config.cache], [], [ignore])
+AT_CHECK([grep 'true.*works.*yes' stdout], [], [ignore])
+
+AT_CHECK_CONFIGURE([--config-cache], [], [stdout])
+AT_CHECK([grep 'true.*works.*cached.*yes' stdout], [], [ignore])
+
+# config.status only pays attention to the cache file with --recheck.
+AT_CHECK([./config.status], [], [stdout])
+AT_CHECK([grep cache stdout], [1])
+AT_CHECK([./config.status --recheck], [], [stdout])
+AT_CHECK([grep cache stdout], [0], [ignore])
+
+# By default, configure uses no cache file, neither loading nor updating it.
+: > a-stamp-file
+AT_CHECK_CONFIGURE([], [], [stdout])
+AT_CHECK([grep cache stdout], [1])
+AT_CHECK([LC_ALL=C ls -t config.cache a-stamp-file | sed 1q | grep config.cache], [1])
+
+# Using a symlinked cache file works.
+: > cache
+rm -f config.cache
+AS_LN_S([cache], [config.cache])
+AT_CHECK_CONFIGURE([-C])
+# Either the system does not support symlinks, or the symlinked-to file
+# should be updated.
+AT_CHECK([test -s cache || test ! -h config.cache])
+
+# config.site can specify a site-wide cache, accumulating information.
+# Also test that we don't run afoul of sourcing a file with leading -.
+AT_DATA([-config.site],
+[[cache_file=sitecache
+]])
+AT_DATA([sitecache],
+[[my_cv_some_preset_cache_var=yes
+]])
+CONFIG_SITE=-config.site
+export CONFIG_SITE
+AT_CHECK_CONFIGURE
+AT_CHECK([grep my_cv_some_preset_cache_var sitecache], [], [ignore])
+AT_CHECK([grep my_cv_shell_true_works sitecache], [], [ignore])
+AT_CHECK_CONFIGURE([], [], [stdout])
+AT_CHECK([grep 'whether true.*works.*cached' stdout], [], [ignore])
+
+dnl Until we can find a way to avoid catastrophic failure,
+dnl skip the rest of this test on such shells.
+echo 'if' > syntax
+AT_CHECK([${CONFIG_SHELL-$SHELL} -c 'case `. ./syntax; echo $?` in
+ 0|"") exit 77;; esac'], [0], [ignore], [ignore])
+
+# Check that config cache scripts must be well-formed.
+AT_DATA([bad.site],
+[[fi
+]])
+CONFIG_SITE=$PWD/bad.site
+AT_CHECK_CONFIGURE([ || exit 1], [1], [stdout], [stderr])
+AT_CHECK([grep 'failed to load site script' stderr], [], [ignore], [ignore],
+ [AT_CHECK([grep 'whether true' stdout], [1])])
+
+# However, a missing file is ignored.
+CONFIG_SITE=./no-such-file
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+## --------------- ##
+## AC_CACHE_LOAD. ##
+## --------------- ##
+
+# Test AC_CACHE_LOAD.
+
+AT_SETUP([AC_CACHE_LOAD])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+$some_test_code
+AC_CACHE_LOAD
+AC_MSG_NOTICE([some_cv_variable is $some_cv_variable])
+AC_OUTPUT
+]])
+AT_CHECK_AUTOCONF
+AS_UNSET([some_test_code])
+AT_DATA([new-cache],
+[[some_cv_variable=value-from-new-cache
+]])
+AT_CHECK_CONFIGURE([some_test_code='eval cache_file=new-cache'], [], [stdout])
+AT_CHECK([grep 'some_cv_variable.*value-from-new-cache' stdout], [], [ignore])
+
+AT_CLEANUP
+
+
+## ---------------- ##
+## AC_COMPUTE_INT. ##
+## ---------------- ##
+
+# Make sure AC_COMPUTE_INT fails properly.
+
+AT_SETUP([AC_COMPUTE_INT])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_COMPUTE_INT([invalid_expression],
+ [**0**],
+ [],
+ [invalid_expression=failed])
+test "$invalid_expression" = failed ||
+ AC_MSG_ERROR([**0** evaluated to $invalid_expression instead of failing])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+## ---------------- ##
+## AC_TRY_COMMAND. ##
+## ---------------- ##
+
+AT_SETUP([AC_TRY_COMMAND])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+
+if AC_TRY_COMMAND([(echo "The Cat in the Hat";
+ echo "The Hat in the Cat" >&2) |
+ grep \^The\ Cat\ in\ the\ Hat\$ >/dev/null]); then
+ :
+else
+ AC_MSG_ERROR([didn't see the Cat in the Hat])
+fi
+
+if AC_TRY_COMMAND([(echo "The Cat in the Hat";
+ echo "The Hat in the Cat" >&2) |
+ grep \^The\ Hat\ in\ the\ Cat\$ >/dev/null]); then
+ AC_MSG_ERROR([saw the Hat in the Cat])
+fi
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([-q])
+
+AT_CLEANUP
+
+
+## ------------ ##
+## Input/Output ##
+## ------------ ##
+
+AT_SETUP([Input/Output])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+cat <&AS@&t@_ORIGINAL_STDIN_FD >&AS@&t@_MESSAGE_FD
+]])
+AT_CHECK_AUTOCONF
+AT_CHECK([echo Hello | CONFIG_SITE=/dev/null ./configure $configure_options | grep -v 'configure: loading site script '],, [Hello
+])
+AT_CHECK([echo Hello | CONFIG_SITE=/dev/null ./configure $configure_options --silent])
+
+AT_CLEANUP
+
+
+## ------------------- ##
+## configure arguments ##
+## ------------------- ##
+
+AT_SETUP([configure arguments])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+echo "$@"
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([FOO=bar --enable-baz --without-zork --silent], [0], [stdout], [ignore])
+AT_CHECK([grep 'FOO=bar --enable-baz --without-zork --silent' stdout], [0], [ignore], [ignore])
+
+dnl check that syntax error is detected
+AT_CHECK_CONFIGURE([=], [1], [], [ignore], [ignore])
+AT_CHECK_CONFIGURE([1=2], [1], [], [ignore], [ignore])
+
+AT_CLEANUP
+
+
+## ------------------------------ ##
+## AC_ARG_ENABLE and AC_ARG_WITH. ##
+## ------------------------------ ##
+
+AT_SETUP([AC_ARG_ENABLE and AC_ARG_WITH])
+
+AT_DATA_M4SH([configure.ac],
+[[AC_INIT
+# Taken from autoconf.texi:Pretty Help Strings.
+AC_ARG_WITH([foo],
+ [AS_HELP_STRING([--with-foo],
+ [use foo (default is no)])],
+ [use_foo=$withval],
+ [use_foo=no])
+AC_ARG_WITH([c++],
+ [AS_HELP_STRING([--with-c++],
+ [with c++])],
+ [choice_with=$withval])
+AC_ARG_ENABLE([c++],
+ [AS_HELP_STRING([--enable-c++],
+ [enable c++])],
+ [choice_enable=$enableval])
+echo "use_foo: $use_foo"
+echo "with_c++: $with_c__, $choice_with"
+echo "enable_c++: $enable_c__, $choice_enable"
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([--help | grep foo], [0],
+[[ --with-foo use foo (default is no)
+]], [ignore])
+AT_CHECK_CONFIGURE([--with-foo=yes --with-c++ --disable-c++],
+ [], [stdout], [ignore])
+AT_CHECK([grep 'use_foo: yes' stdout], [], [ignore])
+AT_CHECK([grep 'with_c++: yes, yes' stdout], [], [ignore])
+AT_CHECK([grep 'enable_c++: no, no' stdout], [], [ignore])
+AT_CHECK([grep 'unrecognized option' stdout], [1])
+AT_CHECK_CONFIGURE([--without-foo --with-c++=no --enable-c++=maybe],
+ [], [stdout], [ignore])
+AT_CHECK([grep 'use_foo: no' stdout], [], [ignore])
+AT_CHECK([grep 'with_c++: no, no' stdout], [], [ignore])
+AT_CHECK([grep 'enable_c++: maybe, maybe' stdout], [], [ignore])
+AT_CHECK([grep 'unrecognized option' stdout], [1])
+AT_CHECK_CONFIGURE([], [], [stdout], [ignore])
+AT_CHECK([grep 'use_foo: no' stdout], [], [ignore])
+AT_CHECK([grep 'with_c++: , $' stdout], [], [ignore])
+AT_CHECK([grep 'enable_c++: , $' stdout], [], [ignore])
+AT_CHECK([grep 'unrecognized option' stdout], [1])
+
+AT_CLEANUP
+
+
+## --------------------- ##
+## configure directories ##
+## --------------------- ##
+
+AT_SETUP([configure directories])
+
+AT_DATA([foo.in],
+[[prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+]])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_FILES([foo])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+dnl check that relative paths are rejected
+AT_CHECK_CONFIGURE([--libdir=.], [1], [ignore], [stderr])
+AT_CHECK([grep 'expected an absolute directory name for --libdir: \.' stderr],
+ [0], [ignore])
+
+dnl check that extra slashes are stripped, and that defaults are not expanded
+AT_CHECK_CONFIGURE([--prefix=/usr//])
+AT_CHECK([cat foo], [0], [[prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+]])
+
+AT_CLEANUP
diff --git a/tests/c.at b/tests/c.at
new file mode 100644
index 0000000..90d60e5
--- /dev/null
+++ b/tests/c.at
@@ -0,0 +1,418 @@
+# -*- Autotest -*-
+
+AT_BANNER([C low level compiling/preprocessing macros.])
+
+# Copyright (C) 2000-2006, 2008-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+# Since the macros which compile are required by most tests, check
+# them first. But remember that looking for a compiler is even more
+# primitive, so check those first.
+
+
+## ------------ ##
+## Extensions. ##
+## ------------ ##
+
+# As far as we know only `foo', `foo.exe' are possible executable,
+# and `foo.o', `foo.obj' are possible object files. Autoconf must not
+# know that, but it is OK for the test suite to take this into account.
+AT_CHECK_MACRO([Extensions],
+[[AC_PROG_CC
+case $ac_exeext in
+ '' | '.exe' ) ;;
+ * ) AC_MSG_ERROR([suspicious executable suffix: $ac_exeext]);;
+esac
+
+case $ac_objext in
+ 'o' | 'obj' ) ;;
+ * ) AC_MSG_ERROR([suspicious object suffix: $ac_objext]);;
+esac
+]])
+
+
+
+## -------------------------- ##
+## Broken/missing compilers. ##
+## -------------------------- ##
+
+
+# Check that Autoconf correctly diagnoses broken compilers, and in
+# particular, if it does not exit 77, the test suite is in trouble...
+# FIXME: Once a precise message decided, check stderr of configure.
+AT_SETUP([Broken/missing compilers])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+CC=no-such-compiler
+AC_PROG_CC
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], 77, ignore, ignore)
+
+AT_CLEANUP
+
+
+## ------------ ##
+## C keywords. ##
+## ------------ ##
+
+# GCC supports `const', `typeof', and `volatile'.
+AT_CHECK_MACRO([C keywords],
+[[AC_PROG_CC
+AC_C_CONST
+AC_C_TYPEOF
+AC_C_VOLATILE
+case $GCC,$ac_cv_c_const,$ac_cv_c_typeof,$ac_cv_c_volatile in
+ yes,*no*)
+ AC_MSG_ERROR([failed to detect `const', `typeof', or `volatile' support]);;
+esac
+]])
+
+
+
+## --------------------------------- ##
+## AC_PROG_CPP requires AC_PROG_CC. ##
+## --------------------------------- ##
+
+# Must invoke AC_PROG_CC.
+AT_CHECK_MACRO([AC_PROG_CPP requires AC_PROG_CC],
+[[AC_PROG_CPP
+test -z "$CC" &&
+ AC_MSG_ERROR([looked for a C preprocessor without looking for a compiler])
+]])
+
+
+
+## --------------------------- ##
+## AC_PROG_CPP with warnings. ##
+## --------------------------- ##
+
+
+# It's Ok for strict preprocessors to produce warnings.
+
+AT_SETUP([AC_PROG_CPP with warnings])
+
+AT_DATA([mycpp],
+[[#! /bin/sh
+echo noise >&2
+exec "$@"
+]])
+
+chmod +x mycpp
+
+_AT_CHECK_AC_MACRO(
+[[AC_PROG_CPP
+# If the preprocessor is not strict, just ignore
+test "x$ac_c_preproc_warn_flag" = xyes &&
+ AC_MSG_ERROR([preprocessor has no warning option], 77)
+CPP="./mycpp $CPP"
+
+# Exercise CPP.
+AC_CHECK_HEADERS(stdio.h autoconf_io.h, [], [], [-])]])
+
+AT_CHECK_DEFINES(
+[/* #undef HAVE_AUTOCONF_IO_H */
+#define HAVE_STDIO_H 1
+])
+
+AT_CLEANUP
+
+
+## ------------------------------ ##
+## AC_PROG_CPP without warnings. ##
+## ------------------------------ ##
+
+AT_SETUP([AC_PROG_CPP without warnings])
+
+# Ignore if /lib/cpp doesn't work
+AT_CHECK([[echo '#include <stdio.h>' | /lib/cpp || exit 77]],
+ [], [ignore], [ignore])
+
+# A cpp which exit status is meaningless.
+AT_DATA([mycpp],
+[[#! /bin/sh
+/lib/cpp "$@"
+exit 0
+]])
+
+chmod +x mycpp
+
+_AT_CHECK_AC_MACRO(
+[[CPP=./mycpp
+AC_PROG_CPP
+test "x$ac_c_preproc_warn_flag" != xyes &&
+ AC_MSG_ERROR([failed to detect preprocessor warning option])
+
+# Exercise CPP.
+AC_CHECK_HEADERS(stdio.h autoconf_io.h, [], [], [-])]])
+
+AT_CHECK_DEFINES(
+[/* #undef HAVE_AUTOCONF_IO_H */
+#define HAVE_STDIO_H 1
+])
+
+AT_CLEANUP
+
+
+
+## -------------------- ##
+## AC_PROG_CPP via CC. ##
+## -------------------- ##
+
+
+# It's Ok for strict preprocessors to produce warnings.
+
+AT_SETUP([AC_PROG_CPP via CC])
+
+# Ignore if /lib/cpp doesn't work
+AT_CHECK([[echo '#include <stdio.h>' | /lib/cpp || exit 77]],
+ [], [ignore], [ignore])
+
+AT_DATA([mycc],
+[[#! /bin/sh
+echo "Annoying copyright message" >&2
+exec "$@"
+]])
+
+chmod +x mycc
+
+# We go through the following contortions, in order to have the
+# configure script go down the same codepaths as it would during a
+# normal CPP selection check. If we explicitly set CPP, it goes down
+# a different codepath.
+_AT_CHECK_AC_MACRO(
+[[AC_PROG_CC
+CC="./mycc $CC"
+AC_PROG_CPP
+# The test $CC compiler should have been selected.
+test "$CPP" != "$CC -E" &&
+ AC_MSG_ERROR([error messages on stderr cause the preprocessor selection to fail])
+
+# Exercise CPP.
+AC_CHECK_HEADERS(stdio.h autoconf_io.h, [], [], [-])]])
+
+AT_CHECK_DEFINES(
+[/* #undef HAVE_AUTOCONF_IO_H */
+#define HAVE_STDIO_H 1
+])
+
+AT_CLEANUP
+
+
+## ------------------------------------ ##
+## AC_NO_EXECUTABLES (working linker). ##
+## ------------------------------------ ##
+
+AT_CHECK_MACRO([AC_NO_EXECUTABLES (working linker)],
+[AC_NO_EXECUTABLES
+AC_PROG_CC
+])
+
+
+## ----------------------------------- ##
+## AC_NO_EXECUTABLES (broken linker). ##
+## ----------------------------------- ##
+
+AT_CHECK_MACRO([AC_NO_EXECUTABLES (broken linker)],
+[LDFLAGS=-lnosuchlibrary
+AC_NO_EXECUTABLES
+AC_PROG_CC
+])
+
+
+## -------------------------- ##
+## AC_USE_SYSTEM_EXTENSIONS. ##
+## -------------------------- ##
+
+AT_SETUP([AC_USE_SYSTEM_EXTENSIONS])
+
+# Some existing configure.ac mixed AC_AIX (now an alias for
+# AC_USE_SYSTEM_EXTENSIONS) and AC_DEFINE([__EXTENSIONS__]), which
+# broke autoheader in 2.62. Test that this is supported.
+
+_AT_CHECK_AC_MACRO(
+[[AC_AIX
+AC_DEFINE([__EXTENSIONS__], [1], [Manually defined for Solaris])
+]])
+
+_AT_CHECK_AC_MACRO(
+[[AC_USE_SYSTEM_EXTENSIONS
+AC_DEFINE([__EXTENSIONS__], [1], [Manually defined for Solaris])
+]])
+
+AT_CLEANUP
+
+
+## ----------------------- ##
+## AC_C_RESTRICT and C++. ##
+## ----------------------- ##
+
+AT_SETUP([AC_C_RESTRICT and C++])
+
+# In some compiler suites, the left hand doesn't know about everything
+# the right hand does; or the user mixes the C compiler from one suite
+# with the C++ compiler from another. In this case, Sun WorkShop CC
+# not like the _Restrict accepted by cc.
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_CC
+AC_PROG_CXX
+AC_C_RESTRICT
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[CC = @CC@
+CXX = @CXX@
+CFLAGS = @CFLAGS@
+CXXFLAGS = @CXXFLAGS@
+CPPFLAGS = -I. @CPPFLAGS@
+OBJEXT = @OBJEXT@
+all: foo.$(OBJEXT) bar.$(OBJEXT)
+cpp-works:
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c cpp-works.cpp
+foo.$(OBJEXT): foo.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c foo.c
+bar.$(OBJEXT): bar.cpp
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c bar.cpp
+]])
+
+AT_DATA([foo.c],
+[[#include <config.h>
+
+int foo (int * restrict i1, int * restrict i2)
+{
+ return i1[0] + i2[0];
+}
+]])
+
+cp foo.c bar.cpp
+
+AT_DATA([cpp-works.cpp],
+[[// This file is just to test whether we have a working C++ compiler at all
+class foo { int x; };
+class foo foobar;
+]])
+
+AT_CHECK([autoconf])
+AT_CHECK([autoheader])
+AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
+AT_CHECK([${MAKE-make} cpp-works || exit 77], [], [ignore], [ignore])
+AT_CHECK([${MAKE-make}], [], [ignore], [ignore])
+
+AT_CLEANUP
+
+
+## ---------------- ##
+## AC_OPENMP and C. ##
+## ---------------- ##
+
+AT_SETUP([AC_OPENMP and C])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_CC
+AC_OPENMP
+if test "X$ac_cv_prog_c_openmp" = Xunsupported; then
+ AS_EXIT([77])
+fi
+CFLAGS="$CFLAGS $OPENMP_CFLAGS"
+CPPFLAGS="$CPPFLAGS $OPENMP_CFLAGS"
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[foo@EXEEXT@: foo.@OBJEXT@
+ @CC@ @CFLAGS@ @LDFLAGS@ -o $@ foo.@OBJEXT@
+
+foo.@OBJEXT@: foo.c
+ @CC@ @CPPFLAGS@ @CFLAGS@ -c foo.c
+]])
+
+AT_DATA([foo.c],
+[[#ifdef _OPENMP
+#include <omp.h>
+#endif
+#include <stdio.h>
+
+int main ()
+{
+#ifdef _OPENMP
+#pragma omp parallel
+ {
+ int id = omp_get_thread_num ();
+ printf ("hello omp world from %d\n", id);
+ }
+#endif
+ return 0;
+}
+]])
+
+: "${MAKE=make}"
+AT_CHECK([env ACLOCAL=true autoreconf -vi], [], [ignore], [ignore])
+AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+
+AT_CLEANUP
+
+
+## ------------------ ##
+## AC_OPENMP anc C++. ##
+## ------------------ ##
+
+AT_SETUP([AC_OPENMP and C++])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_CXX
+AC_LANG([C++])
+AC_OPENMP
+if test "X$ac_cv_prog_cxx_openmp" = Xunsupported; then
+ AS_EXIT([77])
+fi
+CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
+CPPFLAGS="$CPPFLAGS $OPENMP_CXXFLAGS"
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[foo@EXEEXT@: foo.@OBJEXT@
+ @CXX@ @CXXFLAGS@ @LDFLAGS@ -o $@ foo.@OBJEXT@
+
+foo.@OBJEXT@: foo.cpp
+ @CXX@ @CPPFLAGS@ @CXXFLAGS@ -c foo.cpp
+]])
+
+AT_DATA([foo.cpp],
+[[int main ()
+{
+ return 0;
+}
+]])
+
+: "${MAKE=make}"
+AT_CHECK([env ACLOCAL=true autoreconf -vi], [], [ignore], [ignore])
+AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+
+AT_CLEANUP
diff --git a/tests/compile.at b/tests/compile.at
new file mode 100644
index 0000000..a4ad6e2
--- /dev/null
+++ b/tests/compile.at
@@ -0,0 +1,465 @@
+# -*- Autotest -*-
+
+AT_BANNER([Low level compiling/preprocessing macros.])
+
+# Copyright (C) 2000-2001, 2003, 2005-2012 Free Software Foundation,
+# Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+# Since the macros which compile are required by most tests, check
+# them first. But remember that looking for a compiler is even more
+# primitive, so check those first.
+
+
+## ------------------------------------- ##
+## AC_LANG, AC_LANG_PUSH & AC_LANG_POP. ##
+## ------------------------------------- ##
+
+AT_SETUP([[AC_LANG, AC_LANG_PUSH & AC_LANG_POP]])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+# C
+AC_LANG([C])
+# C
+AC_LANG_PUSH([C])
+# C C
+AC_LANG_PUSH([C++])
+# C++ C C
+AC_LANG([C++])
+# C++ C C
+AC_LANG_PUSH([Erlang])
+# Erlang C++ C C
+AC_LANG_PUSH([Fortran 77])
+# F77 Erlang C++ C C
+AC_LANG_POP([Fortran 77])
+# Erlang C++ C C
+AC_LANG_POP([Erlang])
+# C++ C C
+AC_LANG([C++])
+# C++ C C
+AC_LANG_POP([C++])
+# C C
+AC_LANG_POP([C])
+# C
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK([sed -n 's/^ac_ext=//p' configure], 0,
+[c
+c
+c
+cpp
+cpp
+erl
+f
+erl
+cpp
+cpp
+c
+c
+])
+
+AT_CLEANUP
+
+
+## ---------------------- ##
+## AC_REQUIRE & AC_LANG. ##
+## ---------------------- ##
+
+AT_SETUP([AC_REQUIRE & AC_LANG])
+
+AT_DATA([configure.ac],
+[[AC_DEFUN([AC_F77_1],
+[AC_LANG_PUSH([Fortran 77])
+if test $ac_ext != f; then
+ AC_MSG_ERROR([F77_1: current shell language is $ac_ext, expected Fortran])
+fi
+AC_LANG_POP
+])
+
+
+AC_DEFUN([AC_F77_2],
+[AC_LANG_PUSH([Fortran 77])
+AC_REQUIRE([AC_F77_1])
+if test $ac_ext != f; then
+ AC_MSG_ERROR([F77_2: current shell language is $ac_ext, expected Fortran])
+fi
+AC_LANG_POP
+])
+
+AC_INIT
+AC_F77_2
+AS_EXIT(0)
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+## ---------------- ##
+## AC_LANG_SOURCE. ##
+## ---------------- ##
+
+AT_SETUP([AC_LANG_SOURCE])
+
+AT_DATA([configure.ac],
+[[AC_INIT([pkg], [1.0])
+AC_PROG_CC
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef PACKAGE_NAME
+choke me
+#endif
+int main ()
+{
+ return 0;
+}
+]], [], [AC_MSG_FAILURE([confdefs not included])])])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+## --------------------- ##
+## AC_LANG_SOURCE(C++). ##
+## --------------------- ##
+
+AT_SETUP([AC_LANG_SOURCE(C++)])
+
+AT_DATA([configure.ac],
+[[AC_INIT([pkg], [1.0])
+AC_PROG_CXX
+AC_LANG([C++])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef PACKAGE_NAME
+choke me
+#endif
+int main ()
+{
+ return 0;
+}
+]], [], [AC_MSG_FAILURE([confdefs not included])])])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+## ------------------------ ##
+## AC_LANG_SOURCE example. ##
+## ------------------------ ##
+
+AT_SETUP([AC_LANG_SOURCE example])
+
+# Set CONFIG_SITE to a nonexistent file, so that there are
+# no worries about configure output caused by sourcing a config.site.
+CONFIG_SITE=no-such-file
+export CONFIG_SITE
+
+AT_DATA([configure.ac],
+[[# Taken from autoconf.texi:Generating Sources.
+# The only change is to not fail if gcc doesn't work.
+AC_INIT([Hello], [1.0], [bug-hello@example.org], [],
+ [http://www.example.org/])
+AC_DEFINE([HELLO_WORLD], ["Hello, World\n"],
+ [Greetings string.])
+AC_LANG([C])
+AC_LANG_CONFTEST(
+ [AC_LANG_SOURCE([[const char hw[] = "Hello, World\n";]])])
+gcc -E -dD conftest.c || AS_EXIT([77])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], [], [stdout])
+# Taken from autoconf.texi:Generating Sources.
+# Note that the output may contain more defines and lines matching
+# # 1 "conftest.c"
+# so delete everything before the interesting output.
+AT_CHECK([sed -n 's/ *$//; /#define PACKAGE/,$p' stdout], [],
+[[#define PACKAGE_NAME "Hello"
+#define PACKAGE_TARNAME "hello"
+#define PACKAGE_VERSION "1.0"
+#define PACKAGE_STRING "Hello 1.0"
+#define PACKAGE_BUGREPORT "bug-hello@example.org"
+#define PACKAGE_URL "http://www.example.org/"
+#define HELLO_WORLD "Hello, World\n"
+
+const char hw[] = "Hello, World\n";
+]])
+
+AT_CLEANUP
+
+
+## ------------------------- ##
+## AC_LANG_PROGRAM example. ##
+## ------------------------- ##
+
+AT_SETUP([AC_LANG_PROGRAM example])
+
+# Set CONFIG_SITE to a nonexistent file, so that there are
+# no worries about configure output caused by sourcing a config.site.
+CONFIG_SITE=no-such-file
+export CONFIG_SITE
+
+AT_DATA([configure.ac],
+[[# Taken from autoconf.texi:Generating Sources.
+# The only change is to not fail if gcc doesn't work.
+AC_INIT([Hello], [1.0], [bug-hello@example.org], [],
+ [http://www.example.org/])
+AC_DEFINE([HELLO_WORLD], ["Hello, World\n"],
+ [Greetings string.])
+AC_LANG_CONFTEST(
+[AC_LANG_PROGRAM([[const char hw[] = "Hello, World\n";]],
+ [[fputs (hw, stdout);]])])
+gcc -E -dD conftest.c || AS_EXIT([77])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], [], [stdout])
+# Taken from autoconf.texi:Generating Sources.
+# Note that the output may contain more defines and lines matching
+# # 1 "conftest.c"
+# so delete everything before the interesting output.
+AT_CHECK([sed -n 's/ *$//; /#define PACKAGE/,$p' stdout], [],
+[[#define PACKAGE_NAME "Hello"
+#define PACKAGE_TARNAME "hello"
+#define PACKAGE_VERSION "1.0"
+#define PACKAGE_STRING "Hello 1.0"
+#define PACKAGE_BUGREPORT "bug-hello@example.org"
+#define PACKAGE_URL "http://www.example.org/"
+#define HELLO_WORLD "Hello, World\n"
+
+const char hw[] = "Hello, World\n";
+int
+main ()
+{
+fputs (hw, stdout);
+ ;
+ return 0;
+}
+]])
+
+AT_CLEANUP
+
+
+## ------------------- ##
+## AC_COMPILE_IFELSE. ##
+## ------------------- ##
+
+AT_SETUP([AC_COMPILE_IFELSE])
+AT_KEYWORDS([AC_LANG_DEFINES_PROVIDED])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_COMPILE_IFELSE([int main () { return 0; }], [],
+ [AC_MSG_ERROR([compiling trivial program failed])])
+]])
+
+AT_CHECK_AUTOCONF([], [], [], [stderr])
+AT_CHECK([grep 'no AC_LANG_SOURCE call detected in body' stderr], [], [ignore])
+AT_CHECK_AUTOCONF([-W no-syntax])
+AT_CHECK_CONFIGURE([-q])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED()int main () { return 0; }], [],
+ [AC_MSG_ERROR([compiling trivial program failed])])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([-q])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [return 0])],
+ [],
+ [AC_MSG_ERROR([compiling `return 0' failed])])
+
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [return 2])],
+ [],
+ [AC_MSG_ERROR([compiling `return 2' failed])])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([-q])
+
+AT_CLEANUP
+
+## --------------- ##
+## AC_RUN_IFELSE. ##
+## --------------- ##
+
+AT_SETUP([AC_RUN_IFELSE])
+AT_KEYWORDS([AC_TRY_RUN])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+
+AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0])],
+ [],
+ [AC_MSG_ERROR([saw `return 0' as a failure])])
+
+AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 2])],
+ [AC_MSG_ERROR([saw `return 2' as a success])],
+ [estatus=$?
+test $estatus != 2 &&
+ AC_MSG_ERROR([did not get as 2 exit status: $estatus])])
+
+# The old stinky one.
+AC_TRY_RUN([int main () { return 3; }],
+ [AC_MSG_ERROR([saw `return 3' as a success])],
+ [estatus=$?
+test $estatus != 3 &&
+ AC_MSG_ERROR([did not get 3 as exit status: $estatus])])
+
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([-q])
+
+AT_CLEANUP
+
+## -------------------------- ##
+## Order of `rm' and actions. ##
+## -------------------------- ##
+
+AT_SETUP([Order of user actions and cleanup])
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_CC
+
+AC_PREPROC_IFELSE([AC_LANG_PROGRAM([int grepme;], [])],
+ [{ test -f conftest.err && grep grepme conftest.i; } || AS_EXIT([1])],
+ [AS_EXIT([1])])
+AC_PREPROC_IFELSE([AC_LANG_PROGRAM([#define 12 34 /*], [])],
+ [AS_EXIT([1])],
+ [test -f conftest.err || AS_EXIT([1])])
+
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int ok;], [])],
+ [test -f conftest.$ac_objext || AS_EXIT([1])],
+ [AS_EXIT([1])])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int bad bad;], [])],
+ [AS_EXIT([1])],
+ [test -f conftest.err || AS_EXIT([1])])
+
+AC_LINK_IFELSE([AC_LANG_PROGRAM([int ok;], [])],
+ [test -f conftest$ac_exeext || AS_EXIT([1])],
+ [AS_EXIT([1])])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([int bad bad;], [])],
+ [AS_EXIT([1])],
+ [test -f conftest.err || AS_EXIT([1])])
+
+AC_RUN_IFELSE([AC_LANG_PROGRAM([int ok;], [])],
+ [./conftest$ac_exeext || AS_EXIT([1])],
+ [AS_EXIT([1])])
+
+d@&t@nl conftest.err not generated by AC_RUN_IFELSE?
+AC_RUN_IFELSE([AC_LANG_PROGRAM([int bad bad;], [])],
+ [AS_EXIT([1])],
+ [])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([-q])
+
+AT_CLEANUP
+
+
+## ------------------ ##
+## AC_TRY_LINK_FUNC. ##
+## ------------------ ##
+
+AT_CHECK_MACRO([AC_TRY_LINK_FUNC],
+[AC_TRY_LINK_FUNC(printf,,
+ [AC_MSG_ERROR([cannot find `printf'])])
+AC_TRY_LINK_FUNC(Be_doomed_if_your_libc_has_a_function_named_like_this,
+ [AC_MSG_ERROR([found a nonexistent function])])])
+
+## -------------------- ##
+## Multiple languages. ##
+## -------------------- ##
+
+AT_SETUP([Multiple languages])
+
+# This test should be skipped if the C compiler is a C++ compiler.
+AT_DATA([configure.ac],
+[[AC_INIT
+
+AC_PROG_CC
+AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ #ifdef __cplusplus
+ choke me
+ #endif
+ ]])], [], AS_EXIT([77]))
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+# This test should be skipped on systems without a C++ compiler.
+AT_DATA([configure.ac],
+[[AC_INIT
+
+AC_PROG_CXX
+AC_LANG_PUSH([C++])
+AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ #ifndef __cplusplus
+ choke me
+ #endif
+ ]])], [], AS_EXIT([77]))
+AC_LANG_POP([C++])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_DATA([configure.ac],
+[[AC_INIT
+
+AC_PROG_CC
+AC_PROG_CXX
+
+AC_LANG_PUSH([C])
+AC_MSG_CHECKING([a simple C program that is not valid C++])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([enum a { A, B, C };
+ enum a f(enum a in) { return in++; }], [])],
+ [AC_MSG_RESULT([ok])],
+ [AC_MSG_RESULT([failed])
+ AC_MSG_ERROR([could not compile test program])])
+AC_LANG_POP([C])
+
+AC_LANG_PUSH([C++])
+AC_MSG_CHECKING([a simple C++ program that is not valid C])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([class A {};], [])],
+ [AC_MSG_RESULT([ok])],
+ [AC_MSG_RESULT([failed])
+ AC_MSG_ERROR([could not compile test program])])
+
+AC_CHECK_HEADER([cstring])
+AC_LANG_POP([C++])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([-q])
+
+AT_CLEANUP
diff --git a/tests/erlang.at b/tests/erlang.at
new file mode 100644
index 0000000..58789b6
--- /dev/null
+++ b/tests/erlang.at
@@ -0,0 +1,134 @@
+# -*- Autotest -*-
+
+AT_BANNER([Erlang low level compiling and utility macros.])
+
+# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+# Since the macros which compile are required by most tests, check
+# them first. But remember that looking for a compiler is even more
+# primitive, so check those first.
+
+
+## ----------------- ##
+## Erlang Compiler. ##
+## ----------------- ##
+
+AT_CHECK_MACRO([Erlang],
+[[AC_ERLANG_PATH_ERL([no])
+AC_ERLANG_PATH_ERLC([no])
+if test "$ERL" = "no" || test "$ERLC" = "no"; then AS_EXIT([77]); fi
+AC_LANG([Erlang])
+## Can't compile, but can run an Erlang module:
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [halt(0)])],
+ [AC_MSG_RESULT([ok])
+ AC_MSG_ERROR([compiling Erlang program should fail])],
+ [AC_MSG_RESULT([failed])])
+AC_RUN_IFELSE([AC_LANG_PROGRAM([], [halt(0)])],
+ [AC_MSG_RESULT([ok])],
+ [AC_MSG_RESULT([failed])
+ AC_MSG_ERROR([could not run test program])])
+]],
+[AT_KEYWORDS([Erlang])])
+
+
+## ---------------------- ##
+## Erlang lib detection. ##
+## ---------------------- ##
+
+AT_CHECK_MACRO([AC_ERLANG_CHECK_LIB],
+[[AC_ERLANG_PATH_ERL([no])
+AC_ERLANG_PATH_ERLC([no])
+if test "$ERL" = "no" || test "$ERLC" = "no"; then AS_EXIT([77]); fi
+AC_ERLANG_CHECK_LIB([stdlib],
+ [AC_MSG_RESULT([ok])],
+ [AC_MSG_RESULT([failed])])
+## Test that the lib path detection really detected a directory:
+if test "$ERLANG_LIB_DIR_stdlib" != "not found" \
+ && test ! -d "$ERLANG_LIB_DIR_stdlib"; then
+ AC_MSG_ERROR([incorrect ERLANG_LIB_DIR_stdlib variable])
+fi
+]],
+[AT_KEYWORDS([Erlang])])
+
+
+## --------------------------- ##
+## Erlang root dir detection. ##
+## --------------------------- ##
+
+AT_CHECK_MACRO([AC_ERLANG_SUBST_ROOT_DIR],
+[[AC_ERLANG_PATH_ERL([no])
+AC_ERLANG_PATH_ERLC([no])
+if test "$ERL" = "no" || test "$ERLC" = "no"; then AS_EXIT([77]); fi
+AC_ERLANG_SUBST_ROOT_DIR
+## Test that the root path detection really detected a directory:
+if test ! -d "$ERLANG_ROOT_DIR"; then
+ AC_MSG_ERROR([incorrect ERLANG_ROOT_DIR variable])
+fi
+]],
+[AT_KEYWORDS([Erlang])])
+
+
+## -------------------------- ##
+## Erlang lib dir detection. ##
+## -------------------------- ##
+
+AT_CHECK_MACRO([AC_ERLANG_SUBST_LIB_DIR],
+[[AC_ERLANG_PATH_ERL([no])
+AC_ERLANG_PATH_ERLC([no])
+if test "$ERL" = "no" || test "$ERLC" = "no"; then AS_EXIT([77]); fi
+AC_ERLANG_SUBST_LIB_DIR
+## Test that the lib path detection really detected a directory:
+if test ! -d "$ERLANG_LIB_DIR"; then
+ AC_MSG_ERROR([incorrect ERLANG_LIB_DIR variable])
+fi
+]],
+[AT_KEYWORDS([Erlang])])
+
+
+## ----------------------------------- ##
+## Erlang install base dir detection. ##
+## ----------------------------------- ##
+
+AT_CHECK_MACRO([AC_ERLANG_SUBST_INSTALL_LIB_DIR],
+ [AT_KEYWORDS([Erlang])])
+
+
+## ---------------------------------- ##
+## Erlang install lib dir detection. ##
+## ---------------------------------- ##
+
+AT_CHECK_MACRO([AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR],
+[[AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR([test_blah], [1.24-b])
+## Test that the generated directory name is well-formed:
+if test `echo "$ERLANG_INSTALL_LIB_DIR_test_blah" | sed -e 's/^.*\///'` != "test_blah-1.24-b"; then
+ AC_MSG_ERROR([incorrect ERLANG_INSTALL_LIB_DIR_test_blah variable])
+fi
+]],
+[AT_KEYWORDS([Erlang])])
+
+
+## -------------------------- ##
+## Erlang version detection. ##
+## -------------------------- ##
+
+AT_CHECK_MACRO([AC_ERLANG_SUBST_ERTS_VER],
+[[AC_ERLANG_PATH_ERL([no])
+AC_ERLANG_PATH_ERLC([no])
+if test "$ERL" = "no" || test "$ERLC" = "no"; then AS_EXIT([77]); fi
+AC_ERLANG_SUBST_ERTS_VER
+]],
+[AT_KEYWORDS([Erlang])])
diff --git a/tests/foreign.at b/tests/foreign.at
new file mode 100644
index 0000000..7823007
--- /dev/null
+++ b/tests/foreign.at
@@ -0,0 +1,140 @@
+# -*- Autotest -*-
+
+AT_BANNER([Compatibility with other tools.])
+
+# Copyright (C) 2000-2007, 2009-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+## --------- ##
+## Libtool. ##
+## --------- ##
+
+AT_SETUP([Libtool])
+
+# Skip this test if there is no libtoolize.
+AT_CHECK([libtoolize --version || exit 77],
+ [ignore], [ignore], [ignore])
+# Modern Libtool has further tests for compatibility with older autoconf;
+# from the Autoconf side, we will merely assume newer libtool.
+AT_CHECK([[
+case `libtoolize --version |
+ sed -n '/^.* \([0-9][0-9.a-z]*\)$/{
+ s//\1/
+ p
+ q
+ }'` in
+ 0.* ) exit 77;;
+ 1.* ) exit 77;;
+esac]],
+ [ignore], [ignore], [ignore])
+
+# Using a configure.ac, have libtoolize confess where libtool.m4 is.
+AT_DATA([configure.ac],
+[[AC_INIT
+# State that we explicitly want auxiliary files here, so libtoolize
+# won't pollute files outside the test directory.
+AC_CONFIG_AUX_DIR([.])
+AC_PROG_LIBTOOL
+]])
+AT_CHECK([libtoolize -i], [0], [stdout], [ignore])
+
+# Some broken libtoolize fail to install a functional config.guess.
+AT_CHECK([./config.guess || exit 77], [], [ignore], [ignore])
+
+# Make sure at-path contains something valid, and let the test suite
+# display it when verbose. And fail, skipping would too easily hide
+# problems.
+AT_CHECK([sed -n ["s,^.*\`\\(/[^']*\\)'.*,\\1,p"] stdout], [0], [stdout])
+AT_CHECK([test -f "`sed -n 1p stdout`"])
+
+# Older libtoolize installed everything but install-sh...
+AT_CHECK([test -f install-sh || touch install-sh])
+
+# Build the concatenation of libtool.m4 and configure.ac.
+AT_CHECK([[sed 's/.*/m4''_include([&])/' stdout]], [0], [stdout])
+AT_CHECK([mv stdout aclocal.m4])
+cat >configure.ac <<_EOF
+AC_INIT
+AC_CONFIG_AUX_DIR([.])
+AC_CANONICAL_SYSTEM
+AC_PROG_LIBTOOL
+_EOF
+
+# FIXME: Once Libtool really fixed, stop ignoring stderr.
+AT_CHECK_AUTOCONF([], [], [], [ignore])
+
+# Ignore stderr, because ltconfig always loads the cache, which is
+# /dev/null, and some shells choke on this. For instance with Bash
+# 2.05, you get:
+#
+# loading cache /dev/null within ltconfig
+# ./ltconfig: .: /dev/null: not a regular file
+#
+# But the script executes properly.
+AT_CHECK_CONFIGURE([], [], [], [ignore])
+
+AT_CLEANUP
+
+
+AT_SETUP([shtool])
+
+AT_DATA([configure.ac],
+[[AC_INIT([shtool test], [1.0])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_PATH_PROG([SHTOOL], [shtool], [false])
+AC_PROG_INSTALL
+AC_SUBST([ac_install_sh])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[SHTOOL = @SHTOOL@
+# fake these, so that we use shtool wherever possible.
+INSTALL_PROGRAM = $(ac_install_sh)
+INSTALL_DATA = $(ac_install_sh) -m 644
+prefix = @prefix@
+ac_install_sh = @ac_install_sh@
+
+install:
+ $(INSTALL_PROGRAM) file1 $(prefix)/file1
+ $(INSTALL_DATA) file2 $(prefix)/file2
+
+copy-shtool:
+ test '$(SHTOOL)' != false
+ cp '$(SHTOOL)' build-aux
+]])
+
+: >file1
+: >file2
+chmod +x file1
+: "${MAKE=make}"
+mkdir build-aux inst
+instdir=`pwd`/inst
+AT_CHECK_AUTOCONF
+cp "$abs_top_srcdir/build-aux/install-sh" build-aux
+AT_CHECK_CONFIGURE
+AT_CHECK([$MAKE copy-shtool], [], [ignore], [ignore],
+ [AT_CHECK([: >build-aux/shtool])])
+rm -f build-aux/install-sh
+AT_CHECK_CONFIGURE([--prefix="$instdir" ac_cv_path_SHTOOL=false])
+AT_CHECK([grep '^ac_install_sh = .*shtool install -c' Makefile], [], [ignore])
+if test -s build-aux/shtool; then
+ AT_CHECK([$MAKE install], [], [ignore], [ignore])
+ AT_CHECK([test -f inst/file1 && test -f inst/file2 && test -x inst/file1])
+fi
+
+AT_CLEANUP
diff --git a/tests/fortran.at b/tests/fortran.at
new file mode 100644
index 0000000..af23eb9
--- /dev/null
+++ b/tests/fortran.at
@@ -0,0 +1,1164 @@
+# -*- Autotest -*-
+
+AT_BANNER([Fortran low level compiling/preprocessing macros.])
+
+# Copyright (C) 2000-2001, 2003, 2008-2012 Free Software Foundation,
+# Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Since the macros which compile are required by most tests, check
+# them first. But remember that looking for a compiler is even more
+# primitive, so check those first.
+
+
+## --------------------- ##
+## Fortran 77 Compiler. ##
+## --------------------- ##
+
+
+AT_CHECK_MACRO([GNU Fortran 77],
+[[AC_LANG(Fortran 77)
+AC_LANG_COMPILER
+
+: > conftest.f
+if AC_TRY_COMMAND([$F77 --version | grep GNU >&2]) \
+ || AC_TRY_COMMAND([$F77 -v -c conftest.f 2>&1 | grep "f2c " >&2]); then
+ # Be sure to remove files which might be created by compilers that
+ # don't support --version, or by the second compile.
+ rm -f a.exe a.out conftest.f conftest.$ac_objext
+ # Has GNU in --version.
+ test "$G77" != yes &&
+ AC_MSG_ERROR([failed to recognize GNU Fortran 77 compiler])
+else
+ # Be sure to remove files which might be created by compilers that
+ # don't support --version, or by the second compile.
+ rm -f a.exe a.out conftest.f conftest.$ac_objext
+ # Has not.
+ test "$G77" = yes &&
+ AC_MSG_ERROR([incorrectly recognized a GNU Fortran 77 compiler])
+fi
+]])
+
+
+
+## ------------------ ##
+## Fortran Compiler. ##
+## ------------------ ##
+
+
+AT_CHECK_MACRO([GNU Fortran],
+[[AC_LANG(Fortran)
+AC_LANG_COMPILER
+
+# No Fortran compiler is known not to support "*.f".
+AC_FC_SRCEXT([f])
+
+# GNU Fortran is known to support freeform.
+AC_FC_FREEFORM([],
+ [AC_MSG_WARN([Fortran does not accept free-form source])])
+if test "$ac_compiler_gnu" = yes; then
+ case $FCFLAGS in
+ *-ffree-form*) ;;
+ *) AC_MSG_ERROR([failed to recognize GNU Fortran's -ffree-form option]);;
+ esac
+fi
+]])
+
+
+## ------------------------- ##
+## AC_OPENMP and Fortran 77. ##
+## ------------------------- ##
+
+AT_SETUP([AC_OPENMP and Fortran 77])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_F77
+AC_LANG([Fortran 77])
+AC_OPENMP
+if test "X$ac_cv_prog_f77_openmp" = Xunsupported; then
+ AS_EXIT([77])
+fi
+FFLAGS="$FFLAGS $OPENMP_FFLAGS"
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[foo@EXEEXT@: foo.@OBJEXT@
+ @F77@ @FFLAGS@ @LDFLAGS@ -o $@ foo.@OBJEXT@
+
+foo.@OBJEXT@: foo.f
+ @F77@ @FFLAGS@ -c foo.f
+]])
+
+AT_DATA([foo.f],
+[[ program main
+ end
+]])
+
+: "${MAKE=make}"
+AT_CHECK([env ACLOCAL=true autoreconf -vi], [], [ignore], [ignore])
+AT_CHECK_CONFIGURE
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+
+AT_CLEANUP
+
+
+## ---------------------- ##
+## AC_OPENMP and Fortran. ##
+## ---------------------- ##
+
+AT_SETUP([AC_OPENMP and Fortran])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_FC
+AC_LANG([Fortran])
+AC_OPENMP
+if test "X$ac_cv_prog_fc_openmp" = Xunsupported; then
+ AS_EXIT([77])
+fi
+FCFLAGS="$FCFLAGS $OPENMP_FCFLAGS"
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[foo@EXEEXT@: foo.@OBJEXT@
+ @FC@ @FCFLAGS@ @LDFLAGS@ -o $@ foo.@OBJEXT@
+
+foo.@OBJEXT@: foo.f
+ @FC@ @FCFLAGS@ -c foo.f
+]])
+
+AT_DATA([foo.f],
+[[ program main
+ end
+]])
+
+: "${MAKE=make}"
+AT_CHECK([env ACLOCAL=true autoreconf -vi], [], [ignore], [ignore])
+AT_CHECK_CONFIGURE
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+
+AT_CLEANUP
+
+
+# We don't test the AC_F77_LIBRARY_LDFLAGS macro on its own because of
+# (autoconf.info)Fortran Compiler:
+# The macros `AC_F77_DUMMY_MAIN' and `AC_FC_DUMMY_MAIN' or
+# `AC_F77_MAIN' and `AC_FC_MAIN' are probably also necessary to link
+# C/C++ with Fortran; see below.
+#
+# and we would need libtool to create shared libraries.
+
+# Further, for any sensible test of the AC_F{77,C}(_DUMMY)?_MAIN macros
+# we also need to use AC_F{77,C}_WRAPPERS, in order to be able to actually
+# call the functions.
+
+## ------------------------ ##
+## AC_F77_DUMMY_MAIN usage. ##
+## ------------------------ ##
+
+AT_SETUP([AC_F77_DUMMY_MAIN usage])
+
+AT_CONFIGURE_AC([[
+AC_PROG_F77
+AC_F77_DUMMY_MAIN([], [AC_MSG_FAILURE([failed to determine F77 dummy main], [77])])
+AC_F77_WRAPPERS
+AC_PROG_CC
+AC_CONFIG_FILES([Makefile])
+]])
+
+AT_DATA([Makefile.in],
+[[
+all: cprogram@EXEEXT@
+
+cprogram@EXEEXT@: cprogram.@OBJEXT@ foobar.@OBJEXT@
+ @CC@ @CFLAGS@ @LDFLAGS@ -o $@ cprogram.@OBJEXT@ foobar.@OBJEXT@ @LIBS@ @FLIBS@
+
+.SUFFIXES: .c .f .@OBJEXT@
+.f.@OBJEXT@:
+ @F77@ @FFLAGS@ -c $<
+.c.@OBJEXT@:
+ @CC@ @DEFS@ -I. @CPPFLAGS@ @CFLAGS@ -c $<
+]])
+
+AT_DATA([foobar.f],
+[[C This is just a purely numeric routine, no I/O needed.
+C Taken from autoconf.texi:Fortran Compiler.
+ subroutine foobar (x, y)
+ double precision x, y
+ y = 3.14159 * x
+ return
+ end
+]])
+
+AT_DATA([cprogram.c],
+[[#include <config.h>
+#include <math.h>
+
+/* Taken from autoconf.texi:Fortran Compiler. */
+#define FOOBAR_F77 F77_FUNC (foobar, FOOBAR)
+#ifdef __cplusplus
+extern "C" /* prevent C++ name mangling */
+#endif
+void FOOBAR_F77 (double *x, double *y);
+
+/* Taken from autoconf.texi:Fortran Compiler. */
+#ifdef F77_DUMMY_MAIN
+# ifdef __cplusplus
+ extern "C"
+# endif
+ int F77_DUMMY_MAIN () { return 1; }
+#endif
+
+int main(int argc, char *argv[])
+{
+ double x = 2.7183, y;
+ FOOBAR_F77 (&x, &y);
+ if (fabs (8.539784097 - y) > 1.e-6)
+ return 1;
+ return 0;
+}
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
+: "${MAKE=make}"
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+dnl AT_CHECK([./cprogram])
+
+AT_CLEANUP
+
+
+## ----------------------- ##
+## AC_FC_DUMMY_MAIN usage. ##
+## ----------------------- ##
+
+AT_SETUP([AC_FC_DUMMY_MAIN usage])
+
+AT_CONFIGURE_AC([[
+AC_PROG_FC
+AC_FC_FIXEDFORM
+AC_FC_DUMMY_MAIN([], [AC_MSG_FAILURE([failed to determine FC dummy main], [77])])
+AC_FC_WRAPPERS
+AC_PROG_CC
+AC_CONFIG_FILES([Makefile])
+]])
+
+AT_DATA([Makefile.in],
+[[
+all: cprogram@EXEEXT@
+
+cprogram@EXEEXT@: cprogram.@OBJEXT@ foobar.@OBJEXT@
+ @CC@ @CFLAGS@ @LDFLAGS@ -o $@ cprogram.@OBJEXT@ foobar.@OBJEXT@ @LIBS@ @FCLIBS@
+
+.SUFFIXES: .c .f .@OBJEXT@
+.f.@OBJEXT@:
+ @FC@ @FCFLAGS@ -c $<
+.c.@OBJEXT@:
+ @CC@ @DEFS@ -I. @CPPFLAGS@ @CFLAGS@ -c $<
+]])
+
+AT_DATA([foobar.f],
+[[C This is just a purely numeric routine, no I/O needed.
+C Taken from autoconf.texi:Fortran Compiler.
+ subroutine foobar (x, y)
+ double precision x, y
+ y = 3.14159 * x
+ return
+ end
+]])
+
+AT_DATA([cprogram.c],
+[[#include <config.h>
+#include <math.h>
+
+/* Taken from autoconf.texi:Fortran Compiler. */
+#define FOOBAR_FC FC_FUNC (foobar, FOOBAR)
+#ifdef __cplusplus
+extern "C" /* prevent C++ name mangling */
+#endif
+void FOOBAR_FC(double *x, double *y);
+
+/* Taken from autoconf.texi:Fortran Compiler. */
+#ifdef FC_DUMMY_MAIN
+# ifdef __cplusplus
+ extern "C"
+# endif
+ int FC_DUMMY_MAIN () { return 1; }
+#endif
+
+int main (int argc, char *argv[])
+{
+ double x = 2.7183, y;
+ FOOBAR_FC (&x, &y);
+ if (fabs (8.539784097 - y) > 1.e-6)
+ return 1;
+ return 0;
+}
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
+: "${MAKE=make}"
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+dnl AT_CHECK([./cprogram])
+
+AT_CLEANUP
+
+
+## ------------------ ##
+## AC_F77_MAIN usage. ##
+## ------------------ ##
+
+AT_SETUP([AC_F77_MAIN usage])
+
+AT_CONFIGURE_AC([[
+AC_PROG_F77
+AC_F77_MAIN
+AC_F77_WRAPPERS
+AC_PROG_CC
+AC_CONFIG_FILES([Makefile])
+]])
+
+AT_DATA([Makefile.in],
+[[
+all: cprogram@EXEEXT@
+
+cprogram@EXEEXT@: cprogram.@OBJEXT@ foobar.@OBJEXT@
+ @CC@ @CFLAGS@ @LDFLAGS@ -o $@ cprogram.@OBJEXT@ foobar.@OBJEXT@ @LIBS@ @FLIBS@
+
+.SUFFIXES: .c .f .@OBJEXT@
+.f.@OBJEXT@:
+ @F77@ @FFLAGS@ -c $<
+.c.@OBJEXT@:
+ @CC@ @DEFS@ -I. @CPPFLAGS@ @CFLAGS@ -c $<
+]])
+
+AT_DATA([foobar.f],
+[[C This uses Fortran I/O, so is likely to require Fortran startup.
+ subroutine foobar (x)
+ integer x
+ if (x == 42) then
+ write(*,*) 'some output from Fortran sources'
+ end if
+ end
+]])
+
+AT_DATA([cprogram.c],
+[[#include <config.h>
+#include <stdio.h>
+
+/* Taken from autoconf.texi:Fortran Compiler. */
+#define FOOBAR_F77 F77_FUNC (foobar, FOOBAR)
+#ifdef __cplusplus
+extern "C" /* prevent C++ name mangling */
+#endif
+void FOOBAR_F77 (int *x);
+
+/* Taken from autoconf.texi:Fortran Compiler. */
+#ifdef __cplusplus
+ extern "C"
+#endif
+int F77_MAIN (int argc, char *argv[]);
+
+int F77_MAIN (int argc, char *argv[])
+{
+ int x = 42;
+ puts ("output from C main");
+ fflush (stdout);
+ FOOBAR_F77 (&x);
+ puts ("more output from C main");
+ return 0;
+}
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
+: "${MAKE=make}"
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+dnl AT_CHECK([./cprogram], [], [output from C main
+dnl some output from Fortran sources
+dnl more output from C main
+dnl ])
+
+AT_CLEANUP
+
+
+## ----------------- ##
+## AC_FC_MAIN usage. ##
+## ----------------- ##
+
+AT_SETUP([AC_FC_MAIN usage])
+
+AT_CONFIGURE_AC([[
+AC_PROG_FC
+AC_FC_FIXEDFORM
+AC_FC_MAIN
+AC_FC_WRAPPERS
+AC_PROG_CC
+AC_CONFIG_FILES([Makefile])
+]])
+
+AT_DATA([Makefile.in],
+[[all: cprogram@EXEEXT@
+
+cprogram@EXEEXT@: cprogram.@OBJEXT@ foobar.@OBJEXT@
+ @CC@ @CFLAGS@ @LDFLAGS@ -o $@ cprogram.@OBJEXT@ foobar.@OBJEXT@ @LIBS@ @FCLIBS@
+
+.SUFFIXES: .c .f .@OBJEXT@
+.f.@OBJEXT@:
+ @FC@ @FCFLAGS@ -c $<
+.c.@OBJEXT@:
+ @CC@ @DEFS@ -I. @CPPFLAGS@ @CFLAGS@ -c $<
+]])
+
+AT_DATA([foobar.f],
+[[C This uses Fortran I/O, so is likely to require Fortran startup.
+ subroutine foobar (x)
+ integer x
+ if (x == 42) then
+ write (*,*) 'some output from Fortran sources'
+ end if
+ end
+]])
+
+AT_DATA([cprogram.c],
+[[#include <config.h>
+#include <stdio.h>
+
+/* Taken from autoconf.texi:Fortran Compiler. */
+#define FOOBAR_FC FC_FUNC (foobar, FOOBAR)
+#ifdef __cplusplus
+extern "C" /* prevent C++ name mangling */
+#endif
+void FOOBAR_FC (int *x);
+
+/* Taken from autoconf.texi:Fortran Compiler. */
+#ifdef __cplusplus
+ extern "C"
+#endif
+int FC_MAIN (int argc, char *argv[]);
+
+int FC_MAIN (int argc, char *argv[])
+{
+ int x = 42;
+ puts ("output from C main");
+ fflush (stdout);
+ FOOBAR_FC (&x);
+ puts ("more output from C main");
+ return 0;
+}
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
+: "${MAKE=make}"
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+dnl AT_CHECK([./cprogram], [], [output from C main
+dnl some output from Fortran sources
+dnl more output from C main
+dnl ])
+
+AT_CLEANUP
+
+
+## ------------------ ##
+## AC_F77_FUNC usage. ##
+## ------------------ ##
+
+AT_SETUP([AC_F77_FUNC usage])
+
+AT_CONFIGURE_AC([[
+AC_PROG_F77
+AC_F77_FUNC([foobar])
+AC_SUBST([foobar])
+AC_PROG_CC
+AC_CONFIG_FILES([cprogram.c:cprogram.in])
+AC_CONFIG_FILES([Makefile])
+]])
+
+AT_DATA([Makefile.in],
+[[
+all: cprogram@EXEEXT@
+
+cprogram@EXEEXT@: cprogram.@OBJEXT@ foobar.@OBJEXT@
+ @CC@ @CFLAGS@ @LDFLAGS@ -o $@ cprogram.@OBJEXT@ foobar.@OBJEXT@ @LIBS@ @FLIBS@
+
+.SUFFIXES: .c .f .@OBJEXT@
+.f.@OBJEXT@:
+ @F77@ @FFLAGS@ -c $<
+.c.@OBJEXT@:
+ @CC@ @DEFS@ -I. @CPPFLAGS@ @CFLAGS@ -c $<
+]])
+
+AT_DATA([foobar.f],
+[[ subroutine foobar (x)
+ integer x
+ x = 42
+ return
+ end
+]])
+
+AT_DATA([cprogram.in],
+[[#include <config.h>
+#include <math.h>
+
+#ifdef __cplusplus
+extern "C" /* prevent C++ name mangling */
+#endif
+void @foobar@ (int *x);
+
+/* Taken from autoconf.texi:Fortran Compiler. */
+#ifdef F77_DUMMY_MAIN
+# ifdef __cplusplus
+ extern "C"
+# endif
+ int F77_DUMMY_MAIN () { return 1; }
+#endif
+
+int main(int argc, char *argv[])
+{
+ int x;
+ @foobar@ (&x);
+ if (x != 42)
+ return 1;
+ return 0;
+}
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
+: "${MAKE=make}"
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+dnl AT_CHECK([./cprogram])
+
+AT_CLEANUP
+
+
+## ----------------- ##
+## AC_FC_FUNC usage. ##
+## ----------------- ##
+
+AT_SETUP([AC_FC_FUNC usage])
+
+AT_CONFIGURE_AC([[
+AC_PROG_FC
+AC_FC_FUNC([foobar])
+AC_SUBST([foobar])
+AC_PROG_CC
+AC_CONFIG_FILES([cprogram.c:cprogram.in])
+AC_CONFIG_FILES([Makefile])
+]])
+
+AT_DATA([Makefile.in],
+[[
+all: cprogram@EXEEXT@
+
+cprogram@EXEEXT@: cprogram.@OBJEXT@ foobar.@OBJEXT@
+ @CC@ @CFLAGS@ @LDFLAGS@ -o $@ cprogram.@OBJEXT@ foobar.@OBJEXT@ @LIBS@ @FCLIBS@
+
+.SUFFIXES: .c .f .@OBJEXT@
+.f.@OBJEXT@:
+ @FC@ @FCFLAGS@ -c $<
+.c.@OBJEXT@:
+ @CC@ @DEFS@ -I. @CPPFLAGS@ @CFLAGS@ -c $<
+]])
+
+AT_DATA([foobar.f],
+[[ subroutine foobar (x)
+ integer x
+ x = 42
+ return
+ end
+]])
+
+AT_DATA([cprogram.in],
+[[#include <config.h>
+#include <math.h>
+
+#ifdef __cplusplus
+extern "C" /* prevent C++ name mangling */
+#endif
+void @foobar@ (int *x);
+
+/* Taken from autoconf.texi:Fortran Compiler. */
+#ifdef FC_DUMMY_MAIN
+# ifdef __cplusplus
+ extern "C"
+# endif
+ int FC_DUMMY_MAIN () { return 1; }
+#endif
+
+int main(int argc, char *argv[])
+{
+ int x;
+ @foobar@ (&x);
+ if (x != 42)
+ return 1;
+ return 0;
+}
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
+: "${MAKE=make}"
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+dnl AT_CHECK([./cprogram])
+AT_CLEANUP
+
+
+## ------------------- ##
+## AC_FC_SRCEXT usage. ##
+## ------------------- ##
+
+AT_SETUP([AC_FC_SRCEXT usage])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_FC
+FCFLAGS_NOFREE=$FCFLAGS
+AC_SUBST([FCFLAGS_NOFREE])
+AC_FC_FREEFORM
+# Unconditionally require .f to work.
+AC_FC_SRCEXT([f])
+# For each other extension, fail gracefully if it does not work:
+# Not all compilers support all extensions/language versions.
+m4@&t@_foreach([ext], [f77, f90, f95, f03, f08],
+ [AC_FC_SRCEXT(ext, ext[_object='foo]ext[.$(OBJEXT)'], ext[_object=])
+ AC_SUBST(ext[_object])])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[OBJEXT = @OBJEXT@
+
+all: prog@EXEEXT@
+prog@EXEEXT@: foof.@OBJEXT@ @f77_object@ @f90_object@ \
+ @f95_object@ @f03_object@ @f08_object@
+ @FC@ @FCFLAGS@ -o $@ foof.@OBJEXT@ @f77_object@ @f90_object@ \
+ @f95_object@ @f03_object@ @f08_object@
+
+.SUFFIXES: .f .f77 .f90 .f95 .f03 .f08 .@OBJEXT@
+.f.@OBJEXT@:
+ @FC@ -c @FCFLAGS_NOFREE@ @FCFLAGS_f@ $<
+.f77.@OBJEXT@:
+ @FC@ -c @FCFLAGS_NOFREE@ @FCFLAGS_f77@ $<
+.f90.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_f90@ $<
+.f95.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_f95@ $<
+.f03.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_f03@ $<
+.f08.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_f08@ $<
+]])
+
+AT_DATA([foof.f],
+[[ program main
+ end
+]])
+
+AT_DATA([foof77.f77],
+[[ subroutine foof77
+ end
+]])
+
+AT_DATA([foof90.f90],
+[[subroutine foof90
+end
+]])
+
+AT_DATA([foof95.f95],
+[[subroutine foof95
+end
+]])
+
+AT_DATA([foof03.f03],
+[[subroutine foof03
+end
+]])
+
+AT_DATA([foof08.f08],
+[[subroutine foof08
+end
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+: "${MAKE=make}"
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+
+AT_CLEANUP
+
+
+## ---------------------- ##
+## AC_FC_PP_SRCEXT usage. ##
+## ---------------------- ##
+
+AT_SETUP([AC_FC_PP_SRCEXT usage])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_FC
+# Unconditionally require .f and .F to work.
+AC_FC_PP_SRCEXT([f])
+AC_FC_PP_SRCEXT([F])
+# For each other extension, fail gracefully if it does not work:
+# Not all compilers support all extensions/language versions.
+m4@&t@_foreach([ext], [f77, f90, f95, f03, f08],
+ [AC_FC_PP_SRCEXT(ext, ext[_object='foo]ext[.$(OBJEXT)'], ext[_object=])
+ AC_SUBST(ext[_object])])
+m4@&t@_foreach([ext], [F77, F90, F95, F03, F08],
+ [AC_FC_PP_SRCEXT(ext, ext[_object='bar]ext[.$(OBJEXT)'], ext[_object=])
+ AC_SUBST(ext[_object])])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[OBJEXT = @OBJEXT@
+
+all: prog@EXEEXT@
+prog@EXEEXT@: foof.@OBJEXT@ @f77_object@ @f90_object@ \
+ @f95_object@ @f03_object@ @f08_object@ \
+ barF.@OBJEXT@ @F77_object@ @F90_object@ \
+ @F95_object@ @F03_object@ @F08_object@
+ @FC@ @FCFLAGS@ -o $@ foof.@OBJEXT@ @f77_object@ @f90_object@ \
+ @f95_object@ @f03_object@ @f08_object@ \
+ barF.@OBJEXT@ @F77_object@ @F90_object@ \
+ @F95_object@ @F03_object@ @F08_object@
+
+.SUFFIXES: .f .f77 .f90 .f95 .f03 .f08 .F .F77 .F90 .F95 .F03 .F08 .@OBJEXT@
+.f.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_f@ $<
+.f77.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_f77@ $<
+.f90.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_f90@ $<
+.f95.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_f95@ $<
+.f03.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_f03@ $<
+.f08.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_f08@ $<
+.F.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_F@ $<
+.F77.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_F77@ $<
+.F90.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_F90@ $<
+.F95.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_F95@ $<
+.F03.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_F03@ $<
+.F08.@OBJEXT@:
+ @FC@ -c @FCFLAGS@ @FCFLAGS_F08@ $<
+]])
+
+for ext in f77 f90 f95 f03 f08; do
+ cat > foo$ext.$ext <<EOF
+ subroutine foo$ext
+#if 0
+this is not correct fortran
+#endif
+ end
+EOF
+done
+
+for ext in F F77 F90 F95 F03 F08; do
+ cat > bar$ext.$ext <<EOF
+ subroutine bar$ext
+#if 0
+this is not correct fortran
+#endif
+ end
+EOF
+done
+
+AT_DATA([foof.f],
+[[ program main
+#if 0
+this is not correct fortran
+#endif
+ end
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+: "${MAKE=make}"
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+
+AT_CLEANUP
+
+
+## --------------- ##
+## AC_FC_FREEFORM. ##
+## --------------- ##
+
+AT_SETUP([AC_FC_FREEFORM])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_FC
+AC_FC_FREEFORM
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[prog: prog.@OBJEXT@
+ @FC@ @FCFLAGS@ -o $@ prog.@OBJEXT@ @LIBS@
+
+.SUFFIXES: .f .@OBJEXT@
+.f.@OBJEXT@:
+ @FC@ @FCFLAGS@ -c $<
+]])
+
+AT_DATA([prog.f],
+[[program main
+end
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+: "${MAKE=make}"
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+dnl AT_CHECK([./prog])
+
+AT_CLEANUP
+
+
+## --------------------------------- ##
+## AC_FC_FREEFORM with AC_FC_SRCEXT. ##
+## --------------------------------- ##
+
+AT_SETUP([AC_FC_FREEFORM with AC_FC_SRCEXT])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_FC_SRCEXT([f90], [], [AS_EXIT([77])])
+AC_PROG_FC
+AC_FC_FREEFORM
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[prog: prog.@OBJEXT@
+ @FC@ @FCFLAGS@ -o $@ prog.@OBJEXT@ @LIBS@
+
+.SUFFIXES: .f90 .@OBJEXT@
+.f90.@OBJEXT@:
+ @FC@ @FCFLAGS@ -c @FCFLAGS_f90@ $<
+]])
+
+AT_DATA([prog.f90],
+[[program main
+end
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+: "${MAKE=make}"
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+dnl AT_CHECK([./prog])
+
+AT_CLEANUP
+
+
+## ---------------- ##
+## AC_FC_FIXEDFORM. ##
+## ---------------- ##
+
+AT_SETUP([AC_FC_FIXEDFORM])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_FC
+AC_FC_FIXEDFORM
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[prog: prog.@OBJEXT@
+ @FC@ @FCFLAGS@ -o $@ prog.@OBJEXT@ @LIBS@
+
+.SUFFIXES: .f .@OBJEXT@
+.f.@OBJEXT@:
+ @FC@ @FCFLAGS@ -c $<
+]])
+
+AT_DATA([prog.f],
+[[ program main
+C fixed-form style comment
+ end
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+: "${MAKE=make}"
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+dnl AT_CHECK([./prog])
+
+AT_CLEANUP
+
+
+## ---------------------------------- ##
+## AC_FC_FIXEDFORM with AC_FC_SRCEXT. ##
+## ---------------------------------- ##
+
+AT_SETUP([AC_FC_FIXEDFORM with AC_FC_SRCEXT])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_FC
+AC_FC_SRCEXT([f90], [], [AS_EXIT([77])])
+AC_FC_FIXEDFORM
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[prog: prog.@OBJEXT@
+ @FC@ @FCFLAGS@ -o $@ prog.@OBJEXT@ @LIBS@
+
+.SUFFIXES: .f90 .@OBJEXT@
+.f90.@OBJEXT@:
+ @FC@ @FCFLAGS@ -c @FCFLAGS_f90@ $<
+]])
+
+AT_DATA([prog.f90],
+[[ program main
+C fixed-form style comment
+ end
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+: "${MAKE=make}"
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+dnl AT_CHECK([./prog])
+
+AT_CLEANUP
+
+
+## ------------------ ##
+## AC_FC_LINE_LENGTH. ##
+## ------------------ ##
+
+AT_SETUP([AC_FC_LINE_LENGTH])
+
+AT_DATA([Makefile.in],
+[[prog@EXEEXT@: prog.@OBJEXT@
+ @FC@ @FCFLAGS@ -o $@ prog.@OBJEXT@ @LIBS@
+
+.SUFFIXES: .f .@OBJEXT@
+.f.@OBJEXT@:
+ @FC@ @FCFLAGS@ -c @FCFLAGS_f@ $<
+
+clean:
+ rm -f *.@OBJEXT@ prog@EEXEXT@
+]])
+
+line_80=\
+'subroutine foo(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11)'
+line_132=\
+'subroutine foo(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,'\
+'arg12,arg13,arg14,arg15,arg16,arg17,arg18,arg19)'
+line_254=\
+'subroutine foo(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,'\
+'arg12,arg13,arg14,arg15,arg16,arg17,arg18,arg19,arg20,arg21,arg22,arg23,'\
+'arg24,arg25,arg26,arg27,arg28,arg29,arg30,arg31,arg32,arg33,arg34,arg35,'\
+'arg36,arg37,arg38,arg39,arg40)'
+
+for len in 80 132 254
+do
+ if test $len -eq 254; then arg=unlimited; else arg=$len; fi
+ eval long_line=\$line_$len
+
+ # Try free-form first, it has a bigger chance of succeeding.
+ for fixed_or_free in FREEFORM FIXEDFORM
+ do
+
+ cat >configure.ac <<EOF
+AC_INIT
+AC_PROG_FC
+AC_FC_SRCEXT([f])
+AC_FC_$fixed_or_free
+AC_FC_LINE_LENGTH([$arg])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+EOF
+
+ cat >prog.f <<EOF
+ $long_line
+ end subroutine
+ program main
+ end program
+EOF
+
+ AT_CHECK_AUTOCONF
+ AT_CHECK_CONFIGURE
+ : "${MAKE=make}"
+ AT_CHECK([$MAKE], [], [ignore], [ignore])
+ dnl AT_CHECK([./prog])
+ AT_CHECK([$MAKE clean], [], [ignore], [ignore])
+
+ done
+done
+
+AT_CLEANUP
+
+
+## ------------------- ##
+## AC_FC_CHECK_BOUNDS. ##
+## ------------------- ##
+
+AT_SETUP([AC_FC_CHECK_BOUNDS])
+
+AT_DATA([Makefile.in],
+[[prog@EXEEXT@: prog.@OBJEXT@
+ @FC@ @FCFLAGS@ -o $@ prog.@OBJEXT@ @LIBS@
+
+.SUFFIXES: .f .@OBJEXT@
+.f.@OBJEXT@:
+ @FC@ @FCFLAGS@ -c @FCFLAGS_f@ $<
+
+clean:
+ rm -f *.@OBJEXT@ prog@EEXEXT@
+]])
+
+cat >configure.ac <<EOF
+AC_INIT
+AC_PROG_FC
+AC_FC_SRCEXT([f])
+AC_FC_CHECK_BOUNDS
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+EOF
+
+AT_DATA([prog.f],
+[[
+ subroutine copy(a,b,n)
+ integer a(:), b(:), n, i
+ do i = 1, n
+ a(i) = b(i)
+ end do
+ end subroutine
+
+ program main
+ integer, parameter :: n = 20
+ integer a(1:n), b(1:n-1), i
+ interface
+ subroutine copy(a,b,n)
+ integer a(:), b(:), i
+ end subroutine
+ end interface
+
+ call copy(a,b,n)
+ end program
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+: "${MAKE=make}"
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+AT_CHECK([./prog || exit 1], [1], [ignore], [ignore])
+AT_CHECK([$MAKE clean], [], [ignore], [ignore])
+
+AT_CLEANUP
+
+
+## ------------------ ##
+## AC_FC_MODULE_FLAG. ##
+## ------------------ ##
+
+AT_SETUP([AC_FC_MODULE_FLAG])
+
+AT_DATA([Makefile.in],
+[[OBJEXT = @OBJEXT@
+EXEEXT = @EXEEXT@
+LIBS = @LIBS@
+ac_empty = @ac_empty@
+FC = @FC@
+FC_MODEXT = @FC_MODEXT@
+FC_MODINC = @FC_MODINC@
+FCFLAGS = @FCFLAGS@
+FCFLAGS_f = @FCFLAGS_f@
+
+prog$(EXEEXT): sub/mod.$(OBJEXT) prog.$(OBJEXT)
+ $(FC) $(FCFLAGS) -o $@ prog.$(OBJEXT) sub/mod.$(OBJEXT) $(LIBS)
+
+sub/mod.$(OBJEXT): sub/mod.f
+ cd sub && $(FC) $(FCFLAGS) -c $(FCFLAGS_f) mod.f
+
+# Depend on the object, for the module dependency.
+prog.$(OBJEXT): prog.f sub/mod.$(OBJEXT)
+ $(FC) $(FCFLAGS) $(FC_MODINC). $(FC_MODINC)sub -c $(FCFLAGS_f) $<
+
+clean:
+ -test -z "$(FC_MODEXT)" || rm -f *.$(FC_MODEXT) sub/*.$(FC_MODEXT)
+ -rm -f *.$(OBJEXT) sub/*.$(OBJEXT) prog$(EXEEXT)
+]])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_FC
+AC_FC_SRCEXT([f])
+AC_FC_MODULE_FLAG
+if test -n "$FC_MODINC"; then
+ FCFLAGS="$FCFLAGS $FC_MODINC. ${FC_MODINC}sub"
+fi
+AC_FC_MODULE_EXTENSION
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+mkdir sub
+
+AT_DATA([sub/mod.f],
+[[ module foobar
+ end module foobar
+]])
+
+AT_DATA([prog.f],
+[[ program main
+ use foobar
+ end program
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+: "${MAKE=make}"
+AT_CHECK([$MAKE], [], [stdout], [stderr])
+# Both the FCFLAGS setting from configure.ac, and the Makefile rule
+# should add to the module search path.
+AT_CHECK([grep 'sub .*sub ' stdout stderr], [], [ignore])
+AT_CHECK([./prog], [], [ignore], [ignore])
+AT_CHECK([$MAKE clean], [], [ignore], [ignore])
+
+AT_CLEANUP
diff --git a/tests/go.at b/tests/go.at
new file mode 100644
index 0000000..8733aee
--- /dev/null
+++ b/tests/go.at
@@ -0,0 +1,33 @@
+# -*- Autotest -*-
+
+AT_BANNER([Go low level compiling and utility macros.])
+
+# Copyright (C) 2011-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+# Since the macros which compile are required by most tests, check
+# them first. But remember that looking for a compiler is even more
+# primitive, so check those first.
+
+
+## ------------- ##
+## Go Compiler. ##
+## ------------- ##
+
+AT_CHECK_MACRO([Go],
+[[AC_LANG(Go)
+AC_LANG_COMPILER
+]])
diff --git a/tests/local.at b/tests/local.at
new file mode 100644
index 0000000..40b7318
--- /dev/null
+++ b/tests/local.at
@@ -0,0 +1,527 @@
+# M4 macros used in building Autoconf test suites. -*- Autotest -*-
+
+# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+m4_version_prereq([2.57])
+
+# Used in many tests.
+m4_pattern_allow([^AS_EXIT$])
+m4_pattern_allow([^m4_(define|shift)$])
+
+# Programs this package provides
+AT_TESTED([autom4te autoconf autoheader autoupdate autoreconf ifnames])
+
+# Enable colored test output.
+AT_COLOR_TESTS
+
+## ---------------- ##
+## Utility macros. ##
+## ---------------- ##
+
+# AT_CMP(FILE-1, FILE-2)
+# ----------------------
+# Check FILE-1 and FILE-2 for equality, like `cmp FILE-1 FILE-2'.
+m4_define([AT_CMP],
+[m4_ifval([$2],, [m4_fatal([AT_CMP takes two arguments.])])[]dnl
+AT_CHECK([$at_diff "$1" "$2"])
+])# AT_CMP
+
+
+## ---------------- ##
+## Testing syntax. ##
+## ---------------- ##
+
+# AT_CHECK_SHELL_SYNTAX(PROGRAM)
+# ------------------------------
+# If the shell handles `-n' well, use it to check the syntax of PROGRAM;
+# otherwise, do nothing. ksh93 -n also spits outs loads of warnings
+# about older constructs, but we don't care about the warnings.
+m4_define([AT_CHECK_SHELL_SYNTAX],
+[AT_SKIP_IF([test "$ac_cv_sh_n_works" != yes])
+AT_CHECK([/bin/sh -n $1], [], [], [ignore])])
+
+m4_define([AT_CHECK_PERL_SYNTAX],
+[AT_CHECK([autom4te_perllibdir=$abs_top_srcdir/lib $PERL -c "$abs_top_builddir"/bin/$1],
+ 0, [], [ignore])])
+
+## ------------------ ##
+## Testing autom4te. ##
+## ------------------ ##
+
+
+# AT_CHECK_M4(COMMAND, [EXIT-STATUS = 0], STDOUT, STDERR)
+# -------------------------------------------------------
+# If stderr is specified, normalize the observed stderr.
+# This (using GNU M4 1.4.6)
+#
+# /usr/local/bin/m4:script.4s:1: cannot open `foo': No such file or directory
+# autom4te: /usr/local/bin/m4 failed with exit status: 1
+#
+# or this (GNU M4 1.4.11)
+#
+# /usr/local/bin/m4:script.4s:1: include: cannot open `foo': No such file or directory
+# autom4te: /usr/local/bin/m4 failed with exit status: 1
+#
+# or this (GNU M4 1.4 installed as gm4)
+#
+# script.4s:1: /usr/local/bin/gm4: Cannot open foo: No such file or directory
+# autom4te: /usr/local/bin/gm4 failed with exit status: 1
+#
+# or this (GNU M4 1.4.13 installed as m4-1.4.13):
+#
+# /usr/bin/m4-1.4.13:script.4s:1: include: cannot open `foo': No such file or directory
+# autom4te: /usr/bin/m4-1.4.13 failed with exit status: 1
+#
+# becomes
+#
+# m4:script.4s:1: cannot open `foo': No such file or directory
+# autom4te: m4 failed with exit status: 1
+#
+# We use the following sed patterns:
+#
+# (m4): ?(file): ?(line):
+# or (file): ?(line): ?(m4):
+# to m4:(file):(line):
+#
+# and
+# m4:(file):(line): Cannot open foo:
+# or m4:(file):(line): include: cannot open `foo':
+# to m4:(file):(line): cannot open `foo':
+#
+# and
+# autom4te: [^ ]m4
+# or autom4te: [^ ]m4.exe
+# to autom4te: m4
+#
+# Moreover, DJGPP error messages include the error code in brackets;
+# remove the error code during normalization.
+#
+m4_define([AT_CHECK_M4],
+[AT_CHECK([$1], [$2], [$3],
+ m4_case([$4], [], [], [ignore], [ignore], [stderr]))
+m4_case([$4], [], [], [ignore], [],
+[AT_CHECK([[sed 's/^[^:]*m4[-.ex0-9]*: *\([^:]*:\) *\([0-9][0-9]*: \)/m4:\1\2/
+ s/^\([^:]*:\) *\([0-9][0-9]*:\)[^:]*m4[-.ex0-9]*: /m4:\1\2 /
+ s/: C\(annot open \)\([^`:]*\):/: c\1`\2'\'':/
+ s/: include:\( cannot open\)/:\1/
+ s/^autom4te: [^ ]*m4[.ex]* /autom4te: m4 /
+ s/ (E[A-Z]*)$//
+ ' stderr >&2]], [0], [], [$4])])
+])
+
+# AT_CHECK_AUTOM4TE(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
+# -----------------------------------------------------------
+m4_define([AT_CHECK_AUTOM4TE],
+[AT_CHECK_M4([autom4te $1], [$2], [$3], [$4])])
+
+
+
+## ----------------- ##
+## Testing M4sugar. ##
+## ----------------- ##
+
+
+# AT_DATA_M4SUGAR(FILE-NAME, CONTENTS)
+# ------------------------------------
+# Escape the invalid tokens with @&t@.
+m4_define([AT_DATA_M4SUGAR],
+[AT_DATA([$1],
+[m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\)\(_\)\|\(d\)\(nl\)],
+ [\1\3\5@&t@\2\4\6])])])
+
+
+# AT_CHECK_M4SUGAR(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
+# ----------------------------------------------------------
+m4_define([AT_CHECK_M4SUGAR],
+[AT_KEYWORDS([m4sugar])
+AT_CHECK_AUTOM4TE([--language=m4sugar script.4s -o script $1],
+ [$2], [$3], [$4])])
+
+
+
+## -------------- ##
+## Testing M4sh. ##
+## -------------- ##
+
+
+# AT_DATA_M4SH(FILE-NAME, CONTENTS)
+# ---------------------------------
+# Escape the invalid tokens with @&t@.
+m4_define([AT_DATA_M4SH],
+[AT_DATA([$1],
+[m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\|AS\)\(_\)\|\(d\)\(nl\)],
+ [\1\3\5@&t@\2\4\6])])])
+
+
+# AT_CHECK_M4SH(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
+# -------------------------------------------------------
+m4_define([AT_CHECK_M4SH],
+[AT_CHECK_AUTOM4TE([--language=m4sh script.as -o script $1],
+ [$2], [$3], [$4])])
+
+
+
+## ------------------ ##
+## Testing Autoconf. ##
+## ------------------ ##
+
+
+# AT_DATA_AUTOCONF(FILE-NAME, CONTENTS)
+# -------------------------------------
+# Escape the invalid tokens with @&t@.
+m4_define([AT_DATA_AUTOCONF],
+[AT_DATA([$1],
+[m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\|AS\|AC\)\(_\)\|\(d\)\(nl\)],
+ [\1\3\5@&t@\2\4\6])])])
+
+
+
+# AT_CONFIGURE_AC(BODY)
+# ---------------------
+# Create a full configure.ac running BODY, with a config header set up,
+# AC_OUTPUT, and environment checking hooks.
+m4_define([AT_CONFIGURE_AC],
+[AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_HEADERS(config.h:config.hin)
+AC_STATE_SAVE(before)]
+$1
+[AC_OUTPUT
+AC_STATE_SAVE(after)
+]])
+cp "$abs_top_srcdir/build-aux/install-sh" \
+ "$abs_top_srcdir/build-aux/config.guess" \
+ "$abs_top_srcdir/build-aux/config.sub" .
+cp "$abs_top_srcdir/tests/statesave.m4" aclocal.m4
+])# AT_CONFIGURE_AC
+
+
+# AT_CHECK_AUTOCONF(ARGS, [EXIT-STATUS = 0], STDOUT, STDERR)
+# ----------------------------------------------------------
+# We always use "--force", to prevent problems with timestamps if the testsuite
+# were running too fast.
+m4_define([AT_CHECK_AUTOCONF],
+[AT_CHECK_M4([autoconf --force $1], [$2], [$3], [$4])
+if test -s configure && test "$ac_cv_sh_n_works" = yes; then
+ AT_CHECK_SHELL_SYNTAX([configure])
+fi
+])
+
+
+# AT_CHECK_AUTOHEADER(ARGS, [EXIT-STATUS = 0], STDOUT, STDERR)
+# ------------------------------------------------------------
+m4_define([AT_CHECK_AUTOHEADER],
+[AT_CHECK([autoheader $1], [$2], [$3], [$4])
+])
+
+
+# AT_CHECK_CONFIGURE(END-COMMAND,
+# [EXIT-STATUS = 0],
+# [STDOUT = IGNORE], STDERR)
+# ---------------------------------------------
+# `abs_top_srcdir' is needed so that `./configure' finds install-sh.
+# Using --srcdir is more expensive.
+m4_define([AT_CHECK_CONFIGURE],
+[AT_CAPTURE_FILE([config.log])[]dnl
+ AT_CHECK([./configure $configure_options $1],
+ [$2],
+ m4_default([$3], [ignore]), [$4])])
+
+
+# AT_CHECK_ENV
+# ------------
+# Check that the full configure run remained in its variable name space,
+# and cleaned up tmp files.
+#
+# Perhaps grep -E is not supported, or perhaps it chokes on such a big regex.
+# In this case just don't pay attention to the env. It would be great
+# to keep the error message but we can't: that would break AT_CHECK.
+#
+# FreeBSD sh may intermingle the trace output from the egrep and grep
+# commands in the pipe, so turn off tracing for these.
+#
+# Some tests might exit prematurely when they find a problem, in
+# which case `env-after' is probably missing. Don't check it then.
+#
+# Here are the variables `configure' may modify during execution:
+# - ^as_
+# M4sh's shell name space.
+# - ^ac_
+# Autoconf's shell name space.
+# - prefix and exec_prefix
+# are kept undefined (NONE) until AC_OUTPUT which then sets them to
+# `/usr/local' and `${prefix}' for make.
+# - (host|build|target)(_(alias|cpu|vendor|os))?
+# Set by AC_CANONICAL_(HOST|BUILD|TARGET).
+# - cross_compiling
+# Set by AC_INIT.
+# - interpval
+# Set by AC_SYS_INTERPRETER.
+# - CONFIG_STATUS and DEFS
+# Set by AC_OUTPUT.
+# - AC_SUBST'ed variables
+# (FIXME: Generate a list of these automatically.)
+# - _|@|.[*#?$].|argv|ARGC|LINENO|OLDPWD|PIPESTATUS|RANDOM|SECONDS
+# Some variables some shells use and change.
+# `.[*#?$].' catches `$#' etc. which are displayed like this:
+# | '!'=18186
+# | '#'=0
+# | '$'=6908
+#
+m4_define([AT_CHECK_ENV],
+[m4_divert_once([PREPARE_TESTS], [_AT_CHECK_ENV])dnl
+AT_CHECK([at_check_env])])
+m4_define([_AT_CHECK_ENV],
+[AS_FUNCTION_DESCRIBE([at_check_env], [],
+[Compare the directory and environment state both before and after a run,
+and return non-zero status if they differ inappropriately.])
+at_check_env ()
+{
+# Compare directory listings.
+test -f state-ls.before ||
+ AS_ERROR([state-ls.before not present])
+test -f state-ls.after \
+ && { $at_diff state-ls.before state-ls.after || return 1; }
+# Compare variable space dumps.
+if test -f state-env.before && test -f state-env.after; then
+ set +x
+ grep_failed=false
+ for act_file in state-env.before state-env.after
+ do
+ ($EGREP -v '^(m4_join([|],
+ [a[cs]_.*],
+ [(exec_)?prefix|DEFS|CONFIG_STATUS],
+ [CC|CFLAGS|CPP|GCC|CXX|CXXFLAGS|CXXCPP|GXX|F77|FFLAGS|FLIBS|G77],
+ [ERL|ERLC|ERLCFLAGS|ERLANG_PATH_ERL|ERLANG_ROOT_DIR|ERLANG_LIB_DIR],
+ [ERLANG_LIB_DIR_.*|ERLANG_LIB_VER_.*|ERLANG_INSTALL_LIB_DIR],
+ [ERLANG_INSTALL_LIB_DIR_.*|ERLANG_ERTS_VER|OBJC|OBJCPP|OBJCFLAGS],
+ [OBJCXX|OBJCXXCPP|OBJCXXFLAGS],
+ [GOC|GOFLAGS],
+ [OPENMP_CFLAGS],
+ [LIBS|LIB@&t@OBJS|LTLIBOBJS|LDFLAGS],
+ [INSTALL(_(DATA|PROGRAM|SCRIPT))?],
+ [CYGWIN|ISC|MINGW32|MINIX|EMXOS2|XENIX|EXEEXT|OBJEXT],
+ [X_(CFLAGS|(EXTRA_|PRE_)?LIBS)|x_(includes|libraries)|(have|no)_x],
+ [(host|build|target)(_(alias|cpu|vendor|os))?],
+ [cross_compiling|U],
+ [interpval|PATH_SEPARATOR],
+ [GFC|F77_DUMMY_MAIN|f77_(case|underscore)],
+ [FC(_DUMMY_MAIN|FLAGS|LIBS|FLAGS_[fF]|_MODEXT|_MODINC|_MODOUT|_DEFINE)?],
+ [ALLOCA|GETLOADAVG_LIBS|KMEM_GROUP|NEED_SETGID|POW_LIB],
+ [AWK|LEX|LEXLIB|LEX_OUTPUT_ROOT|LN_S|M4|MKDIR_P|RANLIB|SET_MAKE|YACC],
+ [GREP|[EF]GREP|SED],
+ [[_@]|.[*#?$].],
+ [argv|ARGC|LINENO|OLDPWD|PIPESTATUS|RANDOM|SECONDS]))=' \
+ $act_file ||
+ test $? -eq 1 || echo failed >&2
+ ) 2>stderr-$act_file |
+ # There may be variables spread on several lines; remove latter lines.
+ $GREP '^m4_defn([m4_re_word])=' >clean-$act_file ||
+ test $? -eq 1 || grep_failed=:
+ test -s stderr-$act_file && grep_failed=:
+ done
+ $at_traceon
+ $grep_failed || $at_diff clean-state-env.before clean-state-env.after
+fi
+} [#]at_check_env])
+
+
+# AT_CONFIG_CMP(VAR-FILE-A, VAR-FILE-B)
+# -------------------------------------
+# Check the outcomes of two configure runs for equality by comparing dumps of
+# their shell variables. VAR-FILE-A and VAR-FILE-B are two `set'-style shell
+# variable space dumps.
+#
+# We permit variance between runs in the following shell variables:
+# - ^as_
+# M4sh's shell name space.
+# - ^ac_, excluding ^ac_cv_
+# Autoconf's private shell name space.
+# - PPID [bash, zsh]
+# - RANDOM [zsh]
+# - SECONDS [zsh]
+# - '$' [zsh]
+# - argv [zsh]
+# - ARGC [zsh]
+#
+# Furthermore, it is okay for a non-cache variable initialized to empty in one
+# run to be unset in another run. This happens when, for example, cache update
+# code tries a number of values in LIBS and eventually restores LIBS to its
+# original value. If LIBS was previously unset, it will have become set and
+# empty. (OTOH, cache variables indicate the result of the test even if they
+# are empty, so we have to be strict about them.)
+#
+# Lines that do not look like `foo=bar' are probably latter lines of
+# multiline values; trim them.
+#
+m4_define([AT_CONFIG_CMP],
+[for act_file in $1 $2
+do
+ $SED '/^ac_cv_/ b
+ /^m4_defn([m4_re_word])=./ !d
+ /^[[^=]]*='\'''\''$/ d
+ /^a[[cs]]_/ d
+ /^OLDPWD=/ d
+ /^PPID=/ d
+ /^RANDOM=/ d
+ /^SECONDS=/ d
+ /'\'\\\$\''=/ d
+ /^argv=/ d
+ /^ARGC=/ d
+ ' $act_file >at_config_vars-$act_file
+done
+AT_CMP([at_config_vars-$1], [at_config_vars-$2])[]dnl
+])# AT_CONFIG_CMP
+
+
+# AT_CHECK_DEFINES(CONTENT)
+# -------------------------
+# Verify that config.h, once stripped, is CONTENT.
+# Stripping consists of keeping CPP lines (i.e. containing a hash),
+# but those of automatically checked features (STDC_HEADERS etc.)
+# and symbols (PACKAGE_...).
+# AT_CHECK_HEADER is a better name, but too close from AC_CHECK_HEADER.
+m4_define([AT_CHECK_DEFINES],
+[AT_CHECK([[sed '/#/!d
+/INTTYPES/d
+/MEMORY/d
+/PACKAGE_/d
+/STDC_HEADERS/d
+/STDINT/d
+/STDLIB/d
+/STRING/d
+/SYS_STAT/d
+/SYS_TYPES/d
+/UNISTD/d' config.h]],,
+ [$1])])
+
+
+# AT_CHECK_AUTOUPDATE
+# -------------------
+m4_define([AT_CHECK_AUTOUPDATE],
+[AT_CHECK([autoupdate $1], [$2], [$3], [$4])
+])
+
+
+# _AT_CHECK_AC_MACRO(AC-BODY, PRE-TESTS)
+# --------------------------------------
+# Create a minimalist configure.ac running the macro named
+# NAME-OF-THE-MACRO, check that autoconf runs on that script,
+# and that the shell runs correctly the configure.
+m4_define([_AT_CHECK_AC_MACRO],
+[AT_CONFIGURE_AC([$1])
+$2
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
+AT_CHECK_ENV
+])# _AT_CHECK_AC_MACRO
+
+
+# AT_CHECK_MACRO(MACRO, [MACRO-USE], [ADDITIONAL-CMDS],
+# [AUTOCONF-FLAGS = -W obsolete])
+# -----------------------------------------------------
+# Create a minimalist configure.ac running the macro named
+# NAME-OF-THE-MACRO, check that autoconf runs on that script,
+# and that the shell runs correctly the configure.
+#
+# We run `configure' twice, both times with a cache, and compare
+# the environment after each run to detect inconsistencies.
+#
+# New macros are not expected to depend upon obsolete macros.
+m4_define([AT_CHECK_MACRO],
+[AT_SETUP([$1])
+
+AT_CONFIGURE_AC([m4_default([$2], [$1])])
+
+AT_CHECK_AUTOCONF([m4_default([$4], [-W obsolete])])
+AT_CHECK_AUTOHEADER
+
+for at_run in r1 r2
+do
+ AT_CHECK_CONFIGURE([-C])
+ cp -f state-env.after state-env.$at_run
+ cp -f config.h config-h.$at_run
+ AT_CHECK_ENV
+done
+
+AT_CMP([config-h.r1], [config-h.r2])
+AT_CONFIG_CMP([state-env.r1], [state-env.r2])
+
+$3
+
+AT_CLEANUP[]dnl
+])# AT_CHECK_MACRO
+
+
+# AT_CHECK_MACRO_CROSS(MACRO, [MACRO-USE], [ADDITIONAL-CMDS],
+# [AUTOCONF-FLAGS = -W obsolete])
+# -----------------------------------------------------------
+# Like the previous one, but creates two checks: for native
+# compile and for cross-compile.
+m4_define([AT_CHECK_MACRO_CROSS],
+[AT_CHECK_MACRO($@)
+AT_CHECK_MACRO([$1 (cross compile)],
+ [AT_KEYWORDS([cross])
+ # Exercise the code used when cross-compiling.
+ cross_compiling=yes
+ ac_tool_warned=yes
+ m4_default([$2], [$1])],
+ [$3], [$4])
+])
+
+
+# AT_CHECK_AU_MACRO(MACRO)
+# ------------------------
+# Create a minimalist configure.ac running the macro named
+# NAME-OF-THE-MACRO, autoupdate this script, check that autoconf runs
+# on that script, and that the shell runs correctly the configure.
+#
+# Updated configure.ac shall not depend upon obsolete macros, which votes
+# in favor of `-W obsolete', but since many of these macros leave a message
+# to be removed by the user once her code is adjusted, let's not check.
+#
+# Remove config.hin to avoid `autoheader: config.hin is unchanged'.
+m4_define([AT_CHECK_AU_MACRO],
+[AT_SETUP([$1])
+AT_KEYWORDS([autoupdate])
+
+AT_CONFIGURE_AC([$1])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
+AT_CHECK_ENV
+
+rm config.hin
+AT_CHECK_AUTOUPDATE([], 0, [], ignore)
+AT_CHECK([grep '^$1$' configure.ac], 1)
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
+AT_CHECK_ENV
+
+AT_CLEANUP[]dnl
+])# AT_CHECK_AU_MACRO
+
+
+
+## ----------------------- ##
+## Launch the test suite. ##
+## ----------------------- ##
+
+AT_INIT
diff --git a/tests/m4sh.at b/tests/m4sh.at
new file mode 100644
index 0000000..4e4da5d
--- /dev/null
+++ b/tests/m4sh.at
@@ -0,0 +1,1957 @@
+# -*- Autotest -*-
+
+AT_BANNER([M4sh.])
+
+# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+## --------------------------- ##
+## Re-exec with CONFIG_SHELL. ##
+## --------------------------- ##
+
+AT_SETUP([No extra re-exec with CONFIG_SHELL])
+AT_KEYWORDS([CONFIG_SHELL])
+AT_DATA_M4SH([script.as],
+[[
+dnl We have to muck with internal details to goad the script into
+dnl thinking that the default shell is always good enough.
+m4_define([_AS_DETECT_REQUIRED_BODY], [])dnl
+m4_define([_AS_DETECT_SUGGESTED_BODY], [])dnl
+AS_INIT
+echo foo > ok
+]])
+AT_CHECK_M4SH
+AT_CHECK([CONFIG_SHELL=/bin/false ./script], [0], [], [])
+AT_CHECK([test -f ok], [0])
+rm -f ok
+
+AT_CLEANUP
+
+AT_SETUP([Forced re-exec with CONFIG_SHELL])
+AT_KEYWORDS([CONFIG_SHELL])
+
+AT_DATA_M4SH([script.as],
+[[m4_define([_AS_FORCE_REEXEC_WITH_CONFIG_SHELL], [yes])
+AS_INIT
+echo foo > sentinel
+]])
+AT_CHECK_M4SH
+
+# Calling the script simply 'script' could cause problems with
+# Solaris /usr/xpg4/bin/sh in the invocation 'sh script' below.
+mv -f script script2
+
+AT_DATA([fake-shell],
+[[#!/bin/sh
+echo 'Fake shell executed.'
+shift # fake shell
+echo "nargs = @S|@#"
+for i
+do
+ printf ' :%s:\n' "$i"
+done
+]])
+chmod a+x fake-shell
+
+AT_CHECK([CONFIG_SHELL=./fake-shell ./script2 1 2 4 8], [0],
+[Fake shell executed.
+nargs = 4
+ :1:
+ :2:
+ :4:
+ :8:
+], [])
+AT_CHECK([test ! -f sentinel], [0])
+test ! -f sentinel || rm -f sentinel # Cleanup for next test.
+
+AT_CHECK(
+[CONFIG_SHELL=`pwd`/fake-shell sh script2 a 'b c' ' d e '],
+[0],
+[Fake shell executed.
+nargs = 3
+ :a:
+ :b c:
+ : d e :
+], [])
+AT_CHECK([test ! -f sentinel], [0])
+test ! -f sentinel || rm -f sentinel # Cleanup for next test.
+
+AT_CHECK([(PATH=`pwd`:$PATH; export PATH;
+CONFIG_SHELL=fake-shell script2 '' '&' '!;*' '<($[]@%:@)>,' 'x
+y z
+1 2 3')], [0],
+[Fake shell executed.
+nargs = 5
+ ::
+ :&:
+ :!;*:
+ :<($[]@%:@)>,:
+ :x
+y z
+1 2 3:
+], [])
+AT_CHECK([test ! -f sentinel], [0])
+test ! -f sentinel || rm -f sentinel # Cleanup for next test.
+
+AT_CLEANUP
+
+AT_SETUP([Configure re-execs self with CONFIG_SHELL])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+echo foobar >> quux
+]])
+
+AT_CHECK_AUTOCONF
+
+AT_DATA([cfg-sh],
+[[#!/bin/sh
+: > cfg-sh-has-run
+exec sh "@S|@@"
+]])
+chmod a+x cfg-sh
+
+AT_CAPTURE_FILE([config.log])
+# Export CONFIG_SITE to /dev/null to avoid spurious diffs in expected
+# stdout/stderr.
+AT_CHECK([env CONFIG_SITE=/dev/null CONFIG_SHELL=./cfg-sh ./configure],
+ [0], [], [])
+# ./configure re-executed itself.
+AT_CHECK([test -f cfg-sh-has-run], [0])
+# And did that not to cause extra execution of later commands.
+AT_CHECK([cat quux], [0], [foobar
+], [])
+
+rm -f quux cfg-sh*
+AT_CLEANUP
+
+
+## ------------------- ##
+## AS_WARN, AS_ERROR. ##
+## ------------------- ##
+
+AT_SETUP([AS@&t@_WARN and AS@&t@_ERROR])
+AT_KEYWORDS([m4sh])
+
+dnl without logging
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+AS_WARN([*watch out*])dnl
+
+if test x"$die" != x; then
+ AS_ERROR([you're dead])dnl
+
+ AS_ERROR([really])dnl
+
+fi
+echo got here
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [],
+[[got here
+]], [[script: WARNING: *watch out*
+]])
+AT_CHECK([die=: $CONFIG_SHELL ./script], [1],
+[], [[script: WARNING: *watch out*
+script: error: you're dead
+]])
+
+dnl with logging
+rm script
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+m4_define([gone], [AS_ERROR([really])])
+m4_define([AS_MESSAGE_LOG_FD], [5])
+exec AS_MESSAGE_LOG_FD>log.txt
+AS_WARN([*watch out*])dnl
+
+if test x"$die" != x; then
+ AS_ERROR([you're dead])dnl
+
+ AS_ERROR([really])dnl
+
+fi
+echo got here
+exec AS_MESSAGE_LOG_FD>&-
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [],
+[[got here
+]], [[script: WARNING: *watch out*
+]])
+AT_CHECK([[grep 'script:[0-9]*: WARNING: \*watch out\*' log.txt]], [], [ignore])
+AT_CHECK([die=: $CONFIG_SHELL ./script], [1],
+[], [[script: WARNING: *watch out*
+script: error: you're dead
+]])
+AT_CHECK([[grep 'script:[0-9]*: WARNING: \*watch out\*' log.txt]], [], [ignore])
+AT_CHECK([[grep 'script:[0-9]*: error: you'\''re dead' log.txt]], [], [ignore])
+
+AT_CLEANUP
+
+## ---------------- ##
+## LINENO support. ##
+## ---------------- ##
+
+AT_SETUP([LINENO])
+AT_KEYWORDS([m4sh])
+
+# We cannot unset LINENO with Zsh, yet this test case relies on
+# unsetting LINENO to compare its result when (i) LINENO is supported
+# and when (ii) it is not.
+# So just skip if the shell is ZSH.
+AT_CHECK([test -n "${ZSH_VERSION+set}" && exit 77], ignore)
+
+# AT_DATA_LINENO(FILE-NAME,
+# UNSET-LINENO = true | false, COUNTER, COUNTER-RE)
+# ----------------------------------------------------------------
+# Produce the FILE-NAME M4sh script which uses the COUNTER LINENO or
+# _oline_, which we can recognized via COUNTER-RE. Unset LINENO is
+# UNSET-LINENO.
+#
+# Use COUNTER, COUNTER-RE = [__LINENO__], [LINENO]
+# or = [__OLINE__], [_oline__]
+#
+# instead of the obvious $LINENO and __oline__, because they would
+# be replaced in the test suite itself, even before creating these
+# scripts. For the same reason, grep for LINENO and _oline__ (sic).
+#
+# UNSET-LINENO is a shell condition to make sure the scripts have the
+# same number of lines in the output, so that their outputs be identical.
+m4_define([AT_DATA_LINENO],
+[AT_DATA([$1.tas],
+[[AS@&t@_INIT
+m4@&t@_divert_text([], [
+if $2; then
+ AS@&t@_UNSET([LINENO])
+fi
+])
+AS@&t@_LINENO_PREPARE
+echo "Line: $3"
+grep 'Line: .*$4' "$[0]" >/dev/null ||
+ AS@&t@_ERROR([cannot find original script])
+exit 0
+]])
+# If occurrences of $LINENO or __@&t@oline__ were wanted, create them.
+sed 's/__LINENO__/$''LINENO/g;s/__OLINE__/__''oline__/g' $1.tas >$1.as
+AT_CHECK([autom4te -l m4sh $1.as -o $1])
+])# AT_DATA_LINENO
+
+# `_oline_', once processed and ran, produces our reference.
+# We check that we find ourselves by looking at a string which is
+# available only in the original script: `_oline_'.
+AT_DATA_LINENO([reference], [false], [__OLINE__], [_oline__])
+AT_CHECK([./reference], 0, [stdout])
+
+# The reference:
+mv stdout expout
+
+# Now using a maybe-functioning LINENO, with different call conventions.
+# Be sure to be out of the PATH.
+AT_CHECK([mkdir test || exit 77])
+
+AT_DATA_LINENO([test/test-1], [false], [__LINENO__], [LINENO])
+AT_CHECK([./test/test-1], 0, [expout])
+AT_CHECK([(PATH=test$PATH_SEPARATOR$PATH; export PATH; exec test-1)],
+ 0, [expout])
+AT_CHECK([sh ./test/test-1], 0, [expout])
+
+# Now using a disabled LINENO, with different call conventions.
+AT_DATA_LINENO([test/test-2], [true], [__LINENO__], [LINENO])
+AT_CHECK([./test/test-2], 0, [expout])
+AT_CHECK([(PATH=test$PATH_SEPARATOR$PATH; export PATH; exec test-2)],
+ 0, [expout])
+AT_CHECK([sh ./test/test-2], 0, [expout])
+
+AT_CLEANUP
+
+
+## ---------------------- ##
+## LINENO stack support. ##
+## ---------------------- ##
+
+AT_SETUP([LINENO stack])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+
+AS_LINENO_PUSH([9999])
+test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 1])
+AS_LINENO_PUSH([8888])
+test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 2])
+AS_LINENO_POP
+test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 1])
+AS_LINENO_POP
+test x${as_lineno+set} = xset && AS_ERROR([as_lineno set at depth 0])
+
+AS_EXIT([0])
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+## -------- ##
+## AS_BOX. ##
+## -------- ##
+
+# Output a framed one-line message.
+AT_SETUP([AS@&t@_BOX])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+echo
+AS_BOX([Send a simple message, to foobar@example.com])
+AS_BOX([Send a simple message, to foobar@example.com], [$])
+m4_define([msg], [$complex])
+complex='Not quite as simple |$[1]'
+AS_BOX([msg])
+AS_BOX([msg], [,])
+AS_EXIT(0)
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([sed -n '/ -\{44\} /,/ -\{44\} /p' script ]dnl
+[| sed '1 s/.*## -/## -/; 3 s/- ##.*/- ##/'], [],
+[[## -------------------------------------------- ##
+## Send a simple message, to foobar@example.com ##
+## -------------------------------------------- ##
+]])
+
+AT_CHECK([$CONFIG_SHELL ./script], [], [[
+## -------------------------------------------- ##
+## Send a simple message, to foobar@example.com ##
+## -------------------------------------------- ##
+## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ##
+## Send a simple message, to foobar@example.com ##
+## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ##
+## ----------------------- ##
+## Not quite as simple |$1 ##
+## ----------------------- ##
+## ,,,,,,,,,,,,,,,,,,,,,,, ##
+## Not quite as simple |$1 ##
+## ,,,,,,,,,,,,,,,,,,,,,,, ##
+]])
+
+AT_CLEANUP
+
+
+# Strip path from file.
+AT_SETUP([AS@&t@_BASENAME])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+
+m4_define([BASENAME_TEST],
+[base=`AS_BASENAME([$1])`
+test "$base" = "$2" ||
+ echo "basename($1) = $base instead of $2" >&2
+
+base=`_AS_BASENAME_SED([$1])`
+test "$base" = "$2" ||
+ echo "basename_sed($1) = $base instead of $2" >&2])
+
+BASENAME_TEST([//1], [1])
+BASENAME_TEST([/1], [1])
+BASENAME_TEST([./1], [1])
+BASENAME_TEST([../../2], [2])
+BASENAME_TEST([//1/], [1])
+BASENAME_TEST([/1/], [1])
+BASENAME_TEST([./1/], [1])
+BASENAME_TEST([../../2], [2])
+BASENAME_TEST([//1/3], [3])
+BASENAME_TEST([/1/3], [3])
+BASENAME_TEST([./1/3], [3])
+BASENAME_TEST([../../2/3], [3])
+BASENAME_TEST([//1/3///], [3])
+BASENAME_TEST([/1/3///], [3])
+BASENAME_TEST([./1/3///], [3])
+BASENAME_TEST([../../2/3///], [3])
+BASENAME_TEST([//1//3/], [3])
+BASENAME_TEST([/1//3/], [3])
+BASENAME_TEST([./1//3/], [3])
+BASENAME_TEST([a.c], [a.c])
+BASENAME_TEST([a.c/], [a.c])
+BASENAME_TEST([/a.c/], [a.c])
+BASENAME_TEST([/1/a.c], [a.c])
+BASENAME_TEST([/1/a.c/], [a.c])
+BASENAME_TEST([/1/../a.c], [a.c])
+BASENAME_TEST([/1/../a.c/], [a.c])
+BASENAME_TEST([./1/a.c], [a.c])
+BASENAME_TEST([./1/a.c/], [a.c])
+AS_EXIT(0)
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+## ------------ ##
+## AS_DIRNAME. ##
+## ------------ ##
+
+# Strip filename component.
+AT_SETUP([AS@&t@_DIRNAME])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+
+# The EXPR variant is allowed to fail if `expr' was considered as too
+# weak for us, in which case `as_expr=false'.
+m4_define([DIRNAME_TEST],
+[dir=`AS_DIRNAME([$1])`
+test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
+ echo "dirname($1) = $dir instead of $2" >&2
+
+if test "$as_expr" != false; then
+ dir=`_AS_DIRNAME_EXPR([$1])`
+ test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
+ echo "dirname_expr($1) = $dir instead of $2" >&2
+fi
+
+dir=`_AS_DIRNAME_SED([$1])`
+test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
+ echo "dirname_sed($1) = $dir instead of $2" >&2])
+
+DIRNAME_TEST([/], [/])
+DIRNAME_TEST([//], [//], [/])
+DIRNAME_TEST([///], [/])
+DIRNAME_TEST([//1], [//], [/])
+DIRNAME_TEST([/1], [/])
+DIRNAME_TEST([./1], [.])
+DIRNAME_TEST([../../2], [../..])
+DIRNAME_TEST([//1/], [//], [/])
+DIRNAME_TEST([/1/], [/])
+DIRNAME_TEST([./1/], [.])
+DIRNAME_TEST([../../2], [../..])
+DIRNAME_TEST([//1/3], [//1])
+DIRNAME_TEST([/1/3], [/1])
+DIRNAME_TEST([./1/3], [./1])
+DIRNAME_TEST([../../2/3], [../../2])
+DIRNAME_TEST([//1/3///], [//1])
+DIRNAME_TEST([/1/3///], [/1])
+DIRNAME_TEST([./1/3///], [./1])
+DIRNAME_TEST([../../2/3///], [../../2])
+DIRNAME_TEST([//1//3/], [//1])
+DIRNAME_TEST([/1//3/], [/1])
+DIRNAME_TEST([./1//3/], [./1])
+DIRNAME_TEST([../../2//3/], [../../2])
+AS_EXIT(0)
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+## ---------------- ##
+## AS_SET_CATFILE. ##
+## ---------------- ##
+
+AT_SETUP([AS@&t@_SET_CATFILE])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+
+# CATFILE_TEST(DIR, FILE, EXPECTED)
+m4_define([CATFILE_TEST],
+[# AS_SET_CATFILE works and can be used in a compound list.
+if AS_SET_CATFILE([var], [$1], [$2]) \
+ && test "$var" = $3; then :; else
+ echo "catfile($1, $2) = $var != $3" >&2
+fi
+# AS_SET_CATFILE can use non-literals in its arguments.
+varname=var2
+dirpart=$1
+filepart=$2
+if AS_SET_CATFILE([$varname], [$dirpart], [$filepart]) \
+ && test "$var2" = $3; then :; else
+ echo "catfile($dirpart, $filepart) = $var2 != $3" >&2
+fi
+])
+
+CATFILE_TEST([dir], [file], [dir/file])
+CATFILE_TEST([.], [file], [file])
+CATFILE_TEST([dir], [.], [dir])
+CATFILE_TEST([dir], [/abs/file], [/abs/file])
+CATFILE_TEST([dir], [C:/abs/file], [C:/abs/file])
+CATFILE_TEST(["dir name"], ['file name'], ['dir name/file name'])
+
+AS_EXIT(0)
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+## --------- ##
+## AS_ECHO. ##
+## --------- ##
+
+# Print literal strings, with/without newline.
+AT_SETUP([AS@&t@_ECHO and AS@&t@_ECHO_N])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+
+m4_define([ECHO_TEST],
+[echo=`AS_ECHO(['$1'])`
+test "X$echo" = 'X$1' ||
+ echo "AS@&t@_ECHO('"'$1'"') outputs '$echo'" >&2
+
+echo=`AS_ECHO_N(['$1'])`
+test "X$echo" = 'X$1' ||
+ echo "AS@&t@_ECHO_N('"'$1'"') outputs '$echo'" >&2])
+
+ECHO_TEST([-])
+ECHO_TEST([--])
+ECHO_TEST([---...---])
+ECHO_TEST([ ])
+ECHO_TEST([-e])
+ECHO_TEST([-E])
+ECHO_TEST([-n])
+ECHO_TEST([-n -n])
+ECHO_TEST([-e -n])
+ECHO_TEST([ab\ncd])
+ECHO_TEST([abcd\c])
+ECHO_TEST([\a\b\c\f\n\r\t\v\"\])
+ECHO_TEST([ab
+cd
+e])
+ECHO_TEST([
+ ])
+ECHO_TEST([
+\c])
+AS_EXIT(0)
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+
+## ----------------- ##
+## AS_EXECUTABLE_P. ##
+## ----------------- ##
+
+# Check for executable regular files.
+AT_SETUP([AS@&t@_EXECUTABLE_P])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+
+if AS_EXECUTABLE_P([/]); then
+ echo fail
+else
+ echo 1
+fi
+cat > foo.sh <<\EOF || AS_EXIT([1])
+#!/bin/sh
+exit 0
+EOF
+# File systems like FAT tend to fake executable permissions on all files.
+# At this point, foo.sh should be executable iff permissions are faked.
+AS_EXECUTABLE_P([foo.sh])
+st1=$?
+(./foo.sh) >/dev/null 2>&1
+st2=$?
+case $st1:$st2 in
+ *[[1-9]]*:*[[1-9]]* | 0:0 ) echo 2 ;;
+ *) echo "fail ($st1:$st2)" ;;
+esac
+# Now things better be executable
+chmod a+x foo.sh || AS_EXIT([2])
+mkdir 'two spaces' || AS_EXIT([3])
+'two spaces'/../foo.sh || AS_EXIT([4])
+if AS_EXECUTABLE_P(["two spaces/../foo.sh"]); then
+ echo 3
+else
+ echo fail
+fi
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [],
+[[1
+2
+3
+]])
+
+AT_CLEANUP
+
+
+
+## --------- ##
+## AS_EXIT. ##
+## --------- ##
+
+# Exit scripts with given status.
+AT_SETUP([AS@&t@_EXIT])
+AT_KEYWORDS([m4sh AS@&t@_SET_STATUS])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+test x${1} = xa && AS_EXIT
+test x${1} = xb && AS_EXIT([${2}])
+test x${1} = xc && { AS_SET_STATUS([${2}]); AS_EXIT; }
+test x${1} = xd && trap 's=$?; echo $s; AS_EXIT([$s])' 0
+test x${2} = xe && set -e
+test $[#] -gt 0 || AS_EXIT
+AS_SET_STATUS([3])
+dnl Solaris /bin/sh 'set -e' doesn't react to failed function calls
+test x${2} = xe \
+ && { echo 'skipping rest of test: set -e support is lousy'; exit 77; }
+AS_SET_STATUS([4])
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [1])
+AT_CHECK([$CONFIG_SHELL ./script ''], [4])
+AT_CHECK([$CONFIG_SHELL ./script a], [0])
+AT_CHECK([$CONFIG_SHELL ./script b], [0])
+AT_CHECK([$CONFIG_SHELL ./script b 0], [0])
+AT_CHECK([$CONFIG_SHELL ./script b 2], [2])
+AT_CHECK([$CONFIG_SHELL ./script c 0], [0])
+AT_CHECK([$CONFIG_SHELL ./script c 2], [2])
+AT_CHECK([$CONFIG_SHELL ./script d], [4], [[4
+]])
+dnl If we got to this point without a FAIL, then AS_EXIT at least works.
+dnl The rest of this test relies on semi-decent 'set -e' support, even
+dnl though m4sh in general should not try to rely on it because of
+dnl portability nightmares on what constructs are considered errors across
+dnl various shells; therefore, an overall SKIP result is desirable on
+dnl broken shells like Solaris /bin/sh.
+AT_CHECK([$CONFIG_SHELL ./script '' e], [3])
+AT_CHECK([$CONFIG_SHELL ./script d e], [3], [stdout])
+dnl NetBSD sh fails to output on stderr here.
+AT_CHECK([grep 3 stdout || exit 77], [], [ignore])
+
+AT_CLEANUP
+
+
+
+## ------------ ##
+## AS_MKDIR_P. ##
+## ------------ ##
+
+# Build nested dirs.
+AT_SETUP([AS@&t@_MKDIR_P])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+
+pwd=`pwd`
+set -e
+# Absolute
+AS_MKDIR_P(["$pwd/1/2/3/4/5/6"])
+test -d "$pwd/1/2/3/4/5/6" ||
+ AS_ERROR([$pwd/1/2/3/4/5/6 has not been properly created])
+# Relative
+AS_MKDIR_P(["a/b/c/d/e/f"])
+test -d a/b/c/d/e/f ||
+ AS_ERROR([a/b/c/d/e/f has not been properly created])
+AS_EXIT(0)
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+
+
+## -------------------- ##
+## AS_VERSION_COMPARE. ##
+## -------------------- ##
+
+# Three-way version comparison.
+AT_SETUP([AS@&t@_VERSION_COMPARE])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+
+m4_define([VERSION_COMPARE_TEST],
+[AS_VERSION_COMPARE([$1], [$3], [result='<'], [result='='], [result='>'])
+test "X$result" = "X$2" ||
+ AS_ERROR([version $1 $result $3; should be $1 $2 $3])
+m4_if([$1], <,
+[AS_VERSION_COMPARE([$3], [$1], [result='<'], [result='='], [result='>'])
+test "X$result" = "X>" ||
+ AS_ERROR([version $3 $result $1; should be $3 > $1])])])
+
+VERSION_COMPARE_TEST([], =, [])
+VERSION_COMPARE_TEST([1.0], =, [1.0])
+VERSION_COMPARE_TEST([alpha-1.0], =, [alpha-1.0])
+
+# These tests are taken from libc/string/tst-svc.expect.
+tst_svc_expect='
+ 000 001 00 00a 01 01a 0 0a 2.8 2.8-0.4 20 21 22 212 CP037 CP345 CP1257
+ foo foo-0.4 foo-0.4a foo-0.4b foo-0.5 foo-0.10.5 foo-3.01 foo-3.0
+ foo-3.0.0 foo-3.0.1 foo-3.2 foo-3.10 foo00 foo0
+'
+test1=''
+for test2 in $tst_svc_expect; do
+ VERSION_COMPARE_TEST([$test1], <, [$test2])
+ test1=$test2
+done
+
+AS_EXIT(0)
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+
+
+## ------- ##
+## as_me. ##
+## ------- ##
+
+AT_SETUP([as_me])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+AS_ME_PREPARE
+test "$as_me" = script || AS_ECHO([["incorrect value of \$as_me: $as_me"]])
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+
+
+## ----------------------------- ##
+## Negated classes in globbing. ##
+## ----------------------------- ##
+
+# According to http://www.in-ulm.de/~mascheck/bourne/, all shells with
+# functions also support `[!...]'. But `[^...]' is not universally supported.
+
+AT_SETUP([Negated classes in globbing])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+
+case 'with!two!bangs' in
+ *[[!a-z]]*) ;;
+ *) AS_ERROR([[`*[!a-z]*' didn't match `with!two!bangs']]);;
+esac
+
+case without in
+ *[[!a-z]]*) AS_ERROR([[`*[!a-z]*' matched `without']]);;
+esac
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+## ---------------------------- ##
+## Null variable substitution. ##
+## ---------------------------- ##
+
+# According to http://www.in-ulm.de/~mascheck/bourne/, all shells with
+# functions also support `${a:-b}'.
+
+AT_SETUP([Null variable substitution])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+
+AS_UNSET([a])
+b=
+c=.
+case ${a:-x}${b:-y}${c:-z} in
+ xy.) ;;
+ *) exit 1 ;;
+esac
+case ${a-x}${b-y}${c-z} in
+ x.) ;;
+ *) exit 2 ;;
+esac
+
+case ${a+x}${b+y}${c+z} in
+ yz) ;;
+ *) exit 3 ;;
+esac
+case ${a:+x}${b:+y}${c:+z} in
+ z) ;;
+ *) exit 4 ;;
+esac
+
+case ${a=x}${b=y}${c=z} in
+ x.) ;;
+ *) exit 5 ;;
+esac
+AS_UNSET([a])
+case ${a:=x}${b:=y}${c:=z} in
+ xy.) ;;
+ *) exit 6 ;;
+esac
+case $a$b$c in
+ xy.) ;;
+ *) exit 7 ;;
+esac
+AS_UNSET([a])
+b=
+
+(: ${a?oops}; echo fail) 2>err && exit 8
+grep oops err >/dev/null || exit 9
+test "${b?oops}" = '' || exit 10
+test "${c?oops}" = . || exit 11
+(: ${a:?oops}; echo fail) 2>err && exit 12
+grep oops err >/dev/null || exit 13
+(: ${b:?oops}; echo fail) 2>err && exit 14
+grep oops err >/dev/null || exit 15
+test "${c:?oops}" = . || exit 16
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+## ------------------- ##
+## Functions Support. ##
+## ------------------- ##
+
+# All m4sh scripts require function support.
+
+AT_SETUP([Functions Support])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+AS_LINENO_PREPARE
+
+func_return () {
+ (exit $1)
+}
+
+func_success () {
+ func_return 0
+}
+
+func_failure () {
+ func_return 1
+}
+
+if func_success; then
+ if func_failure; then
+ AS_ERROR([func_failure passed])
+ fi
+else
+ AS_ERROR([func_success failed])
+fi
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+
+
+## ------------------------------ ##
+## Functions and return Support. ##
+## ------------------------------ ##
+
+# All m4sh scripts require working return within functions.
+
+AT_SETUP([Functions and return Support])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+AS_LINENO_PREPARE
+
+func_success () {
+ return 0
+}
+
+func_failure () {
+ return 1
+}
+
+if func_success; then
+ if func_failure; then
+ AS_ERROR([func_failure passed])
+ fi
+else
+ AS_ERROR([func_success failed])
+fi
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+## --------------------------- ##
+## Nested AS_REQUIRE_SHELL_FN. ##
+## --------------------------- ##
+
+# Hypothesis: M4sh expands nested AS_REQUIRE_SHELL_FN
+# separately.
+
+AT_SETUP([Nested AS@&t@_REQUIRE_SHELL_FN])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as], [[dnl
+m4_define([INIT], [oops])dnl
+AS_INIT
+
+m4_defun([TEST_FUNC2_BODY], [
+:
+])
+
+m4_defun([TEST_FUNC1_BODY], [
+AS_REQUIRE_SHELL_FN([test_func2], [], [TEST_FUNC2_BODY])
+:
+])
+
+AS_REQUIRE_SHELL_FN([test_func1], [], [TEST_FUNC1_BODY])
+test_func2
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+## ------------------- ##
+## Nested AS_REQUIRE. ##
+## ------------------- ##
+
+# Hypothesis: M4sh expands the requirements of AS_REQUIRE in the
+# requested diversion, even if other AS_REQUIREs are interleaved.
+
+AT_SETUP([Nested AS@&t@_REQUIRE])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+
+m4_defun([in_fn_diversion], still_in_m4sh_init_fn=yes)
+m4_defun([not_in_fn_diversion], still_in_m4sh_init_fn=no)
+
+m4_defun([NESTED], [nested_require_in_fn_diversion=$still_in_m4sh_init_fn])
+
+m4_defun([OUTER], [AS_REQUIRE([NESTED])dnl
+outer_require_in_fn_diversion=$still_in_m4sh_init_fn])
+
+m4_defun([test_init], [
+AS_REQUIRE([in_fn_diversion], , [M4SH-INIT-FN])
+AS_REQUIRE([OUTER], , [M4SH-INIT-FN])
+AS_REQUIRE([not_in_fn_diversion], , [M4SH-INIT-FN])
+])
+
+test_init
+if test $outer_require_in_fn_diversion != yes; then AS_EXIT([1]); fi
+if test $nested_require_in_fn_diversion != no; then AS_EXIT([1]); fi
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+## ------------------------------------ ##
+## AS_REQUIRE_SHELL_FN and m4_require. ##
+## ------------------------------------ ##
+
+# Hypothesis: M4sh expands the requirements of AS_REQUIRE_SHELL_FN
+# in M4SH-INIT-FN. This changed after Autoconf 2.63.
+
+AT_SETUP([AS@&t@_REQUIRE_SHELL_FN and m4@&t@_require])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+
+m4_defun([in_m4_sh_init], still_in_m4sh_init=yes)
+m4_defun([not_in_m4_sh_init], still_in_m4sh_init=no)
+
+m4_defun([error_if_emitted_in_m4sh_init], [
+ if test x$still_in_m4sh_init = xyes; then
+ AS_ERROR([requirement emitted in M4SH-INIT])
+ fi
+])
+
+m4_defun([TEST_FUNC_BODY], [
+m4_require([error_if_emitted_in_m4sh_init])
+: echo in shell function, with parameter = [$]1
+])
+
+
+m4_defun([test_init], [
+AS_REQUIRE([in_m4_sh_init], , [M4SH-INIT-FN])
+AS_REQUIRE_SHELL_FN([test_func], [], [TEST_FUNC_BODY])
+AS_REQUIRE([not_in_m4_sh_init])
+])
+
+test_init
+test_func parameter1
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+## -------------- ##
+## AS_HELP_STRING ##
+## -------------- ##
+
+AT_SETUP([AS@&t@_HELP_STRING])
+AT_KEYWORDS([m4sh m4@&t@_text_wrap m4@&t@_expand])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+
+echo "AS_HELP_STRING([--an-option],[some text])"
+echo "AS_HELP_STRING([--another-much-longer-option],
+[some other text which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([--fooT=barT], [foo bar])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@], [foo bar])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789], [foo bar])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890], [foo bar])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901], [foo bar])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012], [foo bar])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123], [foo bar])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@],
+[some other text which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789],
+[some other text which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890],
+[some other text which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901],
+[some other text which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012],
+[some other text which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123],
+[some other text which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@],
+[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789],
+[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890],
+[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901],
+[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012],
+[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123],
+[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([[--foo[=bar]]],
+[some other t[]t which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([[--foo[=bar]123456789]],
+[some other t[]t which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([[--foo[=bar]1234567890]],
+[some other t[]t which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([[--foo[=bar]12345678901]],
+[some other t[]t which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([[--foo[=bar]123456789012]],
+[some other t[]t which should wrap at our default of 80 characters.])"
+echo "AS_HELP_STRING([[--foo[=bar]1234567890123]],
+[some other t[]t which should wrap at our default of 80 characters.])"
+m4_define([mac], [MACRO])dnl
+echo "AS_HELP_STRING([--mac], [mac])"
+echo "AS_HELP_STRING([--o1, --o2], [two
+options, one description])"
+echo "AS_HELP_STRING([[[--o3, --o4]]], [comma inside literal quoting])"
+echo "AS_HELP_STRING([--tune1], [check out the tuned formatting],
+[ ])"
+echo "AS_HELP_STRING([--tune2], [check out the tuned formatting],
+[12])"
+echo "AS_HELP_STRING([--tune3], [check out the tuned formatting],
+[], [40])"
+echo "AS_HELP_STRING([--tune4], [check out the tuned formatting],
+[12], [40])"
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [0],
+[[ --an-option some text
+ --another-much-longer-option
+ some other text which should wrap at our default of
+ 80 characters.
+ --fooT=barT foo bar
+ --foo[=bar] foo bar
+ --foo[=bar]123456789 foo bar
+ --foo[=bar]1234567890 foo bar
+ --foo[=bar]12345678901 foo bar
+ --foo[=bar]123456789012 foo bar
+ --foo[=bar]1234567890123
+ foo bar
+ --foo[=bar] some other text which should wrap at our default of
+ 80 characters.
+ --foo[=bar]123456789 some other text which should wrap at our default of
+ 80 characters.
+ --foo[=bar]1234567890 some other text which should wrap at our default of
+ 80 characters.
+ --foo[=bar]12345678901 some other text which should wrap at our default of
+ 80 characters.
+ --foo[=bar]123456789012 some other text which should wrap at our default of
+ 80 characters.
+ --foo[=bar]1234567890123
+ some other text which should wrap at our default of
+ 80 characters.
+ --foo[=bar] some other [ex] which should wrap at our default of
+ 80 characters.
+ --foo[=bar]123456789 some other [ex] which should wrap at our default of
+ 80 characters.
+ --foo[=bar]1234567890 some other [ex] which should wrap at our default of
+ 80 characters.
+ --foo[=bar]12345678901 some other [ex] which should wrap at our default of
+ 80 characters.
+ --foo[=bar]123456789012 some other [ex] which should wrap at our default of
+ 80 characters.
+ --foo[=bar]1234567890123
+ some other [ex] which should wrap at our default of
+ 80 characters.
+ --foo[=bar] some other t[]t which should wrap at our default of
+ 80 characters.
+ --foo[=bar]123456789 some other t[]t which should wrap at our default of
+ 80 characters.
+ --foo[=bar]1234567890 some other t[]t which should wrap at our default of
+ 80 characters.
+ --foo[=bar]12345678901 some other t[]t which should wrap at our default of
+ 80 characters.
+ --foo[=bar]123456789012 some other t[]t which should wrap at our default of
+ 80 characters.
+ --foo[=bar]1234567890123
+ some other t[]t which should wrap at our default of
+ 80 characters.
+ --MACRO mac
+ --o1, --o2 two options, one description
+ [--o3, --o4] comma inside literal quoting
+ --tune1 check out the tuned formatting
+ --tune2 check out the tuned formatting
+ --tune3 check out the
+ tuned
+ formatting
+ --tune4 check out the tuned
+ formatting
+]])
+
+AT_CLEANUP
+
+
+## ------------------- ##
+## AS_IF and AS_CASE. ##
+## ------------------- ##
+
+AT_SETUP([AS@&t@_IF and AS@&t@_CASE])
+AT_KEYWORDS([m4sh m4@&t@_map_args_pair])
+
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+# Syntax checks: cope with empty arguments.
+AS_IF([:], [], [echo wrong])
+AS_IF([:], [echo one], [echo wrong])
+AS_IF([false], [echo wrong], [echo two])
+AS_IF([false], [echo wrong])
+# n-ary version
+AS_IF([false], [echo wrong],
+ [:], [echo three])
+AS_IF([false], [echo wrong],
+ [:], [echo four],
+ [echo wrong])
+AS_IF([false], [echo wrong],
+ [false], [echo wrong])
+AS_IF([false], [echo wrong],
+ [false], [echo wrong],
+ [echo five])
+AS_IF([false], [echo wrong],
+ [false], [echo wrong],
+ [:], [echo six],
+ [echo wrong])
+AS_CASE([foo])
+AS_CASE([foo], [echo seven])
+AS_CASE([foo],
+ [foo], [echo eight],
+ [echo wrong])
+AS_CASE([foo],
+ [foo], [echo nine],
+ [*], [echo wrong])
+AS_CASE([foo],
+ [bar], [echo wrong],
+ [foo], [echo ten],
+ [*], [echo wrong])
+
+# check for nesting, lists, and side effects, and quoting robustness
+empty=
+AS_IF([AS_IF([$empty], [echo eleven])]) && AS_CASE([foo]) && echo twelve
+rm -f file
+AS_IF([touch file; false]) && echo thirteen
+test -f file && echo fourteen
+rm -f file
+AS_CASE([`touch file; false`]) && test -f file && echo fifteen
+dnl The next line is badly underquoted; don't intentionally copy this style.
+AS_CASE([foo], [foo], m4_do(AS_CASE([bar], [bar], [echo sixteen])))
+dnl Handle blank arguments.
+AS_IF([false], [:], [ ]) && AS_CASE([foo], [foo], []
+) && echo seventeen
+m4_define([empty])AS_IF([:], [empty]
+) && AS_CASE([foo], [foo], [empty]) && echo eighteen
+dnl We can't handle AS_IF([false], [:], [empty]) unless m4_expand is
+dnl taught how to handle m4_require. The user is responsible for
+dnl avoiding the syntax error in that case.
+
+# check that require works correctly
+m4_for([n], 1, 9, [],
+[m4_defun([FOO]n, [foo]n[=]n)dnl
+m4_defun([BAR]n,
+ [m4_require([FOO]]n[)dnl
+bar]n[=]n)[]dnl
+])
+
+AS_IF([:], [BAR1])
+echo "foo1=$foo1 bar1=$bar1"
+AS_IF([:], [], [BAR2])
+echo "foo2=$foo2 bar2=$bar2"
+AS_IF([false], [BAR3])
+echo "foo3=$foo3 bar3=$bar3"
+AS_IF([false], [], [BAR4])
+echo "foo4=$foo4 bar4=$bar4"
+AS_CASE([x], [x], [BAR5])
+echo "foo5=$foo5 bar5=$bar5"
+AS_CASE([x], [y], [BAR6])
+echo "foo6=$foo6 bar6=$bar6"
+AS_CASE([x],
+ [x], [:],
+ [BAR7])
+echo "foo7=$foo7 bar7=$bar7"
+AS_CASE([x],
+ [y], [:],
+ [BAR8])
+echo "foo8=$foo8 bar8=$bar8"
+AS_CASE([x],
+ [y], [:],
+ [x], [BAR9])
+echo "foo9=$foo9 bar9=$bar9"
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [0], [[one
+two
+three
+four
+five
+six
+seven
+eight
+nine
+ten
+eleven
+twelve
+thirteen
+fourteen
+fifteen
+sixteen
+seventeen
+eighteen
+foo1=1 bar1=1
+foo2=2 bar2=
+foo3=3 bar3=
+foo4=4 bar4=4
+foo5=5 bar5=5
+foo6=6 bar6=
+foo7=7 bar7=
+foo8=8 bar8=8
+foo9=9 bar9=9
+]])
+
+dnl stress test for large number of conditionals
+dnl too large, and we start tickling shell bugs
+m4_pushdef([limit], [1000])dnl
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+AS_IF(m4_shift(m4_for([i], [1], ]limit[, [], [, test $[1] = i, echo i])))
+AS_IF(m4_shift(m4_for([i], [1], ]limit[, [], [, test $[1] = i, echo i])),
+ [echo default])
+AS_CASE([$[1]]m4_for([i], [1], ]limit[, [], [, i, echo i]))
+AS_CASE([$[1]]m4_for([i], [1], ]limit[, [], [, i, echo i]), [echo default])
+]])
+
+dnl Add --force so autom4te doesn't think `script' is still up to date.
+AT_CHECK_M4SH([--force])
+AT_CHECK([$CONFIG_SHELL ./script 1], [0], [[1
+1
+1
+1
+]])
+AT_CHECK([$CONFIG_SHELL ./script limit], [0], [limit
+limit
+limit
+limit
+])
+AT_CHECK([$CONFIG_SHELL ./script default], [0], [[default
+default
+]])
+m4_popdef([limit])
+
+AT_CLEANUP
+
+
+## -------- ##
+## AS_FOR. ##
+## -------- ##
+
+AT_SETUP([AS@&t@_FOR])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+
+# Simple checks.
+AS_FOR([m4var], [shvar], [a],
+[echo "m4var $shvar"])
+AS_FOR([m4var], [shvar], [b c],
+[echo "m4var $shvar"])
+list='d e'
+AS_FOR([m4var], [shvar], [$list],
+[echo "m4var $shvar"])
+AS_FOR([m4var], [shvar], ["$list"],
+[echo "m4var $shvar"])
+AS_FOR([m4var], [shvar], ['$list'],
+[echo "m4var $shvar"])
+AS_FOR([m4var], [shvar], [\'],
+[echo "m4var $shvar"])
+
+# Syntax checks: cope with empty/blank arguments.
+set f g
+AS_FOR([], [shvar], [],
+[echo "m4_defn([]) $shvar"])
+rm -f file
+AS_FOR([], [shvar], [`touch file`])
+test -f file || exit 1
+AS_FOR([], [shvar], [], [ ])
+m4_define([empty])AS_FOR([], [shvar], [], [empty])
+
+# Check that break works.
+while :
+do
+ AS_FOR([m4var], [shvar], [h i],
+ [echo "m4var"; break 2])
+ exit 1
+done
+while :
+do
+ AS_FOR([m4var], [shvar], [j],
+ [echo "m4var"; break 2])
+ exit 1
+done
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [0], [[a a
+b b
+c c
+d d
+e e
+d e d e
+$list $list
+' '
+f f
+g g
+h
+j
+]])
+
+AT_CLEANUP
+
+
+## --------------- ##
+## AS_LITERAL_IF. ##
+## --------------- ##
+
+AT_SETUP([AS@&t@_LITERAL_IF])
+AT_KEYWORDS([m4sh AS@&t@_LITERAL_WORD_IF AS@&t@_LITERAL_HEREDOC_IF])
+
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+echo AS_LITERAL_IF([lit], [ok], [ERR]) 1
+echo AS_LITERAL_IF([l-/.it], [ok], [ERR]) 2
+echo AS_LITERAL_IF([l''it], [ERR], [ok]) 3
+echo AS_LITERAL_IF([l$it], [ERR], [ok]) 4
+echo AS_LITERAL_IF([l$it], [ERR1], [ERR2], [ok]) 5
+echo AS_LITERAL_IF([l${it}], [ERR1], [ERR2], [ok]) 6
+echo AS_LITERAL_IF([l`case a in b) ;; esac`it], [ERR], [ok]) 7
+echo AS_LITERAL_IF([l`case a in b) ;; esac`it], [ERR1], [ok], [ERR2]) 8
+m4_define([mac], [l-/.it])
+echo AS_LITERAL_IF([mac], [ok], [ERR]) 9
+echo AS_LITERAL_IF([mac($, ``)], [ok], [ERR]) 10
+m4_define([mac], [l$it])
+echo AS_LITERAL_IF([mac], [ERR], [ok]) 11
+echo AS_LITERAL_IF([mac], [ERR1], [ERR2], [ok]) 12
+m4_define([mac], [l``it])
+echo AS_LITERAL_IF([mac], [ERR], [ok]) 13
+echo AS_LITERAL_IF([mac], [ERR1], [ok], [ERR2]) 14
+echo AS_LITERAL_IF([ a ][
+b], [ok], [ERR]) 15
+echo AS_LITERAL_WORD_IF([ a ][
+b], [ERR], [ok]) 16
+echo AS_LITERAL_HEREDOC_IF([ a ][
+b], [ok], [ERR]) 17
+echo AS_LITERAL_IF([(a)], [ERR], [ok]) 18
+echo AS_LITERAL_WORD_IF([(a)], [ERR], [ok]) 19
+echo AS_LITERAL_HEREDOC_IF([(a)], [ok], [ERR]) 20
+echo AS_LITERAL_IF([@S|@a], [ERR], [ok]) 21
+echo AS_LITERAL_WORD_IF([@S|@a], [ERR], [ok]) 22
+echo AS_LITERAL_HEREDOC_IF([@S|@a], [ERR], [ok]) 23
+echo AS_LITERAL_IF([${a+b}], [ERR1], [ok], [ERR2]) 24
+echo AS_LITERAL_IF([${a=b}], [ERR1], [ok], [ERR2]) 25
+echo AS_LITERAL_IF([a+b], [ok], [ERR1], [ERR2]) 26
+echo AS_LITERAL_IF([a=b], [ok], [ERR1], [ERR2]) 27
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [],
+[[ok 1
+ok 2
+ok 3
+ok 4
+ok 5
+ok 6
+ok 7
+ok 8
+ok 9
+ok 10
+ok 11
+ok 12
+ok 13
+ok 14
+ok 15
+ok 16
+ok 17
+ok 18
+ok 19
+ok 20
+ok 21
+ok 22
+ok 23
+ok 24
+ok 25
+ok 26
+ok 27
+]])
+
+AT_CLEANUP
+
+
+## --------------------- ##
+## AS_TR_SH, AS_TR_CPP. ##
+## --------------------- ##
+
+AT_SETUP([AS@&t@_TR_SH and AS@&t@_TR_CPP])
+
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+m4_define([abc], [hI])m4_define([ABC], [Hi])
+m4_define([hi], [oops])m4_define([HI], [OOPS])
+echo AS_TR_SH(abc) AS_TR_SH(aBc) AS_TR_SH(ABC)
+echo AS_TR_SH([abc]) AS_TR_SH([aBc]) AS_TR_SH([ABC])
+echo AS_TR_SH([[abc]]) AS_TR_SH([[aBc]]) AS_TR_SH([[ABC]])
+echo AS_TR_CPP(abc) AS_TR_CPP(aBc) AS_TR_CPP(ABC)
+echo AS_TR_CPP([abc]) AS_TR_CPP([aBc]) AS_TR_CPP([ABC])
+echo AS_TR_CPP([[abc]]) AS_TR_CPP([[aBc]]) AS_TR_CPP([[ABC]])
+echo ===
+[var=abc vAr=aBc VAR=ABC]
+echo AS_TR_SH($var) AS_TR_SH($vAr) AS_TR_SH($VAR)
+echo AS_TR_SH([$var]) AS_TR_SH([$vAr]) AS_TR_SH([$VAR])
+echo AS_TR_SH([[$var]]) AS_TR_SH([[$vAr]]) AS_TR_SH([[$VAR]])
+echo AS_TR_CPP($var) AS_TR_CPP($vAr) AS_TR_CPP($VAR)
+echo AS_TR_CPP([$var]) AS_TR_CPP([$vAr]) AS_TR_CPP([$VAR])
+echo AS_TR_CPP([[$var]]) AS_TR_CPP([[$vAr]]) AS_TR_CPP([[$VAR]])
+echo ===
+echo AS_TR_SH(`echo abc`) AS_TR_SH(`echo aBc`) AS_TR_SH(`echo ABC`)
+echo AS_TR_SH([`echo abc`]) AS_TR_SH([`echo aBc`]) AS_TR_SH([`echo ABC`])
+echo AS_TR_SH([[`echo abc`]]) AS_TR_SH([[`echo aBc`]]) AS_TR_SH([[`echo ABC`]])
+echo AS_TR_CPP(`echo abc`) AS_TR_CPP(`echo aBc`) AS_TR_CPP(`echo ABC`)
+echo AS_TR_CPP([`echo abc`]) AS_TR_CPP([`echo aBc`]) AS_TR_CPP([`echo ABC`])
+echo AS_TR_CPP([[`echo abc`]]) AS_TR_CPP([[`echo aBc`]]) AS_TR_CPP([[`echo ABC`]])
+echo ===
+# start here
+echo AS_TR_SH([a.b/c+*-=])
+echo AS_TR_CPP([a.b/c+*-=])
+var=a.b/c+*-=
+echo AS_TR_SH([$var])
+echo AS_TR_CPP([$var])
+m4_define([macro], [a.b/c+*-=])
+echo AS_TR_SH([macro])
+echo AS_TR_CPP([macro])
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [],
+[[hI aBc Hi
+hI aBc Hi
+abc aBc ABC
+HI ABC HI
+HI ABC HI
+ABC ABC ABC
+===
+abc aBc ABC
+abc aBc ABC
+abc aBc ABC
+ABC ABC ABC
+ABC ABC ABC
+ABC ABC ABC
+===
+hI aBc Hi
+hI aBc Hi
+abc aBc ABC
+HI ABC HI
+HI ABC HI
+ABC ABC ABC
+===
+a_b_cpp__
+A_B_C_P__
+a_b_cpp__
+A_B_C_P__
+a_b_cpp__
+A_B_C_P__
+]])
+
+dnl Check that of the last 6 macros, only 2 needed command substitution.
+dnl This test abuses our knowledge of m4sh internals a bit; oh well.
+AT_CHECK([tab=' ' # a single ASCII tab character
+sed -n '/start here/,$ {
+/`.*`/p
+}' script | wc -l | sed "s/[[ $tab]]//g" ], [], [[2
+]])
+
+AT_CLEANUP
+
+
+## ---------- ##
+## AS_VAR_*. ##
+## ---------- ##
+
+AT_SETUP([AS@&t@_VAR basics])
+AT_KEYWORDS([m4sh AS@&t@_VAR_COPY AS@&t@_VAR_SET AS@&t@_VAR_GET])
+AT_KEYWORDS([AS@&t@_VAR_TEST_SET AS@&t@_VAR_SET_IF AS@&t@_VAR_IF])
+AT_KEYWORDS([AS@&t@_VAR_PUSHDEF AS@&t@_VAR_POPDEF])
+
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+ m4_define([with], [WITH])
+# Literals.
+dnl AS_VAR_SET_IF also covers AS_VAR_TEST_SET
+AS_VAR_SET_IF([foo], [echo oops]) && echo ok
+AS_VAR_IF([foo], [], [echo ok], [echo oops])
+foo=
+AS_VAR_SET_IF([foo], [echo ok])
+AS_VAR_SET([foo], ['\a "weird" `value` with; $fun '\''characters
+']) # 'font-lock
+AS_VAR_COPY([bar], [foo])
+AS_ECHO(["$bar-"])
+AS_ECHO(["AS_VAR_GET([foo])-"])
+AS_VAR_SET_IF([foo], [echo ok], [echo oops])
+AS_VAR_IF([foo], [string], [echo oops]) && echo ok
+AS_VAR_PUSHDEF([tmp], [foo])
+AS_VAR_IF([tmp], ['\a "weird" `value` with; $fun '\''characters
+'], [echo ok], [echo oops]) # 'font-lock
+AS_VAR_POPDEF([tmp])
+m4_ifdef([tmp], [echo oops])
+
+# Indirects via shell vars.
+echo '===='
+num=1
+AS_VAR_SET_IF([foo$num], [echo oops]) && echo ok
+AS_VAR_IF([foo$num], [], [echo ok], [echo oops])
+foo1=
+AS_VAR_SET_IF([foo$num], [echo ok])
+AS_VAR_SET([foo$num], ['\a "weird" `value` with; $fun '\''characters
+']) # 'font-lock
+AS_VAR_COPY([bar], [foo$num])
+num=2
+AS_VAR_COPY([foo$num], [bar])
+AS_ECHO(["$foo2-"])
+AS_ECHO(["AS_VAR_GET([foo$num])-"])
+AS_VAR_SET_IF([foo$num], [echo ok], [echo oops])
+AS_VAR_IF([foo$num], [string], [echo oops]) && echo ok
+AS_VAR_PUSHDEF([tmp], [foo$num])
+AS_VAR_IF([tmp], ['\a "weird" `value` with; $fun '\''characters
+'], [echo ok], [echo oops]) # 'font-lock
+AS_VAR_POPDEF([tmp])
+m4_ifdef([tmp], [echo oops])
+
+# Indirects via command substitution.
+echo '===='
+AS_VAR_SET_IF([`echo foo3`], [echo oops]) && echo ok
+AS_VAR_IF([`echo foo3`], [], [echo ok], [echo oops])
+foo3=
+AS_VAR_SET_IF([`echo foo3`], [echo ok])
+AS_VAR_SET([`echo foo3`], ['\a "weird" `value` with; $fun '\''characters
+']) # 'font-lock
+AS_VAR_COPY([bar], [`echo foo3`])
+num=2
+AS_VAR_COPY([`echo foo4`], [bar])
+AS_ECHO(["$foo4-"])
+AS_ECHO(["AS_VAR_GET([`echo foo4`])-"])
+AS_VAR_SET_IF([`echo foo4`], [echo ok], [echo oops])
+AS_VAR_IF([`echo foo4`], [string], [echo oops]) && echo ok
+AS_VAR_PUSHDEF([tmp], [`echo foo4`])
+AS_VAR_IF([tmp], ['\a "weird" `value` with; $fun '\''characters
+'], [echo ok], [echo oops]) # 'font-lock
+AS_VAR_POPDEF([tmp])
+m4_ifdef([tmp], [echo oops])
+:
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [], [[ok
+ok
+ok
+\a "weird" `value` WITH; $fun 'characters
+-
+\a "weird" `value` WITH; $fun 'characters
+-
+ok
+ok
+ok
+====
+ok
+ok
+ok
+\a "weird" `value` WITH; $fun 'characters
+-
+\a "weird" `value` WITH; $fun 'characters-
+ok
+ok
+ok
+====
+ok
+ok
+ok
+\a "weird" `value` WITH; $fun 'characters
+-
+\a "weird" `value` WITH; $fun 'characters-
+ok
+ok
+ok
+]])
+
+AT_CLEANUP
+
+
+## --------------- ##
+## AS_VAR_APPEND. ##
+## --------------- ##
+
+AT_SETUP([AS@&t@_VAR_APPEND])
+AT_KEYWORDS([m4sh AS@&t@_VAR])
+
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+# Literals.
+AS_VAR_APPEND([foo], ["hello, "])
+AS_VAR_APPEND([foo], [world])
+echo "$foo"
+# Indirects via shell vars.
+num=1
+AS_VAR_APPEND([foo$num], ['hello, '])
+AS_VAR_APPEND([foo$num], [`echo "world"`])
+echo "$foo1"
+# Indirects via command substitution.
+h=hello w=', world'
+AS_VAR_APPEND([`echo foo2`], [${h}])
+AS_VAR_APPEND([`echo foo2`], ["$w"])
+echo "$foo2"
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [],
+[[hello, world
+hello, world
+hello, world
+]])
+
+AT_CLEANUP
+
+
+## -------------- ##
+## AS_VAR_ARITH. ##
+## -------------- ##
+
+AT_SETUP([AS@&t@_VAR_ARITH])
+AT_KEYWORDS([m4sh AS@&t@_VAR])
+
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+# Literals.
+AS_VAR_ARITH([foo], [1 + 1])
+echo "$foo"
+# Indirects via shell vars.
+num=1
+AS_VAR_ARITH([foo$num], [\( 2 + 3 \) \* 4])
+echo "$foo1"
+# Indirects via command substitution.
+AS_VAR_ARITH([`echo foo2`], [0 + -2 + $foo1 / 2])
+echo "$foo2"
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [],
+[[2
+20
+8
+]])
+
+AT_CLEANUP
+
+
+## ----------------- ##
+## AS_INIT cleanup. ##
+## ----------------- ##
+
+AT_SETUP([AS@&t@_INIT cleanup])
+AT_KEYWORDS([m4sh m4@&t@_wrap m4@&t@_wrap_lifo])
+
+AT_DATA_M4SH([script.as], [[dnl
+dnl Registered before AS_INIT's cleanups
+m4_wrap([echo cleanup 1
+])
+m4_pushdef([_AS_SHELL_FN_SPY])dnl neutralize the spy, we don't care about it
+AS_INIT
+dnl Registered after AS_INIT's cleanups, thus goes to KILL diversion
+m4_wrap([echo cleanup 2
+dnl However, nested wraps and diversions can still be used
+dnl Also, test wrapping text that looks like parameter reference
+m4_wrap([echo cleanup 3
+m4_divert_text([M4SH-INIT], [m4_define([foo], [$1])dnl
+echo prep foo([4])
+])])])
+dnl Registered before AS_INIT's cleanups
+m4_wrap_lifo([echo cleanup 5
+])
+echo body
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [], [[prep 4
+body
+cleanup 5
+cleanup 1
+]])
+
+AT_CLEANUP
+
+
+## ------------------- ##
+## AS_INIT_GENERATED. ##
+## ------------------- ##
+
+AT_SETUP([AS@&t@_INIT_GENERATED])
+AT_KEYWORDS([AS@&t@_MESSAGE AS@&t@_MESSAGE_LOG_FD])
+
+dnl First run, no logging, tests shell selection
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+AS_INIT_GENERATED([child], [echo hello from child])
+cat >>child <<\EOF
+AS_ECHO(["SHELL=$SHELL"])
+EOF
+echo hello from parent
+AS_ECHO(["SHELL=$SHELL"])
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [0], [stdout])
+AT_CHECK([grep 'SHELL=.' stdout], [0], [ignore])
+sed s/parent/child/ <stdout >expout
+AT_CHECK([./child], [0], [expout])
+SHELL=/bogus
+export SHELL
+cp stdout expout
+mv child child.bak
+AT_CHECK([$CONFIG_SHELL ./script], [0], [expout])
+AT_CHECK([cmp child child.bak])
+AT_CHECK([grep 'SHELL=.' stdout], [0], [ignore])
+sed s/parent/child/ <stdout >expout
+AT_CHECK([./child], [0], [expout])
+
+
+dnl Second run, with logging from parent and child, tests fd handling
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+child=${1-child}
+m4_define([AS_MESSAGE_LOG_FD], [5])
+exec AS_MESSAGE_LOG_FD>log
+AS_INIT_GENERATED([$child], [echo hello1 from $child]) || AS_EXIT([1])
+cat >>$child <<\EOF
+m4_pushdef([AS_MESSAGE_LOG_FD])
+AS_MESSAGE([hello2 from ${child}child])
+m4_popdef([AS_MESSAGE_LOG_FD])
+exec AS_MESSAGE_LOG_FD>>log
+AS_MESSAGE([hello3 from child])
+EOF
+AS_MESSAGE([hello from parent])
+dnl close log in parent before spawning child, for mingw
+exec AS_MESSAGE_LOG_FD>&-
+./$child
+]])
+
+rm -f script
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [0], [[script: hello from parent
+hello1 from child
+child: hello2 from child
+child: hello3 from child
+]])
+AT_CHECK([[sed 's,:[0-9][0-9]*:,:0:,' log]], [0],
+[[script:0: hello from parent
+child:0: hello3 from child
+]])
+
+# Force write error creating a file on stdout
+if test -w /dev/full && test -c /dev/full; then
+ AT_CHECK([$CONFIG_SHELL ./script /dev/full], [1], [ignore], [ignore])
+fi
+
+AT_CLEANUP
+
+
+## --------------- ##
+## AS_MESSAGE_FD. ##
+## --------------- ##
+
+AT_SETUP([AS@&t@_MESSAGE_FD])
+AT_KEYWORDS([AS@&t@_MESSAGE AS@&t@_MESSAGE_LOG_FD AS@&t_ORIGINAL_STDIN_FD])
+AT_KEYWORDS([AS@&t@_LINENO_PUSH])
+
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+m4_define([AS_ORIGINAL_STDIN_FD], [5])
+m4_define([AS_MESSAGE_LOG_FD], [6])
+m4_define([AS_MESSAGE_FD], [7])
+exec AS_ORIGINAL_STDIN_FD<&0 </dev/null AS_MESSAGE_LOG_FD>log
+if test $[#] -gt 0; then
+ exec AS_MESSAGE_FD>/dev/null
+else
+ exec AS_MESSAGE_FD>&1
+fi
+AS_LINENO_PUSH([100])
+cat # tests that stdin is neutralized
+AS_MESSAGE([hello world])
+cat <&AS_ORIGINAL_STDIN_FD
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([echo goodbye | $CONFIG_SHELL ./script], [0],
+[[script: hello world
+goodbye
+]])
+AT_CHECK([cat log], [0],
+[[script:100: hello world
+]])
+rm log
+AT_CHECK([echo goodbye | $CONFIG_SHELL ./script silent], [0],
+[[goodbye
+]])
+AT_CHECK([cat log], [0],
+[[script:100: hello world
+]])
+
+AT_CLEANUP
+
+
+## --------------- ##
+## _AS_CLEAN_DIR. ##
+## --------------- ##
+
+AT_SETUP([_AS@&t@_CLEAN_DIR])
+
+dnl ensure that we can erase all files in a directory. Note that
+dnl _AS_CLEAN_DIR needs three globs to catch all these files.
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+# Unwritable subdirectories are common during 'make distcheck'.
+mkdir sub sub/unwritable || AS_ERROR([failed to mkdir])
+touch sub/unwritable/file || AS_ERROR([failed to touch])
+chmod a-wx sub/unwritable || AS_ERROR([failed to chmod])
+# Cygwin 1.5 can't touch 'sub/...', so make that file optional.
+touch sub/a sub/aa sub/aaa sub/.a sub/..a sub/.aa \
+ || AS_ERROR([failed to touch])
+touch sub/... 2>/dev/null
+_AS_CLEAN_DIR([sub]) || AS_ERROR([failed to clean])
+# rmdir instead of 'rm -fr' here proves that we emptied sub.
+rmdir sub || AS_ERROR([failed to rmdir])
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script])
+
+AT_CLEANUP
+
+
+## -------- ##
+## ECHO_C. ##
+## -------- ##
+
+AT_SETUP([ECHO_C])
+
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+_AS_PREPARE
+foo=`echo foobar`
+echo "$foo"
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [], [foobar
+])
+
+AT_CLEANUP
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
new file mode 100644
index 0000000..997e2dd
--- /dev/null
+++ b/tests/m4sugar.at
@@ -0,0 +1,2140 @@
+# -*- Autotest -*-
+
+AT_BANNER([M4sugar.])
+
+# Copyright (C) 2000-2002, 2005-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+# AT_CHECK_M4SUGAR_TEXT(CODE, STDOUT, STDERR)
+# -------------------------------------------
+# Check that m4sugar CODE expands to STDOUT and emits STDERR.
+m4_define([AT_CHECK_M4SUGAR_TEXT],
+[
+AT_DATA_M4SUGAR([script.4s],
+[[m4_init
+m4_divert_push([])[]dnl
+]$1[[]dnl
+m4_divert_pop([])
+]])
+
+AT_CHECK_M4SUGAR([-o-],, [$2], [$3])
+])# AT_CHECK_M4SUGAR_TEXT
+
+
+## ------------------ ##
+## m4_stack_foreach. ##
+## ------------------ ##
+
+AT_SETUP([m4@&t@_stack])
+
+AT_KEYWORDS([m4@&t@_stack_foreach m4@&t@_stack_foreach_lifo])
+AT_KEYWORDS([m4@&t@_stack_foreach_sep m4@&t@_stack_foreach_sep_lifo])
+AT_KEYWORDS([m4@&t@_copy m4@&t@_n])
+
+# Test the semantics of macros to walk stacked macro definitions.
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_pushdef([abc], [def])dnl
+m4_pushdef([abc], [ghi])dnl
+m4_pushdef([abc], [jkl])dnl
+m4_stack_foreach([abc], [m4_n])
+abc
+m4_stack_foreach_lifo([abc], [m4_n])
+m4_stack_foreach([abc], [m4_n])
+m4_copy([abc], [foo])dnl
+m4_stack_foreach([foo], [m4_n])
+m4_stack_foreach_lifo([foo], [m4_n])
+m4_stack_foreach_sep([abc], [ m4_index([abcdefghijkl],], [)])
+m4_define([colon], [:])m4_define([lt], [<])m4_define([gt], [>])dnl
+m4_stack_foreach_sep_lifo([abc], [lt], [gt], [colon])
+m4_pushdef([xyz], [123])dnl
+m4_pushdef([xyz], [456])dnl
+m4_define([doit], [[$1](m4_stack_foreach_sep([xyz], [m4_dquote(], [)], [,]))
+])dnl
+m4_stack_foreach([abc], [doit])]],
+[[def
+ghi
+jkl
+
+jkl
+jkl
+ghi
+def
+
+def
+ghi
+jkl
+
+def
+ghi
+jkl
+
+jkl
+ghi
+def
+
+ 3 6 9
+<jkl>:<ghi>:<def>
+def([123],[456])
+ghi([123],[456])
+jkl([123],[456])
+]])
+
+AT_CLEANUP
+
+
+## --------- ##
+## m4_defn. ##
+## --------- ##
+
+AT_SETUP([m4@&t@_defn])
+
+AT_KEYWORDS([m4@&t@_popdef m4@&t@_undefine m4@&t@_copy m4@&t@_rename
+m4@&t@_copy_force m4@&t@_rename_force])
+
+# Ensure that m4sugar dies when dereferencing undefined macros, whether
+# this is provided by m4 natively or faked by wrappers in m4sugar.
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_define([good])
+m4_defn([good], [oops])
+]])
+
+AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep good stderr], [1])
+AT_CHECK([grep 'm4@&t@_defn: undefined.*oops' stderr], [0], [ignore])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_define([good])
+m4_popdef([good], [oops])
+]])
+
+AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep good stderr], [1])
+AT_CHECK([grep 'm4@&t@_popdef: undefined.*oops' stderr], [0], [ignore])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_define([good])
+m4_undefine([good], [oops])
+]])
+
+AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep good stderr], [1])
+AT_CHECK([grep 'm4@&t@_undefine: undefined.*oops' stderr], [0], [ignore])
+
+# Cannot rename an undefined macro.
+AT_DATA_M4SUGAR([script.4s],
+[[m4_rename([oops], [good])
+]])
+
+AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep 'm4@&t@_undefine: undefined.*oops' stderr], [0], [ignore])
+
+# Check that pushdef stacks can be renamed.
+AT_CHECK_M4SUGAR_TEXT([[m4_pushdef([a], [1])dnl
+m4_pushdef([a], [2])dnl
+m4_pushdef([a], m4_defn([m4_divnum]))dnl
+a b c
+m4_rename([a], [b])dnl
+a b c
+m4_copy([b], [c])dnl
+a b c
+m4_popdef([b], [c])dnl
+a b c
+m4_popdef([b], [c])dnl
+a b c
+m4_popdef([b], [c])dnl
+a b c
+dnl m4_copy is intentionally a no-op on undefined source
+m4_copy([oops], [dummy])m4_ifdef([dummy], [[oops]])dnl
+dnl allow forceful overwrites
+m4_define([d], [4])m4_define([e], [5])m4_define([f], [6])dnl
+m4_copy_force([d], [e])dnl
+m4_rename_force([d], [f])dnl
+d e f
+m4_popdef([e], [f])dnl
+d e f
+]], [[0 b c
+a 0 c
+a 0 0
+a 2 2
+a 1 1
+a b c
+d 4 4
+d e f
+]])
+
+AT_CLEANUP
+
+
+## ------------ ##
+## m4_dumpdef. ##
+## ------------ ##
+
+AT_SETUP([m4@&t@_dumpdef])
+
+AT_KEYWORDS([m4@&t@_dumpdefs])
+
+# Ensure that m4sugar dies when dereferencing undefined macros.
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_define([good], [yep])
+m4_dumpdef([good], [oops])
+]])
+
+AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep '^good: \[[yep\]]$' stderr], [0], [ignore])
+AT_CHECK([grep 'm4@&t@_dumpdef: undefined.*oops' stderr], [0], [ignore])
+
+# Check that pushdef stacks can be dumped.
+AT_CHECK_M4SUGAR_TEXT([[m4_divert_push([KILL])
+m4_pushdef([a], [1])
+m4_pushdef([a], [2])
+m4_dumpdef([a])
+m4_dumpdefs([oops], [a])
+m4_divert_pop([KILL])dnl
+]], [],
+[[a: [2]
+a: [2]
+a: [1]
+]])
+
+# Check behavior when dumping builtins. Unfortunately, when using M4 1.4.x
+# (or more precisely, when __m4_version__ is undefined), builtins get
+# flattened to an empty string. It takes M4 1.6 to work around this.
+AT_DATA_M4SUGAR([script.4s],
+[[m4_ifdef([__m4_version__], [_m4_undefine([__m4_version__])])
+m4_init
+m4_dumpdef([m4_define])
+]])
+
+AT_CHECK_M4SUGAR([-o-], [0], [],
+[[m4_define: []
+]])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_init
+m4_ifdef([__m4_version__],
+[m4_dumpdef([m4_define])],
+[m4_errprintn([m4_define: <define>])])
+]])
+
+AT_CHECK_M4SUGAR([-o-], [0], [],
+[[m4_define: <define>
+]])
+
+AT_CLEANUP
+
+
+## --------- ##
+## m4_warn. ##
+## --------- ##
+
+AT_SETUP([m4@&t@_warn])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_init
+m4_defun([cross_warning], [m4_warn([cross], [cross])])
+
+m4_divert([0])dnl
+m4_warn([obsolete], [obsolete])dnl
+cross_warning[]dnl
+m4_warn([syntax], [syntax])dnl
+cross_warning[]dnl
+m4_warn([syntax], [syntax])dnl
+]])
+
+AT_CHECK_M4SUGAR([-o-], 0, [],
+[script.4s:4: warning: prefer named diversions
+script.4s:7: warning: syntax
+script.4s:9: warning: syntax
+])
+
+AT_CHECK_M4SUGAR([-o- -Wall], 0, [],
+[script.4s:4: warning: prefer named diversions
+script.4s:5: warning: obsolete
+script.4s:6: warning: cross
+script.4s:2: cross_warning is expanded from...
+script.4s:6: the top level
+script.4s:7: warning: syntax
+script.4s:8: warning: cross
+script.4s:2: cross_warning is expanded from...
+script.4s:8: the top level
+script.4s:9: warning: syntax
+])
+
+AT_CHECK_M4SUGAR([-o- -Wnone,cross], 0, [],
+[script.4s:6: warning: cross
+script.4s:2: cross_warning is expanded from...
+script.4s:6: the top level
+script.4s:8: warning: cross
+script.4s:2: cross_warning is expanded from...
+script.4s:8: the top level
+])
+
+AT_CHECK_M4SUGAR([-o- -Wnone,cross,error], 1, [],
+[[script.4s:6: warning: cross
+script.4s:2: cross_warning is expanded from...
+script.4s:6: the top level
+script.4s:8: warning: cross
+script.4s:2: cross_warning is expanded from...
+script.4s:8: the top level
+]])
+
+AT_CLEANUP
+
+
+## ----------------- ##
+## m4_divert_stack. ##
+## ----------------- ##
+
+AT_SETUP([m4@&t@_divert_stack])
+AT_KEYWORDS([m4@&t@_divert m4@&t@_divert_push m4@&t@_divert_pop
+m4@&t@_undivert m4@&t@_cleardivert m4@&t@_divert_text])
+
+dnl This test names some diversions to avoid a warning.
+AT_CHECK_M4SUGAR_TEXT([[m4_define([_m4_divert(ten)], [10])dnl
+m4_define([_m4_divert(twenty)], [20])dnl
+m4_define([_m4_divert(thirty)], [30])dnl
+1.m4_divert_stack
+m4_divert_push([ten])2.m4_divert_stack
+m4_divert_text([twenty], [3.m4_divert_stack])dnl
+m4_divert([thirty])4.m4_divert_stack
+m4_divert_pop([thirty])dnl
+5.m4_undivert([twenty], [thirty])
+m4_pattern_allow([^m4_divert])dnl
+]], [[1.script.4s:2: m4@&t@_divert_push:
+script.4s:1: m4@&t@_divert: KILL
+5.3.script.4s:8: m4@&t@_divert_push: twenty
+script.4s:7: m4@&t@_divert_push: ten
+script.4s:2: m4@&t@_divert_push:
+script.4s:1: m4@&t@_divert: KILL
+4.script.4s:9: m4@&t@_divert: thirty
+script.4s:2: m4@&t@_divert_push:
+script.4s:1: m4@&t@_divert: KILL
+
+2.script.4s:7: m4@&t@_divert_push: ten
+script.4s:2: m4@&t@_divert_push:
+script.4s:1: m4@&t@_divert: KILL
+]])
+
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_divert_text([3], [three])dnl
+m4_divert_text([4], [four])dnl
+m4_divert_text([1], [one])dnl
+m4_divert_text([2], [two])dnl
+m4_cleardivert([2], [3])dnl
+]],
+[[one
+four
+]],
+[[script.4s:4: warning: prefer named diversions
+script.4s:5: warning: prefer named diversions
+script.4s:6: warning: prefer named diversions
+script.4s:7: warning: prefer named diversions
+script.4s:8: warning: prefer named diversions
+]])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_divert_pop
+]])
+AT_CHECK_M4SUGAR([-o-], [1], [],
+[[script.4s:1: error: too many m4@&t@_divert_pop
+script.4s:1: the top level
+autom4te: m4 failed with exit status: 1
+]])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_init
+m4_divert_push([1])
+m4_divert_pop([2])
+]])
+AT_CHECK_M4SUGAR([-o-], [1], [],
+[[script.4s:3: error: m4@&t@_divert_pop(2): diversion mismatch:
+script.4s:2: m4@&t@_divert_push: 1
+script.4s:1: m4@&t@_divert: KILL
+script.4s:3: the top level
+autom4te: m4 failed with exit status: 1
+]])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_divert([1])
+m4_init
+m4_divert_push([2])
+]])
+AT_CHECK_M4SUGAR([-o-], [1], [],
+[[script.4s:2: error: m4@&t@_init: unbalanced m4@&t@_divert_push:
+script.4s:3: m4@&t@_divert_push: 2
+script.4s:2: m4@&t@_divert: KILL
+script.4s:2: the top level
+autom4te: m4 failed with exit status: 1
+]])
+
+AT_CLEANUP
+
+
+## -------------------- ##
+## m4_expansion_stack. ##
+## -------------------- ##
+
+AT_SETUP([m4@&t@_expansion_stack])
+
+AT_CHECK_M4SUGAR_TEXT([[1.m4_expansion_stack
+m4_defun([a], [b])dnl
+m4_define([c], [d])dnl
+m4_defun([d], [2.m4_expansion_stack])dnl
+m4_defun([b], [c])dnl
+a
+3.m4_ifdef([_m4_expansion_stack], [m4_expansion_stack])
+]], [[1.script.4s:3: the top level
+2.script.4s:6: d is expanded from...
+script.4s:7: b is expanded from...
+script.4s:4: a is expanded from...
+script.4s:8: the top level
+3.
+]])
+
+AT_CLEANUP
+
+
+## --------------------------- ##
+## m4_require: error message. ##
+## --------------------------- ##
+
+AT_SETUP([m4@&t@_require: error message])
+AT_KEYWORDS([m4@&t@_require])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_defun([foo], [FOO])
+m4_require([foo])
+]])
+
+AT_CHECK_M4SUGAR([], 1, [],
+[[script.4s:2: error: m4@&t@_require(foo): cannot be used outside of an m4_defun'd macro
+script.4s:2: the top level
+autom4te: m4 failed with exit status: 1
+]])
+AT_CLEANUP
+
+
+## ----------------------------------- ##
+## m4_require: circular dependencies. ##
+## ----------------------------------- ##
+
+AT_SETUP([m4@&t@_require: circular dependencies])
+AT_KEYWORDS([m4@&t@_require])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_defun([foo], [m4_require([bar])])
+
+m4_defun([bar], [m4_require([foo])])
+
+m4_defun([baz], [m4_require([foo])])
+
+m4_init
+m4_divert([0])dnl
+baz
+]])
+
+AT_CHECK_M4SUGAR([], 1, [],
+[[script.4s:9: error: m4@&t@_require: circular dependency of foo
+script.4s:3: bar is expanded from...
+script.4s:1: foo is expanded from...
+script.4s:5: baz is expanded from...
+script.4s:9: the top level
+autom4te: m4 failed with exit status: 1
+]])
+AT_CLEANUP
+
+
+## ---------------------- ##
+## m4_require: one-shot. ##
+## ---------------------- ##
+
+AT_SETUP([m4@&t@_require: one-shot initialization])
+AT_KEYWORDS([m4@&t@_require])
+AT_KEYWORDS([m4@&t@_defun_init m4@&t@_copy m4@&t@_defun_once])
+
+dnl check out m4_defun_init, m4_copy, and odd macro names
+AT_CHECK_M4SUGAR_TEXT([[
+m4_define([t], [text])dnl
+m4_defun_init([a], [[init a
+]], [[common a] t])dnl
+m4_defun([b], [[b]m4_require([a])])dnl
+m4_defun([c], [[c]m4_require([a])])dnl
+b
+c
+a()dnl
+
+m4_defun_init([-], [hello, ], [m4_if([$#], [0], [world], [[$1]])])dnl
+m4_copy([-], [.])dnl
+m4_indir([.])
+m4_indir([.], [goodbye])
+m4_indir([-], [again])
+]], [[
+init a
+common a text
+b
+c
+common a text
+hello, world
+goodbye
+hello, again
+]])
+
+dnl Check m4_defun_once behavior
+AT_CHECK_M4SUGAR_TEXT([[
+m4_defun_once([a], [[a]])dnl
+m4_defun([b], [[b]m4_require([a])])dnl
+m4_defun([c], [[c]a[]m4_require([b])])dnl
+c
+a
+m4_defun_once([d], [[d]m4_require([a])])dnl
+d
+m4_defun_once([e], [[e]])dnl
+m4_defun([f], [[f]m4_require([e])e])dnl
+f
+]], [[
+a
+b
+c
+
+d
+e
+f
+]])
+
+
+AT_CLEANUP
+
+
+## -------------------- ##
+## m4_require: nested. ##
+## -------------------- ##
+
+AT_SETUP([m4@&t@_require: nested])
+AT_KEYWORDS([m4@&t@_require m4@&t@_defun])
+
+dnl From the m4sugar.m4 discourse: Require chains, top level
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_defun([a], [[a]])dnl aka TEST2a
+m4_defun([b], [[b]m4_require([a])])dnl aka TEST3
+m4_defun([c], [[c]m4_require([b])])dnl aka TEST2b
+m4_defun([d], [[d]m4_require([a])m4_require([c])])dnl aka TEST1
+pre
+d
+d
+post
+]],
+[[pre
+a
+b
+c
+d
+d
+post
+]])
+
+dnl From the m4sugar.m4 discourse: Require chains, nested
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_defun([a], [[a]])dnl aka TEST2a
+m4_defun([b], [[b]m4_require([a])])dnl aka TEST3
+m4_defun([c], [[c]m4_require([b])])dnl aka TEST2b
+m4_defun([d], [[d]m4_require([a])m4_require([c])])dnl aka TEST1
+m4_defun([wrap],
+[pre
+d
+d
+post])dnl
+wrap
+]],
+[[a
+b
+c
+pre
+d
+d
+post
+]])
+
+dnl Direct invocation, nested requires, top level
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_defun([a], [[a]])dnl
+m4_defun([b], [[b]m4_require([a])])dnl
+m4_defun([c], [[c]m4_require([b])])dnl
+pre
+a
+c
+a
+c
+post
+]],
+[[pre
+a
+b
+c
+a
+c
+post
+]])
+
+dnl Direct invocation, nested requires, nested defun. This is an example
+dnl of expansion before requirement, such that b occurs before its
+dnl prerequisite a. This indicates a bug in the macros (but not in
+dnl autoconf), so we should be emitting a warning.
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_defun([a], [[a]])dnl
+m4_defun([b], [[b]m4_require([a])])dnl
+m4_defun([c], [[c]m4_require([b])])dnl
+dnl the extra macro layer works around line number differences in older m4
+m4_define([foo], [m4_defun([outer],
+[pre
+a
+c
+a
+c
+post])])foo[]dnl
+outer
+]],
+[[a
+b
+pre
+a
+c
+a
+c
+post
+]],
+[[script.4s:15: warning: m4@&t@_require: `a' was expanded before it was required
+script.4s:15: http://www.gnu.org/software/autoconf/manual/autoconf.html#Expanded-Before-Required
+script.4s:5: b is expanded from...
+script.4s:6: c is expanded from...
+script.4s:14: outer is expanded from...
+script.4s:15: the top level
+]])
+
+dnl Direct invocation, expand-before-require but no nested require. As this
+dnl is common in real life, but does not result in out-of-order expansion,
+dnl we silently permit this.
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_defun([a], [[a]])dnl
+m4_defun([b], [[b]m4_require([a])])dnl
+m4_defun([c], [[c]])dnl
+m4_defun([d], [[d]m4_require([c])])dnl
+pre1
+a
+b
+a
+b
+post1
+m4_defun([outer],
+[pre2
+c
+d
+c
+d
+post2])dnl
+outer
+m4_defun([e], [[e]])dnl
+m4_defun([f], [[f]m4_require([e])])dnl
+m4_defun([g], [[g]
+e
+f])dnl
+m4_defun([h], [[h]m4_require([g])])dnl
+h
+m4_defun([i], [[i]])dnl
+m4_defun([j], [[j]
+i])dnl
+m4_defun([k], [[k]m4_require([i])])dnl
+m4_defun([l], [[l]m4_require([k])])dnl
+m4_defun([m], [[m]m4_require([j])m4_require([l])])dnl
+m
+]],
+[[pre1
+a
+b
+a
+b
+post1
+pre2
+c
+d
+c
+d
+post2
+g
+e
+f
+h
+j
+i
+k
+l
+m
+]])
+
+AT_CLEANUP
+
+
+## ------------------------------------------------- ##
+## m4_ifval, m4_ifblank, m4_ifset, m4_default, etc. ##
+## ------------------------------------------------- ##
+
+AT_SETUP([m4sugar shorthand conditionals])
+AT_KEYWORDS([m4@&t@_ifval m4@&t@_ifblank m4@&t@_ifnblank m4@&t@_ifset
+m4@&t@_default m4@&t@_default_quoted m4@&t@_default_nblank
+m4@&t@_default_nblank_quoted])
+
+AT_CHECK_M4SUGAR_TEXT([[m4_define([active], [ACTIVE])m4_define([empty])
+m4_ifval([active], [yes], [no])
+m4_ifval([empty], [yes], [no])
+m4_ifval([ ], [yes], [no])
+m4_ifval([], [yes], [no])
+m4_ifblank([active], [yes], [no])
+m4_ifblank([empty], [yes], [no])
+m4_ifblank([ ], [yes], [no])
+m4_ifblank([], [yes], [no])
+m4_ifnblank([active], [yes], [no])
+m4_ifnblank([empty], [yes], [no])
+m4_ifnblank([ ], [yes], [no])
+m4_ifnblank([], [yes], [no])
+m4_ifset([active], [yes], [no])
+m4_ifset([empty], [yes], [no])
+m4_ifset([ ], [yes], [no])
+m4_ifset([], [yes], [no])
+---
+m4_define([demo1], [m4_default([$1], [$2])])dnl
+m4_define([demo2], [m4_default_quoted([$1], [$2])])dnl
+m4_define([demo3], [m4_default_nblank([$1], [$2])])dnl
+m4_define([demo4], [m4_default_nblank_quoted([$1], [$2])])dnl
+demo1([active], [default])
+demo1([], [active])
+demo1([empty], [text])
+-demo1([ ], [active])-
+demo2([active], [default])
+demo2([], [active])
+demo2([empty], [text])
+-demo2([ ], [active])-
+demo3([active], [default])
+demo3([], [active])
+demo3([empty], [text])
+-demo3([ ], [active])-
+demo4([active], [default])
+demo4([], [active])
+demo4([empty], [text])
+-demo4([ ], [active])-
+]], [[
+yes
+yes
+yes
+no
+no
+no
+yes
+yes
+yes
+yes
+no
+no
+yes
+no
+no
+no
+---
+ACTIVE
+ACTIVE
+
+- -
+active
+active
+empty
+- -
+ACTIVE
+ACTIVE
+
+-ACTIVE-
+active
+active
+empty
+-active-
+]])
+
+AT_CLEANUP
+
+## --------- ##
+## m4_cond. ##
+## --------- ##
+
+AT_SETUP([m4@&t@_cond])
+
+AT_CHECK_M4SUGAR_TEXT([[m4_define([side], [m4_errprintn([$1])$1])
+m4_cond([side(1)], [1], [a],
+ [side(1)], [1], [b],
+ [side(1)], [2], [c])
+m4_cond([side(2)], [1], [a],
+ [side(2)], [1], [b],
+ [side(2)], [2], [c],
+ [side(2)])
+m4_cond([side(3)], [1], [a],
+ [side(3)], [1], [b],
+ [side(3)], [2], [c],
+ [side(3)])
+m4_cond([a,a], [a,a], [yes], [no])
+m4_cond([[a,a]], [a,a], [yes])
+m4_cond([a,a], [a,b], [yes], [no])
+m4_cond([a,a], [a,b], [yes])
+m4_cond([m4_eval([0xa])])
+m4_define([ab], [AB])dnl
+m4_cond([a])b
+m4_cond([1], [1], [a])b
+m4_cond([1], [2], [3], [a])b
+]], [[
+a
+c
+3
+yes
+yes
+no
+
+10
+AB
+AB
+AB
+]], [[1
+2
+2
+2
+3
+3
+3
+3
+]])
+
+AT_CLEANUP
+
+
+## ---------- ##
+## m4 lists. ##
+## ---------- ##
+
+AT_SETUP([m4 lists])
+
+AT_KEYWORDS([m4@&t@_car m4@&t@_cdr m4@&t@_argn _m4@&t_cdr])
+
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_define([a], [A])m4_define([b], [B])m4_define([c], [C])
+m4_argn([1], [a], [b], [c])
+m4_argn([2], [a], [b], [c])
+m4_argn([3], [a], [b], [c])
+m4_argn([4], [a], [b], [c])
+m4_car([a], [b], [c])
+m4_cdr([a], [b], [c])
+m4_cdr([a], [b])
+m4_cdr([a])
+_m4_cdr([a], [b], [c])
+_m4_cdr([a], [b])
+_m4_cdr([a])
+m4_if(m4_cdr([], []), [[]], [good], [bad])
+m4_if(m4_cdr([]), [], [good], [bad])
+]], [[
+a
+b
+c
+
+a
+[b],[c]
+[b]
+
+, [b],[c]
+, [b]
+
+good
+good
+]])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_init
+m4_argn([0], [a], [b], [c])
+]])
+AT_CHECK_M4SUGAR([-o-], [1], [],
+[[script.4s:2: error: assert failed: 0 < 0
+script.4s:2: the top level
+autom4te: m4 failed with exit status: 1
+]])
+
+AT_CLEANUP
+
+
+## ---------- ##
+## m4_split. ##
+## ---------- ##
+
+AT_SETUP([m4@&t@_split])
+
+AT_CHECK_M4SUGAR_TEXT(
+[[m4_define([active], [ACT, IVE])m4_define([bd], [oops])
+m4_split
+m4_split([[]])
+m4_split([ ])
+m4_split([active])
+m4_split([ active active ])end
+m4_split([ ], [ ])
+m4_split([active], [ ])
+m4_split([ active active ], [ ])end
+m4_split([abcde], [bd])
+m4_split([abcde], [[bd]])
+m4_split([foo=`` bar=''])
+m4_split([foo='' bar=``])
+dnl these next two are from the manual; keep this in sync if the internal
+dnl quoting strings in m4_split are changed
+m4_define([a], [A])m4_define([b], [B])m4_define([c], [C])dnl
+m4_split([a )}>=- b -=<{( c])
+m4_split([a )}@&t@>=- b -=<@&t@{( c])
+]],
+[[
+
+[[]]
+[], []
+[active]
+[], [active], [active], []end
+[], []
+[active]
+[], [active active], []end
+[abcde]
+[a], [c], [e]
+[foo=``], [bar='']
+[foo=''], [bar=``]
+[a], [], [B], [], [c]
+[a], [)}>=@&t@-], [b], [-@&t@=<{(], [c]
+]])
+
+AT_CLEANUP
+
+
+## ------- ##
+## m4_do. ##
+## ------- ##
+
+AT_SETUP([m4@&t@_do])
+
+AT_CHECK_M4SUGAR_TEXT(
+[[m4_define([ab], [1])m4_define([bc], [2])m4_define([abc], [3])dnl
+m4_define([AB], [4])m4_define([BC], [5])m4_define([ABC], [6])dnl
+m4_do
+m4_do([a])
+m4_do([a], [b])c
+m4_unquote(m4_join([], [a], [b]))c
+m4_define([a], [A])m4_define([b], [B])m4_define([c], [C])dnl
+m4_do([a], [b])c
+m4_unquote(m4_join([], [a], [b]))c
+]],
+[[
+a
+abc
+3
+ABC
+3
+]])
+
+AT_CLEANUP
+
+
+## ----------- ##
+## m4_append. ##
+## ----------- ##
+
+AT_SETUP([m4@&t@_append])
+AT_KEYWORDS([m4@&t@_append_uniq m4@&t@_append_uniq_w])
+
+AT_CHECK_M4SUGAR_TEXT(
+[[m4_define([active], [ACTIVE])dnl
+m4_append([sentence], [This is an])dnl
+m4_append([sentence], [ active ])dnl
+m4_append([sentence], [symbol.])dnl
+sentence
+m4_undefine([active])dnl
+sentence
+m4_define([active], [ACTIVE])dnl
+m4_append([hooks], [m4_define([act1], [act2])])dnl
+m4_append([hooks], [m4_define([act2], [active])])dnl
+m4_undefine([active])dnl
+act1
+hooks
+act1
+dnl Test for bug fixed in 2.62 when separator is active.
+m4_define([a], [A])dnl
+m4_append_uniq([foo], [-], [a])dnl
+m4_append_uniq([foo], [-], [a])dnl
+m4_append_uniq([bar], [-], [a])dnl
+m4_append_uniq([bar], [~], [a])dnl
+m4_append_uniq([bar], [-], [a])dnl
+m4_defn([foo])
+m4_defn([bar])
+foo
+bar
+m4_append_uniq([blah], [one], [, ], [new], [existing])
+m4_append_uniq([blah], [two], [, ], [new], [existing])
+m4_append_uniq([blah], [two], [, ], [new], [existing])
+m4_append_uniq([blah], [three], [, ], [new], [existing])
+m4_append([blah], [two], [, ])dnl
+blah
+m4_dquote(blah)
+m4_append([list], [one], [[, ]])dnl
+m4_append([list], [two], [[, ]])dnl
+m4_append([list], [three], [[, ]])dnl
+list
+m4_dquote(list)
+m4_append_uniq_w([numbers], [1 1 2])dnl
+m4_append_uniq_w([numbers], [ 2 3 ])dnl
+numbers
+]],
+[[This is an ACTIVE symbol.
+This is an active symbol.
+act1
+
+active
+-
+-a~
+-
+-A~
+new
+new
+existing
+new
+one, two, three, two
+[one],[two],[three],[two]
+one, two, three
+[one, two, three]
+1 2 3
+]])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_init[]dnl
+m4_append_uniq([str], [a], [ ])
+m4_append_uniq([str], [a b], [ ])
+m4_divert([])dnl
+str
+]])
+
+AT_CHECK_M4SUGAR([-o-], 0, [[a a b
+]], [[script.4s:3: warning: m4@&t@_append_uniq: `a b' contains ` '
+]])
+
+AT_CLEANUP
+
+
+## --------- ##
+## m4_join. ##
+## --------- ##
+
+AT_SETUP([m4@&t@_join])
+
+AT_KEYWORDS([m4@&t@_joinall])
+
+AT_CHECK_M4SUGAR_TEXT(
+[[m4_define([active], [ACTIVE])
+m4_join
+m4_join([|])
+m4_join([, ], [one], [two])
+m4_dquote(m4_join([, ], [one], [two]))
+m4_join([|], [active], [active])
+m4_join([|], ,,,[one])
+m4_join([|], [one],,,)
+m4_join([], ,,,[two])
+m4_join([], [two],,,)
+m4_join([ active ], [one], , [two])
+m4_join([], [one], [two])
+m4_joinall([-], [one], [], [two])
+m4_joinall([-], [], [], [three], [], [])
+m4_joinall([], [one], [], [two])
+m4_joinall
+m4_joinall([-])
+m4_joinall([-], [one])
+]],
+[[
+
+
+one, two
+[one, two]
+active|active
+one
+one
+two
+two
+one active two
+onetwo
+one--two
+--three--
+onetwo
+
+
+one
+]])
+
+AT_CLEANUP
+
+
+## ----------- ##
+## m4_expand. ##
+## ----------- ##
+
+AT_SETUP([m4@&t@_expand])
+
+AT_CHECK_M4SUGAR_TEXT(
+[[m4_define([active], [ACTIVE])dnl
+m4_expand([#active
+active])
+m4_expand([[active]])
+dnl properly quoted case statements
+m4_expand([case a in @%:@(
+ *) echo active, ;;
+esac
+case b in
+ *[)] echo active, ;;
+esac])
+dnl unbalanced underquoted `)', but we manage anyway (gasp!)
+m4_expand([case c in #(
+ *) echo active, ;;
+esac
+case d in
+ *) echo active, ;;
+esac])
+dnl unterminated comment/dnl
+m4_expand([active # active])
+m4_expand([a
+dnl])
+m4_expand([a
+-dnl])
+]],
+[[#active
+ACTIVE
+active
+case a in #(
+ *) echo ACTIVE, ;;
+esac
+case b in
+ *) echo ACTIVE, ;;
+esac
+case c in #(
+ *) echo ACTIVE, ;;
+esac
+case d in
+ *) echo ACTIVE, ;;
+esac
+ACTIVE # active
+a
+a
+-
+]])
+
+AT_CLEANUP
+
+
+## ------------- ##
+## m4_text_box. ##
+## ------------- ##
+
+AT_SETUP([m4@&t@_text_box])
+
+AT_CHECK_M4SUGAR_TEXT([[
+m4_text_box([a $1 @&t@b])
+m4_text_box([a $1 @&t@b], [$])
+m4_text_box([a $1 @&t@b], [,])
+]], [[
+## ------ ##
+## a $1 b ##
+## ------ ##
+## $$$$$$ ##
+## a $1 b ##
+## $$$$$$ ##
+## ,,,,,, ##
+## a $1 b ##
+## ,,,,,, ##
+]])
+
+AT_CLEANUP
+
+## -------------- ##
+## m4_text_wrap. ##
+## -------------- ##
+
+AT_SETUP([m4@&t@_text_wrap])
+AT_KEYWORDS([m4@&t@_escape])
+
+# m4_text_wrap is used to display the help strings. Also, check that
+# commas and $ are not swallowed. This can easily happen because of
+# m4-listification.
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_init[]m4_divert([])dnl
+m4_define([a], [OOPS])dnl
+m4_escape([a[b $c#]d])
+m4_if(m4_escape([a[b $c#]d]), [a[b $c#]d], [oops],
+ m4_escape([a[b $c#]d]), [a@<:@b @S|@c@%:@@:>@d], [pass], [oops])
+
+m4_text_wrap([Short string */], [ ], [/* ], 20)
+
+m4_text_wrap([Much longer string */], [ ], [/* ], 20)
+
+m4_text_wrap([Short doc.], [ ], [ --short ], 30)
+
+m4_text_wrap([Short doc.], [ ], [ --too-wide], 30)
+
+m4_text_wrap([Super long documentation.], [ ], [ --too-wide], 30)
+
+m4_text_wrap([First, second , third, [,quoted space]])
+m4_define([xfff], [oops])
+m4_text_wrap([Some $1 $2 $3 $4 embedded dollars.], [ $* ], [ $@ ], [0xfff & 20])
+]])
+
+AT_DATA([expout],
+[[a[b $c#]d
+pass
+
+/* Short string */
+
+/* Much longer
+ string */
+
+ --short Short doc.
+
+ --too-wide
+ Short doc.
+
+ --too-wide
+ Super long
+ documentation.
+
+First, second , third, [,quoted space]
+
+ $@ Some $1 $2 $3
+ $* $4 embedded
+ $* dollars.
+]])
+
+AT_CHECK_M4SUGAR([-o-], 0, [expout])
+
+AT_CLEANUP
+
+## -------------------- ##
+## m4_version_compare. ##
+## -------------------- ##
+
+AT_SETUP([m4@&t@_version_compare])
+
+AT_KEYWORDS([m4@&t@_list_cmp])
+
+AT_CHECK_M4SUGAR_TEXT(
+[[m4_version_compare([1.1], [2.0])
+m4_version_compare([2.0b], [2.0a])
+m4_version_compare([2.0z], [2.0y])
+m4_version_compare([1.1.1], [1.1.1a])
+m4_version_compare([1.2], [1.1.1a])
+m4_version_compare([1.0], [1])
+m4_version_compare([1.0a], [1.0a])
+m4_version_compare([1.1a], [1.1a.1])
+m4_version_compare([1.10], [1.1a])
+m4_version_compare([1-1a], [1,1A])
+m4_define([a], [oops])dnl
+m4_version_compare([1.1a], [1.1A])
+m4_version_compare([1z], [1aa])
+m4_version_compare([2.61a], [2.61a-248-dc51])
+m4_version_compare([2.61b], [2.61a-248-dc51])
+m4_version_compare([08], [09])
+m4_version_compare([010], [8])
+dnl Test that side effects to m4_list_cmp occur exactly once
+m4_list_cmp([[0], [0], [0]m4_errprintn([hi])],
+ [[0], [0], [0]m4_errprintn([hi])])
+m4_list_cmp([[0], [0], [0]m4_errprintn([hi])],
+ [[0], [0], [0]m4_errprintn([bye])])
+]],
+[[-1
+1
+1
+-1
+1
+0
+0
+-1
+1
+0
+0
+-1
+-1
+1
+-1
+1
+0
+0
+]], [[hi
+hi
+hi
+bye
+]])
+
+AT_CLEANUP
+
+## ------------------------------ ##
+## Standard regular expressions. ##
+## ------------------------------ ##
+
+AT_SETUP([Standard regular expressions])
+
+# AT_CHECK_M4RE(RE-NAME, TEXT, INTENT = `ok' | `')
+# ------------------------------------------------
+# Check whether RE-NAME (a macro whose definition is a regular expression)
+# matches TEXT. INTENT = `ok' if the match should succeed or else empty.
+m4_define([AT_CHECK_M4RE],
+[AT_CHECK_M4SUGAR_TEXT(
+[[m4_bregexp([$2], ^m4_defn([$1])$, [ok])
+]], [$3
+])])
+
+AT_CHECK_M4RE([m4_re_word], [ab9_c], [ok])
+AT_CHECK_M4RE([m4_re_word], [_9abc], [ok])
+AT_CHECK_M4RE([m4_re_word], [9ab_c])
+
+AT_CHECK_M4RE([m4_re_string], [ab9_c], [ok])
+AT_CHECK_M4RE([m4_re_string], [_9abc], [ok])
+AT_CHECK_M4RE([m4_re_string], [9ab_c], [ok])
+AT_CHECK_M4RE([m4_re_string], [9a@_c])
+
+AT_CLEANUP
+
+## ----------- ##
+## m4_bmatch. ##
+## ----------- ##
+
+AT_SETUP([m4@&t@_bmatch])
+
+AT_CHECK_M4SUGAR_TEXT(
+[[m4_bmatch([abc], [default\])
+m4_bmatch([abc], [^a], [yes])
+m4_bmatch([abc], [^a], [yes], [no])
+m4_bmatch([abc], [^.a], [yes])
+m4_bmatch([abc], [^.a], [yes], [no\])
+m4_bmatch([abc], [a], [1], [b], [2])
+m4_bmatch([abc], [A], [1], [b], [2])
+m4_define([ab], [AB])dnl
+m4_bmatch([$*], [a])b
+m4_bmatch([$*], [\*], [a])b
+m4_bmatch([$*], [1], [2], [a])b
+]], [[default\
+yes
+yes
+
+no\
+1
+2
+AB
+AB
+AB
+]])
+
+AT_CLEANUP
+
+## ------------------------ ##
+## m4_toupper, m4_tolower. ##
+## ------------------------ ##
+
+AT_SETUP([m4@&t@_toupper and m4@&t@_tolower])
+
+AT_CHECK_M4SUGAR_TEXT(
+[[m4_define([abc], [hI])m4_define([ABC], [Hi])
+m4_toupper(abc aBc ABC)
+m4_tolower(abc aBc ABC)
+m4_toupper([abc aBc ABC])
+m4_tolower([abc aBc ABC])
+m4_echo(m4_toupper(abc aBc ABC))
+m4_echo(m4_tolower(abc aBc ABC))
+m4_echo(m4_toupper([abc aBc ABC]))
+m4_echo(m4_tolower([abc aBc ABC]))
+m4_do(m4_toupper(abc aBc ABC))
+m4_do(m4_tolower(abc aBc ABC))
+m4_do(m4_toupper([abc aBc ABC]))
+m4_do(m4_tolower([abc aBc ABC]))
+]], [[
+HI ABC HI
+hi abc hi
+ABC ABC ABC
+abc abc abc
+HI ABC HI
+hi abc hi
+ABC ABC ABC
+abc abc abc
+HI Hi HI
+hi hI hi
+Hi Hi Hi
+hI hI hI
+]])
+
+AT_CLEANUP
+
+## --------------- ##
+## m4_bpatsubsts. ##
+## --------------- ##
+
+AT_SETUP([m4@&t@_bpatsubsts])
+
+AT_CHECK_M4SUGAR_TEXT(
+[[m4_bpatsubsts([11], [^..$])
+m4_bpatsubsts([11], [\(.\)1], [\12])
+m4_bpatsubsts([11], [^..$], [], [1], [2])
+m4_bpatsubsts([11], [\(.\)1], [\12], [1], [3])
+m4_define([a], [oops])m4_define([c], [oops])dnl
+m4_define([AB], [good])m4_define([bc], [good])dnl
+m4_bpatsubsts([abc], [a], [A], [b], [B], [c])
+m4_bpatsubsts([ab], [a])c
+m4_bpatsubsts([ab], [c], [C], [a])c
+m4_bpatsubsts([$1$*$@], [\$\*], [$#])
+]], [[11
+21
+22
+23
+good
+good
+good
+$1$#$@
+]])
+
+AT_CLEANUP
+
+## -------------- ##
+## m4_esyscmd_s. ##
+## -------------- ##
+
+AT_SETUP([m4@&t@_esyscmd_s])
+AT_KEYWORDS([m4@&t@_chomp m4@&t@_chomp_all])
+
+AT_CHECK_M4SUGAR_TEXT(
+[[m4_define([world], [WORLD])dnl
+m4_chomp([abc])
+m4_chomp([world
+
+])
+m4_esyscmd_s([echo hello world])
+m4_esyscmd_s([echo '[goodbye,
+cruel world
+
+]'])
+]], [[abc
+world
+
+hello WORLD
+goodbye,
+cruel world
+]])
+
+AT_CLEANUP
+
+## ---------- ##
+## M4 Loops. ##
+## ---------- ##
+
+AT_SETUP([M4 loops])
+
+AT_KEYWORDS([m4@&t@_for m4@&t@_foreach m4@&t@_foreach_w m4@&t@_map_args_w])
+
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_define([myvar], [outer value])dnl
+m4_for([myvar], 1, 3, 1, [ myvar])
+m4_for([myvar], 1, 3, , [ myvar])
+m4_for([myvar], 3, 1,-1, [ myvar])
+m4_for([myvar], 3, 1, , [ myvar])
+m4_for([myvar], 1, 3, 2, [ myvar])
+m4_for([myvar], 3, 1,-2, [ myvar])
+m4_for([myvar],-1,-3,-2, [ myvar])
+m4_for([myvar],-3,-1, 2, [ myvar])
+dnl Make sure we recalculate the bounds correctly:
+m4_for([myvar], 1, 3, 3, [ myvar])
+m4_for([myvar], 1, 6, 3, [ myvar])
+m4_for([myvar],22,-7,-5, [ myvar])
+m4_for([myvar],-2,-7,-4, [ myvar])
+m4_for([myvar],-7,-2, 4, [ myvar])
+dnl Make sure we are not exposed to division truncation:
+m4_for([myvar], 2, 5, 2, [ myvar])
+m4_for([myvar],-5,-2, 2, [ myvar])
+m4_for([myvar], 5, 2,-2, [ myvar])
+m4_for([myvar],-2,-5,-2, [ myvar])
+dnl Make sure we do not divide by zero:
+m4_for([myvar], 1, 1, , [ myvar])
+m4_for([myvar], 1, 1,+2, [ myvar])
+m4_for([myvar], 1, 1,-2, [ myvar])
+dnl Make sure we do not loop endlessly
+m4_for([myval], 1, 1, 0, [ myval])
+dnl Make sure to properly parenthesize
+m4_for([myvar], 3-5, -2+8, , [ myvar])
+m4_for([myvar], -2+8, 3-5, , [ myvar])
+m4_for([myvar], 8, 16, 3 * 2, [ myvar])
+m4_for([myvar], 8, 16, -3 * -2, [ myvar])
+m4_for([myvar], [2<<2], [2<<3], [-3 * (-2)], [ myvar])
+dnl Modifying var does not affect the number of iterations
+m4_for([myvar], 1, 5, , [ myvar[]m4_define([myvar], 5)])
+dnl Make sure we can do nameless iteration
+m4_for(, 1, 10, , -)
+dnl foreach tests
+m4_foreach([myvar], [[a], [b, c], [d], [e
+],[f]], [ myvar|])
+m4_foreach_w([myvar], [a b c, d,e f
+g], [ myvar|])
+myvar
+m4_map_args_w([a b c, d,e f
+g], [ ], [|])
+m4_map_args_w([a b], [\1], [/])
+m4_define([dashes], [--])dnl
+m4_map_args_w([a b c], [/], [\1], [dashes])
+dnl only one side effect expansion, prior to visiting list elements
+m4_foreach([i], [[1], [2], [3]m4_errprintn([hi])], [m4_errprintn(i)])dnl
+dnl shifting forms an important part of loops
+m4_shift3:m4_shift3(1,2,3):m4_shift3(1,2,3,4)
+m4_shiftn(3,1,2,3):m4_shiftn(3,1,2,3,4)
+]],
+[[ 1 2 3
+ 1 2 3
+ 3 2 1
+ 3 2 1
+ 1 3
+ 3 1
+ -1 -3
+ -3 -1
+ 1
+ 1 4
+ 22 17 12 7 2 -3
+ -2 -6
+ -7 -3
+ 2 4
+ -5 -3
+ 5 3
+ -2 -4
+ 1
+ 1
+ 1
+ 1
+ -2 -1 0 1 2 3 4 5 6
+ 6 5 4 3 2 1 0 -1 -2
+ 8 14
+ 8 14
+ 8 14
+ 1 2 3 4 5
+----------
+ a| b, c| d| e
+| f|
+ a| b| c,| d,e| f| g|
+outer value
+ a| b| c,| d,e| f| g|
+\1a/\1b/
+/a\1--/b\1--/c\1
+::4
+:4
+]], [[hi
+1
+2
+3
+]])
+
+dnl bounds checking in m4_for
+AT_DATA_M4SUGAR([script.4s],
+[[m4_init
+m4_divert([0])dnl
+m4_for([myvar], 1, 3,-1, [ myvar])
+]])
+AT_CHECK_M4SUGAR([], 1, [],
+[[script.4s:3: error: assert failed: -1 > 0
+script.4s:3: the top level
+autom4te: m4 failed with exit status: 1
+]])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_init
+m4_divert([0])dnl
+m4_for([myvar], 1, 2, 0, [ myvar])
+]])
+AT_CHECK_M4SUGAR([], 1, [],
+[[script.4s:3: error: assert failed: 0 > 0
+script.4s:3: the top level
+autom4te: m4 failed with exit status: 1
+]])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_init
+m4_divert([0])dnl
+m4_for([myvar], 2, 1, 0, [ myvar])
+]])
+AT_CHECK_M4SUGAR([], 1, [],
+[[script.4s:3: error: assert failed: 0 < 0
+script.4s:3: the top level
+autom4te: m4 failed with exit status: 1
+]])
+
+dnl m4_shiftn also does bounds checking
+AT_DATA_M4SUGAR([script.4s],
+[[m4_init
+m4_divert([0])dnl
+m4_shiftn(3,1,2)
+]])
+AT_CHECK_M4SUGAR([], 1, [],
+[[script.4s:3: error: assert failed: 0 < 3 && 3 < 3
+script.4s:3: the top level
+autom4te: m4 failed with exit status: 1
+]])
+
+AT_CLEANUP
+
+
+## --------------------- ##
+## m4_map{,all}{,_sep}. ##
+## --------------------- ##
+
+AT_SETUP([m4@&t@_map])
+AT_KEYWORDS([m4@&t@_apply m4@&t@_map_sep m4@&t@_mapall m4@&t@_mapall_sep])
+AT_KEYWORDS([m4@&t@_count])
+
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_map([m4_count], [])
+m4_map([ m4_count], [[],
+ [[1]],
+ [[1], [2]]])
+m4_mapall([ m4_count], [[],
+ [[1]],
+ [[1], [2]]])
+m4_map_sep([m4_eval], [,], [[[1+2]],
+ [[10], [16]]])
+m4_count(m4_map_sep([m4_echo], [,], [[], [[1]], [[2]]]))
+m4_count(m4_mapall_sep([m4_echo], [,], [[], [[1]], [[2]]]))
+m4_map_sep([m4_eval], [[,]], [[[1+2]],
+ [[10], [16]]])
+m4_count(m4_map_sep([m4_echo], [[,]], [[], [[1]], [[2]]]))
+m4_count(m4_mapall_sep([m4_echo], [[,]], [[], [[1]], [[2]]]))
+m4_map([-], [[]])
+m4_mapall([-], [[]])
+m4_map_sep([-], [:], [[]])
+m4_mapall_sep([-], [:], [[]])
+m4_define([a], [m4_if([$#], [0], [oops], [$1], [a], [pass], [oops])])dnl
+m4_define([a1], [oops])dnl
+m4_define([pass1], [oops])dnl
+m4_map([a], [[[a]]])1
+m4_map([m4_unquote([a])], [m4_dquote([a])])
+dnl only one side effect expansion, prior to visiting list elements
+m4_map([m4_errprintn], [[[1]], [[2]], [[3]]m4_errprintn([hi])])dnl
+m4_map_sep([m4_errprintn], [], [[[1]], [[2]], [[3]]m4_errprintn([hi])])dnl
+m4_mapall([m4_errprintn], [[[1]], [[2]], [[3]]m4_errprintn([hi])])dnl
+m4_mapall_sep([m4_errprintn], [], [[[1]], [[2]], [[3]]m4_errprintn([hi])])dnl
+]],
+[[
+ 1 2
+ 0 1 2
+3,a
+2
+3
+3,a
+1
+1
+
+-
+
+-
+pass1
+pass
+]], [[hi
+1
+2
+3
+hi
+1
+2
+3
+hi
+1
+2
+3
+hi
+1
+2
+3
+]])
+
+AT_CLEANUP
+
+
+## --------------------------------------- ##
+## m4_map_args{,_sep,_pair} and m4_curry. ##
+## --------------------------------------- ##
+
+AT_SETUP([m4@&t@_map_args and m4@&t@_curry])
+AT_KEYWORDS([m4@&t@_map_args_sep m4@&t@_map_args_pair m4@&t@_reverse
+m4@&t@_map])
+
+dnl First, make sure we can curry in isolation.
+AT_CHECK_M4SUGAR_TEXT(
+[[m4_curry([m4_echo])([1])
+m4_curry([m4_curry], [m4_reverse], [1])([2])([3])
+m4_define([add], [m4_eval(([$1]) + ([$2]))])dnl
+m4_define([add_one], [m4_curry([add], [1])])dnl
+add_one()([4])
+]],
+[[1
+3, 2, 1
+5
+]])
+
+dnl Now, check that we can map a list of arguments.
+AT_CHECK_M4SUGAR_TEXT([[m4_define([active], [ACTIVE])dnl
+m4_map_args([ m4_echo])
+m4_map_args([ m4_echo], [plain], [active])
+m4_map_args([m4_unquote], [plain], [active])
+m4_map_args_pair([, m4_reverse], [])
+m4_map_args_pair([, m4_reverse], [], [1])
+m4_map_args_pair([, m4_reverse], [], [1], [2])
+m4_map_args_pair([, m4_reverse], [], [1], [2], [3])
+m4_map_args_pair([, m4_reverse], [], [1], [2], [3], [4])
+m4_map_args_pair([, m4_reverse], [, m4_dquote], [1])
+m4_map_args_pair([, m4_reverse], [, m4_dquote], [1], [2])
+m4_map_args_pair([, m4_reverse], [, m4_dquote], [1], [2], [3])
+m4_map_args_pair([, m4_reverse], [, m4_dquote], [1], [2], [3], [4])
+m4_map_args_sep([<], [>], [:], [1], [2], [3])
+m4_map_args_sep([m4_echo(], [)], [ ], [plain], [active])
+]],
+[[
+ plain active
+plainACTIVE
+
+, 1
+, 2, 1
+, 2, 1, 3
+, 2, 1, 4, 3
+, [1]
+, 2, 1
+, 2, 1, [3]
+, 2, 1, 4, 3
+<1>:<2>:<3>
+plain active
+]])
+
+dnl Finally, put the two concepts together, to show the real power of the API.
+AT_CHECK_M4SUGAR_TEXT(
+[[m4_define([add], [m4_eval(([$1]) + ([$2]))])dnl
+m4_define([list], [[-1], [0], [1]])dnl
+dnl list_add_n(value, arg...)
+dnl add VALUE to each ARG and output the resulting list
+m4_define([list_add_n],
+ [m4_shift(m4_map_args([,m4_curry([add], [$1])], m4_shift($@)))])
+list_add_n([1], list)
+list_add_n([2], list)
+]], [[
+0,1,2
+1,2,3
+]])
+
+AT_CLEANUP
+
+
+## ------------ ##
+## m4_combine. ##
+## ------------ ##
+
+AT_SETUP([m4@&t@_combine])
+
+AT_CHECK_M4SUGAR_TEXT([[m4_define([a], [oops])dnl
+m4_combine([, ], [[a], [b], [c]], [-], [1], [2], [3])
+m4_combine([, ], [[a], [b]], [-])
+m4_combine([, ], [[a], [b]], [-], [])
+m4_combine([, ], [], [-], [a], [b])
+m4_combine([, ], [[]], [-], [a], [b])
+m4_combine([ a ], [[-], [+]], [a], [-], [+])
+m4_combine([$* ], [[$1], [$2]], [$#], [$@])
+]],
+[[a-1, a-2, a-3, b-1, b-2, b-3, c-1, c-2, c-3
+
+a-, b-
+
+-a, -b
+-a- a -a+ a +a- a +a+
+$1$#$@$* $2$#$@
+]], [])
+
+AT_CLEANUP
+
+
+## -------------- ##
+## m4_{max,min}. ##
+## -------------- ##
+
+AT_SETUP([m4@&t@_max and m4@&t@_min])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_max
+]])
+
+AT_CHECK_M4SUGAR([], 1, [],
+[[script.4s:1: error: too few arguments to m4@&t@_max
+script.4s:1: the top level
+autom4te: m4 failed with exit status: 1
+]])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_min
+]])
+
+AT_CHECK_M4SUGAR([], 1, [],
+[[script.4s:1: error: too few arguments to m4@&t@_min
+script.4s:1: the top level
+autom4te: m4 failed with exit status: 1
+]])
+
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_min(0)
+m4_min(0xa)
+m4_min(0, 0)
+m4_min(0, 1)
+m4_min(1, 0)
+m4_min(0+1, 1+1)
+m4_min(0+1, 1+0)
+m4_min(0, 1, 2)
+m4_min(2, 1, 0)
+m4_min(1m4_for([i], 2, 100, , [,i]))
+m4_min(m4_for([i], 100, 2, , [i,])1)
+----
+m4_max(0)
+m4_max(0xa)
+m4_max(0, 0)
+m4_max(0, 1)
+m4_max(1, 0)
+m4_max(1+0, 1+1)
+m4_max(1+0, 1+0)
+m4_max(0, 1, 2)
+m4_max(2, 1, 0)
+m4_max(1m4_for([i], 2, 100, , [,i]))
+m4_max(m4_for([i], 100, 2, , [i,])1)
+]],
+[[0
+10
+0
+0
+0
+1
+1
+0
+0
+1
+1
+----
+0
+10
+0
+1
+1
+2
+1
+2
+2
+100
+100
+]], [])
+
+AT_CLEANUP
+
+
+## ----------- ##
+## Recursion. ##
+## ----------- ##
+
+AT_SETUP([recursion])
+
+AT_KEYWORDS([m4@&t@_foreach m4@&t@_foreach_w m4@&t@_case m4@&t@_cond
+m4@&t@_bpatsubsts m4@&t@_shiftn m4@&t@_do m4@&t@_dquote_elt m4@&t@_reverse
+m4@&t@_map m4@&t@_join m4@&t@_joinall m4@&t@_list_cmp m4@&t@_max m4@&t@_min
+m4@&t@_bmatch m4@&t@_map_args m4@&t@_map_args_pair])
+
+dnl This test completes in a reasonable time if m4_foreach is linear,
+dnl but thrashes if it is quadratic. If we are testing with m4 1.4.x,
+dnl only the slower foreach.m4 implementation will work. But if we
+dnl are testing with m4 1.6, we can rerun the test with __m4_version__
+dnl undefined to exercise the alternate code path.
+AT_DATA_M4SUGAR([script.4s],
+[[m4_init
+m4_divert_push([])[]dnl
+m4_len(m4_foreach_w([j], m4_do(m4_for([i], [1], [10000], [], [,i ])), [j ]))
+m4_shiftn(9998m4_for([i], [1], [10000], [], [,i]))
+m4_len(m4_join([--],, m4_dquote_elt(m4_for([i], [1], [10000], [], [,i])),))
+m4_len(m4_joinall([--], m4_map([, m4_echo],
+ m4_dquote([1]m4_for([i], [2], [10000], [], [,i])))))
+m4_max(m4_min([1]m4_for([i], [2], [10000], [],
+ [,i]))m4_for([i], [2], [10000], [], [,i]))
+m4_case([10000]m4_for([i], [1], [10000], [], [,i]),[end])
+m4_list_cmp(m4_dquote(1m4_for([i], [2], [10000], [], [,i])),
+ m4_dquote(m4_reverse(10000m4_for([i], [9999], [1], [], [,i])), [0]))
+m4_list_cmp([0], [0m4_for([i], [1], [10000], [], [,0])])
+m4_list_cmp([0m4_for([i], [1], [10000], [], [,0])], [0])
+m4_for([i], [1], [10000], [], [m4_define(i)])dnl
+m4_undefine(1m4_for([i], [2], [10000], [], [,i]))dnl
+m4_bpatsubsts([a1]m4_for([i], [1], [10000], [], [,i]), [a2], [A])
+m4_bmatch([9997]m4_for([i], [1], [10000], [], [,^i$]))
+m4_define([up], [m4_define([$1], m4_incr($1))$1])m4_define([j], 0)dnl
+m4_cond(m4_for([i], [1], [10000], [], [[up([j])], [9990], i,]) [oops]) j
+m4_count(m4_map_args_pair([,m4_quote], []m4_map_args([,m4_echo]m4_for([i],
+ [1], [10000], [], [,i]))))
+m4_divert_pop([])
+]])
+
+AT_CHECK_M4SUGAR([-o-], [0], [[48894
+9999,10000
+78896
+58894
+10000
+end
+0
+0
+0
+A
+^9998$
+9990 9990
+5001
+]])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_ifdef([__m4_version__],
+[m4_undefine([__m4_version__])],
+[m4_divert_push([])48894
+9999,10000
+78896
+58894
+10000
+end
+0
+0
+0
+A
+^9998$
+9990 9990
+5001
+m4_exit([0])])
+m4_init
+m4_divert_push([])[]dnl
+m4_len(m4_foreach_w([j], m4_do(m4_for([i], [1], [10000], [], [,i ])), [j ]))
+m4_shiftn(9998m4_for([i], [1], [10000], [], [,i]))
+m4_len(m4_join([--],, m4_dquote_elt(m4_for([i], [1], [10000], [], [,i])),))
+m4_len(m4_joinall([--], m4_map([, m4_echo],
+ m4_dquote([1]m4_for([i], [2], [10000], [], [,i])))))
+m4_max(m4_min([1]m4_for([i], [2], [10000], [],
+ [,i]))m4_for([i], [2], [10000], [], [,i]))
+m4_case([10000]m4_for([i], [1], [10000], [], [,i]),[end])
+m4_list_cmp(m4_dquote(1m4_for([i], [2], [10000], [], [,i])),
+ m4_dquote(m4_reverse(10000m4_for([i], [9999], [1], [], [,i])), [0]))
+m4_list_cmp([0], [0m4_for([i], [1], [10000], [], [,0])])
+m4_list_cmp([0m4_for([i], [1], [10000], [], [,0])], [0])
+m4_for([i], [1], [10000], [], [m4_define(i)])dnl
+m4_undefine(1m4_for([i], [2], [10000], [], [,i]))dnl
+m4_bpatsubsts([a1]m4_for([i], [1], [10000], [], [,i]), [a2], [A])
+m4_bmatch([9997]m4_for([i], [1], [10000], [], [,^i$]))
+m4_define([up], [m4_define([$1], m4_incr($1))$1])m4_define([j], 0)dnl
+m4_cond(m4_for([i], [1], [10000], [], [[up([j])], [9990], i,]) [oops]) j
+m4_count(m4_map_args_pair([,m4_quote], []m4_map_args([,m4_echo]m4_for([i],
+ [1], [10000], [], [,i]))))
+m4_divert_pop([])
+]])
+
+AT_CHECK_M4SUGAR([-o-], [0], [[48894
+9999,10000
+78896
+58894
+10000
+end
+0
+0
+0
+A
+^9998$
+9990 9990
+5001
+]])
+
+AT_CLEANUP
+
+
+## ---------- ##
+## m4_set_*. ##
+## ---------- ##
+
+AT_SETUP([m4@&t@_set])
+
+AT_KEYWORDS([m4@&t@_set_add m4@&t@_set_add_all m4@&t@_set_contains
+m4@&t@_set_contents m4@&t@_set_delete m4@&t@_set_difference m4@&t@_set_dump
+m4@&t@_set_empty m4@&t@_set_foreach m4@&t@_set_intersection m4@&t@_set_list
+m4@&t@_set_listc m4@&t@_set_map m4@&t@_set_remove m4@&t@_set_size
+m4@&t@_set_union])
+
+# Simple tests
+AT_CHECK_M4SUGAR_TEXT([[m4_set_contains([a], [1], [yes], [no])
+m4_set_add([a], [1], [added], [dup])
+m4_set_contains([a], [1], [yes], [no])
+m4_set_add([a], [1], [added], [dup])
+m4_set_contents([a])
+m4_set_remove([a], [1], [removed], [missing])
+m4_set_contains([a], [1], [yes], [no])
+m4_set_remove([a], [1], [removed], [missing])
+m4_set_add([a], [2], [added], [dup])
+m4_set_empty([a], [yes], [no])
+m4_set_delete([a])
+m4_set_empty([a], [yes], [no])
+m4_set_add_all([c], [1], [2], [3])
+m4_set_add_all([a]m4_set_listc([c]))
+m4_set_contents([c], [-])
+m4_set_dump([a], [-])
+m4_set_contents([a])
+m4_set_add_all([a], [1], [2], [3])m4_set_add_all([b], [3], [], [4])
+m4_set_difference([a], [b])
+m4_set_difference([b], [a])
+m4_set_intersection([a], [b])
+m4_set_union([a], [b])
+m4_define([printodd], [m4_if(m4_eval([$1 & 1]), [1], [:$1])])dnl
+m4_set_map([a], [printodd])
+m4_set_foreach([a], [i], [m4_if(m4_eval(i & 1), [1], [m4_set_remove([a], i)])])
+m4_set_list([a])
+m4_set_add([a], [])
+m4_set_list([a])
+m4_set_remove([a], [2])
+m4_dquote(m4_set_list([a]))
+m4_set_listc([a])
+m4_set_size([a])
+m4_set_delete([a])
+m4_dquote(m4_set_list([a]))
+m4_indir([m4_dquote]m4_set_listc([a]))
+m4_set_listc([a])
+m4_set_size([a])
+]], [[no
+added
+yes
+dup
+1
+removed
+no
+missing
+added
+no
+
+yes
+
+
+1-2-3
+3-2-1
+
+
+,1,2
+,,4
+,3
+,1,2,3,,4
+:1:3
+
+2
+
+2,
+
+[]
+,
+1
+
+[]
+
+
+0
+]])
+
+# Stress tests - check for unusual names/values
+AT_CHECK_M4SUGAR_TEXT([[m4_define([a], [oops])dnl
+m4_set_add([a], [a])dnl
+m4_set_remove([a], [oops], [yes], [no])
+m4_set_add([a,b], [c])dnl
+m4_set_add([a,b], [$*[]])dnl
+m4_set_add_all([a], [b,c])dnl
+m4_set_size([a])
+m4_count(m4_set_contents([a], [,]))
+m4_count(m4_set_list([a], [,]))
+m4_set_dump([a], [,])
+m4_set_contents([a,b], [,])
+m4_set_list([a,b])
+m4_set_foreach([$*[]], [$*[]], [oops])
+m4_set_add([$*[]], [])dnl
+m4_set_remove([$*[]], [a], [yes], [no])
+m4_set_add([$*[]], [a])dnl
+m4_set_foreach([$*[]], [$*[]], [-m4_defn([$*[]])m4_indir([$*[]])-])
+m4_set_remove([$*[]], [], [yes], [no])
+m4_set_add([c], [,])dnl
+m4_set_foreach([a,b], [set], [:m4_set_listc(_m4_defn([set])):])
+]],[[no
+2
+1
+2
+b,c,a
+c,$*[]
+c,$*[]
+
+no
+---aoops-
+yes
+:,,::,a:
+]])
+
+# Stress tests - check for linear scaling (won't necessarily fail if
+# quadratic, but hopefully users will complain if it appears to hang)
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_for([i], [1], [10000], [], [m4_set_add([a], i)])dnl
+m4_set_add_all([b]m4_for([i], [1], [10000], [], [,i]))dnl
+m4_set_remove([a], [1])dnl
+m4_set_remove([b], [10000])dnl
+m4_set_add_all([a]m4_for([i], [1], [10000], [], [,i]))dnl
+m4_for([i], [1], [10000], [], [m4_set_add([b], i)])dnl
+m4_len(m4_set_contents([a]))
+m4_len(m4_set_foreach([b], [b], [m4_if(m4_eval(b & 1), [1],
+ [m4_set_remove([b], b, [-])])]))
+m4_set_size([b])
+m4_define([prune3x], [m4_if(m4_eval([$1 % 3]), [0],
+ [m4_set_remove([a], [$1], [-])])])dnl
+m4_len(m4_set_map([a], [prune3x]))
+m4_count(m4_shift(m4_set_intersection([a], [b])))
+]], [[38894
+5000
+5000
+3333
+3334
+]])
+
+AT_CLEANUP
+
+
+## ---------------------- ##
+## __file__ and __line__. ##
+## ---------------------- ##
+
+AT_SETUP([[__file__ and __line__]])
+
+# Check that __file__ and __line__ work.
+# Check that m4__file__ and m4__line__ are not defined
+# (and get them to pass by the undefined-macro check).
+# Try to not assume too much about AT_CHECK_M4SUGAR_TEXT.
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_pattern_allow([m4__file__])dnl
+m4_pattern_allow([m4__line__])dnl
+m4__file__
+m4__line__
+__file__
+m4_define([first], __line__)dnl
+m4_define([second], __line__)dnl
+m4_assert(first + 1 == second)dnl
+]], [[m4@&t@__@&t@file__
+m4@&t@__@&t@line__
+script.4s
+]])
+
+AT_CLEANUP
diff --git a/tests/mktests.sh b/tests/mktests.sh
new file mode 100755
index 0000000..41058e2
--- /dev/null
+++ b/tests/mktests.sh
@@ -0,0 +1,236 @@
+#! /bin/sh
+
+# Build some of the Autoconf test files.
+
+# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# If we fail, clean up, but touch the output files. We probably failed
+# because we used some non-portable tool.
+
+as_me=`echo "$0" | sed 's|.*[\\/]||'`
+
+trap 'echo "'"$as_me"': failed." >&2
+ rm -f acdefuns audefuns requires *.tat
+ trap "" 0
+ exit 1' \
+ 0 1 2 15
+
+# If ever something goes wrong, fail, so that the trap is launched.
+set -e
+
+# We need arguments.
+test $# != 0
+
+# We need these arguments.
+src="$@"
+
+# Set locale to C so that `sort' behaves in a uniform way.
+LANGUAGE=C; export LANGUAGE
+LANG=C; export LANG
+LC_ALL=C export LC_ALL
+
+
+# requires
+# --------
+# Get the list of macros that are required: there is little interest
+# in testing them since they will be run by the guy who requires them.
+sed -n 's/dnl.*//;s/.*AC_REQUIRE(\[*\([a-zA-Z0-9_]*\).*$/\1/p' $src |
+ sort -u >requires
+
+
+# exclude_list
+# ------------
+# Macros which must not be checked at all (not with AT_CHECK_MACRO nor
+# AT_CHECK_AU_MACRO).
+exclude_list='
+ # Not a macro name at all.
+ /^$/ {next}
+
+ # Not macros, just mapping from old variable name to a new one.
+ /^ac_cv_prog_(gcc|gxx|g77)$/ {next}
+'
+
+
+# ac_exclude_list
+# ---------------
+# We try to test all the Autoconf macros with AT_CHECK_MACRO to check
+# for syntax problems, etc. Not every macros can be run without
+# arguments, and some are already tested elsewhere. AC_EXCLUDE_LIST
+# filters out the macros we don't want to test.
+ac_exclude_list='
+ # Internal macros are used elsewhere.
+ /^_?_AC_/ {next}
+
+ # Used in many places.
+ /^AC_.*_IFELSE$/ {next}
+ /^AC_LANG/ {next}
+ /^AC_RUN_LOG$/ {next}
+ /^AC_TRY/ {next}
+
+ # Need an argument.
+ /^AC_(CANONICALIZE|PREFIX_PROGRAM|PREREQ)$/ {next}
+ /^AC_(SEARCH_LIBS|REPLACE_FUNCS)$/ {next}
+ /^AC_(CACHE_CHECK|COMPUTE)_INT$/ {next}
+ /^AC_ARG_VAR$/ {next}
+ /^AC_REQUIRE_SHELL_FN$/ {next}
+
+ # Performed in the semantics tests.
+ /^AC_CHECK_(ALIGNOF|DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|(TARGET_)?TOOL|TYPE)S?$/ {next}
+ /^AC_PATH_PROGS_FEATURE_CHECK$/ {next}
+
+ # Fail when the source does not exist.
+ /^AC_CONFIG/ {next}
+
+ # AU defined to nothing.
+ /^AC_(CYGWIN|CYGWIN32|EMXOS2|MING32|EXEEXT|OBJEXT)$/ {next}
+
+ # Produce "= val" because $1, the variable used to store the result,
+ # is empty.
+ /^AC_(F77|FC)_FUNC$/ {next}
+ /^AC_FC_(PP_)?SRCEXT$/ {next}
+ /^AC_PATH_((TARGET_)?TOOL|PROG)S?$/ {next}
+
+ # Is a number.
+ /^AC_FD_CC$/ {next}
+
+ # Obsolete, but needs to be AC_DEFUNed.
+ /^AC_FOREACH$/ {next}
+
+ # Require a file that is not shipped with Autoconf. But it should.
+ /^AC_FUNC_(GETLOADAVG|FNMATCH_GNU)$/ {next}
+ /^AC_REPLACE_FNMATCH$/ {next}
+
+ # Obsolete, checked in semantics.
+ /^AC_FUNC_WAIT3$/ {next}
+ /^AC_FUNC_SETVBUF_REVERSED$/ {next}
+ /^AC_SYS_RESTARTABLE_SYSCALLS$/ {next}
+
+ # Not intended to be invoked at the top level.
+ /^AC_INCLUDES_DEFAULT$/ {next}
+
+ # AC_INIT includes all the AC_INIT macros.
+ # There is an infinite m4 recursion if AC_INIT is used twice.
+ /^AC_INIT/ {next}
+
+ # Checked in semantics.
+ /^AC_(PROG_CC|C_CONST|C_VOLATILE)$/ {next}
+ /^AC_PATH_XTRA$/ {next}
+
+ # Requires a working C++ compiler, which is not a given.
+ /^AC_PROG_CXX_C_O$/ {next}
+
+ # Already tested by AT_CHECK_MACRO.
+ /^AC_OUTPUT$/ {next}
+
+ # Tested alongside m4_divert_text.
+ /^AC_PRESERVE_HELP_ORDER$/ {next}
+'
+
+
+# ac_exclude_script
+# -----------------
+# Build a single awk script out of the above.
+ac_exclude_script="$exclude_list $ac_exclude_list {print}"
+
+
+# au_exclude_list
+# ---------------
+# Check all AU_DEFUN'ed macros with AT_CHECK_AU_MACRO, except these.
+au_exclude_list='
+ # Empty.
+ /^AC_(C_CROSS|PROG_CC_STDC)$/ {next}
+
+ # Use AC_REQUIRE.
+ /^AC_(CYGWIN|MINGW32|EMXOS2)$/ {next}
+
+ # Already in configure.ac.
+ /^AC_(INIT|OUTPUT)$/ {next}
+
+ # AC_LANG_SAVE needs user interaction to be removed.
+ # AC_LANG_RESTORE cannot be used alone.
+ /^AC_LANG_(SAVE|RESTORE)$/ {next}
+
+ # Need arguments and are tested elsewhere.
+ /^AC_(LINK_FILES|PREREQ)$/ {next}
+'
+
+# au_exclude_script
+# -----------------
+# Build a single awk script out of the above.
+au_exclude_script="$exclude_list $au_exclude_list {print}"
+
+
+## ------------------------- ##
+## Creating the test files. ##
+## ------------------------- ##
+
+for file in $src
+do
+ base=`echo "$file" | sed 's|.*[\\/]||;s|\..*||'`
+ # Get the list of macros which are defined in Autoconf level.
+ # Get rid of the macros we are not interested in.
+ sed -n -e 's/^AC_DEFUN(\[*\([a-zA-Z0-9_]*\).*$/\1/p' \
+ -e 's/^AC_DEFUN_ONCE(\[*\([a-zA-Z0-9_]*\).*$/\1/p' $file |
+ awk "$ac_exclude_script" |
+ sort -u >acdefuns
+
+ # Get the list of macros which are defined in Autoupdate level.
+ sed -n 's/^AU_DEFUN(\[*\([a-zA-Z][a-zA-Z0-9_]*\).*$/\1/p' $file |
+ awk "$au_exclude_script" |
+ sort -u >audefuns
+
+ # Filter out required macros.
+ {
+ sed 's/^ *//' <<MK_EOF
+ # Generated by $as_me. -*- Autotest -*-
+
+ ## --------------------- ##
+ ## Do not edit by hand. ##
+ ## --------------------- ##
+
+ # Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+ # 2010 Free Software Foundation, Inc.
+
+ AT_BANNER([Testing autoconf/$base macros.])
+
+MK_EOF
+
+ echo "# Modern macros."
+ comm -23 acdefuns requires | sed 's/.*/AT_CHECK_MACRO([&])/'
+ echo
+ echo "# Obsolete macros."
+ comm -23 audefuns requires | sed 's/.*/AT_CHECK_AU_MACRO([&])/'
+ } >ac$base.tat
+
+ # In one atomic step so that if something above fails, the trap
+ # preserves the old version of the file. If there is nothing to
+ # check, output /rien du tout/[1].
+ if grep AT_CHECK ac$base.tat >/dev/null 2>&1; then
+ mv -f ac$base.tat ac$base.at
+ else
+ rm -f ac$base.tat ac$base.at
+ touch ac$base.at
+ fi
+ # Help people not to update these files by hand.
+ chmod a-w ac$base.at
+done
+
+rm -f acdefuns audefuns requires
+
+trap '' 0
+exit 0
+
+# [1] En franc,ais dans le texte.
diff --git a/tests/mktests.stamp b/tests/mktests.stamp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/mktests.stamp
diff --git a/tests/semantics.at b/tests/semantics.at
new file mode 100644
index 0000000..de54cf8
--- /dev/null
+++ b/tests/semantics.at
@@ -0,0 +1,746 @@
+# -*- Autotest -*-
+
+AT_BANNER([Semantics.])
+
+# Copyright (C) 2000-2002, 2004-2007, 2009-2012 Free Software
+# Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+## -------------------------------- ##
+## Members of the AC_CHECK family. ##
+## -------------------------------- ##
+
+
+# AC_CHECK_LIB
+# ------------
+# Well, I can't imagine a system where `cos' is neither in libc, nor
+# in libm. Nor can I imagine a lib more likely to exists than libm.
+# But there are systems without libm, on which we don't want to have
+# this test fail, so exit successfully if `cos' is in libc.
+AT_CHECK_MACRO([AC_CHECK_LIB],
+[AC_TRY_LINK_FUNC(cos,
+ [AC_MSG_ERROR([`cos' is in `libc'], 77)])
+
+AC_CHECK_LIB(m, cos,,
+ [AC_MSG_ERROR([cannot find `cos' in `libm'])])
+
+# No kidding, using variables was broken in 2.50 :(
+ac_sin=sin
+AC_CHECK_LIB(m, $ac_sin,,
+ [AC_MSG_ERROR([cannot find `\$ac_sin' (= `$ac_sin') in `libm'])])
+
+ac_m=m
+AC_CHECK_LIB($ac_m, acos,,
+ [AC_MSG_ERROR([cannot find `acos' in `\$ac_m' (= `$ac_m')])])
+
+ac_asin=asin
+AC_CHECK_LIB($ac_m, $ac_asin,,
+ [AC_MSG_ERROR([cannot find `\$ac_asin' (= `$ac_asin') in `\$ac_m' (= `$ac_m')])])
+
+# But if the bug is in the caching mechanism, then be sure we
+# correctly detect failures.
+
+AC_CHECK_LIB(m, cossack,
+ [AC_MSG_ERROR([found `cossack' in `libm'])])
+
+# No kidding, using variables was broken in 2.50 :(
+ac_sinner=sinner
+AC_CHECK_LIB(m, $ac_sinner,
+ [AC_MSG_ERROR([found `\$ac_sinner' (= `$ac_sinner') in `libm'])])
+
+ac_m=m
+AC_CHECK_LIB($ac_m, acossack,
+ [AC_MSG_ERROR([found `acossack' in `\$ac_m' (= `$ac_m')])])
+
+ac_asinner=asinner
+AC_CHECK_LIB($ac_m, $ac_asinner,
+ [AC_MSG_ERROR([found `\$ac_asinner' (= `$ac_asinner') in `\$ac_m' (= `$ac_m')])])
+
+])
+
+
+# AC_SEARCH_LIBS
+# --------------
+AT_CHECK_MACRO([AC_SEARCH_LIBS],
+[
+AC_SEARCH_LIBS(cos, oser m ust,,
+ [AC_MSG_ERROR([cannot find `cos'])])
+
+case "$ac_cv_search_cos" in
+ -loser|-lust) AC_MSG_ERROR([jeez, $ac_cv_search_cos must be a cool library!]) ;;
+esac
+])
+
+
+# AC_SEARCH_LIBS (none needed)
+# ----------------------------
+AT_CHECK_MACRO([AC_SEARCH_LIBS (none needed)],
+[
+AC_SEARCH_LIBS(printf, oser c ust,,
+ [AC_MSG_ERROR([cannot find `printf'])])
+
+case "$ac_cv_search_printf" in
+ -loser|-lust) AC_MSG_ERROR([jeez, $ac_cv_search_printf must be a cool library!]) ;;
+ -lc) AC_MSG_ERROR([huh, you need to give -lc?])
+esac
+])
+
+
+# AC_CHECK_DECLS
+# --------------
+# Check that it performs the correct actions:
+AT_CHECK_MACRO([AC_CHECK_DECLS],
+[[AC_CHECK_DECLS([yes, no, myenum, mystruct, myfunc, mymacro1, mymacro2],,,
+ [[int yes = 1;
+ enum { myenum };
+ struct { int x[20]; } mystruct;
+ extern int myfunc();
+ #define mymacro1(arg) arg
+ #define mymacro2]])
+ # The difference in space-before-open-paren is intentional.
+ AC_CHECK_DECLS([basenam (char *), dirnam(char *),
+ [moreargs (char, short, int, long, void *, char [], float, double)]],,,
+ [[#ifdef __cplusplus
+ extern "C++" char *basenam (char *);
+ extern "C++" const char *basenam (const char *);
+ #else
+ extern char *basenam (const char *);
+ #endif
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ extern int moreargs (char, short, int, long, void *,
+ char [], float, double);
+ #ifdef __cplusplus
+ }
+ #endif
+ ]])
+ AC_CHECK_DECL([declared (char *)],, [AS_EXIT([1])],
+ [[#ifdef __cplusplus
+ extern "C++" char *declared (char *);
+ extern "C++" const char *declared (const char *);
+ #else
+ extern char *declared (const char *);
+ #endif
+ ]])
+ AC_CHECK_DECL([undeclared (char *)], [AS_EXIT([1])],, [[]])
+]],
+[AT_CHECK_DEFINES(
+[#define HAVE_DECL_BASENAM 1
+#define HAVE_DECL_DIRNAM 0
+#define HAVE_DECL_MOREARGS 1
+#define HAVE_DECL_MYENUM 1
+#define HAVE_DECL_MYFUNC 1
+#define HAVE_DECL_MYMACRO1 1
+#define HAVE_DECL_MYMACRO2 1
+#define HAVE_DECL_MYSTRUCT 1
+#define HAVE_DECL_NO 0
+#define HAVE_DECL_YES 1
+])])
+
+
+# AC_CHECK_FUNCS
+# --------------
+# Check that it performs the correct actions:
+# Must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
+AT_CHECK_MACRO([AC_CHECK_FUNCS],
+[AC_CHECK_FUNCS(printf autoconf_ftnirp)],
+[AT_CHECK_DEFINES(
+[/* #undef HAVE_AUTOCONF_FTNIRP */
+#define HAVE_PRINTF 1
+])])
+
+
+# AC_REPLACE_FUNCS
+# ----------------
+# Check that it performs the correct actions: autoconf_ftnirp.c must
+# be compiled, and must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
+# FIXME: Maybe check the traces?
+AT_SETUP([AC_REPLACE_FUNCS])
+
+AT_DATA([config.in],
+[@LIBOBJS@
+])
+
+AT_CONFIGURE_AC(
+[AC_CONFIG_FILES([config.libobjs:config.in])
+AC_REPLACE_FUNCS([printf \
+autoconf_ftnirp])
+funcs='fprintf fopen autoconf_ftnirpf'
+AH_TEMPLATE([HAVE_FOPEN], [])
+AH_TEMPLATE([HAVE_FPRINTF], [])
+AH_TEMPLATE([HAVE_AUTOCONF_FTNIRPF], [])
+AC_REPLACE_FUNCS([\
+$funcs])
+AS_UNSET([funcs])])
+
+AT_CHECK_AUTOCONF([-W obsolete])
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
+AT_CHECK_ENV
+AT_CHECK_DEFINES(
+[/* #undef HAVE_AUTOCONF_FTNIRP */
+/* #undef HAVE_AUTOCONF_FTNIRPF */
+#define HAVE_FOPEN 1
+#define HAVE_FPRINTF 1
+#define HAVE_PRINTF 1
+])
+
+AT_CHECK([sed 's/ */ /g;s/^ //;s/ $//' config.libobjs], [],
+ [${LIBOBJDIR}autoconf_ftnirp$U.o ${LIBOBJDIR}autoconf_ftnirpf$U.o
+])
+
+AT_CLEANUP
+
+
+# AC_CHECK_HEADERS
+# ----------------
+# Check that it performs the correct actions:
+# Must define HAVE_STDIO_H, but not HAVE_AUTOCONF_IO_H.
+AT_SETUP([AC_CHECK_HEADERS])
+
+AT_DATA([autoconf_io.h],
+[blah blah
+])
+
+AT_CONFIGURE_AC([AC_CHECK_HEADERS(stdio.h autoconf_io.h)])
+AT_CHECK_AUTOCONF([-W obsolete])
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE([CPPFLAGS=-I.], [0], [ignore],
+[configure: WARNING: autoconf_io.h: present but cannot be compiled
+configure: WARNING: autoconf_io.h: check for missing prerequisite headers?
+configure: WARNING: autoconf_io.h: see the Autoconf documentation
+configure: WARNING: autoconf_io.h: section "Present But Cannot Be Compiled"
+configure: WARNING: autoconf_io.h: proceeding with the compiler's result
+])
+AT_CHECK_ENV
+AT_CHECK_DEFINES(
+[/* #undef HAVE_AUTOCONF_IO_H */
+#define HAVE_STDIO_H 1
+])
+
+AT_CLEANUP
+
+
+# AC_CHECK_HEADERS_OLD
+# --------------------
+# Check that it performs the correct actions:
+# Must not check prerequisites, hence define header2.h
+AT_SETUP([AC_CHECK_HEADERS (preprocessor test)])
+
+AT_DATA([header1.h],
+[typedef int foo;
+])
+
+AT_DATA([header2.h],
+[typedef foo bar;
+])
+
+AT_CONFIGURE_AC([AC_CHECK_HEADERS(header2.h, [], [], -)])
+
+AT_CHECK_AUTOCONF([-W obsolete])
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
+AT_CHECK_ENV
+AT_CHECK_DEFINES(
+[#define HAVE_HEADER2_H 1
+])
+
+AT_CLEANUP
+
+
+# AC_CHECK_HEADERS_NEW
+# --------------------
+# Check that it performs the correct actions:
+# Must check prerequisites, hence define header2.h but not header3.h
+AT_SETUP([AC_CHECK_HEADERS (compiler test)])
+
+AT_DATA([header1.h],
+[typedef int foo;
+])
+
+AT_DATA([header2.h],
+[typedef foo bar;
+])
+
+AT_DATA([header3.h],
+[typedef bar wow;
+])
+
+AT_CONFIGURE_AC(
+[AC_CHECK_HEADERS(header2.h header3.h, [], [], [[@%:@include "header1.h"]])])
+
+AT_CHECK_AUTOCONF([-W obsolete])
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
+AT_CHECK_ENV
+AT_CHECK_DEFINES(
+[#define HAVE_HEADER2_H 1
+/* #undef HAVE_HEADER3_H */
+])
+
+AT_CLEANUP
+
+
+# AC_CHECK_MEMBER
+# ---------------
+# Check that it performs the correct actions.
+# Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
+AT_CHECK_MACRO([AC_CHECK_MEMBER],
+[[AC_CHECK_MEMBER([struct yes_s.yes],
+ [AC_DEFINE([HAVE_STRUCT_YES_S_YES], [1],
+ [Define to 1 if `yes' is a member of `struct yes_s'.])],,
+ [struct sub { int x; };
+ struct yes_s { int yes; struct sub substruct; };])
+ AC_CHECK_MEMBER([struct yes_s.no],
+ [AC_DEFINE([HAVE_STRUCT_YES_S_NO], [1],
+ [Define to 1 if `no' is a member of `struct yes_s'.])],,
+ [struct sub { int x; };
+ struct yes_s { int yes; struct sub substruct; };])
+ AC_CHECK_MEMBER([struct yes_s.substruct],
+ [AC_DEFINE([HAVE_STRUCT_YES_S_SUBSTRUCT], [1],
+ [Define to 1 if `substruct' is a member of `struct yes_s'.])],,
+ [struct sub { int x; };
+ struct yes_s { int yes; struct sub substruct; };])]],
+[AT_CHECK_DEFINES(
+[/* #undef HAVE_STRUCT_YES_S_NO */
+#define HAVE_STRUCT_YES_S_SUBSTRUCT 1
+#define HAVE_STRUCT_YES_S_YES 1
+])])
+
+# AC_CHECK_MEMBERS
+# ----------------
+# Check that it performs the correct actions.
+# Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
+AT_CHECK_MACRO([AC_CHECK_MEMBERS],
+[[AC_CHECK_MEMBERS([struct yes_s.yes, struct yes_s.no, struct yes_s.substruct],,,
+ [struct sub { int x; };
+ struct yes_s { int yes; struct sub substruct; };])]],
+[AT_CHECK_DEFINES(
+[/* #undef HAVE_STRUCT_YES_S_NO */
+#define HAVE_STRUCT_YES_S_SUBSTRUCT 1
+#define HAVE_STRUCT_YES_S_YES 1
+])
+AT_CHECK([grep 'yes.*member of.*yes_s' config.h], [], [ignore])
+])
+
+
+# AC_CHECK_ALIGNOF
+# ----------------
+AT_CHECK_MACRO_CROSS([AC_CHECK_ALIGNOF],
+[[AC_CHECK_ALIGNOF(char)
+AC_CHECK_ALIGNOF(charchar,
+[[#include <stddef.h>
+#include <stdio.h>
+typedef char charchar[2];]])
+AC_CHECK_ALIGNOF(charcharchar)
+]],
+[AT_CHECK_DEFINES(
+[#define ALIGNOF_CHAR 1
+#define ALIGNOF_CHARCHAR 1
+#define ALIGNOF_CHARCHARCHAR 0
+])])
+
+
+# AC_CHECK_ALIGNOF struct
+# -----------------------
+AT_CHECK_MACRO_CROSS([AC_CHECK_ALIGNOF struct],
+[[AC_CHECK_ALIGNOF([struct { char c; }])
+AC_CHECK_ALIGNOF([struct nosuchstruct])
+]],
+[AT_CHECK([[grep "#define ALIGNOF_STRUCT___CHAR_C___ [1-9]" config.h]],
+ 0, ignore)
+AT_CHECK([[grep "#define ALIGNOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
+ 0, ignore)
+])
+
+# AC_CHECK_SIZEOF
+# ---------------
+AT_CHECK_MACRO_CROSS([AC_CHECK_SIZEOF],
+[[AC_CHECK_SIZEOF(char)
+AC_CHECK_SIZEOF(charchar,,
+[[#include <stdio.h>
+typedef char charchar[2];]])
+AC_CHECK_SIZEOF(charcharchar)
+]],
+[AT_CHECK_DEFINES(
+[#define SIZEOF_CHAR 1
+#define SIZEOF_CHARCHAR 2
+#define SIZEOF_CHARCHARCHAR 0
+])])
+
+
+# AC_CHECK_SIZEOF struct
+# ----------------------
+AT_CHECK_MACRO_CROSS([AC_CHECK_SIZEOF struct],
+[[AC_C_CONST
+AC_CHECK_SIZEOF([struct x], [], [struct x { char c; int x; };])
+AC_CHECK_SIZEOF([const struct x], [], [struct x { const char *p; int x; };])
+AC_CHECK_SIZEOF([struct nosuchstruct])
+# Taken from autoconf.texi:Generic Compiler Characteristics.
+AC_CHECK_SIZEOF([int *])
+]],
+[AT_CHECK([[grep "#define SIZEOF_STRUCT_X [1-9]" config.h]],
+ 0, ignore)
+AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT_X [1-9]" config.h]],
+ 0, ignore)
+AT_CHECK([[grep "#define SIZEOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
+ 0, ignore)
+AT_CHECK([[grep "#define SIZEOF_INT_P [1-9]" config.h]],
+ 0, ignore)
+])
+
+
+# AC_CHECK_TYPES
+# --------------
+# Check that it performs the correct actions.
+# Must define HAVE_STRUCT_YES_S, HAVE_INT, but not HAVE_STRUCT_NO_S.
+# `int' and `struct yes_s' are both checked to test both the compiler
+# builtin types, and defined types.
+AT_CHECK_MACRO([AC_CHECK_TYPES],
+[[AC_CHECK_TYPES([int, struct yes_s, struct no_s],,,
+ [struct yes_s { int yes ;} ;])]],
+[AT_CHECK_DEFINES(
+[#define HAVE_INT 1
+/* #undef HAVE_STRUCT_NO_S */
+#define HAVE_STRUCT_YES_S 1
+])])
+
+
+# AC_CHECK_TYPES
+# --------------
+# Check that we properly dispatch properly to the old implementation
+# or to the new one.
+AT_SETUP([AC_CHECK_TYPES: backward compatibility])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+define([_AC_CHECK_TYPE_NEW], [NEW])
+define([_AC_CHECK_TYPE_OLD], [OLD])
+#(cut-from-here
+AC_CHECK_TYPE(ptrdiff_t)
+AC_CHECK_TYPE(ptrdiff_t, int)
+AC_CHECK_TYPE(quad, long long int)
+AC_CHECK_TYPE(table_42, [int[42]])
+# Nice machine!
+AC_CHECK_TYPE(uint8_t, uint65536_t)
+AC_CHECK_TYPE(a,b,c,d)
+#to-here)
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK([[sed -e '/^#(cut-from-here/,/^#to-here)/!d' -e '/^#/d' configure]],
+ 0,
+ [NEW
+OLD
+OLD
+OLD
+OLD
+NEW
+])
+
+AT_CLEANUP
+
+
+# AC_CHECK_FILES
+# --------------
+# FIXME: To really test HAVE_AC_EXISTS2 and HAVE_AC_MISSING2 we need to
+# open AH_TEMPLATE to `configure.ac', which is not yet the case.
+AT_CHECK_MACRO([AC_CHECK_FILES],
+[touch at-exists1 at-exists2
+ac_exists2=at-exists2
+ac_missing2=at-missing2
+AC_CHECK_FILES(at-exists1 at-missing1 $ac_exists2 $ac_missing2)
+rm at-exists1 at-exists2],
+[AT_CHECK_DEFINES(
+[#define HAVE_AT_EXISTS1 1
+/* #undef HAVE_AT_MISSING1 */
+])])
+
+
+
+## ------------------------------ ##
+## AC_CHECK_PROG & AC_PATH_PROG. ##
+## ------------------------------ ##
+
+
+# AT_CHECK_PROGS_PREPARE
+# ----------------------
+# Create a sub directory `path' with 6 subdirs which all 7 contain
+# an executable `tool'. `6' contains a `better' tool.
+m4_define([AT_CHECK_PROGS_PREPARE],
+[mkdir path
+
+cat >path/tool <<\EOF
+#! /bin/sh
+exit 0
+EOF
+chmod +x path/tool
+
+for i in 1 2 3 4 5 6
+do
+ mkdir path/$i
+ cp path/tool path/$i
+done
+cp path/tool path/6/better])
+
+
+# -------------------------------- #
+# AC_CHECK_PROG & AC_CHECK_PROGS. #
+# -------------------------------- #
+
+AT_SETUP([AC_CHECK_PROG & AC_CHECK_PROGS])
+
+AT_CHECK_PROGS_PREPARE
+
+AT_DATA([configure.ac],
+[[AC_INIT
+pwd=`pwd`
+p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
+path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
+fail=false
+
+AC_CHECK_PROG(TOOL1, tool, found, not-found, $path)
+test "$TOOL1" = found || fail=:
+
+# Yes, the semantics of this macro is weird.
+AC_CHECK_PROG(TOOL2, tool,, not-found, $path)
+test "$TOOL2" = not-found || fail=:
+
+AC_CHECK_PROG(TOOL3, tool, tool, not-found, $path, $pwd/path/1/tool)
+test "$TOOL3" = "$pwd/path/2/tool" || fail=:
+
+AC_CHECK_PROG(TOOL4, better, better, not-found, $path, $pwd/path/1/tool)
+test "$TOOL4" = better || fail=:
+
+# When a tool is not found, and no value is given for not-found,
+# the variable is left empty.
+AC_CHECK_PROGS(TOOL5, missing,, $path)
+test -z "$TOOL5" || fail=:
+
+AC_CHECK_PROGS(TOOL6, missing tool better,, $path)
+test "$TOOL6" = tool || fail=:
+
+# No AC-OUTPUT, we don't need config.status.
+$fail &&
+ AC_MSG_ERROR([[CHECK_PROG failed]])
+AS_EXIT(0)
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+
+## ---------------- ##
+## AC_C_BIGENDIAN. ##
+## ---------------- ##
+
+AT_SETUP([AC_C_BIGENDIAN])
+AT_KEYWORDS([cross])
+
+# Make sure that AC_C_BIGENDIAN behave the same whether we are
+# cross-compiling or not.
+
+_AT_CHECK_AC_MACRO(
+ [[AC_C_BIGENDIAN(
+ [ac_endian=big],
+ [ac_endian=little],
+ [ac_endian=unknown],
+ [ac_endian=universal])
+ echo $ac_endian > at-endian
+]])
+
+rm -f config.hin # So that next run of autoheader is quiet.
+_AT_CHECK_AC_MACRO(
+ [[# Force cross compiling.
+ cross_compiling=yes
+ ac_tool_warned=yes
+ AC_C_BIGENDIAN(
+ [ac_endian=big],
+ [ac_endian=little],
+ [ac_endian=unknown],
+ [ac_endian=universal])
+ ac_prevendian=`cat at-endian`
+ # Check that we have found the same result as in the previous run
+ # or unknown (because the cross-compiling check is allowed to fail;
+ # although it might be interesting to suppress this comparison, just
+ # to know on which system it fails if it ever does).
+ if test $ac_endian != $ac_prevendian && test $ac_endian != unknown; then
+ AC_MSG_ERROR([unexpected endianness: first run found '$ac_prevendian' but second run found '$ac_endian'])
+ fi
+]])
+
+# Make sure AC_C_BIGENDIAN with no argument will create a config.h template
+# containing "WORDS_BIGENDIAN".
+AT_CONFIGURE_AC([[AC_C_BIGENDIAN]])
+# --force is necessary, the computer might be too fast.
+AT_CHECK_AUTOHEADER([--force])
+AT_CHECK([grep WORDS_BIGENDIAN config.hin], [], [ignore])
+
+AT_CLEANUP
+
+
+# ------------------------------ #
+# AC_PATH_PROG & AC_PATH_PROGS. #
+# ------------------------------ #
+
+AT_SETUP([AC_PATH_PROG & AC_PATH_PROGS])
+
+AT_CHECK_PROGS_PREPARE
+
+AT_DATA([configure.ac],
+[[AC_INIT
+pwd=`pwd`
+p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
+path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
+fail=false
+
+AC_PATH_PROG(TOOL1, tool, not-found, $path)
+test "$TOOL1" = "$pwd/path/1/tool" || fail=:
+
+AC_PATH_PROG(TOOL2, better, not-found, $path)
+test "$TOOL2" = "$pwd/path/6/better" || fail=:
+
+# When a tool is not found, and no value is given for not-found,
+# the variable is left empty.
+AC_PATH_PROGS(TOOL3, missing,, $path)
+test -z "$TOOL3" || fail=:
+
+AC_PATH_PROGS(TOOL4, missing tool better,, $path)
+test "$TOOL4" = "$pwd/path/1/tool" || fail=:
+
+# No AC-OUTPUT, we don't need config.status.
+$fail &&
+ AC_MSG_ERROR([[PATH_PROG failed]])
+AS_EXIT(0)
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+
+# ----------------------------- #
+# AC_PATH_PROGS_FEATURE_CHECK. #
+# ----------------------------- #
+
+AT_SETUP([AC_PATH_PROGS_FEATURE_CHECK])
+
+# This test doesn't work if `pwd` contains white space
+case `pwd` in
+ *\ * | *\ *) AT_CHECK([exit 77]) ;;
+esac
+
+AT_CHECK_PROGS_PREPARE
+
+AT_DATA([configure.ac],
+[[AC_INIT
+pwd=`pwd`
+p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
+path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
+fail=false
+
+# Find first candidate and stop search
+AC_PATH_PROGS_FEATURE_CHECK(TOOL1, [tool better],
+ [$ac_path_TOOL1 && ac_cv_path_TOOL1=$ac_path_TOOL1 ac_path_TOOL1_found=:],
+ fail=:, $path)
+test -z "$TOOL1" || fail=:
+test "$ac_cv_path_TOOL1" = "$pwd/path/1/tool" || fail=:
+
+# Keep searching each candidate
+AC_PATH_PROGS_FEATURE_CHECK(TOOL2, [tool better],
+ [$ac_path_TOOL2 && ac_cv_path_TOOL2=$ac_path_TOOL2],
+ fail=:, $path)
+test "$ac_cv_path_TOOL2" = "$pwd/path/6/better" || fail=:
+
+# Only accept better candidate
+AC_PATH_PROGS_FEATURE_CHECK(TOOL3, [tool better],
+ [case "$ac_path_TOOL3" in #(
+ *better) ac_cv_path_TOOL3=$ac_path_TOOL3;;
+ esac],
+ fail=:, $path)
+test "$ac_cv_path_TOOL3" = "$pwd/path/6/better" || fail=:
+
+# When a tool is not found, and no action is given for not-found,
+# the variable is left empty.
+AC_PATH_PROGS_FEATURE_CHECK(TOOL4, missing,
+ [ac_cv_path_TOOL4=$ac_path_TOOL4], [], $path)
+test -z "$ac_cv_path_TOOL4" || fail=:
+
+# Test action when tool is not found
+AC_PATH_PROGS_FEATURE_CHECK(TOOL5, missing, [],
+ [ac_cv_path_TOOL5='not found'], $path)
+test "$ac_cv_path_TOOL5" = "not found" || fail=:
+
+# Test that pre-set tool bypasses feature test
+TOOL6=$pwd/path/6/better
+AC_PATH_PROGS_FEATURE_CHECK(TOOL6, tool, fail=:, fail=:, $path)
+test "$ac_cv_path_TOOL6" = "$pwd/path/6/better" || fail=:
+
+# A blank pre-set does not bypass feature test
+TOOL7=
+AC_PATH_PROGS_FEATURE_CHECK(TOOL7, [tool better],
+ [$ac_path_TOOL7 && ac_cv_path_TOOL7=$ac_path_TOOL7 ac_path_TOOL7_found=:],
+ fail=:, $path)
+test -z "$TOOL7" || fail=:
+test "$ac_cv_path_TOOL7" = "$pwd/path/1/tool" || fail=:
+
+# No AC-OUTPUT, we don't need config.status.
+$fail &&
+ AC_MSG_ERROR([[PATH_PROG failed]])
+AS_EXIT(0)
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+
+
+## -------------- ##
+## AC_PATH_XTRA. ##
+## -------------- ##
+
+
+AT_SETUP([AC_PATH_XTRA])
+
+_AT_CHECK_AC_MACRO([AC_PATH_XTRA])
+
+# Check X_DISPLAY_MISSING.
+AT_CHECK_CONFIGURE([--without-x])
+AT_CHECK_DEFINES(
+[#define X_DISPLAY_MISSING 1
+])
+
+AT_CLEANUP
+
+
+## ------------------------------- ##
+## Obsolete non-updatable macros. ##
+## ------------------------------- ##
+
+
+AT_CHECK_MACRO([AC_SYS_RESTARTABLE_SYSCALLS], , ,[-W no-obsolete])
+AT_CHECK_MACRO([AC_FUNC_SETVBUF_REVERSED], , ,[-W no-obsolete])
+AT_CHECK_MACRO([AC_FUNC_WAIT3], , ,[-W no-obsolete])
diff --git a/tests/statesave.m4 b/tests/statesave.m4
new file mode 100644
index 0000000..2f63ae5
--- /dev/null
+++ b/tests/statesave.m4
@@ -0,0 +1,43 @@
+# statesave.m4 serial 2
+
+# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# AC_STATE_SAVE(FILE)
+# -------------------
+# Save the shell variables and directory listing. AT_CHECK_ENV uses these to
+# confirm that no test modifies variables outside the Autoconf namespace or
+# leaves temporary files. AT_CONFIG_CMP uses the variable dumps to confirm
+# that tests have the same side effects regardless of caching.
+#
+# The sed script duplicates uniq functionality (thanks to 'info sed
+# uniq' for the recipe), in order to avoid a MacOS 10.5 bug where
+# readdir can list a file multiple times in a rapidly changing
+# directory, while avoiding yet another fork.
+m4_defun([AC_STATE_SAVE],
+[(set) 2>&1 | sort >state-env.$1
+ls | sed '/^at-/d;/^state-/d;/^config\./d
+ h
+ :b
+ $b
+ N
+ /^\(.*\)\n\1$/ {
+ g
+ bb
+ }
+ $b
+ P
+ D' >state-ls.$1
+])# AC_STATE_SAVE
diff --git a/tests/suite.at b/tests/suite.at
new file mode 100644
index 0000000..10c8c4f
--- /dev/null
+++ b/tests/suite.at
@@ -0,0 +1,79 @@
+# Validation suite for Autoconf -*- Autotest -*-
+
+# Copyright (C) 2000-2001, 2003-2005, 2009-2012 Free Software
+# Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Run the tests from the lowest level to the highest level, and from
+# the most selective to the easiest.
+
+# The executables.
+# Even the tests on M4sugar and M4sh use `autoconf', so check it first.
+m4_include([tools.at])
+
+# M4sugar.
+m4_include([m4sugar.at])
+
+# M4sh.m4.
+m4_include([m4sh.at])
+
+# Autotest.
+m4_include([autotest.at])
+
+# Autoconf base macros.
+m4_include([base.at])
+
+# Testing config.status
+# ---------------------
+# Actually should be named config.status.at but I fear problems with
+# the name. Does no `checking ...' at all, but exercises only code
+# which following section use too. Hence, run it first.
+m4_include([torture.at])
+
+# Checking AC_PROG_CC, AC_COMPILE_IFELSE etc.
+m4_include([compile.at])
+
+# Language support.
+m4_include([aclang.at])
+m4_include([c.at])
+m4_include([acc.at])
+m4_include([fortran.at])
+m4_include([acfortran.at])
+m4_include([erlang.at])
+m4_include([go.at])
+m4_include([acgo.at])
+
+# Checking that AC_CHECK_FOO macros work properly.
+m4_include([semantics.at])
+
+# Blind testing the macros.
+# Include them as is suggested for a `configure.ac', as looking for
+# for types requires looking for headers etc.
+m4_include([acgeneral.at])
+m4_include([acstatus.at])
+m4_include([acautoheader.at])
+m4_include([acautoupdate.at])
+m4_include([acspecific.at])
+m4_include([acprograms.at])
+m4_include([acheaders.at])
+m4_include([actypes.at])
+m4_include([acfunctions.at])
+m4_include([aclibs.at])
+
+# Compatibility with foreign tools.
+m4_include([foreign.at])
+
+# Autoscan test
+m4_include([autoscan.at])
diff --git a/tests/tools.at b/tests/tools.at
new file mode 100644
index 0000000..31d4aad
--- /dev/null
+++ b/tests/tools.at
@@ -0,0 +1,1337 @@
+# -*- Autotest -*-
+
+AT_BANNER([Executables (autoheader, autoupdate...).])
+
+# Copyright (C) 2000-2001, 2003-2004, 2006-2012 Free Software
+# Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+## ----------------------------- ##
+## Syntax of the shell scripts. ##
+## ----------------------------- ##
+
+# 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 shell scripts])
+
+AT_CHECK([test "$ac_cv_sh_n_works" = yes || exit 77])
+
+# Specify the absolute name of the tool, as some shells don't honor PATH when
+# running `sh PROG'.
+
+AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/bin/autoconf"])
+AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/tests/autoconf"])
+AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/tests/testsuite"])
+
+# These are not built, they are in the src tree.
+AT_CHECK_SHELL_SYNTAX(["$abs_top_srcdir/build-aux/install-sh"])
+AT_CHECK_SHELL_SYNTAX(["$abs_top_srcdir/build-aux/missing"])
+
+AT_CLEANUP
+
+
+
+
+## ---------------------------- ##
+## Syntax of the Perl scripts. ##
+## ---------------------------- ##
+
+AT_SETUP([Syntax of the Perl scripts])
+
+AT_CHECK_PERL_SYNTAX([autoheader])
+AT_CHECK_PERL_SYNTAX([autom4te])
+AT_CHECK_PERL_SYNTAX([autoreconf])
+AT_CHECK_PERL_SYNTAX([autoscan])
+AT_CHECK_PERL_SYNTAX([autoupdate])
+AT_CHECK_PERL_SYNTAX([ifnames])
+
+AT_CLEANUP
+
+
+
+
+## ------------------ ##
+## autom4te's cache. ##
+## ------------------ ##
+
+AT_SETUP([autom4te cache])
+
+AT_DATA_M4SUGAR([[script.4s]],
+[[m4_include([foo])
+]])
+
+# Everything is OK.
+touch foo
+AT_CHECK_M4SUGAR
+
+# We moved a file: it should fail
+mkdir sub
+mv foo sub
+AT_CHECK_M4SUGAR([], [1], [],
+[m4:script.4s:1: cannot open `foo': No such file or directory
+autom4te: m4 failed with exit status: 1
+])
+
+# But if we change the main file, then we should no longer complain of
+# missing files.
+AT_DATA_M4SUGAR([[script.4s]],
+[[m4_include([sub/foo])
+]])
+AT_CHECK_M4SUGAR
+
+AT_CLEANUP
+
+
+# autom4te --force
+# ----------------
+
+AT_SETUP([autom4te --force])
+
+AT_DATA([file.m4],
+[[right
+]])
+AT_CHECK_AUTOM4TE([-o file file.m4])
+
+# Create a file whose time stamp is in the future.
+# (next year)-01-01 00:01 UTC should always be in the future,
+# even on slow machines.
+echo BAD >file
+this_year=`TZ=UTC0 date +%Y`
+AS_VAR_ARITH([next_year], [$this_year + 1])
+TZ=UTC0 touch -t ${next_year}01010001 file
+
+AT_CHECK_AUTOM4TE([--force -o file file.m4])
+AT_CHECK([cat file], 0,
+[[right
+]])
+
+AT_CLEANUP
+
+
+# autom4te and file names containing whitespace
+# ---------------------------------------------
+
+AT_SETUP([autom4te and whitespace in file names])
+
+x=
+export x
+rm -f a b
+for funny in \
+ 'with funny '\'' $x & #! name' \
+ 'with funny \ '\'' \'\'' " <a >b * ? name ' # "restore font-lock
+do
+ funny=`func_sanitize_file_name "$funny"`
+ file=" file $funny"
+ outfile="$file out "
+ dir=`func_sanitize_dir_name " dir $funny"`
+ cachedir=" cache$dir"
+ TMPDIR=" tmp$dir"
+ export TMPDIR
+
+ # skip if we cannot create such a file or directory
+ AT_CHECK([mkdir "$dir" "$cachedir" "$TMPDIR" && touch "$file" || exit 77])
+
+ cat >"$file" <<'END'
+[m4@&t@_init[]m4@&t@_include(foo.m4)
+m4@&t@_divert([])d@&t@nl
+FOO]
+END
+ cat >"$dir"/foo.m4 <<'END'
+[m4@&t@_define([FOO], [bar])]
+END
+
+ AT_CHECK_AUTOM4TE([-C "$cachedir" -B "$dir" --language=m4sugar -o "$outfile" "$file"])
+ AT_CHECK([cat "$outfile"], [],
+ [[bar
+]])
+ rm -rf "$outfile" "$cachedir"
+ AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar -o "$outfile" "$file"])
+ AT_CHECK([cat "$outfile"], [],
+ [[bar
+]])
+
+ # This exercises a slightly different code path and will catch an open with
+ # trailing whitespace:
+ cat >"$file" <<'END'
+[m4@&t@_init[]m4@&t@_include(foo.m4)
+m4@&t@_pattern_forbid([^bar$])
+m4@&t@_divert([])d@&t@nl
+FOO]
+END
+ rm -rf "$outfile" "$cachedir"
+ AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar -o "$outfile" "$file"],
+ [1], [], [stderr])
+ AT_CHECK([grep 'possibly undefined macro' stderr], [], [ignore])
+
+ cat >"$file" <<'END'
+[m4@&t@_init[]m4@&t@_include(foo.m4)
+m4@&t@_divert([])d@&t@nl]
+END
+ rm -rf "$file.m4f"
+ AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar --freeze -o "$file.m4f" "$file"])
+ AT_CHECK([test -s "$file.m4f"])
+
+ # Check --reload-state
+ AT_CHECK_AUTOM4TE([-C "$cachedir" --language=m4sugar -o "$outfile" "$file.m4f" /dev/null])
+
+ test ! -f b
+done
+
+AT_CLEANUP
+
+
+# autom4te --trace and unusual macro names
+# ----------------------------------------
+
+AT_SETUP([autom4te --trace and unusual macro names])
+
+AT_DATA([file.m4],
+[[
+]])
+AT_CHECK_AUTOM4TE([-t 'TR A CE' -t 'TR(A)CE' file.m4])
+
+AT_CLEANUP
+
+
+AT_SETUP([autom4te --trace and whitespace])
+
+dnl line numbering differs between m4 1.4.6 and 1.4.13 if we don't
+dnl go through a single line wrapper
+AT_DATA_M4SUGAR([file.m4],
+[[m4_define([foo], [m4_echo([ a
+b c ], [\
+d\
+])])
+foo
+]])
+AT_CHECK_AUTOM4TE([--language=m4sugar -t 'm4@&t@_echo' file.m4], [0],
+[[file.m4:5:m4@&t@_echo: a b c :d
+]])
+
+AT_CLEANUP
+
+
+## ------------------ ##
+## autoconf --trace. ##
+## ------------------ ##
+
+
+# autoconf --trace: user macros
+# -----------------------------
+AT_SETUP([autoconf --trace: user macros])
+
+AT_DATA([configure.ac],
+[[m4_define([active], [ACTIVE])
+m4_define([TRACE1], [TRACE2(m4_shift($@))])
+m4_define([TRACE2], [[$2], $1])
+
+# No arguments.
+TRACE1
+TRACE2
+
+# With arguments, single line.
+TRACE1(foo, @bar, @baz)
+TRACE1(foo, TRACE1(bar, baz))
+TRACE1(foo, active, baz)
+TRACE1(foo, [active], TRACE1(active, [active]))
+]])
+
+# Several --traces.
+AT_CHECK_AUTOCONF([-t TRACE1 -t TRACE2], 0,
+[[configure.ac:6:TRACE1:
+configure.ac:6:TRACE2:
+configure.ac:7:TRACE2:
+configure.ac:10:TRACE1:foo:@bar:@baz
+configure.ac:10:TRACE2:@bar:@baz
+configure.ac:11:TRACE1:bar:baz
+configure.ac:11:TRACE2:baz
+configure.ac:11:TRACE1:foo::baz
+configure.ac:11:TRACE2::baz
+configure.ac:12:TRACE1:foo:ACTIVE:baz
+configure.ac:12:TRACE2:ACTIVE:baz
+configure.ac:13:TRACE1:ACTIVE:active
+configure.ac:13:TRACE2:active
+configure.ac:13:TRACE1:foo:active::ACTIVE
+configure.ac:13:TRACE2:active::ACTIVE
+]])
+
+# Several line requests.
+AT_CHECK_AUTOCONF([[-t TRACE1:'
+[$1], [$2], [$3].']], 0,
+[[
+[], [], [].
+
+[foo], [@bar], [@baz].
+
+[bar], [baz], [].
+
+[foo], [], [baz].
+
+[foo], [ACTIVE], [baz].
+
+[ACTIVE], [active], [].
+
+[foo], [active], [].
+]])
+
+# ${sep}@.
+AT_CHECK_AUTOCONF([-t TRACE2:'${)===(}@'], 0,
+[[[]
+[]
+[@bar])===([@baz]
+[baz]
+[])===([baz]
+[ACTIVE])===([baz]
+[active]
+[active])===([])===([ACTIVE]
+]])
+
+# Arguments spanning multiple lines.
+AT_DATA([configure.ac],
+[[m4_define([TRACE], [])
+TRACE(foo
+bar,
+bar
+foo)
+]])
+
+AT_CHECK_AUTOCONF([-t TRACE:'$%'], 0,
+[[foo bar:bar foo
+]])
+
+AT_CLEANUP
+
+
+# autoconf --trace: builtins
+# --------------------------
+AT_SETUP([autoconf --trace: builtins])
+
+AT_DATA([configure.ac],
+[[define([active], [ACTIVE])
+]])
+
+AT_CHECK_AUTOCONF([[-t define | sed -n '$p']],
+ 0,
+[[configure.ac:1:define:active:ACTIVE
+]])
+
+# FIXME: Without `$1' the following test dies. Groumphf, once again to
+# dive into obscure feature interaction...
+# Note that using `-i' means we need the *.m4 files, not the *.m4f files,
+# hence we need srcdir, not builddir.
+AT_CHECK_AUTOCONF([[-t define:'$1' -i| sed -n '$p']],
+ 0,
+[[active
+]])
+
+AT_CLEANUP
+
+
+
+## ---------------------------- ##
+## autoconf: forbidden tokens. ##
+## ---------------------------- ##
+
+
+# autoconf: forbidden tokens, basic
+# ---------------------------------
+AT_SETUP([autoconf: forbidden tokens,[] basic])
+
+AT_DATA_M4SH([configure.ac],
+[[AS_INIT
+m4_foo
+_m4_bar
+AS_FOO
+_AS_BAR
+[dnl]
+]])
+
+dnl This test needs autom4te's cache, in spite of any ~/.autom4te.cfg.
+AT_DATA([.autom4te.cfg], [[
+begin-language: "Autoconf"
+args: --cache=autom4te.cache
+end-language: "Autoconf"
+begin-language: "Autoconf-without-aclocal-m4"
+args: --cache=autom4te.cache
+end-language: "Autoconf-without-aclocal-m4"
+]])
+
+AT_CHECK_AUTOCONF([], 1, [],
+[[configure.ac:2: error: possibly undefined macro: m4@&t@_foo
+ If this token and others are legitimate, please use m4@&t@_pattern_allow.
+ See the Autoconf documentation.
+configure.ac:3: error: possibly undefined macro: _m4@&t@_bar
+configure.ac:4: error: possibly undefined macro: AS@&t@_FOO
+configure.ac:5: error: possibly undefined macro: _AS@&t@_BAR
+configure.ac:6: error: possibly undefined macro: d@&t@nl
+]])
+# Second run should succeed and yield no output.
+AT_CHECK([autoconf])
+
+AT_CLEANUP
+
+
+# autoconf: forbidden tokens, exceptions
+# --------------------------------------
+AT_SETUP([autoconf: forbidden tokens,[] exceptions])
+
+AT_DATA_M4SH([configure.ac],
+[[AS_INIT
+
+# This is allowed in spite of the name.
+# It is on purpose that we check the case where there are several
+# tokens on the same line.
+m4_pattern_allow([^AS_ALLOWED$])
+NOT_AS_ALLOWED AS_ALLOWED AS_ALLOWED_NOT
+
+# Test forbidding.
+m4_pattern_forbid([^FORBIDDEN$])
+NOT_FORBIDDEN FORBIDDEN FORBIDDEN_NOT
+
+# Test Autoconf's patterns.
+AS_THIS_IS_INVALID and _AS_THIS_IS_INVALID_TOO
+BUT_AZ_THIS_IS_NOT ALTHOUGH_AS_THIS_IS
+# This is legal, although there is `AS_DEFINE' in there.
+BAS_DEFINE
+# AS_THIS_IS_A_COMMENT so just shut up.
+It would be very bad if Autoconf forgot to expand [AS_]INIT!
+]])
+
+AT_CHECK_AUTOCONF([], 1, [],
+[[configure.ac:1: error: possibly undefined macro: AS@&t@_INIT
+ If this token and others are legitimate, please use m4@&t@_pattern_allow.
+ See the Autoconf documentation.
+configure.ac:7: error: possibly undefined macro: AS@&t@_ALLOWED_NOT
+configure.ac:10: error: possibly undefined macro: FORBIDDEN
+configure.ac:14: error: possibly undefined macro: AS@&t@_THIS_IS_INVALID
+configure.ac:14: error: possibly undefined macro: _AS@&t@_THIS_IS_INVALID_TOO
+]])
+
+AT_CLEANUP
+
+
+# autoconf: automatically allowed tokens
+# --------------------------------------
+AT_SETUP([autoconf: automatically allowed tokens])
+
+AT_DATA_M4SH([configure.ac],
+[[AC_INIT
+m4_pattern_forbid([^FB_])
+AC_DEFINE([FB_ONE])
+AC_SUBST([FB_TWO])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+
+AT_CLEANUP
+
+
+# autoconf: do not forbid the empty token
+# ---------------------------------------
+AT_SETUP([autoconf: the empty token])
+
+AT_DATA_M4SH([configure.ac],
+[[m4_init[]m4_pattern_allow([^foo$])
+m4_divert([])dnl
+ line that begins with a space
+]])
+
+AT_CHECK_AUTOCONF
+
+AT_CLEANUP
+
+
+# autoconf: subdirectories
+# ------------------------
+AT_SETUP([autoconf: subdirectories])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_MKDIR_P
+AC_CONFIG_FILES(sub/foo)
+AC_OUTPUT
+]])
+
+mkdir sub
+
+AT_DATA([sub/foo.in],
+[[@MKDIR_P@
+]])
+
+AT_DATA([install-sh])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+AT_CHECK([[grep '^[^/].*/mkdir -p' sub/foo]], 1)
+
+AT_CLEANUP
+
+
+# autoconf: input from stdin
+# --------------------------
+AT_SETUP([autoconf: input from stdin])
+
+# Past Autoconf versions failed to read from stdin when other, non-frozen input
+# files were present.
+AT_DATA([aclocal.m4])
+
+AT_CHECK([echo 'AC_INIT(X, 1.0, bug-autoconf@gnu.org)' | autoconf -t AC_INIT -],
+ 0, [stdin:1:AC_INIT:X:1.0:bug-autoconf@gnu.org
+])
+AT_CHECK([echo 'AC_INIT(X, 2.0, bug-autoconf@gnu.org)' | autoconf -t AC_INIT -],
+ 0, [stdin:1:AC_INIT:X:2.0:bug-autoconf@gnu.org
+])
+
+AT_CLEANUP
+
+
+# autoconf: AC_AUTOCONF_VERSION
+# -----------------------------
+AT_SETUP([autoconf: AC_AUTOCONF_VERSION])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+version m4@&t@_defn([AC_AUTOCONF_VERSION]) version
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK([[grep 'version ]]AT_PACKAGE_VERSION[[ version' configure]],
+0, [ignore])
+
+AT_CLEANUP
+
+
+
+# autoconf: AC_PRESERVE_HELP_ORDER
+# --------------------------------
+AT_SETUP([autoconf: AC_PRESERVE_HELP_ORDER])
+AT_KEYWORDS([m4@&t@_divert_text])
+
+AT_DATA_AUTOCONF([configure.ac],
+[[AC_INIT
+AC_PRESERVE_HELP_ORDER
+AC_ARG_WITH([one], [ --with-one])
+AC_ARG_ENABLE([two], [ --enable-two])
+m4_divert_text([HELP_ENABLE], [arbitrary $text])
+AC_ARG_WITH([three], [ --with-three])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([--help], [], [stdout])
+AT_CHECK([sed -n '/^Optional/,/^$/p' stdout], [],
+[[Optional Features and Packages:
+ --disable-option-checking ignore unrecognized --enable/--with options
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-one
+ --enable-two
+arbitrary $text
+ --with-three
+
+]])
+
+AT_CLEANUP
+
+
+
+## --------- ##
+## ifnames. ##
+## --------- ##
+
+AT_SETUP([ifnames])
+
+AT_DATA([iftest1.c],
+[[#ifdef DEF1
+#ifndef DEF2
+#if ! defined DEF3 && defined DEF4 /* but not defined DEF5 */
+ # if SPACES
+ # if TABS
+/* #if C_COMMENTS */
+// #if CXX_COMMENTS
+#if LINE1 = \
+LINE2
+#if (VAL1*VAL2)==VAL3+VAL4 /* Not VAL5 !!! */
+]])
+
+AT_DATA([iftest2.c],
+[[#ifdef IFTEST2
+#if VAL1
+]])
+
+AT_CHECK([ifnames iftest1.c iftest2.c], 0,
+[DEF1 iftest1.c
+DEF2 iftest1.c
+DEF3 iftest1.c
+DEF4 iftest1.c
+IFTEST2 iftest2.c
+LINE1 iftest1.c
+LINE2 iftest1.c
+SPACES iftest1.c
+TABS iftest1.c
+VAL1 iftest1.c iftest2.c
+VAL2 iftest1.c
+VAL3 iftest1.c
+VAL4 iftest1.c
+], [])
+
+AT_CLEANUP
+
+
+
+## ------------ ##
+## autoheader. ##
+## ------------ ##
+
+# autoheader is intensively used in its modern form throughout this
+# test suite. But we also have to check that acconfig.h still works.
+# autoheader uses autoconf --trace, so traces first.
+
+AT_SETUP([autoheader])
+
+AT_DATA([acconfig.h],
+[[/* Define this to whatever you want. */
+#undef this
+]])
+
+
+# 1. Check that `acconfig.h' is still honored.
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_HEADERS(config.h:config.hin)
+AC_DEFINE(this, "whatever you want.")
+]])
+
+AT_CHECK_AUTOHEADER([], [], [], [ignore])
+AT_CHECK([cat config.hin], 0,
+[[/* config.hin. Generated from configure.ac by autoheader. */
+/* Define this to whatever you want. */
+#undef this
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+]])
+
+
+# 2. Check that missing templates are a fatal error.
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_HEADERS(config.h:config.hin)
+AC_DEFINE(that, "whatever you want.")
+]])
+
+# The test suite goes too fast for the cache time stamps...
+# Pass --force.
+AT_CHECK_AUTOHEADER([--force], [1], [], [ignore])
+
+
+# 3. Check TOP and BOTTOM.
+AT_DATA([acconfig.h],
+[[/* Top from acconfig.h. */
+@TOP@
+/* Middle from acconfig.h. */
+@BOTTOM@
+/* Bottom from acconfig.h. */
+]])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_HEADERS(config.h:config.hin)
+AH_TOP([Top1 from configure.ac.])
+AH_TOP([Top2 from configure.ac.])
+AH_TOP([The Cat in a h@t.])
+AH_VERBATIM([Middle], [Middle from configure.ac.])
+AH_VERBATIM([Mouse], [The Mouse in a h@t.])
+AH_BOTTOM([Bottom1 from configure.ac.])
+AH_BOTTOM([Bottom2 from configure.ac.])
+AH_BOTTOM([The Dog in a h@t.])
+
+AC_DEFINE([ANT], [@], [The Ant in a h@t.])
+]])
+
+
+# Yes, that's right: the `middle' part of `acconfig.h' is still before
+# the AH_TOP part. But so what, you're not supposed to use the two
+# together.
+# Ignore STDERR which is the longish complaint against autoheader junk
+# files.
+AT_CHECK_AUTOHEADER([--force], [], [], [ignore])
+AT_CHECK([cat config.hin], 0,
+[[/* config.hin. Generated from configure.ac by autoheader. */
+/* Top from acconfig.h. */
+/* Middle from acconfig.h. */
+
+Top1 from configure.ac.
+
+Top2 from configure.ac.
+
+The Cat in a h@t.
+
+/* The Ant in a h@t. */
+#undef ANT
+
+Middle from configure.ac.
+
+The Mouse in a h@t.
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+Bottom1 from configure.ac.
+
+Bottom2 from configure.ac.
+
+The Dog in a h@t.
+/* Bottom from acconfig.h. */
+]])
+
+AT_CLEANUP
+
+
+# autoheader should see through m4 macros, just like autoconf
+# http://lists.gnu.org/archive/html/bug-autoconf/2009-06/msg00000.html
+AT_SETUP([autoheader and macros])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_HEADER([config.h])
+m4_define([PETER], [SIMSALABIM])
+m4_define([PAUL], [OPENSESAME])
+AC_DEFINE([PETER], [10], [Peter's public info])
+AC_DEFINE_UNQUOTED([PAUL], [`expr 4 + 6`], [Paul's public info])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK([grep -c SIMSALABIM configure config.h.in], [0],
+[[configure:1
+config.h.in:1
+]])
+AT_CHECK([grep -c OPENSESAME configure config.h.in], [0],
+[[configure:1
+config.h.in:1
+]])
+AT_CHECK([grep -c PETER configure config.h.in], [1],
+[[configure:0
+config.h.in:0
+]])
+AT_CHECK([grep -c PAUL configure config.h.in], [1],
+[[configure:0
+config.h.in:0
+]])
+
+AT_CLEANUP
+
+
+
+
+## ------------ ##
+## autoupdate. ##
+## ------------ ##
+
+# Check that AC_CANONICAL_SYSTEM and AC_OUTPUT are properly updated.
+AT_SETUP([autoupdate])
+
+AT_DATA([configure.ac],
+[[AC_INIT(Test, 1.0)
+AC_CANONICAL_SYSTEM
+# The doc says 27 is a valid fubar.
+fubar=27
+AC_OUTPUT(Makefile, echo $fubar, fubar=$fubar)
+]])
+
+AT_DATA([expout],
+[[AC_INIT([Test],[1.0])
+AC_CANONICAL_TARGET
+# The doc says 27 is a valid fubar.
+fubar=27
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_COMMANDS([default],[echo $fubar],[fubar=$fubar])
+AC_OUTPUT
+]])
+
+# Checking `autoupdate'.
+AT_CHECK_AUTOUPDATE
+AT_CHECK([cat configure.ac], 0, [expout])
+# Checking that `autoupdate' is idempotent
+AT_CHECK_AUTOUPDATE
+AT_CHECK([cat configure.ac], 0, [expout])
+
+AT_CLEANUP
+
+
+# autoupdating AC_LINK_FILES
+# --------------------------
+AT_SETUP([autoupdating AC_LINK_FILES])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_LINK_FILES(dst1 dst2, src1 src2)
+AC_OUTPUT
+]])
+
+AT_DATA([dst1], dst1
+)
+AT_DATA([dst2], dst2
+)
+
+# Checking `autoupdate'.
+AT_CHECK_AUTOUPDATE([], 0, [], ignore)
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+AT_CHECK([cat src1], 0, [dst1
+])
+AT_CHECK([cat src2], 0, [dst2
+])
+
+AT_CLEANUP
+
+
+# autoupdating AC_PREREQ
+# ----------------------
+AT_SETUP([autoupdating AC_PREREQ])
+
+# Produce `AC_PREREQ(<AUTOUPDATE VERSION>)'.
+AT_CHECK([autoupdate --version | sed 's/.*) //;q'], 0, [stdout])
+autoupdate_version=`cat stdout`
+[echo "AC_PREREQ([$autoupdate_version])" >expout]
+
+AT_CHECK([echo "AC_PREREQ(1.0)" | autoupdate -],
+ 0, [expout], [])
+
+AT_CHECK([echo "AC_PREREQ($autoupdate_version)" | autoupdate -],
+ 0, [expout], [])
+
+AT_CHECK([echo "AC_PREREQ(999.99)" | autoupdate -],
+ 63, [], [ignore])
+
+AT_CLEANUP
+
+
+# autoupdating AU_ALIAS
+# ---------------------
+AT_SETUP([autoupdating AU_ALIAS])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_DEFUN([FOO], [$#])
+AU_ALIAS([BAZ],[FOO])
+test "FOO:FOO():FOO(x) BAZ:BAZ():BAZ(x)" = "0:1:1 0:1:1" || exit 1
+AC_PROG_CC
+AC_STDC_HEADERS
+AC_OUTPUT
+]])
+
+# Checking `autoupdate'.
+AT_CHECK_AUTOUPDATE
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+AT_CHECK([grep 'AC_HEADER_STDC[(]' configure.ac], 1, [ignore], [ignore])
+AT_CHECK([grep 'AC_HEADER_STDC' configure.ac], 0, [ignore], [ignore])
+
+AT_CLEANUP
+
+
+# autoupdating OLD to NEW
+# -----------------------
+
+# The example taken from the code comments.
+AT_SETUP([autoupdating OLD to NEW])
+
+AT_DATA([aclocal.m4],
+[[AU_DEFUN([OLD], [NEW([$1, $2], m4@&t@_eval([$1 + $2]))])
+AC_DEFUN([NEW], [echo "sum($1) = $2"])
+]])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+OLD(1, 2)
+NEW([0, 0], [0])
+]])
+
+# Checking `autoupdate'.
+AT_CHECK_AUTOUPDATE
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+AT_CHECK([[grep 'NEW(\[1, 2], *\[3])' configure.ac]], 0, [ignore], [ignore])
+AT_CHECK([[grep 'NEW(\[0, 0], *\[0])' configure.ac]], 0, [ignore], [ignore])
+
+AT_CLEANUP
+
+
+# autoupdating macros recursively
+# -------------------------------
+
+AT_SETUP([autoupdating macros recursively])
+
+AT_XFAIL_IF([:])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_CC
+AC_TRY_COMPILE([], [choke me], [echo bogus1],
+ [AC_TRY_COMPILE([], [return 0;], [echo good], [echo bogus2])])
+AC_OUTPUT
+]])
+
+# Checking `autoupdate'.
+AT_CHECK_AUTOUPDATE
+AT_CHECK([grep changequote configure.ac], [1])
+AT_CHECK([grep TRY_COMPILE configure.ac], [1])
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+# autoupdating AC_HELP_STRING
+# ---------------------------
+AT_SETUP([autoupdating AC_HELP_STRING])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_ARG_ENABLE([foo], [AC_HELP_STRING([--enable-foo], [foo bar])], [:], [:])
+]])
+
+# Checking `autoupdate'.
+AT_CHECK_AUTOUPDATE([], [], [], [ignore])
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], [], [], [ignore])
+AT_CHECK([[grep '\[--enable-foo], *\[foo bar]' configure.ac]], 0, [ignore], [ignore])
+
+AT_CLEANUP
+
+
+# autoupdating with m4sugar
+# -------------------------
+AT_SETUP([autoupdating with m4sugar])
+
+AT_DATA([aclocal.m4],
+[[AU_DEFUN([OLD],
+[m4@&t@_pushdef([foo], [bar])dn@&t@l
+echo "foo $1 foo"
+m4@&t@_popdef([foo])dn@&t@l
+])
+]])
+
+touch foo.in
+
+AT_DATA([configure.ac],
+[[AC_PREREQ(2.54)
+m4_define([gnumeric_version_epoch], [1])
+AC_INIT
+OLD([ bla bla ])
+AC_FOREACH([name], [n1 n2],
+ [echo name
+])
+AC_CHECKING([for feature])
+AC_MSG_RESULT_UNQUOTED([`echo done`])
+
+AC_OUTPUT([foo])
+]])
+
+# Checking `autoupdate'.
+AT_CHECK_AUTOUPDATE([], [], [], [ignore])
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], [], [], [ignore])
+
+AT_CLEANUP
+
+
+# autoupdating with m4_pushdef
+# ----------------------------
+AT_SETUP([autoupdating with m4@&t@_pushdef])
+
+AT_XFAIL_IF([:])
+
+touch foo.in
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_CC
+# temporarily override this macro
+m4@&t@_pushdef([AC_MSG_RESULT_UNQUOTED], [:])
+AC_C_BIGENDIAN
+m4@&t@_popdef([AC_MSG_RESULT_UNQUOTED])
+AC_OUTPUT
+]])
+
+# Checking `autoupdate'.
+AT_CHECK_AUTOUPDATE([], [], [], [ignore])
+AT_CHECK([grep changequote configure.ac], [1])
+AT_CHECK([grep [pushdef.*AC_MSG_RESULT_UNQUOTED] configure.ac], [0], [ignore])
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], [], [], [ignore])
+
+AT_CLEANUP
+
+
+# autoupdating with AC_REQUIRE
+# ----------------------------
+AT_SETUP([autoupdating with AC_REQUIRE])
+
+AT_XFAIL_IF([:])
+
+AT_DATA([configure.ac],
+[[AC_DEFUN([MACRO],
+[AC_REQUIRE([AC_DECL_SYS_SIGLIST])
+AC_CHECK_DECLS([_sys_siglist], [], [], [#include <signal.h>])
+])
+
+AC_INIT
+MACRO
+AC_OUTPUT
+]])
+
+# Checking `autoupdate'.
+AT_CHECK_AUTOUPDATE([], [], [], [ignore])
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], [], [], [ignore])
+
+AT_CLEANUP
+
+
+# autoupdating with complex quoting
+# ---------------------------------
+AT_SETUP([autoupdating with complex quoting])
+
+AT_XFAIL_IF([:])
+
+AT_DATA([configure.ac],
+[[m4_define([MACRO],
+[[#define STRING "hello, world\n"
+]])
+
+AC_INIT
+AC_TRY_COMPILE([#include <stdio.h>
+ ]MACRO[], [printf (STRING);],
+ [], [AS_EXIT([1])])
+AC_OUTPUT
+]])
+
+# Checking `autoupdate'.
+AT_CHECK_AUTOUPDATE([], [], [], [ignore])
+AT_CHECK_AUTOCONF
+AT_CHECK([grep MACRO configure], [1])
+AT_CHECK_CONFIGURE([], [], [], [ignore])
+
+AT_CLEANUP
+
+
+# autoupdating AC_LANG_SAVE
+# -------------------------
+AT_SETUP([autoupdating AC_LANG_SAVE])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_LANG_SAVE
+AC_LANG_RESTORE
+AC_LANG_SAVE
+AC_LANG_RESTORE
+]])
+
+# Checking `autoupdate'.
+AT_CHECK_AUTOUPDATE([], [], [], [ignore])
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], [], [], [ignore])
+
+AT_CLEANUP
+
+
+# autoupdating AC_FOREACH
+# -----------------------
+AT_SETUP([autoupdating AC_FOREACH])
+
+AT_DATA([aclocal.m4],
+[[AU_DEFUN([OLD], [AC_FOREACH([myvar], [4 5 6], [' myvar'])])
+]])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+echo AC_FOREACH([myvar], [1 2 3], [' myvar'])OLD
+]])
+
+# Checking `autoupdate'.
+AT_CHECK_AUTOUPDATE
+AT_CHECK([[grep 'echo 1 2 3 4 5 6' configure.ac]], 1, [ignore], [ignore])
+AT_CHECK([[grep 'm4@&t@_foreach_w' configure.ac]], 0, [ignore], [ignore])
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], [0], [stdout])
+AT_CHECK([[grep ' 1 2 3 4 5 6' stdout]], 0, [ignore], [ignore])
+
+AT_CLEANUP
+
+
+# autoupdating with aclocal and m4_include
+# ----------------------------------------
+AT_SETUP([autoupdating with aclocal and m4@&t@_include])
+
+# We use aclocal.
+AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
+
+mkdir m4 aclocal
+AT_DATA([configure.in],
+[[AC_INIT(x,0)
+AC_UNCHANGED_MACRO
+AC_OLD_MACRO
+AC_OUTPUT
+]])
+AT_DATA([m4/stuff.m4],
+[[AU_ALIAS([AC_OLD_MACRO], [AC_NEW_MACRO])
+AC_DEFUN([AC_NEW_MACRO], [echo hi])
+AC_DEFUN([AC_UNCHANGED_MACRO], [echo one])
+]])
+cp m4/stuff.m4 aclocal/stuff.m4
+AT_CHECK([aclocal -I aclocal], [0], [ignore], [ignore])
+# Checking `autoupdate'.
+AT_CHECK_AUTOUPDATE
+AT_CHECK([aclocal -I m4], [0], [ignore], [ignore])
+AT_CHECK_AUTOUPDATE
+
+AT_CLEANUP
+
+
+# Keeping autom4te.cfg complete
+# -----------------------------
+
+AT_SETUP([autom4te preselections])
+: ${sleep='sleep 1'} # Command to force different time stamps.
+# If this test should run on FAT file systems and older w32,
+# then setting $sleep correctly needs to be revisited.
+
+# We use aclocal and automake. Skip broken automake wrappers.
+AT_CHECK([automake --version || exit 77], [], [stdout], [ignore])
+AT_CHECK([[grep '[1-9]\.[0-9]' stdout || exit 77]], [], [ignore])
+AT_CHECK([test ! -f $HOME/.autom4te.cfg || exit 77], [], [ignore], [ignore])
+
+AT_DATA([configure.in],
+[[AC_INIT(GNU foo, 1.0)
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.am],
+[[AUTOMAKE_OPTIONS = foreign
+]])
+
+$sleep # `aclocal.m4' should be strictly younger than its inputs
+
+# If Autoconf is too old, or the user has turned caching off, skip:
+AT_CHECK([aclocal || { ret=$?; test $ret -eq 63 && ret=77; exit $ret; }],
+ [], [], [ignore])
+AT_CHECK([test -d autom4te.cache || exit 77])
+AT_CHECK([autoconf])
+
+# If this test fails due to missing entries in lib/autom4te.in, then
+# comparing the old and new requests is a good place to start debugging:
+cp autom4te.cache/requests old-requests
+echo newer >newer
+$sleep # if `configure' is regenerated, we want it to be strictly newer,
+ # to catch the error consistently.
+AT_CHECK([aclocal], [], [], [ignore])
+AT_CHECK([automake --no-force --add-missing], [], [], [ignore])
+AT_CHECK([autoconf])
+AT_CHECK([test "`find configure -newer newer`" = "" ||
+ { diff old-requests autom4te.cache/requests; exit 1; }],
+ [], [], [],
+ [extract_version=['s/^[^0-9]*\([0-9][^ ]*\).*/\1/;q']
+ automake_version=`automake --version | sed "$extract_version"`
+ used_automake_version=`sed "$extract_version" "$abs_top_srcdir/Makefile.in"`
+ AT_CHECK([if test "$automake_version" = "$used_automake_version"; ]dnl
+ [then exit 1; else exit 77; fi])])
+AT_CLEANUP
+
+
+# autom4te cache creation
+# -----------------------
+# Ensure autom4te fails when it cannot create the cache directory
+# or create files there.
+AT_SETUP([autom4te cache creation])
+
+AT_CHECK([test ! -f $HOME/.autom4te.cfg || exit 77], [], [ignore], [ignore])
+
+# Work in a subdirectory so autotest can scribble in the toplevel.
+mkdir sub
+chmod a-w sub
+
+AT_DATA([configure.ac],
+[[AC_INIT
+]])
+
+AT_DATA([.autom4te.cfg],
+[[begin-language: "Autoconf-without-aclocal-m4"
+args: --cache=sub/autom4te.cache
+end-language: "Autoconf-without-aclocal-m4"
+]])
+
+# Do not try this when we are root or on systems without permissions.
+# A failed redirection may cause a status of 2 with FreeBSD sh.
+AT_CHECK([(: > sub/some-file) || exit 1 && exit 77], 1, [ignore], [ignore])
+
+# Failure to create cache directory.
+AT_CHECK_AUTOCONF([], [1], [ignore], [stderr])
+AT_CHECK([grep 'cannot create .*autom4te.cache' stderr], [0], [ignore])
+AT_CHECK([test -f configure], [1])
+
+chmod u+w sub
+AT_CHECK_AUTOCONF
+
+rm -f configure sub/autom4te.cache/*
+chmod a-w sub/autom4te.cache
+
+# Failure to create a file in the cache directory.
+AT_CHECK_AUTOCONF([], [1], [ignore], [stderr])
+AT_CHECK([grep 'cannot open.*autom4te.cache' stderr], [0], [ignore])
+
+AT_CLEANUP
+
+
+# autom4te cache locking
+# ----------------------
+
+AT_SETUP([autom4te cache locking])
+
+# Cannot use AT_CHECK here, autotest internals could be messed up.
+
+(echo AC_INIT; sleep 2; echo) \
+ | (autom4te --language=autoconf -o configure -; echo $? >&2 ) 2>errlog &
+AT_CHECK([echo AC_INIT | autom4te --language=autoconf -o configure -])
+wait
+
+# Ignore additional output from shell verbose or xtrace mode.
+AT_CHECK([grep 'cannot rename' errlog], [1])
+AT_CHECK([grep '^0$' errlog], [], [ignore])
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+# autotools and file names containing whitespace
+# ----------------------------------------------
+
+AT_SETUP([autotools and whitespace in file names])
+
+# We use aclocal.
+AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
+
+x=
+export x
+rm -f a b
+for funny in \
+ 'with funny '\'' $x & #! name ' \
+ 'with funny \ '\'' \'\'' " <a >b * ? name ' #"
+do
+ funny=`func_sanitize_file_name "$funny"`
+ file=" file $funny"
+ dir=`func_sanitize_dir_name " dir $funny"`
+ TMPDIR=" tmp$dir"
+ export TMPDIR
+
+ # skip if we cannot create such a file or directory
+ AT_CHECK([mkdir "$dir" "$TMPDIR" && touch "$file.in" || exit 77])
+
+ cat >"$file.in" <<'END'
+[AC_INIT(x,0)
+m4@&t@_include([foo.m4])
+AC_CONFIG_HEADERS([config.h:config.hin])
+AC_MACRO
+AC_OUTPUT]
+END
+ cat >"$dir"/foo.m4 <<'END'
+[AC_DEFUN([AC_MACRO], [echo hi])]
+END
+
+ AT_CHECK_AUTOHEADER([-B "$dir" "$file.in"])
+ AT_CHECK_AUTOHEADER([--force -I "$dir" "$file.in"])
+ AT_CHECK_AUTOUPDATE([-B "$dir" "$file.in"])
+ AT_CHECK_AUTOUPDATE([--force -I "$dir" "$file.in"])
+ AT_CHECK_AUTOUPDATE([-B "$dir" - < "$file.in"], [], [ignore])
+ AT_CHECK_AUTOCONF([-B "$dir" -o "$file" "$file.in"])
+ AT_CHECK_AUTOCONF([-I "$dir" -o "$file" "$file.in"])
+ # In autoconf, these exercise a slightly different code path:
+ AT_CHECK_AUTOCONF([--prepend-include="$dir" -o "$file" "$file.in"])
+ AT_CHECK_AUTOCONF([--include="$dir" -o "$file" "$file.in"])
+ AT_CHECK([autoscan -B "$dir"], [], [], [ignore])
+ AT_CHECK([autoscan --force -I "$dir"], [], [], [ignore])
+ # autoreconf requires a sane input file name. Also, disable aclocal.
+ mv -f "$file.in" configure.in
+ AT_DATA([aclocal.m4])
+ AT_CHECK([autoreconf -B "$dir"])
+ AT_CHECK([autoreconf --force -I "$dir"])
+
+ cat >"$file.c" <<'END'
+#if FOO
+#endif
+END
+ AT_CHECK([ifnames "$file.c"], [], [ignore])
+
+ test ! -f b
+done
+
+AT_CLEANUP
diff --git a/tests/torture.at b/tests/torture.at
new file mode 100644
index 0000000..9923305
--- /dev/null
+++ b/tests/torture.at
@@ -0,0 +1,1835 @@
+# -*- Autotest -*-
+
+# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+AT_BANNER([[Testing config.status.]])
+
+
+## ---------------------------------------- ##
+## AC_CONFIG_COMMANDS with empty commands. ##
+## ---------------------------------------- ##
+
+AT_CHECK_MACRO([AC_CONFIG_COMMANDS with empty commands],
+[[AC_CONFIG_COMMANDS([foo], [], [:])
+]])
+
+
+## --------------------------------------------- ##
+## AC_CONFIG_COMMANDS with temporary directory. ##
+## --------------------------------------------- ##
+
+AT_CHECK_MACRO([AC_CONFIG_COMMANDS with temporary directory],
+[[AC_CONFIG_COMMANDS([foo], [
+case $ACTION in
+ use)
+ echo "$tmp" > tmpdir
+ test -d "$tmp" || AC_MSG_ERROR([No $tmp directory])
+ echo garbage-in > "$tmp/garbage-out"
+ ;;
+ corrupt)
+ echo "$tmp" > tmpdir
+ tmp=./nosuch
+ ;;
+ *) ;;
+esac
+])
+]], [
+AT_CHECK([test ! -f tmpdir])
+AT_CHECK([ACTION=use ./config.status], [], [ignore])
+AT_CHECK([test -s tmpdir && test ! -d "`cat tmpdir`"])
+AT_CHECK([ACTION=corrupt ./config.status], [], [ignore])
+AT_CHECK([test -s tmpdir && test ! -d "`cat tmpdir`"])
+])
+
+
+## -------------------------- ##
+## Multiple AC_CONFIG_FILES. ##
+## -------------------------- ##
+
+AT_SETUP([Multiple AC_CONFIG_FILES])
+
+AT_CONFIGURE_AC([[AC_CONFIG_FILES([foo foo])]])
+AT_CHECK_AUTOCONF([], 1, [], [ignore])
+
+AT_CLEANUP
+
+
+## ------------------------------- ##
+## parameterized AC_CONFIG_FILES. ##
+## ------------------------------- ##
+
+AT_SETUP([Parameterized AC_CONFIG_FILES])
+
+AT_CONFIGURE_AC([[
+files="foo
+bar"
+AC_CONFIG_FILES([$files])]])
+AT_CHECK_AUTOCONF([], [], [], [ignore])
+touch foo.in bar.in config.hin
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+
+## ------------ ##
+## AC_ARG_VAR. ##
+## ------------ ##
+
+# AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE, [STATUS = 1])
+# ------------------------------------------------------------
+# Check that AC_ARG_VAR caches the latest values, diagnoses
+# inconsistencies, and arms config.status. Check that recheck
+# returns STATUS, save configure output in files 'stdout' and 'stderr'
+# for further inspection.
+m4_define([AT_CHECK_AC_ARG_VAR],
+[rm -f config.cache
+
+# Initial value.
+m4_ifval([$1],
+ [precious='m4_bpatsubst([$1], [[']], ['\\''])'; export precious],
+ [unset precious])
+AT_CHECK_CONFIGURE([--config-cache -q])
+AT_CHECK([cat file], [], [`$1'
+])
+
+# Testing --recheck: 1. have the environment `forget' about PRECIOUS.
+unset precious
+# 2. Rerun config.status to recreate `file'.
+AT_CHECK([./config.status --recheck], [], [ignore])
+AT_CHECK([./config.status], [], [ignore])
+# 3. Check that file contains the old value of PRECIOUS.
+AT_CHECK([cat file], [], [`$1'
+])
+
+# Second value: we should issue an error here: the value
+# has changed!
+m4_ifval([$2],
+ [precious='$2'; export precious],
+ [unset precious])
+AT_CHECK_CONFIGURE([--config-cache], [m4_default([$3], [1])], [stdout], [stderr])
+
+])# AT_CHECK_AC_ARG_VAR
+
+
+AT_SETUP([AC_ARG_VAR])
+
+# We don't want to run this test if this shell doesn't support
+# `unset'.
+AT_CHECK([
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+ exit 0
+else
+ exit 77
+fi
+])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_ARG_VAR([precious], [this variable costs a lot])
+echo "precious:$precious"
+AC_OUTPUT(file)
+]])
+
+AT_DATA([file.in],
+[[`@precious@'
+]])
+
+AT_CHECK_AUTOCONF
+
+# Set a precious variable
+AT_CHECK_AC_ARG_VAR([], [apple of my eye])
+
+# Unset a precious variable
+AT_CHECK_AC_ARG_VAR([apple of my eye], [])
+
+# Change a precious variable
+AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
+
+# Change a precious variable that contains braces
+AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
+
+# Change a precious variable that contains all kinds of fun
+AT_CHECK_AC_ARG_VAR(['p r ec"iou$], [orange of my eye])
+dnl restore font-lock: "
+
+# Warn (but do not fail) about a whitespace-only change
+AT_CHECK_AC_ARG_VAR([ apple of my eye ], [apple of my eye],
+ [0], ["has whitespace changes"])
+mv stdout configure-output
+AT_CHECK([grep "ignoring whitespace changes" stderr], [], [ignore])
+AT_CHECK([grep "precious: apple" configure-output], [], [ignore])
+
+AT_CLEANUP
+
+
+
+
+## ---------------------------------------------- ##
+## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS. ##
+## ---------------------------------------------- ##
+
+AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_FGREP
+rm -f -r header var-header file var-file link var-link command var-command
+echo 'OK' >input
+
+# Be sure to also stress the associated INIT-CMDS.
+case $what_to_test in
+ header)
+ AC_CONFIG_HEADERS(header:input);;
+ var-header)
+ AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
+
+ file)
+ AC_CONFIG_FILES(file:input);;
+ var-file)
+ AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
+
+ command)
+ AC_CONFIG_COMMANDS(command,
+ [cp input command]);;
+ var-command)
+ AC_CONFIG_COMMANDS(var-command,
+ [cp $command_in var-command], [command_in=input]);;
+
+ link)
+ AC_CONFIG_LINKS(link:input);;
+ var-link)
+ AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
+esac
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+
+
+# AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
+# ------------------------------------------------------------------
+# Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
+# are properly created, with the right content.
+# Use `grep OK' instead of a simple `cat' to avoid banners such as in
+# AC_CONFIG_HEADERS.
+m4_define([AT_CHECK_CONFIG_CREATION],
+[AT_CHECK_CONFIGURE([what_to_test=$1])
+AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
+ [ignore], [$1
+])
+AT_CHECK([grep OK $1], [], [OK
+])
+
+AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
+# config.status might be stupidly expecting data on stdin, if it's
+# really broken...
+AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
+AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
+ [ignore], [var-$1
+])
+AT_CHECK([grep OK var-$1], [], [OK
+])
+])# AT_CHECK_CONFIG_CREATION
+
+
+# AT_CHECK_CONFIG_CREATION_NOWRITE(THING = (header | link | file | command))
+# --------------------------------------------------------------------------
+# Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
+# are properly created, with the right content.
+# Use `grep OK' instead of a simple `cat' to avoid banners such as in
+# AC_CONFIG_HEADERS.
+m4_define([AT_CHECK_CONFIG_CREATION_NOWRITE],
+[AT_CHECK_CONFIGURE([what_to_test=$1])
+AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
+ [ignore], [$1
+])
+AT_CHECK([grep OK $1], [], [OK
+])
+
+AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
+# config.status might be stupidly expecting data on stdin, if it's
+# really broken...
+# Skip check if user can rename files into a read-only directory (when
+# run by root or on w32).
+touch t
+chmod a-w .
+mv t t1 >/dev/null 2>&1 \
+ || AT_CHECK([./config.status var-$1 </dev/null || exit 1],
+ [1], [ignore], [ignore])
+chmod u+w .
+rm -rf t t1
+])# AT_CHECK_CONFIG_CREATION_NOWRITE
+
+
+# Create a file
+AT_CHECK_CONFIG_CREATION(file)
+
+# Create a header
+AT_CHECK_CONFIG_CREATION(header)
+
+# Execute a command
+AT_CHECK_CONFIG_CREATION(command)
+
+# Create a link
+AT_CHECK_CONFIG_CREATION(link)
+
+# Now check for write errors
+
+# Create a file
+AT_CHECK_CONFIG_CREATION_NOWRITE(file)
+# Create a file with bits from stdin
+AT_CHECK([echo from-stdin | ./config.status --file=file:-],
+ [0], [ignore])
+AT_CHECK([grep from-stdin file], [], [from-stdin
+])
+# Force write error creating a file on stdout
+if test -w /dev/full && test -c /dev/full; then
+ AT_CHECK([./config.status --file=-:input </dev/null >/dev/full || exit 1],
+ [1], [ignore], [ignore])
+fi
+
+# Validate that --file requires an argument
+AT_CHECK([./config.status --file], [1], [ignore], [stderr])
+AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
+AT_CHECK([./config.status --file=], [1], [ignore], [stderr])
+AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
+
+# Create a header
+AT_CHECK_CONFIG_CREATION_NOWRITE(header)
+# Create a header on stdout
+AT_CHECK([./config.status --header=-:input </dev/null],
+ [0], [stdout], [ignore])
+AT_CHECK([grep OK stdout], [], [OK
+])
+# Force write error creating a header on stdout
+if test -w /dev/full && test -c /dev/full; then
+ AT_CHECK([./config.status --header=-:input </dev/null >/dev/full || exit 1],
+ [1], [ignore], [ignore])
+fi
+
+# Execute a command
+AT_CHECK_CONFIG_CREATION_NOWRITE(command)
+
+# Create a link
+AT_CHECK_CONFIG_CREATION_NOWRITE(link)
+
+# Check that no use of `ac_write_fail' escaped into config.status
+AT_CHECK([grep ac_write_fail config.status], [1])
+
+# Check that --file and --header accept funny file names
+AT_DATA([fgrep.in],
+[[FGREP="@FGREP@"
+]])
+./config.status --file=fgrep:fgrep.in
+. ./fgrep
+
+x=
+export x
+for file in \
+ 'with funny '\'' $x & #! name' \
+ 'file with funny \ '\'' \'\'' $ & #!*? name' \
+ 'with funny \ '\'' \'\'' " | <a >b & * ? name ' # "restore font-lock
+do
+ # The function func_sanitize_file_name comes from tools.at
+ file=`func_sanitize_file_name "$file"`
+ cat >"$file.in" <<'END'
+@configure_input@
+END
+ AT_CHECK([./config.status "--file=$file:$file.in"],
+ [0], [ignore])
+ AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
+ AT_CHECK([./config.status "--header=$file:$file.in"],
+ [0], [ignore])
+ # Run the same test a 2nd time to see that config.status does not recreate
+ # the header (regression test)
+ AT_CHECK_UNQUOTED([./config.status "--header=$file:$file.in"],
+ [0], [config.status: creating $file
+config.status: $file is unchanged
+])
+ AT_CHECK_UNQUOTED([grep ' & ' "$file"], [],
+[/* $file. Generated from $file.in by configure. */
+])
+ AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
+done
+AT_CLEANUP
+
+
+
+## ---------------------------------------- ##
+## Macro calls in AC_CONFIG_COMMANDS tags. ##
+## ---------------------------------------- ##
+
+AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
+
+AT_DATA_M4SUGAR([configure.ac],
+[[AC_INIT
+AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+
+## ------------------- ##
+## Missing templates. ##
+## ------------------- ##
+
+# Check that config.status detects missing input files
+AT_SETUP([Missing templates])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_FILES([nonexistent])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+mkdir build
+AT_CAPTURE_FILE([build/config.log])[]dnl
+cd build
+AT_CHECK([../configure], [1], [ignore],
+[[config.status: error: cannot find input file: `nonexistent.in'
+]])
+# Make sure that the output file doesn't exist
+AT_CHECK([test -f nonexistent], 1)
+cd ..
+AT_CHECK_CONFIGURE([], [1], [],
+[[config.status: error: cannot find input file: `nonexistent.in'
+]])
+# Make sure that the output file doesn't exist
+AT_CHECK([test -f nonexistent], 1)
+
+AT_CLEANUP
+
+
+
+
+## ---------------------- ##
+## configure invocation. ##
+## ---------------------- ##
+
+# Check that `configure' and `config.status' honor their interface.
+#
+# We run `./configure one=val1 --enable-two=val2 --with-three=val3'
+# and verify that (i) `configure' correctly receives the arguments,
+# (ii) correctly passes them to `config.status', which we check by
+# running `config.status --recheck', (iii) correctly passes them
+# to sub-configure scripts, and (iv) correctly reproduces them with
+# `config.status --config'.
+
+AT_SETUP([configure invocation])
+
+mkdir sub
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_SUBDIRS([sub])
+echo "result=$one$enable_two$with_three"
+AC_OUTPUT
+]])
+
+AT_DATA([sub/configure.ac],
+[[AC_INIT
+echo "result=$one$enable_two$with_three"
+AC_OUTPUT
+]])
+
+echo fake install-sh script >install-sh
+
+AT_CHECK_AUTOCONF
+cd sub
+AT_CHECK_AUTOCONF
+cd ..
+
+AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
+ sed -n -e 's/^result=//p'], 0,
+ [m4_do([onetwothree
+], [onetwothree
+])])
+AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
+ [onetwothree
+])
+AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
+ sed -n -e 's/^result=//p'], 0,
+ [m4_do([onetwothree
+], [onetwothree
+])])
+
+AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" ' $" --with-three=" \"'$"|
+ sed -n -e 's/^result=//p'], 0,
+ [m4_do(["'$ " ' $ "'$
+], ["'$ " ' $ "'$
+])])
+AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
+ ["'$ " ' $ "'$
+])
+dnl restore font-lock: "
+AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
+ sed -n -e 's/^result=//p'], 0,
+ [m4_do(["'$ " ' $ "'$
+], ["'$ " ' $ "'$
+])])
+
+AT_CLEANUP
+
+
+
+## -------------------------------------------- ##
+## Check that `#define' templates are honored. ##
+## -------------------------------------------- ##
+
+# Use various forms of `#define' templates, and make sure there are no
+# problems when a symbol is prefix of another.
+
+AT_SETUP([@%:@define header templates])
+AT_KEYWORDS([AC@&t@_DEFINE])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_HEADERS(config.h:config.hin)
+
+# I18n of dummy variables: their French translations.
+AC_DEFINE(foo, toto)
+AC_DEFINE(bar, tata)
+AC_DEFINE(baz, titi)
+AC_DEFINE(fubar, tutu)
+
+# Symbols which are prefixes of another.
+AC_DEFINE(a, A)
+AC_DEFINE(aaa, AAA)
+AC_DEFINE(aa, AA)
+
+# backslash-newline combinations
+AC_DEFINE([multiline], [line1\
+line2\
+line3 \
+line4])
+AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
+ARG1])
+AC_CONFIG_FILES(defs)
+
+# underquoted #
+AC_DEFINE([paste(a,b)], [a##b])
+
+# Things included in confdefs.h, but which make no sense in
+# config.h, nor in $DEFS.
+cat <<\EOF >>confdefs.h
+/* Hi Mum! Look, I am doing C++! */
+#ifdef __cplusplus
+void exit (int status);
+#endif
+EOF
+
+# In addition of config.h output a full DEFS
+AC_OUTPUT_MAKE_DEFS
+DEFS_SAVED=$DEFS
+AC_SUBST(DEFS_SAVED)
+AC_OUTPUT
+]])
+
+AT_DATA([defs.in],
+[[@DEFS_SAVED@
+]])
+
+AT_DATA([config.hin],
+[[#define foo 0
+# define bar bar
+# define baz "Archimedes was sinking in his baz"
+ # define fubar tutu
+#define a B
+ #define aa BB
+ # define aaa BBB
+#undef a
+ # undef aa
+#undef aaa
+#define aaa(a, aa) aa a
+#define aaab
+#define aaac(a, aa) aa a
+#undef multiline
+# undef multiline_args
+#define paste(a,b) a##b
+/* an ugly one: */
+#define str(define) \
+#define
+#define stringify(arg) str(arg)
+#undef aaa /* with comments */
+#undef not_substed /* with comments */
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_DATA([expout],
+[[/* config.h. Generated from config.hin by configure. */
+#define foo toto
+# define bar tata
+# define baz titi
+ # define fubar tutu
+#define a A
+ #define aa AA
+ # define aaa AAA
+#define a A
+ # define aa AA
+#define aaa AAA
+#define aaa AAA
+#define aaab
+#define aaac(a, aa) aa a
+#define multiline line1\
+line2\
+line3 \
+line4
+# define multiline_args(ARG1, ARG2) ARG2 \
+ARG1
+#define paste(a,b) a##b
+/* an ugly one: */
+#define str(define) \
+#define
+#define stringify(arg) str(arg)
+#define aaa AAA
+/* #undef not_substed */
+]])
+AT_CHECK([cat config.h], 0, expout)
+
+# Check the value of DEFS.
+AT_DATA([expout],
+[[-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA -Dmultiline=line1line2line3\ line4 -Dmultiline_args\(ARG1,\ ARG2\)=ARG2\ ARG1 -Dpaste\(a,b\)=a\#\#b
+]])
+
+# Because we strip trailing spaces in `testsuite' we can't leave one in
+# expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
+AT_CHECK([sed -e 's/ $//' defs], 0, expout)
+
+AT_CLEANUP
+
+
+
+## ------------------------- ##
+## Torturing config.status. ##
+## ------------------------- ##
+
+## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
+## big value. This is mostly to check that Autoconf produces portable sed
+## scripts in config.status. sed is used to skip the first two lines
+## `Generated by ...'.
+
+# We use m4_for many times.
+m4_pattern_allow([^m4_for$])
+
+AT_SETUP([Torturing config.status])
+
+dnl The value used as a big value for AC_DEFINE.
+dnl Don't use sh active chars here, below it is also used in a sh
+dnl assignment.
+m4_define([AT_BIG_VALUE],
+[This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
+
+m4_define([AT_DESCRIPTION],
+[Define to a long string if your `Autoconf' works properly.])
+
+
+# AT_DUMMY_VAR(NUMBER)
+# --------------------
+# Build a name used for AC_SUBST and AC_DEFINE. Put ac_ in it
+# so that the check for user name space invasion does not complain
+# of the new variables defined.
+#
+# Note that you should not use the name ac_dummy, because it will be
+# turned into ac_uummy during the construction of config.status. Yes,
+# this is admittedly a bug, but it would be too hard to fix this.
+# There is really no point in AC_DEFINE a var named ac_d.*.
+m4_pattern_allow([^m4_bpatsubst$])
+m4_define([AT_DUMMY_VAR],
+[ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
+
+
+
+AT_DATA([dummy.in],
+[m4_for([AT_Count], 1, 100, 1,
+[@AT_DUMMY_VAR(AT_Count)@
+@[f]AT_Count@
+])])
+
+
+i=1
+while test $i != 101; do
+ echo "content of file $i" > file_$i
+ AS_VAR_ARITH([i], [$i + 1])
+done
+
+
+# ------------ #
+# configure.ac #
+# ------------ #
+
+m4_pattern_allow([^m4_(define|defun)$])
+AT_DATA([configure.ac],
+dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
+dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
+[[m4_define([AC_DUMMY_VAR],]
+m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
+
+[[m4_define([AC_DESCRIPTION],]
+m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
+
+[[m4_define([AC_BIG_VALUE],]
+m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
+
+[[# AC_DEFUBST(NAME)
+# ----------------
+# Related VALUE to NAME both with AC_SUBST and AC_DEFINE. This is
+# used in the torture tests.
+m4_defun([AC_DEFUBST],
+[AC_DUMMY_VAR($1)="AC_BIG_VALUE"
+AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
+ AC_DESCRIPTION)
+AC_SUBST(AC_DUMMY_VAR($1))
+AC_SUBST_FILE([f]$1)
+f$1=file_$1
+])
+
+AC_INIT
+AC_CONFIG_HEADERS(config.h:config.hin)
+AC_CONFIG_FILES(dummy)
+m4_for(AC_Count, 1, 100, 1,
+ [AC_DEFUBST(AC_Count)])
+AC_PROG_AWK
+AC_OUTPUT
+]])# configure.ac
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+# Check both awk and the result of AC_PROG_AWK.
+# Quote the first word in the for list for Solaris sh.
+for awk_arg in "FOO=" AWK=awk; do
+ AT_CHECK_CONFIGURE([$awk_arg])
+
+ # Checking that AC_DEFINE worked properly.
+ AT_DATA([expout],
+[/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME ""
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING ""
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME ""
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION ""
+m4_for(AT_Count, 1, 100, 1,
+[
+/* AT_DESCRIPTION */
+[#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE AT_BIG_VALUE"
+])])
+
+ AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
+
+ # Checking that AC_SUBST worked properly.
+ AT_DATA([expout],
+[m4_for(AT_Count, 1, 100, 1,
+[AT_BIG_VALUE
+content of file AT_Count
+])])
+
+ AT_CHECK([cat dummy], 0, expout)
+done
+
+AT_CLEANUP
+
+
+## ------------------------------- ##
+## Substitute a 2000-byte string. ##
+## ------------------------------- ##
+
+# Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes. HP/UX
+# sed dumps core around 8 KiB. However, POSIX says that sed need not
+# handle lines longer than 2048 bytes (including the trailing newline).
+# So we'll just test a 2000-byte value, and for awk, we test a line with
+# almost 1000 words, and one variable with 5 lines of 2000 bytes each:
+# multi-line values should allow to get around the limitations.
+# We also test runs of around 148 backslashes: they need to be escaped,
+# and 148 is the portable limit for awk string literals. config.status
+# uses concatenation to generate longer strings.
+
+AT_SETUP([Substitute a 2000-byte string])
+
+AT_DATA([Foo.in], [@foo@
+])
+AT_DATA([Bar.in], [@bar@
+])
+AT_DATA([Baz.in], [@baz@
+])
+AT_DATA([Boo.in], [@b147@
+@b148@
+@b149@
+@b295@
+@b296@
+@b297@
+])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
+AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
+baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
+"
+baz=$baz$baz$baz$baz$baz
+AC_SUBST([baz])
+b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+b147=$b29$b29$b29$b29$b29'\\'
+b148=$b147'\'
+b149=$b148'\'
+b295=$b147$b147'\'
+b296=$b295'\'
+b297=$b296'\'
+AC_SUBST([b147])
+AC_SUBST([b148])
+AC_SUBST([b149])
+AC_SUBST([b295])
+AC_SUBST([b296])
+AC_SUBST([b297])
+AC_PROG_AWK
+AC_CONFIG_FILES([Foo Bar Baz Boo])
+AC_OUTPUT
+]])
+
+cp "$abs_top_srcdir/build-aux/install-sh" .
+
+b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+b147=$b29$b29$b29$b29$b29'\\'
+b295=$b147$b147'\'
+cat >Boo-exp <<EOF
+$b147
+$b147\\
+$b147\\\\
+$b295
+$b295\\
+$b295\\\\
+EOF
+
+AT_CHECK_AUTOCONF
+# Check both awk and the result of AC_PROG_AWK
+# Quote the first word in the for list for Solaris sh.
+for awk_arg in "Foo=" AWK=awk; do
+ AT_CHECK_CONFIGURE([$awk_arg])
+ AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
+)
+ AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
+)
+ AT_DATA([stdout],
+ [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
+)])
+ AT_CHECK([cat Baz], 0, [stdout])
+ AT_CHECK([diff Boo-exp Boo])
+done
+AT_CLEANUP
+
+
+## ------------------------------ ##
+## Define to a 2000-byte string. ##
+## ------------------------------ ##
+
+AT_SETUP([Define to a 2000-byte string])
+AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
+
+AT_CONFIGURE_AC(
+[[
+AC_DEFINE_UNQUOTED([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
+AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
+AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
+@%:@define fooq m4_for([n], 1, 100,, ....................)
+])
+AT_CLEANUP
+
+
+## ------------------------------------------ ##
+## Substitute and define special characters. ##
+## ------------------------------------------ ##
+
+# Use characters special to the shell, sed, awk, and M4.
+
+AT_SETUP([Substitute and define special characters])
+AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
+
+AT_XFAIL_IF([byte=\\200s; dnl
+test `{ printf $byte; echo; } | sed -n '/^./p' | wc -l` = 0])
+
+AT_DATA([Foo.in], [@foo@
+@bar@@notsubsted@@baz@ stray @ and more@@@baz@
+abc@bar@baz@baz
+abc@bar@@baz@baz
+abc@bar@@baz@baz@
+abc@bar @baz@baz
+abc@bar @baz@baz@
+abc@bar @baz@@baz@
+@file@
+ @file@
+X@file@
+@file@X
+])
+
+AT_DATA([File],
+[@foo@@bar@
+])
+
+AT_DATA([Zardoz.in], [@zardoz@
+])
+
+AT_CONFIGURE_AC(
+[[foo="AS@&t@_ESCAPE([[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
+#"
+bar="@foo@ @baz@"
+baz=bla
+( for i in 0 1 2 3; do
+ for j in 0 1 2 3 4 5 6 7; do
+ for k in 0 1 2 3 4 5 6 7; do
+ case $i$j$k in #(
+ 000 | 015 | 377) ;; # MinGW awk dislikes 0xFF, and the test does
+ # the wrong thing for CR on MinGW.
+ #(
+ *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
+ esac
+ done
+ done
+ done
+ printf \\n
+) >allowed-chars
+zardoz=`cat allowed-chars`
+AC_SUBST([foo])
+AC_SUBST([bar])
+AC_SUBST([baz])
+AC_SUBST([zardoz])
+file=File
+AC_SUBST_FILE([file])
+AC_DEFINE([fooq], [[X*'[]+ ", & &`\($foo !]], [Awful value.])
+AC_DEFINE([barq], [[%!_!# X]], [Value that is used as special delimiter.])
+AC_DEFINE_UNQUOTED([foo], [[X*'[]+ ", & &\`\\(\$foo !]], [Awful value.])
+AC_DEFINE_UNQUOTED([bar], [[%!_!# X]], [Value that is used as special delimiter.])
+AC_DEFINE_UNQUOTED([unq1], [$baz], [unquoted, test 1])
+AC_DEFINE_UNQUOTED([unq2], [\$baz], [unquoted, test 2])
+AC_DEFINE_UNQUOTED([unq3], ["$baz"], [unquoted, test 3])
+AC_DEFINE_UNQUOTED([unq4], [${baz+set}], [unquoted, test 4])
+AC_DEFINE_UNQUOTED([unq5], ["${baz+`echo "a "' b'`}"], [unquoted, test 5])
+AC_DEFINE_UNQUOTED([unq6], [`echo hi`], [unquoted, test 6])
+AC_DEFINE_UNQUOTED([unq7], ['\\"'], [unquoted, test 7])
+AC_PROG_AWK
+AC_CONFIG_FILES([Foo Zardoz])]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+# Check both awk and the result of AC_PROG_AWK
+# Quote the first word in the for list for Solaris sh.
+for awk_arg in "FOO=" AWK=awk; do
+ AT_CHECK_CONFIGURE([$awk_arg])
+ AT_CHECK([cat Foo], 0, [[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
+@foo@ @baz@@notsubsted@bla stray @ and more@@bla
+abc@foo@ @baz@baz@baz
+abc@foo@ @baz@blabaz
+abc@foo@ @baz@blabaz@
+abc@bar blabaz
+abc@bar blabaz@
+abc@bar blabla
+@foo@@bar@
+@foo@@bar@
+X@file@
+@file@X
+]])
+ AT_CHECK([cmp allowed-chars Zardoz])
+ AT_CHECK_DEFINES([[#define bar %!_!# X
+#define barq %!_!# X
+#define foo X*'[]+ ", & &`\($foo !
+#define fooq X*'[]+ ", & &`\($foo !
+#define unq1 bla
+#define unq2 $baz
+#define unq3 "bla"
+#define unq4 set
+#define unq5 "a b"
+#define unq6 hi
+#define unq7 '\"'
+]])
+done
+AT_CLEANUP
+
+
+## ---------------------- ##
+## Substitute a newline. ##
+## ---------------------- ##
+
+AT_SETUP([Substitute a newline])
+
+AT_DATA([Foo.in],
+[@foo@
+@bar@
+])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+foo='one
+two'
+bar='%!_!# ''
+x'
+AC_SUBST([foo])
+AC_SUBST([bar])
+AC_CONFIG_FILES([Foo])
+AC_PROG_AWK
+AC_OUTPUT
+]])
+
+cp "$abs_top_srcdir/build-aux/install-sh" .
+
+echo 'one
+two
+%!_!# ''
+x' >expout
+
+AT_CHECK_AUTOCONF
+# Check both awk and the result of AC_PROG_AWK
+# Quote the first word in the for list for Solaris sh.
+for awk_arg in "FOO=" AWK=awk; do
+ AT_CHECK_CONFIGURE([$awk_arg])
+ AT_CHECK([cat Foo], 0, [expout])
+done
+AT_CLEANUP
+
+
+## ------------------ ##
+## Define a newline. ##
+## ------------------ ##
+
+AT_SETUP([Define a newline])
+AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
+AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
+two], [This spans two lines.])
+]])
+AT_CHECK_AUTOCONF([], [], [], [stderr])
+dnl Older versions of m4 report error at line 5 (end of macro);
+dnl newer versions report it at line 4 (start of macro).
+AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
+[[warning: AC_DEFINE: `one
+two' is not a valid preprocessor define value
+]])
+AT_CHECK_AUTOHEADER([], [], [], [stderr])
+AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
+[[warning: AC_DEFINE: `one
+two' is not a valid preprocessor define value
+]])
+AT_CHECK_CONFIGURE
+AT_CHECK_DEFINES([[#define foo one
+]])
+
+AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
+two], [This spans two lines.])
+]])
+AT_CHECK_AUTOCONF([], [], [], [stderr])
+AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
+[[warning: AC_DEFINE_UNQUOTED: `one
+two' is not a valid preprocessor define value
+]])
+AT_CHECK_AUTOHEADER([], [], [], [stderr])
+AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
+[[warning: AC_DEFINE_UNQUOTED: `one
+two' is not a valid preprocessor define value
+]])
+AT_CHECK_CONFIGURE
+AT_CHECK_DEFINES([[#define foo one
+]])
+
+AT_CLEANUP
+
+
+## ------------------------------------ ##
+## AC_SUBST: variable name validation. ##
+## ------------------------------------ ##
+
+AT_SETUP([AC_SUBST: variable name validation])
+
+AT_CONFIGURE_AC([[AC_SUBST(, [])
+AC_CONFIG_FILES([Makefile])
+]])
+AT_DATA([Makefile.in], [[
+]])
+mv -f configure.ac configure.tmpl
+
+# Invalid names.
+for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
+ sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
+ AT_CHECK_AUTOCONF([], [1], [], [ignore])
+done
+
+# Valid names.
+for var in ab a4 'a@@&t@\&t@b'; do
+ sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
+ AT_CHECK_AUTOCONF
+ AT_CHECK_AUTOHEADER
+ AT_CHECK_CONFIGURE
+done
+
+AT_CLEANUP
+
+
+## ------------------------ ##
+## datarootdir workaround. ##
+## ------------------------ ##
+
+AT_SETUP([datarootdir workaround])
+
+AT_DATA([Foo.in],
+[@datadir@
+@docdir@
+@infodir@
+@localedir@
+@mandir@
+])
+
+AT_DATA([Bar.in],
+[@mydatadir@
+])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+d@&t@nl The following line silences the warnings, if uncommented:
+d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
+
+# This substitution is wrong and bogus! Don't use it in your own code!
+# Read `info Autoconf "Defining Directories"'!
+AC_SUBST([mydatadir], [${datadir}/my])
+
+AC_CONFIG_FILES([Foo Bar])
+AC_OUTPUT
+]])
+
+cp "$abs_top_srcdir/build-aux/install-sh" .
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], [], [],
+ [config.status: WARNING: 'Foo.in' seems to ignore the --datarootdir setting
+config.status: WARNING: Bar contains a reference to the variable `datarootdir'
+which seems to be undefined. Please make sure it is defined
+])
+AT_CHECK([grep datarootdir Foo], 1, [])
+
+rm configure
+sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
+mv t configure.ac
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+## -------- ##
+## srcdir. ##
+## -------- ##
+
+AT_SETUP([srcdir])
+
+rm -f -r at-dir
+mkdir at-dir
+: >at-dir/bar.in
+: >foo.in
+
+AT_DATA([configure.ac],
+[[AC_INIT
+
+AC_CONFIG_FILES([foo at-dir/bar])
+
+# Use quotes in the INIT-COMMANDS to accommodate a value of $srcdir
+# containing e.g., spaces or shell meta-characters.
+# Use *single* quotes because the context is an unquoted here-doc.
+AC_CONFIG_COMMANDS([report],
+[test -f "$srcdir/configure.ac" ||
+ AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
+ [srcdir='$srcdir'])
+
+AC_OUTPUT
+rm -f -r foo at-dir/bar
+]])
+
+AT_CHECK_AUTOCONF
+
+# In place.
+AT_CHECK([./configure $configure_options], [], [ignore])
+
+# Relative name.
+AT_CHECK([cd at-dir && ../configure $configure_options], [], [ignore])
+
+# Absolute name.
+at_here=`pwd`
+AT_CHECK([cd at-dir && "$at_here/configure" $configure_options], [], [ignore])
+
+AT_CLEANUP
+
+
+## ------- ##
+## VPATH. ##
+## ------- ##
+
+AT_SETUP([VPATH])
+
+dirs='at paren brace space'
+for dir in $dirs; do
+ mkdir $dir $dir/s1 $dir/s2
+ touch $dir/f $dir/s1/f1 $dir/s2/f2
+done
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_FILES([at/Makefile paren/Makefile brace/Makefile space/Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([at/Makefile.in],
+[[# This is what you should use in order to be portable to old makes.
+srcdir = @srcdir@
+VPATH = @srcdir@/s1:@srcdir@:@srcdir@/s2
+all: f f1 f2
+ @echo ok
+]])
+
+AT_DATA([paren/Makefile.in],
+[[# This works with some makes but not with old ones.
+srcdir = @srcdir@
+VPATH = $(srcdir)/s1:$(srcdir):$(srcdir)/s2
+all: f f1 f2
+ @echo ok
+]])
+
+AT_DATA([brace/Makefile.in],
+[[# This works with some makes but not with old ones.
+srcdir = @srcdir@
+VPATH = ${srcdir}/s1:${srcdir}:${srcdir}/s2
+all: f f1 f2
+ @echo ok
+]])
+
+AT_DATA([space/Makefile.in],
+[[# This fails with FreeBSD make, for example.
+srcdir = @srcdir@
+VPATH = @srcdir@/s1 @srcdir@ @srcdir@/s2
+all: f f1 f2
+ @echo ok
+]])
+
+AT_CHECK_AUTOCONF
+
+: "${MAKE=make}"
+
+# In place.
+AT_CHECK([./configure $configure_options], [], [ignore])
+# Treat BSD make separately, afterwards, for maximal coverage.
+dirs='at paren brace'
+for dir in $dirs; do
+ AT_CHECK([cd $dir && $MAKE], [], [ignore], [ignore])
+done
+
+rm -f config.status
+mkdir build absbuild
+
+# Relative name.
+AT_CHECK([cd build && ../configure $configure_options], [], [ignore])
+for dir in $dirs; do
+ AT_CHECK([cd build/$dir && $MAKE], [], [ignore], [ignore])
+done
+
+# Absolute name.
+at_here=`pwd`
+AT_CHECK([cd absbuild && "$at_here/configure" $configure_options], [], [ignore])
+for dir in $dirs; do
+ AT_CHECK([cd absbuild/$dir && $MAKE], [], [ignore], [ignore])
+done
+
+# These will not pass with BSD make.
+AT_CHECK([cd space && { $MAKE || exit 77; }], [], [ignore], [ignore])
+AT_CHECK([cd build/space && $MAKE], [], [ignore], [ignore])
+AT_CHECK([cd absbuild/space && $MAKE], [], [ignore], [ignore])
+
+AT_CLEANUP
+
+
+## ----------------- ##
+## Signal handling. ##
+## ----------------- ##
+
+AT_SETUP([Signal handling])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+kill -2 $$
+exit 77
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], 1, ignore, ignore)
+
+AT_CLEANUP
+
+
+## ----------------- ##
+## AC_CONFIG_LINKS. ##
+## ----------------- ##
+
+AT_SETUP([AC_CONFIG_LINKS])
+
+AT_DATA([configure.ac],
+[[AC_INIT([config links to config files test], [1.0])
+AC_CONFIG_SRCDIR([sub1/file1.in])
+AC_CONFIG_FILES([sub1/file1 file2])
+AC_CONFIG_LINKS([file1:sub1/file1 sub2/file2:file2])
+AC_OUTPUT
+]])
+
+mkdir sub1
+
+AT_DATA([sub1/file1.in],
+[[/* @configure_input@ */
+#define PACKAGE_STRING "@PACKAGE_STRING@"
+]])
+
+AT_DATA([file2.in],
+[[/* @configure_input@ */
+#define PACKAGE_STRING "@PACKAGE_STRING@"
+]])
+
+mkdir build
+AT_CHECK_AUTOCONF
+cd build
+AT_CHECK([../configure && ../configure], 0, [ignore])
+AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
+])
+AT_CHECK([../configure && ../configure], 0, [ignore])
+AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
+])
+cd ..
+rm -rf build
+mkdir build
+cd build
+cwd=`pwd`
+AT_CHECK(["$cwd"/../configure && "$cwd"/../configure], 0, [ignore])
+AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
+])
+cd ..
+AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
+AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
+])
+cwd=`pwd`
+AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
+AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
+])
+
+AT_CLEANUP
+
+
+## ------------------------------------- ##
+## AC_CONFIG_LINKS and identical files. ##
+## ------------------------------------- ##
+AT_SETUP([AC_CONFIG_LINKS and identical files])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_LINKS([src/s:src/s])
+test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
+AC_OUTPUT
+]])
+
+mkdir src build
+echo file1 > src/s
+echo file2 > src/t
+AT_CHECK_AUTOCONF
+cd build
+AT_CHECK([../configure $configure_options && ../configure $configure_options],
+ 0, [ignore])
+AT_CHECK([cat src/s src/t], 0, [file1
+file2
+])
+
+cd ..
+rm -rf build
+mkdir build
+cd build
+cwd=`pwd`
+AT_CHECK(["$cwd"/../configure], 0, [ignore])
+AT_CHECK([cat src/s src/t], 0, [file1
+file2
+])
+AT_CHECK(["$cwd"/../configure], 0, [ignore])
+AT_CHECK([cat src/s src/t], 0, [file1
+file2
+])
+cd ..
+AT_CHECK([./configure $configure_options && ./configure $configure_options],
+ 0, [ignore], [stderr])
+AT_CHECK([grep src/t stderr], 1)
+AT_CHECK([cat src/s src/t], 0, [file1
+file2
+])
+cwd=`pwd`
+AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
+AT_CHECK([cat src/s src/t], 0, [file1
+file2
+])
+
+AT_CLEANUP
+
+
+AT_BANNER([autoreconf.])
+
+## ---------------------------- ##
+## Configuring subdirectories. ##
+## ---------------------------- ##
+
+# .
+# |-- builddir
+# | |-- config.log
+# | |-- config.status
+# | `-- inner
+# | |-- config.log
+# | |-- config.status
+# | `-- innermost
+# | `-- config
+# |-- configure
+# |-- configure.ac
+# |-- inner
+# | |-- configure
+# | |-- configure.ac
+# | `-- innermost
+# | `-- config.in
+# `-- install-sh
+#
+AT_SETUP([Configuring subdirectories])
+AT_KEYWORDS(autoreconf)
+
+# We use aclocal (via autoreconf).
+AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
+AT_CHECK([[grep '[1-9]\.[0-9]' stdout || exit 77]], [], [ignore])
+
+# It should understand configure.ac.
+AT_CHECK([[grep '[^0-9]1\.[01234][^0-9]' stdout && exit 77]], [1], [ignore])
+
+# Set CONFIG_SITE to a nonexistent file, so that there are
+# no worries about nonstandard values for 'prefix'.
+CONFIG_SITE=no-such-file
+export CONFIG_SITE
+
+# The contents of `inner/', and `inner/innermost/'.
+AS_MKDIR_P([inner/innermost])
+
+# We have to use configure.in, not configure.ac, if we still want to
+# be compatible with Automake 1.4: aclocal (run by autoreconf) would
+# die because it can't find configure.in.
+AT_DATA([inner/configure.in],
+[[AC_INIT(GNU Inner, 1.0)
+AC_CONFIG_SRCDIR([innermost/config.in])
+AC_ARG_VAR([INNER], [an inner variable])
+AC_SUBST([INNER])
+if test "x$INNER" = x; then
+ INNER=inner
+fi
+AC_CONFIG_FILES([innermost/config])
+AC_OUTPUT
+]])
+
+AT_DATA([inner/innermost/config.in],
+[INNER=@INNER@
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+prefix=@prefix@
+])
+
+# The contents of `.'
+AT_DATA([install-sh], [])
+
+# nonexistent is allowed not to exist.
+AT_DATA([configure.in],
+[[AC_INIT(GNU Outer, 1.0)
+AC_ARG_VAR([OUTER], [an outer variable])
+if false; then
+ AC_CONFIG_SUBDIRS([nonexistent])
+fi
+AC_CONFIG_SUBDIRS([inner])
+AC_OUTPUT
+]])
+
+# If there are improperly quoted AC_DEFUN installed in share/aclocal,
+# they trigger warnings from aclocal 1.8, so ignore stderr.
+AT_CHECK([autoreconf], [], [], [ignore])
+AT_CHECK([test -f inner/configure])
+
+# Running the outer configure recursively should provide the innermost
+# help strings.
+chmod a-w inner/innermost inner .
+AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep INNER], 0,
+ [ignore], [stderr],
+ [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
+chmod u+w . inner inner/innermost
+
+# Running the outer configure should trigger the inner.
+AT_CHECK_CONFIGURE
+AT_CHECK([cat inner/innermost/config], 0,
+[INNER=inner
+srcdir=.
+top_srcdir=..
+prefix=/usr/local
+])
+
+# The same, but from a builddir.
+AS_MKDIR_P([builddir])
+AT_CHECK([cd builddir && ../configure $configure_options], 0, [ignore])
+AT_CHECK([cat builddir/inner/innermost/config], 0,
+[INNER=inner
+srcdir=../../../inner/innermost
+top_srcdir=../../../inner
+prefix=/usr/local
+])
+
+# Make sure precious variables and command line options are properly
+# passed, even when there are duplicates.
+AT_CHECK([cd builddir && ../configure $configure_options --prefix /bad --prefix /good INNER=bad INNER=good],
+ 0, [ignore])
+AT_CHECK([cat builddir/inner/innermost/config], 0,
+[INNER=good
+srcdir=../../../inner/innermost
+top_srcdir=../../../inner
+prefix=/good
+])
+
+# Make sure --prefix is properly quoted
+AT_CHECK([cd builddir && ../configure --prefix "/a b c$ 'd"], 0, [ignore])
+AT_CHECK([cat builddir/inner/innermost/config], 0,
+[INNER=inner
+srcdir=../../../inner/innermost
+top_srcdir=../../../inner
+prefix=/a b c$ 'd
+])
+
+# Make sure --silent is properly passed...
+AT_CHECK([cd builddir && ../configure $configure_options --silent], 0, [])
+# ...but not stored in config.status.
+AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
+AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
+
+# --cache-file is adjusted for subdirectories, so the cache is shared.
+AT_CHECK([cd builddir && ../configure $configure_options --config-cache],
+ [], [stdout])
+AT_CHECK([grep 'loading .*\.\./config.cache' stdout], [], [ignore])
+
+# Make sure we can run autoreconf on a subdirectory
+rm -f configure configure.in
+AT_CHECK([autoreconf inner], [], [], [ignore])
+
+# Make sure we can pass a configure.ac name
+AT_CHECK([cd inner && autoreconf configure.in], [], [], [ignore])
+AT_CHECK([autoreconf inner/configure.in], [], [], [ignore])
+
+AT_CLEANUP
+
+
+
+## -------------- ##
+## Deep Package. ##
+## -------------- ##
+
+AT_SETUP([Deep Package])
+AT_KEYWORDS(autoreconf)
+
+# We use aclocal (via autoreconf).
+AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
+
+# The contents of `.'
+AT_DATA([install-sh], [])
+AT_DATA([configure.in],
+[[AC_INIT(GNU Outer, 1.0)
+AC_ARG_VAR([OUTER], [an outer variable])
+AC_CONFIG_SUBDIRS([
+ inner
+ inner2
+])
+AC_OUTPUT
+]])
+
+# The contents of `inner/', and `inner/innermost/'.
+AS_MKDIR_P([inner/innermost])
+AS_MKDIR_P([inner2])
+
+AT_DATA([inner/configure.in],
+[[AC_INIT(GNU Inner, 1.0)
+AC_ARG_VAR([INNER], [an inner variable])
+AC_CONFIG_SUBDIRS(innermost)
+AC_OUTPUT
+]])
+
+AT_DATA([inner/innermost/configure.in],
+[[AC_INIT(GNU Innermost, 1.0)
+AC_ARG_VAR([INNERMOST], [an innermost variable])
+AC_CONFIG_HEADERS(config.h:config.hin)
+AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
+if test -n "$innermost_error"; then
+ AC_MSG_FAILURE([error in $PACKAGE_NAME])
+fi
+AC_OUTPUT
+]])
+
+AT_DATA([inner2/configure.in],
+[[AC_INIT(GNU Inner 2, 1.0)
+AC_ARG_VAR([INNER2], [an inner2 variable])
+AC_OUTPUT
+]])
+
+AT_CHECK([autoreconf -Wall -v], [0], [ignore], [stderr])
+# We should not warn about nonliteral argument to AC_CONFIG_SUBDIRS here.
+AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [1])
+AT_CHECK([test -f inner/configure])
+AT_CHECK([test -f inner/innermost/configure])
+AT_CHECK([test -f inner/innermost/config.hin])
+AT_CHECK([test -f inner2/configure])
+
+# Running the outer configure recursively should provide the innermost
+# help strings.
+chmod a-w inner/innermost inner
+AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
+ 0, [ignore], [stderr],
+ [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
+chmod a-w .
+AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
+ 0, [ignore], [stderr],
+ [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
+chmod a-w .
+AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
+ 0, [ignore], [stderr],
+ [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
+chmod a-w .
+AT_CHECK([{ /bin/sh ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
+ 0, [ignore], [stderr],
+ [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
+chmod a-w .
+AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { /bin/sh configure $configure_options --help=recursive; chmod +w .; } | grep " INNERMOST "],
+ 0, [ignore], [stderr],
+ [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
+chmod a-w .
+AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
+ 0, [ignore], [stderr],
+ [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
+chmod u+w inner inner/innermost
+
+# Running the outer configure should trigger the inner.
+AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
+AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
+[[#define INNERMOST tsomrenni
+]])
+
+# Ensure we point to the right config.log file for errors.
+AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
+AT_CHECK([grep 'inner/innermost' stderr], [], [ignore])
+cd inner
+AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
+AT_CHECK([grep 'innermost' stderr], [], [ignore])
+cd ..
+
+# The same, but from a builddir.
+AS_MKDIR_P([builddir])
+chmod a-w builddir inner/innermost inner
+AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
+ 0, [ignore], [stderr],
+ [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
+chmod a-w builddir
+AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
+ 0, [ignore], [stderr],
+ [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
+chmod a-w builddir
+AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
+ 0, [ignore], [stderr],
+ [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
+chmod a-w builddir
+AT_CHECK([cd builddir && { /bin/sh ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
+ 0, [ignore], [stderr],
+ [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
+chmod a-w builddir
+# Not all shells search $PATH for scripts.
+if (cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help) >/dev/null 2>&1; then
+ AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help=recursive | grep " INNERMOST "], 0, [ignore])
+fi
+AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
+ 0, [ignore], [stderr],
+ [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
+chmod u+w builddir inner inner/innermost
+AT_CHECK([cd builddir && ../configure $configure_options INNERMOST=build/tsomrenni], 0, [ignore])
+AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
+[[#define INNERMOST build/tsomrenni
+]])
+
+AT_CLEANUP
+
+
+
+## -------------------------------- ##
+## Non-Autoconf AC_CONFIG_SUBDIRS. ##
+## -------------------------------- ##
+
+AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
+AT_KEYWORDS([autoreconf])
+
+# We use aclocal (via autoreconf).
+AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
+
+AT_DATA([install-sh], [])
+AT_DATA([configure.in],
+[[AC_INIT(GNU Outer, 1.0)
+AC_CONFIG_SUBDIRS([inner])
+AC_OUTPUT
+]])
+
+AS_MKDIR_P([inner])
+
+AT_DATA([inner/configure],
+[[#! /bin/sh
+case "$*" in
+ *--help*) echo 'No Autoconf here, folks!' ;;
+ *) echo got_it >myfile ;;
+esac
+exit 0
+]])
+chmod +x inner/configure
+
+AT_CHECK([autoreconf -Wall -v], 0, [ignore], [ignore])
+
+# Running the outer configure recursively should provide the innermost
+# help strings.
+AT_CHECK([./configure $configure_options --help=recursive | grep "folks"], 0, [ignore])
+
+# Running the outer configure should trigger the inner.
+AT_CHECK([./configure $configure_options], 0, [ignore])
+AT_CHECK([test -f inner/myfile], 0)
+
+AT_CLEANUP
+
+
+## ------------------------------- ##
+## Non-literal AC_CONFIG_SUBDIRS. ##
+## ------------------------------- ##
+
+AT_SETUP([Non-literal AC_CONFIG_SUBDIRS])
+AT_KEYWORDS([autoreconf])
+
+AT_DATA([install-sh], [])
+AT_DATA([configure.in],
+[[AC_INIT(GNU Outer, 1.0)
+
+my_subdirs=
+# Taken from autoconf.texi:Subdirectories.
+if test "x$package_foo_enabled" = xyes; then
+ my_subdirs="$my_subdirs foo"
+fi
+AC_CONFIG_SUBDIRS([$my_subdirs])
+AC_OUTPUT
+]])
+
+# Hand-written aclocal.m4, so we don't invoke `aclocal -Werror' which
+# could barf over warnings in third-party macro files, or fail over
+# warnings with older aclocal which didn't yet understand -W*.
+AT_DATA([aclocal.m4])
+
+AS_MKDIR_P([foo])
+
+AT_DATA([foo/configure],
+[[#! /bin/sh
+touch innerfile
+exit 0
+]])
+chmod +x foo/configure
+
+# autoreconf should warn without -Wno-syntax, but should not fail without -Werror.
+AT_CHECK([autoreconf -Werror -v], [1], [ignore], [stderr])
+AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
+AT_CHECK([autoreconf -v], [0], [ignore], [stderr])
+AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
+AT_CHECK([autoreconf -v --force -Wno-syntax], 0, [ignore], [stderr])
+AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [1])
+
+AT_CHECK([./configure $configure_options], [0], [ignore])
+AT_CHECK([test ! -f foo/innerfile])
+# Running the outer configure should trigger the inner.
+AT_CHECK([./configure $configure_options package_foo_enabled=yes], [0], [ignore])
+AT_CHECK([test -f foo/innerfile])
+
+AT_CLEANUP
+
+
+## ----------------- ##
+## Empty directory. ##
+## ----------------- ##
+
+AT_SETUP([Empty directory])
+AT_KEYWORDS([autoreconf])
+
+# We use aclocal (via autoreconf).
+AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
+
+# The test group directory is not necessarily _empty_, but it does not contain
+# files meaningful to `autoreconf'.
+
+AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
+
+AT_CLEANUP
+
+
+
+## ------------------------------ ##
+## Unusual Automake input files. ##
+## ------------------------------ ##
+
+# This parallels gnumake.test in Automake.
+
+AT_SETUP([Unusual Automake input files])
+AT_KEYWORDS([autoreconf])
+
+# We use aclocal and automake via autoreconf.
+AT_CHECK([automake --version || exit 77], [], [stdout], [ignore])
+AT_CHECK([[grep '[1-9]\.[0-9]' stdout || exit 77]], [], [ignore])
+
+AT_DATA([configure.in],
+[[AC_INIT(GNU foo, 1.0)
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([HeeHee])
+AC_OUTPUT
+]])
+
+AT_DATA([HeeHee.am],
+[[# Humans do no worse than `GNUmakefile.am'.
+AUTOMAKE_OPTIONS = foreign 1.8
+]])
+
+AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
+ [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
+AT_CHECK([test -f HeeHee.in])
+
+AT_CLEANUP
diff --git a/tests/wrapper.as b/tests/wrapper.as
new file mode 100644
index 0000000..7a77a04
--- /dev/null
+++ b/tests/wrapper.as
@@ -0,0 +1,41 @@
+AS_INIT[]dnl -*- shell-script -*-
+# wrapper.as -- running `@wrap_program@' as if it were installed.
+# @configure_input@
+# Copyright (C) 2003-2004, 2007, 2009-2012 Free Software Foundation,
+# Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+testdir='@abs_top_builddir@/tests'
+PATH=$testdir$PATH_SEPARATOR$PATH
+AUTOCONF=autoconf
+AUTOHEADER=autoheader
+AUTOM4TE=autom4te
+AUTOM4TE_CFG='@abs_top_builddir@/lib/autom4te.cfg'
+autom4te_perllibdir='@abs_top_srcdir@/lib'
+export AUTOCONF AUTOHEADER AUTOM4TE AUTOM4TE_CFG autom4te_perllibdir
+
+case '@wrap_program@' in
+ ifnames)
+ # Does not have lib files.
+ exec '@abs_top_builddir@/bin/@wrap_program@' ${1+"$@"}
+ ;;
+ *)
+ # We might need files from the build tree (frozen files), in
+ # addition of src files.
+ exec '@abs_top_builddir@/bin/@wrap_program@' \
+ -B '@abs_top_builddir@'/lib \
+ -B '@abs_top_srcdir@'/lib ${1+"$@"}
+esac
+exit 1