| # Process with autom4te to create an -*- Autotest -*- test suite. | |
| # Test suite for GNU M4. | |
| # Copyright (C) 2001, 2006-2010, 2013-2014, 2017 Free Software | |
| # Foundation, Inc. | |
| # This file is part of GNU M4. | |
| # | |
| # GNU M4 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. | |
| # | |
| # GNU M4 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 need a recent Autotest. | |
| m4_version_prereq([2.63b-41]) | |
| # Default to testing "m4 -b", but allow overrides. | |
| dnl This uses knowledge of undocumented autotest internals; hopefully | |
| dnl it isn't too much of a problem. FIXME: Help autoconf document | |
| dnl proper usage of HELP_OTHER, at_write_fail, and at_tested (or better | |
| dnl yet, add AT_FOO macros that wrap these internal details). | |
| m4_divert_text([HELP_OTHER], | |
| [cat <<\_ATEOF || at_write_fail=1 | |
| The environment variable `M4' controls which binary is tested, default `m4 -b'. | |
| _ATEOF]) | |
| m4_divert_text([PREPARE_TESTS], | |
| [[if test "${M4+set}" = set; then | |
| case $M4 in | |
| *[\\/]* ) at_tested= ;; | |
| * ) at_tested=`set x $M4; echo $2` ;; | |
| esac | |
| else | |
| M4='m4 -b' | |
| fi]]) | |
| # AT_CHECK_M4(ARGS, [EXIT-STATUS = 0], [STDOUT = `'], [STDERR = `'], | |
| # [STDIN = `/dev/null'], [INHIBIT-D]) | |
| # ------------------------------------------------------------------ | |
| # Run m4 with ARGS, and stdin redirected from STDIN, or with stdin closed | |
| # if STDIN is `-'. ARGS may redirect stdout and/or stderr, but should | |
| # not redirect stdin. Expect EXIT-STATUS, with output matching STDOUT and | |
| # STDERR as in AT_CHECK. If STDERR is specified, normalize the observed | |
| # error output. Unless INHIBIT-D is specified, add -d prior to ARGS. | |
| # | |
| # When testing an uninstalled wrapper, tests/m4 is on the path, but invokes | |
| # src/m4, which may itself be a libtool wrapper. Also, some platforms | |
| # choose to display argv[0] differently: | |
| # path/to/lt-m4:file:line: message | |
| # or m4.exe:file:line: message | |
| # to m4:file:line | |
| # | |
| # When testing closed file descriptors, the message is platform-dependent: | |
| # m4: error closing file: Bad file number | |
| # to m4: error closing file: Bad file descriptor | |
| # | |
| # When tracing modules, the module name is platform-dependent: | |
| # m4debug: module gnu: opening file `gnu.so' | |
| # or m4debug: module gnu: opening file `gnu.a' | |
| # to m4debug: module gnu: opening file | |
| # | |
| # When testing modules, a failed module name is platform-dependent: | |
| # m4:input.m4:7: cannot open module `no_such': no_such.so: cannot open shared object file: No such file or directory | |
| # or m4:input.m4:7: cannot open module `no_such': can't open the module | |
| # to m4:input.m4:7: cannot open module `no_such' | |
| # | |
| # When encountering command line option errors, the error message is | |
| # platform-dependent, but contains " option ": | |
| # m4: unrecognized option `--diversions=1' # glibc 2.6 | |
| # or m4: unrecognized option '--diversions=1' # glibc 2.11 | |
| # or m4: unknown option -- --diversions # BSD | |
| # or m4: option '--debu' is ambiguous # glibc 2.11 | |
| # or m4: ambiguous option -- --debu # BSD | |
| # to m4: bad option | |
| m4_define([AT_CHECK_M4], | |
| [AT_CHECK([$M4 m4_ifval([$6], [], [-d ])$1 ]m4_if([$5], [-], [<&-], | |
| [< m4_default([$5], [/dev/null])]), | |
| [$2], [$3], m4_case([$4], [], [], [ignore], [ignore], [stderr])) | |
| m4_case([$4], [], [], [ignore], [], | |
| [AT_CHECK([[$SED 's/^[^:]*[lt-]*m4[.ex]*:/m4:/ | |
| /^m4debug: module/s/opening file.*/opening file/ | |
| s/\(cannot open module [^:]*\):.*/\1/ | |
| s/Bad file number/Bad file descriptor/ | |
| s/^m4:.* option .*/m4: bad option/ | |
| ' stderr >&2]], [0], [], [$4])]) | |
| ]) | |
| # M4_ONE_MEG_DEFN | |
| # --------------- | |
| # emit a code snippet for use in AT_DATA that will define a macro `f' to | |
| # consist of 1M bytes of newlines. With that in place, it is then easy | |
| # to use divert and invoke `f' in the test file to force diversions to | |
| # spill into a temporary file. | |
| m4_define([M4_ONE_MEG_DEFN], | |
| [pushdef(`diversion', divnum)divert(-1) | |
| define(`f', ` | |
| ') | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| define(`f', defn(`f')defn(`f')) | |
| divert(diversion)popdef(`diversion')]) | |
| # AT_TEST_M4(TITLE, INPUT, [STDOUT = `'], [STDERR = `']) | |
| # ------------------------------------------------------ | |
| # Run m4 on INPUT, expecting a success. | |
| m4_define([AT_TEST_M4], | |
| [AT_SETUP([$1]) | |
| AT_DATA([[input.m4]], [$2]) | |
| AT_CHECK_M4([[input.m4]], 0, [$3], [$4]) | |
| AT_CLEANUP | |
| ]) | |
| # We use `dnl' in zillions of places... | |
| m4_pattern_allow([^dnl$]) | |
| # We exercise m4. | |
| AT_TESTED([m4]) | |
| # AT_CHECK_GMP | |
| # ----------------------- | |
| # Add keyword `gmp' to the test, and skip the test if the use of GMP | |
| # was disabled at configure time. | |
| m4_define([AT_CHECK_GMP], | |
| [AT_KEYWORDS([gmp]) | |
| AT_CHECK([if test "x$USE_GMP" = xno ; then | |
| echo libgmp support not detected, skipping this test. | |
| exit 77 | |
| fi])]) | |
| ## ----------- ## | |
| ## The suite. ## | |
| ## ----------- ## | |
| AT_INIT | |
| # Macro definitions, uses, tracing etc. | |
| m4_include([macros.at]) | |
| # Torturing builtins. | |
| m4_include([builtins.at]) | |
| # Options. | |
| m4_include([options.at]) | |
| # Frozen files. | |
| m4_include([freeze.at]) | |
| # Hand crafted tests. | |
| m4_include([others.at]) | |
| # Torturing the modules support. | |
| m4_include([modules.at]) | |
| # From the documention. | |
| m4_include([generated.at]) |