# -*- Autotest -*- AT_BANNER([Executables (autoheader, autoupdate...).]) # Copyright 2000, 2001 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 2, 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, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. ## ----------------------------- ## ## 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]) # A script that never returns. We don't care that it never returns, # broken /bin/sh loop equally with `false', but it makes it easier to # test the robusteness in a good environment: just remove the `-n'. AT_DATA([endless.sh], [[while : do : done ]]) # A script in charge of testing `/bin/sh -n'. AT_DATA([syntax.sh], [[(/bin/sh -n endless.sh) & sleep 2 if kill $! >/dev/null 2>&1; then # We managed to kill the child, which means that we probably # can't trust `/bin/sh -n', hence the test failed. exit 77 fi ]]) # If we can't trust sh, just skip. AT_CHECK([/bin/sh ./syntax.sh]) # Specify the path to the tool, some shells don't honor PATH when # running `sh PROG'. AT_CHECK([/bin/sh -n ../bin/autoconf], 0) AT_CHECK([/bin/sh -n ../bin/autoreconf], 0) AT_CHECK([/bin/sh -n ../bin/ifnames], 0) # These are not built, they are in the src tree. AT_CHECK([/bin/sh -n $at_top_srcdir/config/install-sh], 0) AT_CHECK([/bin/sh -n $at_top_srcdir/config/mkinstalldirs], 0) AT_CHECK([/bin/sh -n $at_top_srcdir/config/missing], 0) AT_CLEANUP ## ---------------------------- ## ## Syntax of the Perl scripts. ## ## ---------------------------- ## AT_SETUP([Syntax of the Perl scripts]) # Perl says things like: # | % perl -c ./autom4te # | ./autom4te syntax OK # Ignore it, it might change between releases. AT_CHECK([$PERL -c ../bin/autom4te], 0, [], [ignore]) AT_CHECK([$PERL -c ../bin/autoscan], 0, [], [ignore]) AT_CHECK([$PERL -c ../bin/autoupdate], 0, [], [ignore]) AT_CLEANUP ## ----------------- ## ## AWK portability. ## ## ----------------- ## AT_SETUP([AWK portability]) # Skip if we don't have GNU Awk. AT_CHECK([gawk --version || exit 77], 0, ignore, ignore) # Syntax correctness of ifnames. AT_CHECK([AWK='gawk --posix' ifnames /dev/null]) AT_CLEANUP ## ------------------ ## ## autoconf --trace. ## ## ------------------ ## # autoconf --trace: user macros # ----------------------------- AT_SETUP([autoconf --trace: user macros]) m4_pattern_allow([^m4_(define|shift)$]) 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])) # With arguments, multiple lines. TRACE1(foo bar, bar foo) ]]) # 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 configure.ac:19:TRACE1:foo bar:bar foo configure.ac:19:TRACE2:bar foo ]]) # 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], []. [foo bar], [bar foo], []. ]]) # ${sep}@. AT_CHECK_AUTOCONF([-t TRACE2:'${)===(}@'], 0, [[[] [] [bar])===([baz] [baz] [])===([baz] [ACTIVE])===([baz] [active] [active])===([])===([ACTIVE] [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([[--autoconf-dir $at_top_srcdir/lib -t define:'$1' -i| sed -n '$p']], 0, [[active ]]) AT_CLEANUP ## ---------------------------- ## ## autoconf: forbidden tokens. ## ## ---------------------------- ## # autoconf: forbidden tokens, basic # --------------------------------- AT_SETUP([autoconf: forbidden tokens, basic]) m4_pattern_allow([^(m4_foo|_m4_bar|AS_FOO|_AS_BAR)$]) AT_DATA([configure.ac], [[AC_PLAIN_SCRIPT() AC_FOO _AC_BAR m4_foo _m4_bar BAC_FOO B_AC_FOO AS_FOO _AS_BAR [d@__@nl] ]]) AT_CHECK_AUTOCONF([], 1, [], [[configure.ac:2: error: possibly undefined macro: AC_FOO configure.ac:3: error: possibly undefined macro: _AC_BAR configure.ac:4: error: possibly undefined macro: m4_foo configure.ac:5: error: possibly undefined macro: _m4_bar configure.ac:7: error: possibly undefined macro: B_AC_FOO configure.ac:8: error: possibly undefined macro: AS_FOO configure.ac:9: error: possibly undefined macro: _AS_BAR configure.ac:10: error: possibly undefined macro: d@__@nl ]]) AT_CLEANUP # autoconf: forbidden tokens, exceptions # -------------------------------------- AT_SETUP([autoconf: forbidden tokens, exceptions]) AT_DATA([configure.ac], [[AC_PLAIN_SCRIPT # 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([^AC_ALLOWED$]) NOT_AC_ALLOWED AC_ALLOWED AC_ALLOWED_NOT # Test forbidding. m4@__@_pattern_forbid([^FORBIDDEN$]) NOT_FORBIDDEN FORBIDDEN FORBIDDEN_NOT # Test Autoconf's patterns. AC_THIS_IS_INVALID and _AC_THIS_IS_INVALID_TOO BUT_AZ_THIS_IS_NOT ALTHOUGH_AC_THIS_IS # This is legal, although there is `AC_DEFINE' in there. BAC_DEFINE # AC_THIS_IS_A_COMMENT so just shut up. It would be very bad if Autoconf forgot to expand [AC_]OUTPUT! ]]) AT_CHECK_AUTOCONF([], 1, [], [[configure.ac:7: error: possibly undefined macro: NOT_AC_ALLOWED configure.ac:7: error: possibly undefined macro: AC_ALLOWED_NOT configure.ac:10: error: possibly undefined macro: FORBIDDEN configure.ac:14: error: possibly undefined macro: AC_THIS_IS_INVALID configure.ac:14: error: possibly undefined macro: _AC_THIS_IS_INVALID_TOO configure.ac:15: error: possibly undefined macro: ALTHOUGH_AC_THIS_IS configure:18: error: possibly undefined macro: AC_OUTPUT ]]) 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 throught 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) AC_DEFINE(this, "whatever you want.") ]]) AT_CHECK([autoheader --autoconf-dir ../lib -expout <