3 AT_BANNER([[Testing config.status.
5 ## ---------------------------------------------------------------- ##
6 ## This section of torture tests is trying to make Autoconf produce ##
7 ## failing `configure' scripts, which must never happen. If one of ##
8 ## these tests ever fails, it is extremely important that you ##
9 ## report the failure to bug-autoconf@gnu.org. ##
10 ## ---------------------------------------------------------------- ##]])
17 # AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE)
18 # ----------------------------------------------
19 # Check that AC_ARG_VAR caches the latest values, diagnoses
20 # inconsistances, and arms config.status.
21 m4_define([AT_CHECK_AC_ARG_VAR],
26 [precious='$1'; export precious],
28 AT_CHECK_CONFIGURE([--config-cache])
29 AT_CHECK([cat file], [], [`$1'
34 AT_CHECK([./config.status --recheck], [], [ignore])
35 AT_CHECK([./config.status], [], [ignore])
36 AT_CHECK([cat file], [], [`$1'
41 [precious='$2'; export precious],
43 AT_CHECK_CONFIGURE([--config-cache], [1], [], [ignore])
45 ])# AT_CHECK_AC_ARG_VAR
48 AT_SETUP([AC_ARG_VAR])
50 # We don't want to run this test if this shell doesn't support
53 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
60 AT_DATA([configure.ac],
62 AC_ARG_VAR([precious], [this variable costs a lot])
72 # Set a precious variable
73 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
75 # Unset a precious variable
76 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
78 # Change a precious variable
79 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
86 ## ---------------------------------------------- ##
87 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS. ##
88 ## ---------------------------------------------- ##
90 AT_SETUP([AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS])
94 rm -rf header var-header file var-file link var-link command var-command
97 # Be sure to also stress the associated INIT-CMDS.
100 AC_CONFIG_HEADERS(header:input);;
102 AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
105 AC_CONFIG_FILES(file:input);;
107 AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
110 AC_CONFIG_COMMANDS(command:input,
111 [cp input command]);;
113 AC_CONFIG_COMMANDS(var-command:$command_in,
114 [cp $command_in var-command], [command_in=input]);;
117 AC_CONFIG_LINKS(link:input);;
119 AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
127 # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
128 # ------------------------------------------------------------------
129 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
130 # are properly created, with the right content.
131 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
133 m4_define([AT_CHECK_CONFIG_CREATION],
134 [AT_CHECK_CONFIGURE([what_to_test=$1])
135 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
138 AT_CHECK([grep OK $1], [], [OK
141 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
142 # config.status might be stupidly expecting data on stdin, if it's
144 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
145 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
148 AT_CHECK([grep OK var-$1], [], [OK
150 ])# AT_CHECK_CONFIG_CREATION
154 AT_CHECK_CONFIG_CREATION(file)
157 AT_CHECK_CONFIG_CREATION(header)
160 AT_CHECK_CONFIG_CREATION(command)
163 AT_CHECK_CONFIG_CREATION(link)
165 AT_CLEANUP(header file link commandvar-header var-file var-link var-command
170 ## ------------------- ##
171 ## Missing templates. ##
172 ## ------------------- ##
174 # Check that config.status detects missing input files
175 AT_SETUP([Missing templates])
177 AT_DATA(configure.ac,
179 AC_CONFIG_FILES([nonexistent])
184 AT_CHECK_CONFIGURE([], [1], [],
185 [[config.status: error: cannot find input file: nonexistent.in
187 # Make sure that the output file doesn't exist
188 AT_CHECK([test -f nonexistent], 1)
195 ## ---------------------- ##
196 ## configure invocation. ##
197 ## ---------------------- ##
199 # Check that `configure' and `config.status' honor their interface.
201 # We run `./configure one=val1 --enable-two=val2 --with-three=val3'
202 # and verify that (i) `configure' correctly receives the arguments and
203 # (ii) correctly passes them to `config.status', which we check by
204 # running `config.status --recheck'.
206 AT_SETUP([configure invocation])
208 AT_DATA(configure.ac,
210 echo "result=$one$enable_two$with_three"
216 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
217 sed -n -e 's/^result=//p'], 0,
220 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
224 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" ' $" --with-three=" \"'$"|
225 sed -n -e 's/^result=//p'], 0,
228 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
232 AT_CLEANUP(configure config.status config.log config.cache)
236 ## -------------------------------------------- ##
237 ## Check that `#define' templates are honored. ##
238 ## -------------------------------------------- ##
240 # Use various forms of `#define' templates, and make sure there are no
241 # problems when a symbol is prefix of another.
243 AT_SETUP([#define header templates])
245 AT_DATA([configure.ac],
247 AC_CONFIG_HEADERS(config.h:config.hin)
249 # I18n of dummy variables: their French translations.
253 AC_DEFINE(fubar, tutu)
255 # Symbols which are prefixes of another.
259 AC_CONFIG_FILES(defs)
261 # Things included in confdefs.h, but which make no sense in
262 # config.h, nor in $DEFS.
263 cat <<\EOF >>confdefs.h
264 /* Hi Mum! Look, I'm doing C++! */
266 void exit (int status);
270 # In addition of config.h output a full DEFS
281 AT_DATA([config.hin],
284 # define baz "Archimedes was sinking in his baz"
298 [[/* config.h. Generated automatically by configure. */
310 AT_CHECK([cat config.h], 0, expout)
312 # Check the value of DEFS. Note the leading space.
314 [[-Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA]
317 # Because we strip trailing spaces in `testsuite' we can't leave one in
318 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
319 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
325 ## ------------------------- ##
326 ## Torturing config.status. ##
327 ## ------------------------- ##
329 ## Require 100 AC_DEFINE and AC_SUBST with a significantly big value.
330 ## This is mostly to check that Autoconf produces portable sed scripts
331 ## in config.status. sed is used to skip the first two lines
332 ## `Generated by...'.
334 AT_SETUP([Torturing config.status])
336 dnl The value used as a big value for AC_DEFINE.
337 dnl Don't use sh active chars here, below it is also used in a sh
339 m4_define([AT_BIG_VALUE],
340 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
342 m4_define([AT_DESCRIPTION],
343 [Define to a long string if your `Autoconf' works properly.])
346 # AT_DUMMY_VAR(NUMBER)
347 # --------------------
348 # Build a name used for AC_SUBST and AC_DEFINE. Put ac_ in it
349 # so that the check for user name space invasion does not complain
350 # of the new variables defined.
352 # Note that you should not use the name ac_dummy, because it will be
353 # turned into ac_uummy during the construction of config.status. Yes,
354 # this is admittedly a bug, but it would be too hard to fix this.
355 # There is really no point in AC_DEFINE a var named ac_d.*.
356 m4_define([AT_DUMMY_VAR],
357 [ac_Dummy_[]m4_patsubst([000$1], [.*\(...\)$], [\1])])
362 [m4_for([AT_Count], 1, 100, 1,
363 [@AT_DUMMY_VAR(AT_Count)@
371 AT_DATA(configure.ac,
372 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
373 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
374 [[m4_define([AC_DUMMY_VAR],]
375 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
377 [[m4_define([AC_DESCRIPTION],]
378 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
380 [[m4_define([AC_BIG_VALUE],]
381 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
385 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE. This is
386 # used in the torture tests.
387 m4_defun([AC_DEFUBST],
388 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
389 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1)",
391 AC_SUBST(AC_DUMMY_VAR($1))])
394 AC_CONFIG_HEADERS(config.h:config.hin)
395 AC_CONFIG_FILES(dummy)
396 m4_for(AC_Count, 1, 100, 1,
397 [AC_DEFUBST(AC_Count)])
405 # Checking that AC_DEFINE worked properly.
407 [m4_for(AT_Count, 1, 100, 1,
410 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE"
412 AT_CHECK([sed -n '3,$ p' config.h], 0, expout)
414 # Checking that AC_SUBST worked properly.
416 [m4_for(AT_Count, 1, 100, 1,
434 AT_DATA([configure.ac],
437 AC_CONFIG_FILES([foo at-dir/bar])
439 AC_CONFIG_COMMANDS([report],
440 [test -f $srcdir/configure.ac ||
441 AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
445 rm -rf foo at-dir/bar
451 AT_CHECK([./configure], [], [ignore])
454 AT_CHECK([cd at-dir && ../configure], [], [ignore])
458 AT_CHECK([cd at-dir && $at_here/configure], [], [ignore])
460 AT_CLEANUP(at-dir foo.in foo)
463 ## ----------------- ##
464 ## Signal handling. ##
465 ## ----------------- ##
467 AT_SETUP([Signal handling])
469 AT_DATA([configure.ac],
476 AT_CHECK_CONFIGURE([], 1, ignore, ignore)