Debian Codegraph @

tests/tools.at

raw
1 # -*- autoconf -*-
2
3 AT_BANNER([Executables (autoheader, autoupdate...).])
4
5 ## -------------------------------------------------------- ##
6 ## Check that the shell scripts are syntactically correct. ##
7 ## -------------------------------------------------------- ##
8
9 # We use `/bin/sh -n script' to check that there are no syntax errors
10 # in the scripts. Although incredible, there are /bin/sh that go into
11 # endless loops with `-n', e.g., SunOS's:
12 #
13 # $ uname -a
14 # SunOS ondine 4.1.3 2 sun4m unknown
15 # $ cat endless.sh
16 # while false
17 # do
18 # :
19 # done
20 # exit 0
21 # $ time sh endless.sh
22 # sh endless.sh 0,02s user 0,03s system 78% cpu 0,064 total
23 # $ time sh -nx endless.sh
24 # ^Csh -nx endless.sh 3,67s user 0,03s system 63% cpu 5,868 total
25 #
26 # So before using `/bin/sh -n' to check our scripts, we first check
27 # that `/bin/sh -n' is not broken to death.
28
29 AT_SETUP([Syntax of the scripts])
30
31 # A script that never returns. We don't care that it never returns,
32 # broken /bin/sh loop equally with `false', but it makes it easier to
33 # test the robusteness in a good environment: just remove the `-n'.
34 AT_DATA(endless.sh,
35 [[while :
36 do
37 :
38 done
39 ]])
40
41 # A script in charge of testing `/bin/sh -n'.
42 AT_DATA(syntax.sh,
43 [[(/bin/sh -n endless.sh) &
44 sleep 2
45 if kill $! >/dev/null 2>&1; then
46 # We managed to kill the child, which means that we probably
47 # can't trust `/bin/sh -n', hence the test failed.
48 exit 77
49 fi
50 ]])
51
52 # If we can't trust sh, just skip.
53 AT_CHECK([/bin/sh ./syntax.sh])
54
55 # Specify the path to the tool, some shells don't honor PATH when
56 # running `sh PROG'.
57
58 AT_CHECK([/bin/sh -n ../autoconf], 0)
59 AT_CHECK([/bin/sh -n ../autoreconf], 0)
60 AT_CHECK([/bin/sh -n ../ifnames], 0)
61
62 # These are not built, they are in the src tree.
63 AT_CHECK([/bin/sh -n $top_srcdir/config/install-sh], 0)
64 AT_CHECK([/bin/sh -n $top_srcdir/config/missing], 0)
65
66 AT_CLEANUP
67
68
69
70
71 ## ----------------- ##
72 ## AWK portability. ##
73 ## ----------------- ##
74
75 AT_SETUP([AWK portability])
76
77 AT_DATA([configure.ac],
78 [])
79
80 # Skip if we don't have GNU Awk.
81 AT_CHECK([gawk --version || exit 77], 0, ignore, ignore)
82
83 # Generation of the script.
84 AT_CHECK([AWK='gawk --posix' autoconf --autoconf-dir .. -l $at_srcdir], 0,
85 [], [])
86 # Tracing.
87 AT_CHECK([AWK='gawk --posix' autoconf --autoconf-dir .. -l $at_srcdir -t AC_INIT], 0,
88 ignore, [])
89 # Syntax correctness of ifnames.
90 AT_CHECK([AWK='gawk --posix' ifnames /dev/null], 0,
91 [], [])
92
93 AT_CLEANUP(configure)
94
95
96
97
98
99
100 ## ------------------ ##
101 ## autoconf --trace. ##
102 ## ------------------ ##
103
104
105 # autoconf --trace: user macros
106 # -----------------------------
107 AT_SETUP([autoconf --trace: user macros])
108
109 AT_DATA(configure.ac,
110 [[m4_define([active], [ACTIVE])
111 m4_define([TRACE1], [TRACE2(m4_shift($@))])
112 m4_define([TRACE2], [[$2], $1])
113 TRACE1(foo, bar, baz)
114 TRACE1(foo, TRACE1(bar, baz))
115 TRACE1(foo, active, baz)
116 TRACE1(foo, [active], TRACE1(active, [active]))
117 ]])
118
119 # Several --traces.
120 AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir -t TRACE1 -t TRACE2], 0,
121 [[configure.ac:4:TRACE1:foo:bar:baz
122 configure.ac:4:TRACE2:bar:baz
123 configure.ac:5:TRACE1:bar:baz
124 configure.ac:5:TRACE2:baz
125 configure.ac:5:TRACE1:foo::baz
126 configure.ac:5:TRACE2::baz
127 configure.ac:6:TRACE1:foo:ACTIVE:baz
128 configure.ac:6:TRACE2:ACTIVE:baz
129 configure.ac:7:TRACE1:ACTIVE:active
130 configure.ac:7:TRACE2:active
131 configure.ac:7:TRACE1:foo:active::ACTIVE
132 configure.ac:7:TRACE2:active::ACTIVE
133 ]])
134
135 # Several line requests.
136 AT_CHECK([[autoconf --autoconf-dir .. -l $at_srcdir -t TRACE1:'
137 [$1], [$2], [$3].']], 0,
138 [[
139 [foo], [bar], [baz].
140
141 [bar], [baz], [].
142
143 [foo], [], [baz].
144
145 [foo], [ACTIVE], [baz].
146
147 [ACTIVE], [active], [].
148
149 [foo], [active], [].
150 ]])
151
152 # ${sep}@.
153 AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir -t TRACE2:'${)===(}@'], 0,
154 [[[bar])===([baz]
155 [baz]
156 [])===([baz]
157 [ACTIVE])===([baz]
158 [active]
159 [active])===([])===([ACTIVE]
160 ]])
161
162 AT_CLEANUP
163
164
165 # autoconf --trace: builtins
166 # --------------------------
167 AT_SETUP([autoconf --trace: builtins])
168
169 AT_DATA(configure.ac,
170 [[define([active], [ACTIVE])
171 ]])
172
173 AT_CHECK([[autoconf --autoconf-dir .. -l $at_srcdir -t define |
174 sed -n '$p']],
175 0,
176 [[configure.ac:1:define:active:ACTIVE
177 ]])
178
179 # FIXME: Without `$1' the following test dies. Groumphf, once again to
180 # dive into obscure feature interaction...
181 # Note that using `-i' means we need the *.m4 files, not the *.m4f files,
182 # hence we need srcdir, not builddir.
183 AT_CHECK([[autoconf --autoconf-dir $top_srcdir -l $at_srcdir -t define:'$1' -i|
184 sed -n '$p']],
185 0,
186 [[active
187 ]])
188
189 AT_CLEANUP
190
191
192
193
194 ## ---------------------------- ##
195 ## autoconf: forbidden tokens. ##
196 ## ---------------------------- ##
197
198 # autoconf: forbidden tokens, basic
199 # ---------------------------------
200 AT_SETUP([autoconf: forbidden tokens, basic])
201
202 AT_DATA([configure.ac],
203 [[AC_PLAIN_SCRIPT()dnl
204 AC_FOO
205 _AC_BAR
206 m4_foo
207 _m4_bar
208 BAC_FOO
209 B_AC_FOO
210 AS_FOO
211 _AS_BAR
212 ]])
213
214 AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 1, [], [stderr])
215 # The output of autoconf is not deterministic here because it
216 # uses `for (ind in array)'. So be sure to have a unique representation.
217 AT_CHECK([sort stderr], 0,
218 [[configure.ac:2: error: possibly undefined macro: AC_FOO
219 configure.ac:3: error: possibly undefined macro: _AC_BAR
220 configure.ac:4: error: possibly undefined macro: m4_foo
221 configure.ac:7: error: possibly undefined macro: B_AC_FOO
222 configure.ac:8: error: possibly undefined macro: AS_FOO
223 configure.ac:9: error: possibly undefined macro: _AS_BAR
224 ]])
225
226 AT_CLEANUP(configure)
227
228
229 # autoconf: forbidden tokens, exceptions
230 # --------------------------------------
231 AT_SETUP([autoconf: forbidden tokens, exceptions])
232
233 AT_DATA([configure.ac],
234 [[AC_PLAIN_SCRIPT()dnl
235
236 # This is allowed in spite of the name.
237 # It is on purpose that we check the case where there are several
238 # tokens on the same line.
239 m4_pattern_allow([^AC_ALLOWED$])
240 NOT_AC_ALLOWED AC_ALLOWED AC_ALLOWED_NOT
241
242 # Test forbidding.
243 m4_pattern_forbid([^FORBIDDEN$])
244 NOT_FORBIDDEN FORBIDDEN FORBIDDEN_NOT
245
246 # Test Autoconf's patterns.
247 AC_THIS_IS_INVALID and _AC_THIS_IS_INVALID_TOO
248 BUT_AZ_THIS_IS_NOT ALTHOUGH_AC_THIS_IS
249 # This is legal, although there is `AC_DEFINE' in there.
250 BAC_DEFINE
251 # AC_THIS_IS_A_COMMENT so just shut up.
252 It would be very bad if Autoconf forgot to expand [AC_]OUTPUT!
253 ]])
254
255 AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 1, [], [stderr])
256 # The output of autoconf is not deterministic here because it
257 # uses `for (ind in array)'. So be sure to have a unique representation.
258 AT_CHECK([sort stderr], 0,
259 [[configure.ac:10: error: possibly undefined macro: FORBIDDEN
260 configure.ac:14: error: possibly undefined macro: AC_THIS_IS_INVALID
261 configure.ac:14: error: possibly undefined macro: _AC_THIS_IS_INVALID_TOO
262 configure.ac:15: error: possibly undefined macro: ALTHOUGH_AC_THIS_IS
263 configure.ac:7: error: possibly undefined macro: AC_ALLOWED_NOT
264 configure.ac:7: error: possibly undefined macro: NOT_AC_ALLOWED
265 configure:18: error: possibly undefined macro: AC_OUTPUT
266 ]])
267
268 AT_CLEANUP(configure err)
269
270
271
272
273
274 ## --------- ##
275 ## ifnames. ##
276 ## --------- ##
277
278 AT_SETUP([ifnames])
279
280 AT_DATA([iftest1.c],
281 [[#ifdef DEF1
282 #ifndef DEF2
283 #if !defined(DEF3) && defined(DEF4) /* but not defined(DEF5) */
284 # if SPACES
285 # if TABS
286 /* #if C_COMMENTS */
287 // #if CXX_COMMENTS
288 #if LINE1 = \
289 LINE2
290 #if (VAL1*VAL2)==VAL3+VAL4 /* Not VAL5 !!! */
291 ]])
292
293 AT_DATA([iftest2.c],
294 [[#ifdef IFTEST2
295 #if VAL1
296 ]])
297
298 AT_CHECK([ifnames iftest1.c iftest2.c], 0,
299 [DEF1 iftest1.c
300 DEF2 iftest1.c
301 DEF3 iftest1.c
302 DEF4 iftest1.c
303 IFTEST2 iftest2.c
304 LINE1 iftest1.c
305 LINE2 iftest1.c
306 SPACES iftest1.c
307 TABS iftest1.c
308 VAL1 iftest1.c iftest2.c
309 VAL2 iftest1.c
310 VAL3 iftest1.c
311 VAL4 iftest1.c
312 ], [])
313
314 AT_CLEANUP
315
316
317
318 ## ------------ ##
319 ## autoheader. ##
320 ## ------------ ##
321
322 # autoheader is intensively used in its modern form through this
323 # test suite. But we also have to check that acconfig.h still works.
324 # autoheader uses autoconf --trace, so traces first.
325
326 AT_SETUP([autoheader])
327
328 AT_DATA(acconfig.h,
329 [[/* Define this to whatever you want. */
330 #undef this
331 ]])
332
333
334 # 1. Check that `acconfig.h' is still honored.
335 AT_DATA(configure.ac,
336 [[AC_INIT
337 AC_CONFIG_HEADERS(config.h)
338 AC_DEFINE(this, "whatever you want.")
339 ]])
340
341 AT_CHECK([autoheader --autoconf-dir .. -<configure.ac], 0,
342 [[/* config.h.in. Generated automatically from - by autoheader. */
343 /* Define this to whatever you want. */
344 #undef this
345 ]], ignore)
346
347
348 # 2. Check that missing templates are a fatal error.
349 AT_DATA(configure.ac,
350 [[AC_INIT
351 AC_CONFIG_HEADERS(config.h)
352 AC_DEFINE(that, "whatever you want.")
353 ]])
354
355 AT_CHECK([autoheader --autoconf-dir .. -<configure.ac], 1, [],
356 [autoheader: No template for symbol `that'
357 ])
358
359
360 # 3. Check TOP and BOTTOM.
361 AT_DATA(acconfig.h,
362 [[/* Top from acconfig.h. */
363 @TOP@
364 /* Middle from acconfig.h. */
365 @BOTTOM@
366 /* Bottom from acconfig.h. */
367 ]])
368
369 AT_DATA(configure.ac,
370 [[AC_INIT
371 AC_CONFIG_HEADERS(config.h)
372 AH_TOP([Top1 from configure.ac.])
373 AH_TOP([Top2 from configure.ac.])
374 AH_VERBATIM([Middle], [Middle from configure.ac.])
375 AH_BOTTOM([Bottom1 from configure.ac.])
376 AH_BOTTOM([Bottom2 from configure.ac.])
377 ]])
378
379
380 # Yes, that's right: the `middle' part of `acconfig.h' is still before
381 # the AH_TOP part. But so what, you're not supposed to use the two
382 # together.
383 AT_CHECK([autoheader --autoconf-dir .. -<configure.ac], 0,
384 [[/* config.h.in. Generated automatically from - by autoheader. */
385 /* Top from acconfig.h. */
386
387 /* Middle from acconfig.h. */
388
389 Top1 from configure.ac.
390
391 Top2 from configure.ac.
392
393 Middle from configure.ac.
394
395 Bottom1 from configure.ac.
396
397 Bottom2 from configure.ac.
398 /* Bottom from acconfig.h. */
399 ]], [])
400
401
402 AT_CLEANUP
403
404
405
406
407 ## ------------ ##
408 ## autoupdate. ##
409 ## ------------ ##
410
411 # Check that AC_CANONICAL_SYSTEM and AC_OUTPUT are properly updated.
412 AT_SETUP([autoupdate])
413
414 AT_DATA(configure.ac,
415 [[AC_INIT(Test, 1.0)
416 AC_CANONICAL_SYSTEM
417 dnl The doc says 27 is a valid fubar.
418 fubar=27
419 AC_OUTPUT(Makefile, echo $fubar, fubar=$fubar)
420 ]])
421
422 AT_DATA([expout],
423 [[AC_INIT([Test],[1.0])
424 AC_CANONICAL_TARGET([])
425 dnl The doc says 27 is a valid fubar.
426 fubar=27
427 AC_OUTPUT(Makefile, echo $fubar, fubar=$fubar)
428 ]])
429
430 # Checking `autoupdate'.
431 AT_CHECK_AUTOUPDATE
432 AT_CHECK([cat configure.ac], 0, [expout])
433 # Checking that `autoupdate' is idempotent
434 AT_CHECK([autoupdate --autoconf-dir $top_srcdir], 0, [],
435 [autoupdate: `configure.ac' is unchanged
436 ])
437 AT_CHECK([cat configure.ac], 0, [expout])
438
439 AT_CLEANUP(configure.ac~)
440
441
442 # autoupdating AC_LINK_FILES
443 # --------------------------
444 AT_SETUP([autoupdating AC_LINK_FILES])
445
446 AT_DATA(configure.ac,
447 [[AC_INIT
448 AC_LINK_FILES(dst1 dst2, src1 src2)
449 AC_OUTPUT
450 ]])
451
452 AT_DATA(dst1, dst1
453 )
454 AT_DATA(dst2, dst2
455 )
456
457 # Checking `autoupdate'.
458 AT_CHECK_AUTOUPDATE
459 AT_CHECK_AUTOCONF
460 AT_CHECK_CONFIGURE
461 AT_CHECK([cat src1], 0, [dst1
462 ])
463 AT_CHECK([cat src2], 0, [dst2
464 ])
465
466 AT_CLEANUP(src1 src2 configure.ac~)
467
468
469 # autoupdating AC_PREREQ
470 # ----------------------
471 AT_SETUP([autoupdating AC_PREREQ])
472
473 cat >expout <<EOF
474 AC_PREREQ($at_version)
475 EOF
476
477 AT_CHECK([autoupdate --version || exit 77], ignore, ignore, ignore)
478 AT_CHECK([echo "AC_PREREQ(1.0)" |
479 autoupdate --autoconf-dir $top_srcdir -],
480 0, [expout], [])
481
482 AT_CHECK([echo "AC_PREREQ($at_version)" |
483 autoupdate --autoconf-dir $top_srcdir -],
484 0, [expout], [])
485
486 AT_CHECK([echo "AC_PREREQ(999.99)" |
487 autoupdate --autoconf-dir $top_srcdir -],
488 1, [], [ignore])
489
490 AT_CLEANUP