5 # Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation,
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 # AT_CHECK_AT_PREP(NAME, SUITE-CODE, [STATUS = 0], [STDOUT], [STDERR],
25 # --------------------------------------------------------------------
26 # Create a new testsuite named NAME that runs a minimal Autotest test suite,
27 # SUITE-CODE. Do not use `testsuite' for NAME, or the log file it generates
28 # will overwrite the log that the Autoconf test produces when managing
29 # this test case. STATUS, STDOUT, and STDERR pass directly to the AT_CHECK
30 # that compiles the testsuite. DIR can specify a particular subdirectory
31 # where the testsuite should live.
32 m4_define([AT_CHECK_AT_PREP],
33 [AT_KEYWORDS([autotest])dnl
34 dnl overquote AT_dir, to make it easier to use
35 m4_pushdef([AT_dir], m4_ifval([$6], [[[$6]]], [.]))dnl
37 AT_CAPTURE_FILE([$1.log])dnl
39 AT_DATA(AT_dir[/package.m4],
40 [[m4_define([AT@&t@_PACKAGE_NAME], [GNU Nonsense])
41 m4_define([AT@&t@_PACKAGE_TARNAME], [nonsense])
42 m4_define([AT@&t@_PACKAGE_VERSION], [1.0])
43 m4_define([AT@&t@_PACKAGE_STRING], [GNU Nonsense 1.0])
44 m4_define([AT@&t@_PACKAGE_BUGREPORT], [bug-autoconf@gnu.org])
47 AT_DATA(AT_dir[/$1.at], m4_bpatsubst([[$2]], [AT_], [AT@&t@_]))
48 m4_ifval([$6], [(cd AT_dir])
49 AT_CHECK_AUTOM4TE([--language=autotest -o $1 $1.at], [$3], [$4], [$5])
51 m4_popdef([AT_dir])dnl
54 # AT_CHECK_AT(TITLE, SUITE-CODE, [XFAIL-CONDITION], [STATUS = 0],
55 # [STDOUT = ignore], STDERR, [POST-TEST-CODE], [SUITE-ARGS])
56 # ----------------------------------------------------------------------
57 # Create a new test named TITLE that runs a minimal Autotest test suite,
58 # SUITE-CODE with additional SUITE-ARGS, once without and once with
59 # '-v -x' added. Call AT_XFAIL_IF with XFAIL-CONDITION. Pass STDERR
60 # directly to the AT_CHECK that calls the minimal test suite, STDOUT to
61 # the AT_CHECK without '-v -x'; ignore stdout for the latter.
62 # Run POST-TEST-CODE at the top level after the micro-suite has been run.
63 m4_define([AT_CHECK_AT],
66 AT_CHECK_AT_PREP([micro-suite], [$2])
68 AT_CHECK([$CONFIG_SHELL ./micro-suite $8], m4_default([$4], 0),
69 m4_default([$5], [ignore]), [$6])
70 AT_CHECK([$CONFIG_SHELL ./micro-suite -v -x $8], m4_default([$4], 0),
76 # AT_CHECK_AT_TEST(TITLE, SUITE-SNIPPET, ...)
77 # -----------------------------------------------------------------------
78 # Wrapper for AT_CHECK_AT that surrounds SUITE-SNIPPET with a boilerplate
79 # AT_INIT, AT_SETUP, and AT_CLEANUP and passes other arguments verbatim.
80 m4_define([AT_CHECK_AT_TEST],
83 AT_INIT([artificial test suite])
84 AT_SETUP([my only test])
87 ]], m4_shift2($@))]) # AT_CHECK_AT_TEST
89 # AT_CHECK_AT_SYNTAX(TITLE, SUITE, MESSAGE)
90 # -----------------------------------------
91 # Create a test named TITLE that tries compiling SUITE with syntax
92 # errors with autotest. Expect a failed compilation, and grep for
93 # MESSAGE occuring within the error output.
94 m4_define([AT_CHECK_AT_SYNTAX],
96 AT_CHECK_AT_PREP([micro-suite], [$2], [1], [], [stderr])
97 AT_CHECK([grep '$3' stderr], [0], [ignore])
99 ])# AT_CHECK_AT_SYNTAX
104 m4_define([AT_NO_CMDSUBST],
105 [if (eval 'foo=$(echo bar) && test "$foo" = bar') >/dev/null 2>&1; then ]dnl
108 # AT_CHECK_EGREP(PATTERN, STATUS, COUNT)
109 # --------------------------------------
110 # Run grep -E, counting how many times PATTERN occurs in the file 'stdout',
111 # and expecting exit STATUS and output COUNT.
112 m4_define([AT_CHECK_EGREP],
113 [AT_CHECK([$EGREP -c '$1' stdout], [$2], [$3
118 ## ------------------ ##
119 ## Empty test suite. ##
120 ## ------------------ ##
122 # This is not a sensible thing to do, but the user should not get an unhelpful
124 AT_CHECK_AT([Empty test suite],
125 [[AT_INIT([empty test suite])
128 AT_CHECK_AT([Banner-only test suite],
129 [[AT_INIT([empty test suite])
133 # Next level of emptiness.
134 AT_CHECK_AT_TEST([Empty test], [])
136 # And finally, an empty check should not cause a syntax error.
137 AT_CHECK_AT_TEST([Empty check], [AT_CHECK])
139 # Check for sensible error messages for common bugs.
140 AT_CHECK_AT_SYNTAX([AT@&t@_SETUP without AT@&t@_INIT],
141 [[AT_SETUP([only test])
144 ]], [AT@&t@_SETUP: missing AT@&t@_INIT detected])
146 AT_CHECK_AT_SYNTAX([AT@&t@_BANNER without AT@&t@_INIT],
147 [[AT_BANNER([just a banner])
148 ]], [AT@&t@_BANNER: missing AT@&t@_INIT detected])
150 AT_CHECK_AT_SYNTAX([AT@&t@_CLEANUP without AT@&t@_INIT],
152 ]], [AT@&t@_CLEANUP: missing AT@&t@_INIT detected])
154 AT_CHECK_AT_SYNTAX([Missing AT@&t@_CLEANUP],
155 [[AT_INIT([incomplete test suite])
156 AT_SETUP([only test])
158 ]], [missing AT@&t@_CLEANUP detected])
160 AT_CHECK_AT_SYNTAX([AT@&t@_CHECK without AT@&t@_SETUP],
161 [[AT_INIT([incomplete test suite])
163 ]], [AT@&t@_CHECK: missing AT@&t@_SETUP detected])
165 AT_CHECK_AT_SYNTAX([AT@&t@_DATA without AT@&t@_SETUP],
166 [[AT_INIT([incomplete test suite])
168 ]], [AT@&t@_DATA: missing AT@&t@_SETUP detected])
170 AT_CHECK_AT_SYNTAX([AT@&t@_XFAIL_IF without AT@&t@_SETUP],
171 [[AT_INIT([incomplete test suite])
173 ]], [AT@&t@_XFAIL_IF: missing AT@&t@_SETUP detected])
175 AT_CHECK_AT_SYNTAX([AT@&t@_KEYWORDS without AT@&t@_SETUP],
176 [[AT_INIT([incomplete test suite])
177 AT_KEYWORDS([keyword])
178 ]], [AT@&t@_KEYWORDS: missing AT@&t@_SETUP detected])
180 AT_CHECK_AT_SYNTAX([AT@&t@_CLEANUP without AT@&t@_SETUP],
181 [[AT_INIT([incomplete test suite])
183 ]], [AT@&t@_CLEANUP: missing AT@&t@_SETUP detected])
185 AT_CHECK_AT_SYNTAX([AT@&t@_BANNER inside AT@&t@_SETUP],
186 [[AT_INIT([incomplete test suite])
187 AT_SETUP([only test])
191 ]], [AT@&t@_BANNER: nested AT@&t@_SETUP detected])
193 AT_CHECK_AT_SYNTAX([AT@&t@_SETUP inside AT@&t@_SETUP],
194 [[AT_INIT([incomplete test suite])
195 AT_SETUP([only test])
196 AT_SETUP([nested test])
201 ]], [AT@&t@_SETUP: nested AT@&t@_SETUP detected])
203 AT_CHECK_AT_SYNTAX([Multiple AT@&t@_INIT],
204 [[AT_INIT([[suite, take one]])
206 ]], [AT@&t@_INIT: invoked multiple times])
208 # Check for tested programs. autoconf should only appear once.
209 AT_CHECK_AT([Tested programs],
210 [[AT_INIT([programs test suite])
211 AT_TESTED([autoconf autom4te])
212 AT_TESTED([autoconf])
214 [AT_CHECK([[sed -n 's|.*/\([^ /]* --version\)|\1|p' micro-suite.log]], [],
219 ## ----------------------------------------------------- ##
220 ## Newlines and command substitutions in test commands. ##
221 ## ----------------------------------------------------- ##
223 AT_CHECK_AT_TEST([Truth],
224 [AT_CHECK([:], 0, [], [])])
226 AT_CHECK_AT_TEST([Fallacy],
227 [AT_CHECK([false], [], [], [])],
228 [], [1], [], [ignore],
229 [AT_CHECK([grep failed micro-suite.log], [], [ignore])])
231 AT_CHECK_AT_TEST([Skip],
232 [AT_CHECK([exit 77], 0, [], [])],
234 [AT_CHECK([grep skipped micro-suite.log], [], [ignore])])
236 AT_CHECK_AT_TEST([errexit],
239 AT_SETUP([test that should not be run])
241 [], [1], [stdout], [stderr],
242 [AT_CHECK([test -f micro-suite.log], [1])
243 touch micro-suite.log # shut up AT_CAPTURE_FILE.
244 AT_CHECK([grep "should not be run" stdout], [1])
245 AT_CHECK([grep "1 .* inhibited subsequent" stderr], [], [ignore])],
248 AT_CHECK_AT_TEST([Literal multiline command],
249 [AT_CHECK([echo Auto'
254 AT_CHECK_AT_TEST([Multiline parameter expansion],
257 AT_CHECK([echo "$FOO"], 0, [one
261 AT_CHECK_AT_TEST([Backquote command substitution],
262 [AT_CHECK([echo `echo hi`], 0, [hi
266 AT_CHECK_AT_TEST([Multiline backquote command substitution],
267 [AT_DATA([myfile],[foo
270 AT_CHECK([echo "`cat myfile`"], 0, [foo
274 AT_CHECK_AT_TEST([Parenthetical command substitution],
275 [AT_CHECK([echo $(echo hi)], 0, [hi
279 AT_CHECK_AT_TEST([Multiline parenthetical command substitution],
280 [AT_DATA([myfile],[foo
283 AT_CHECK([echo "$(cat myfile)"], 0, [foo
289 ## ------------------------- ##
290 ## ${...} in test commands. ##
291 ## ------------------------- ##
293 # If this invalid parameter expansion capsizes the test suite, the entire
294 # AT_SETUP ... AT_CLEANUP subshell will exit, and the commands it runs will
295 # appear to have succeeded. Therefore, we verify a failing test case.
297 AT_CHECK_AT_TEST([Invalid brace-enclosed parameter expansion],
298 [AT_CHECK([echo '${=invalid}'], 0, [wrong])], [false], 1, ignore, ignore)
301 ## ---------------------------- ##
302 ## M4 macros in test commands. ##
303 ## ---------------------------- ##
305 # The last paragaph in the comment above _AT_DECIDE_TRACEABLE illustrates why
306 # this test fails (except with Korn shell-style quoting $'foo\nbar').
307 AT_CHECK_AT_TEST([Multiline command from M4 expansion],
308 [m4_define([GNU], ['foo
310 AT_CHECK([echo GNU], 0, [foo
312 ], [])], [case `( set -x; echo 'foo
313 bar') 2>&1` in *\$\'foo\\nbar\'*) false;; *) :;; esac])
315 AT_CHECK_AT_TEST([Double-M4-quoted command],
316 [m4_define([GNU], ['foo
318 AT_CHECK([[echo GNU]], 0, [[GNU
322 ## -------------------------------------- ##
323 ## Backslash-<newline> in test commands. ##
324 ## -------------------------------------- ##
326 AT_CHECK_AT_TEST([BS-newline in command],
327 [AT_CHECK([echo Auto"\
331 AT_CHECK_AT_TEST([^BS-newline in command],
336 AT_CHECK_AT_TEST([BSx641-newline in command],
337 [AT_CHECK([printf '%s\n' Auto"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
338 "conf], 0, [Auto\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\conf
341 AT_CHECK_AT_TEST([BS-BS-newline in command],
342 [AT_CHECK([printf '%s\n' Auto"\\
347 # A `^BS-BS-newline in command' test will run a command named `\'. No, thanks.
349 AT_CHECK_AT_TEST([BSx640-newline in command],
350 [AT_CHECK([printf '%s\n' Auto"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
351 "conf], 0, [Auto\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
355 # This command has both escaped and unescaped newlines.
356 AT_CHECK_AT_TEST([Newline-CODE-BS-newline in command],
357 [AT_CHECK([printf '%s\n' Auto'
363 AT_CHECK_AT_TEST([Single-quote-BS-newline in command],
364 [AT_CHECK([printf '%s\n' Auto'\
369 AT_CHECK_AT_TEST([Single-quote-newline-BS-newline in command],
370 [AT_CHECK([printf '%s\n' Auto'
378 ## ----------------- ##
379 ## Input from stdin. ##
380 ## ----------------- ##
382 AT_SETUP([Input from stdin])
384 AT_CHECK_AT_PREP([micro-suite],
386 AT_SETUP([please enter hello<RETURN><EOF>])
387 AT_CHECK([cat], [], [hello
392 AT_CHECK([echo hello | $CONFIG_SHELL ./micro-suite], [], [ignore])
393 AT_CHECK([$CONFIG_SHELL ./micro-suite </dev/null], [1], [ignore], [ignore])
398 ## ------------------------------- ##
399 ## Funny characters in test names. ##
400 ## ------------------------------- ##
402 # AT_CHECK_AT_TITLE(TITLE, TITLE-TO-TEST, EXPANDED-TITLE-TO-TEST
403 # [XFAIL-CONDITION], [COLUMN = 53])
404 # ---------------------------------------------------------------
405 # Create a new test named TITLE that runs an Autotest test suite
406 # comprised of a trivial test named TITLE-TO-TEST, which expands
407 # to EXPANDED-TITLE-TO-TEST. XFAIL-CONDITION passes verbatim to
408 # AT_CHECK_AT. Verify that `ok' prints at COLUMN.
409 m4_define([AT_CHECK_AT_TITLE],
412 m4@&t@_define([macro_name], [[macro_expanded]])
413 m4@&t@_define([macro_expanded], [[macro_overexpanded]])
414 m4@&t@_define([macro_backquote], [`])
415 m4@&t@_define([macro_single_quote], ['])
416 m4@&t@_define([macro_double_quote], ["])
417 ]]dnl restore font-lock: "
418 [[m4@&t@_define([macro_backslash], [\])
419 m4@&t@_define([macro_echo], [$][1])
420 AT_INIT([artificial test suite])
424 ]], [$4], [], [], [],
425 dnl This sed script checks for two things - that the output is properly
426 dnl expanded, and that the 'ok' starts on the right column.
427 [AT_CHECK([[$CONFIG_SHELL ./micro-suite |
430 s/[^:]*: \(.*[^ ]\)[ ]*ok.*/\1/p
432 s/^.\{]]]m4_default($5, 53)[[[\}ok.*/ok/p
437 AT_CHECK([[$CONFIG_SHELL ./micro-suite -l |
438 sed -n 's/.*[0-9]: [^ ][^ ]*[ ][ ]*\(.*[^ ]\)[ ]*/\1/p']],,
441 AT_CHECK([[sed -n 's/[^.]*\. \(.*\) ([^)]*): ok.*/\1/p' micro-suite.log]],,
446 m4_define([AT_CHECK_AT_TITLE_CHAR],
447 [AT_CHECK_AT_TITLE([$1 in a test title], [A $2 in my name],
448 [A ]m4_ifval([$3], [[$3]], [[$2]])[ in my name], $4, $5)])
450 AT_CHECK_AT_TITLE_CHAR([Backquote], [`])
451 AT_CHECK_AT_TITLE_CHAR([Single-quote], ['])
452 AT_CHECK_AT_TITLE_CHAR([Double-quote], ["])
453 dnl restore font-lock: "
454 AT_CHECK_AT_TITLE_CHAR([Backslash], [\])
455 AT_CHECK_AT_TITLE_CHAR([Brackets], [[[]]], [[]])
456 AT_CHECK_AT_TITLE_CHAR([Left bracket], [@<@&t@:@], [@<:@])
457 AT_CHECK_AT_TITLE_CHAR([Right bracket], [@:@&t@>@], [@:>@])
458 AT_CHECK_AT_TITLE_CHAR([Pound], [[#]], [#])
459 AT_CHECK_AT_TITLE_CHAR([Quoted comma],[[,]], [,])
460 AT_CHECK_AT_TITLE_CHAR([Comma], [,], [,])
461 AT_CHECK_AT_TITLE_CHAR([Parentheses], [()])
462 AT_CHECK_AT_TITLE_CHAR([Left paren], [@{@&t@:@], [(])
463 AT_CHECK_AT_TITLE_CHAR([Right paren], [@:@&t@}@], [)])
465 AT_CHECK_AT_TITLE_CHAR([Quoted Macro], [[macro_name]], [macro_name])
466 AT_CHECK_AT_TITLE_CHAR([Macro], [macro_name], [macro_expanded])
467 AT_CHECK_AT_TITLE_CHAR([Macro with backquote], [macro_backquote], [`])
468 AT_CHECK_AT_TITLE_CHAR([Macro with single-quote], [macro_single_quote], ['])
469 AT_CHECK_AT_TITLE_CHAR([Macro with double-quote], [macro_double_quote], ["])
470 dnl restore font-lock: "
471 AT_CHECK_AT_TITLE_CHAR([Macro with backslash], [macro_backslash], [\])
472 AT_CHECK_AT_TITLE_CHAR([Macro echoing macro], [macro_echo([macro_name])],
474 AT_CHECK_AT_TITLE_CHAR([Macro echoing single-quote], [macro_echo(['])], ['])
475 AT_CHECK_AT_TITLE_CHAR([Long test title], [0123456789012345678901234567890123])
476 AT_CHECK_AT_TITLE_CHAR([Longer test title],
477 [01234567890123456789012345678901234], [], [], [54])
480 ## ----------------------- ##
481 ## Long test source lines. ##
482 ## ----------------------- ##
484 # Create a test file that has more than 99 words in a line, for Solaris awk.
485 # While at that, try out the limit of 2000 bytes in a text file line.
487 AT_CHECK_AT_TEST([Long test source lines],
488 [m4_for([nnn], [1], [999], [], [: ])
490 ], [], [], [], [ignore],
491 [AT_CHECK([$CONFIG_SHELL ./micro-suite -k skipalltests], [], [ignore], [ignore])
495 ## ----------------- ##
496 ## Debugging a test. ##
497 ## ----------------- ##
499 AT_CHECK_AT_TEST([Debugging a successful test],
500 [AT_CHECK([:])], [], [], [], [ignore],
501 [# Without options, when all tests pass, no test directory should exist.
502 AT_CHECK([test -d micro-suite.dir/1 && exit 42
503 $CONFIG_SHELL ./micro-suite -d 1], [], [ignore], [ignore])
504 # Running with -d should leave a reproducible test group.
505 # Also, running the test script from the test group locks the
506 # directory from removal on some platforms; the script should still be
507 # able to run even if rmdir fails.
508 AT_CHECK([(cd micro-suite.dir/1 && ./run)], [], [ignore], [ignore])
509 # Running a debugging script implies -d.
510 AT_CHECK([(cd micro-suite.dir/1 && ./run)], [], [ignore], [ignore])
513 AT_CHECK_AT_TEST([Debugging script and environment],
514 [AT_CHECK([test "$MY_VAR" = pass || exit 42])],
515 [], [1], [], [ignore], [
516 # Changing environment outside of debugging script is not preserved.
517 AT_CHECK([(cd micro-suite.dir/1 && MY_VAR=pass ./run)],
518 [0], [ignore], [ignore])
519 AT_CHECK([(cd micro-suite.dir/1 && ./run)],
520 [1], [ignore], [ignore])
521 # Changing environment as argument to debugging script is preserved.
522 AT_CHECK([(cd micro-suite.dir/1; ./run MY_VAR=pass)],
523 [0], [ignore], [ignore])
524 AT_CHECK([(cd micro-suite.dir/1; ./run)],
525 [0], [ignore], [ignore])
528 # The run script must still be valid when shell metacharacters are passed
529 # in via an environment option.
530 AT_CHECK_AT_TEST([Debugging a failed test],
531 [AT_CHECK([test "$MY_VAR" = "one space" || exit 42])],
532 [], [1], [], [ignore], [
533 AT_CHECK([(cd micro-suite.dir/1 && ./run MY_VAR='two spaces')],
534 [1], [ignore], [ignore])
535 AT_CHECK([(cd micro-suite.dir/1 && ./run MY_VAR='one space')],
536 [0], [ignore], [ignore])
540 # Setting default variable values via atlocal.
541 AT_CHECK_AT_TEST([Using atlocal],
542 [AT_CHECK([test "x$MY_VAR" = "xodd; 'string" || exit 42])],
543 [], [1], [ignore], [ignore], [
544 dnl check that command line can set variable
545 AT_CHECK([$CONFIG_SHELL ./micro-suite MY_VAR="odd; 'string"], [0], [ignore])
546 dnl check that command line overrides environment
547 AT_CHECK([MY_VAR="odd; 'string" $CONFIG_SHELL ./micro-suite MY_VAR=unset],
548 [1], [ignore], [ignore])
549 dnl check that atlocal can give it a default
550 AT_CHECK([cat <<EOF >atlocal
551 MY_VAR="odd; 'string"
553 dnl Also populate enough of atlocal to do what atconfig normally does.
559 abs_top_srcdir='`pwd`'
561 abs_top_builddir='`pwd`'
564 AT_CHECK([$CONFIG_SHELL ./micro-suite], [0], [ignore])
565 dnl check that atlocal overrides environment
566 AT_CHECK([MY_VAR=unset $CONFIG_SHELL ./micro-suite], [0], [ignore])
567 dnl check that command line overrides atlocal
568 AT_CHECK([$CONFIG_SHELL ./micro-suite MY_VAR=], [1], [ignore], [ignore])
569 dnl check that syntax error is detected
570 AT_CHECK([$CONFIG_SHELL ./micro-suite =], [1], [], [ignore], [ignore])
571 AT_CHECK([$CONFIG_SHELL ./micro-suite 1=2], [1], [], [ignore], [ignore])
575 # Controlling where the testsuite is run.
576 AT_CHECK_AT_TEST([Choosing where testsuite is run],
577 [AT_CHECK([:])], [], [], [], [], [
578 dnl AT_CHECK_AT_TEST tests the default of running in `.'.
579 AT_CHECK([$CONFIG_SHELL ./micro-suite --clean])
580 AT_CHECK([test -f micro-suite.log], [1])
581 AT_CHECK([test -d micro-suite.dir], [1])
582 AT_CHECK([mkdir sub1 sub2])
583 dnl check specifying a different relative path to run in.
584 AT_CHECK([$CONFIG_SHELL ./micro-suite -C sub1], [0], [ignore], [])
585 AT_CHECK([test -f micro-suite.log], [1])
586 AT_CHECK([test -f sub1/micro-suite.log], [0])
587 AT_CHECK([test -d micro-suite.dir], [1])
588 AT_CHECK([test -d sub1/micro-suite.dir], [0])
589 AT_CHECK([$CONFIG_SHELL ./micro-suite -C sub1 --clean])
590 AT_CHECK([test -f sub1/micro-suite.log], [1])
591 AT_CHECK([test -d sub1/micro-suite.dir], [1])
592 dnl check specifying an absolute path to run in.
593 AT_CHECK([$CONFIG_SHELL ./micro-suite --directory="`pwd`/sub2"],
595 AT_CHECK([test -f micro-suite.log], [1])
596 AT_CHECK([test -f sub2/micro-suite.log], [0])
597 AT_CHECK([$CONFIG_SHELL ./micro-suite --clean --directory="`pwd`/sub2"])
598 AT_CHECK([test -f sub2/micro-suite.log], [1])
599 AT_CHECK([test -f sub2/micro-suite.dir], [1])
600 dnl check for failure detection with bad, missing, or empty directory.
601 AT_CHECK([$CONFIG_SHELL ./micro-suite -C nonesuch], [1], [ignore], [ignore])
602 AT_CHECK([$CONFIG_SHELL ./micro-suite -C ''], [1], [ignore], [ignore])
603 AT_CHECK([$CONFIG_SHELL ./micro-suite -C -], [1], [ignore], [ignore])
604 AT_CHECK([$CONFIG_SHELL ./micro-suite -C], [1], [ignore], [ignore])
605 dnl check that --help overrides bad directory selection.
606 AT_CHECK([$CONFIG_SHELL ./micro-suite -C nonesuch --help], [0], [ignore], [])
615 AT_CHECK_AT_PREP([b],
643 # AT_CHECK_BANNERS(TESTSUITE-OPTIONS, PATTERN1, COUNT1, PATTERN2, COUNT2)
644 m4_define([AT_CHECK_BANNERS],
645 [AT_CHECK([$CONFIG_SHELL ./b $1], [], [stdout])
646 AT_CHECK_EGREP([$2], m4_if([$3], [0], [1], [0]), [$3])
647 AT_CHECK_EGREP([$4], m4_if([$5], [0], [1], [0]), [$5])
650 AT_CHECK_BANNERS([], [first], [1], [second], [1])
651 AT_CHECK_BANNERS([-k zero], [first], [0], [second], [0])
652 AT_CHECK_BANNERS([1], [first], [0], [second], [0])
653 AT_CHECK_BANNERS([-2], [first], [1], [second], [0])
654 AT_CHECK_BANNERS([-3], [first], [1], [second], [0])
655 AT_CHECK_BANNERS([-k one], [first], [1], [second], [0])
656 AT_CHECK_BANNERS([3-4], [first], [1], [second], [0])
657 AT_CHECK_BANNERS([3-5], [first], [1], [second], [1])
658 AT_CHECK_BANNERS([4-5], [first], [0], [second], [1])
659 AT_CHECK_BANNERS([3-], [first], [1], [second], [1])
660 AT_CHECK_BANNERS([-k a], [first], [1], [second], [1])
661 AT_CHECK_BANNERS([4], [first], [0], [second], [0])
662 AT_CHECK_BANNERS([4-], [first], [0], [second], [1])
663 AT_CHECK_BANNERS([-k two], [first], [0], [second], [0])
664 AT_CHECK_BANNERS([1 4], [first], [0], [second], [0])
665 AT_CHECK_BANNERS([-k three], [first], [0], [second], [1])
666 AT_CHECK_BANNERS([5], [first], [0], [second], [0])
667 AT_CHECK_BANNERS([5-], [first], [0], [second], [1])
674 AT_SETUP([Keywords and ranges])
676 AT_CHECK_AT_PREP([k],
690 AT_KEYWORDS([key1 key2])
695 dnl check that AT_KEYWORDS does not duplicate words
696 AT_CHECK([grep 'key1.*key1' k], [1])
697 dnl check that -k requires an argument
698 AT_CHECK([$CONFIG_SHELL ./k -k], [1], [], [ignore])
700 # AT_CHECK_KEYS(TESTSUITE-OPTIONS, PATTERN1, COUNT1, PATTERN2, COUNT2)
701 m4_define([AT_CHECK_KEYS],
702 [AT_CHECK([$CONFIG_SHELL ./k $1], 0, [stdout])
703 AT_CHECK_EGREP([$2], 0, [$3])
704 AT_CHECK_EGREP([$4], 1, [$5])
707 AT_CHECK_KEYS([-k key1], [first|both], [2], [none|second], [0])
708 AT_CHECK_KEYS([-k key2], [second|both], [2], [none|first], [0])
709 AT_CHECK_KEYS([-k key1,key2], [both], [1], [none|first|second], [0])
710 AT_CHECK_KEYS([-k key1 -k key2], [first|second|both], [3], [none], [0])
711 AT_CHECK_KEYS([-k '!key1'], [none|second], [2], [first|both], [0])
712 AT_CHECK_KEYS([-k '!key2'], [none|first], [2], [second|both], [0])
713 AT_CHECK_KEYS([-k '!key1,key2'], [second], [1], [none|first|both], [0])
714 AT_CHECK_KEYS([-k 'key1,!key2'], [first], [1], [none|second|both], [0])
715 AT_CHECK_KEYS([-k '!key1,!key2'], [none], [1], [first|second|both], [0])
716 AT_CHECK_KEYS([-k '!key1' -k KEY2], [none|second|both], [3], [first], [0])
717 AT_CHECK_KEYS([-k key1 -k '!key2'], [none|first|both], [3], [second], [0])
718 AT_CHECK_KEYS([-k '!KEY1' -k '!key2'], [none|first|second], [3], [both], [0])
720 AT_CHECK_KEYS([-k none], [none], [1], [first|second|both], [0])
721 AT_CHECK_KEYS([-k key1,both], [both], [1], [none|first|second], [0])
722 AT_CHECK_KEYS([-k key1 -k both], [first|both], [2], [none|second], [0])
723 AT_CHECK_KEYS([-k none,first], [successful], [1], [none|first|second|both], [0])
724 AT_CHECK_KEYS([-k none,first,second,both], [successful], [1], [none|first|second|both], [0])
725 AT_CHECK_KEYS([-k !none,first], [first], [1], [none|second|both], [0])
727 AT_CHECK_KEYS([-k '.*eco.*'], [second], [1], [none|first|both], [0])
728 AT_CHECK_KEYS([-k 'ECO'], [successful], [1], [none|first|second|both], [0])
729 AT_CHECK_KEYS([-k '.*eco'], [successful], [1], [none|first|second|both], [0])
730 AT_CHECK_KEYS([-k 'eco.*'], [successful], [1], [none|first|second|both], [0])
731 AT_CHECK_KEYS([-k 'fir.*'], [first], [1], [none|second|both], [0])
733 AT_CHECK_KEYS([1-2], [none|first], [2], [second|both], [0])
734 AT_CHECK_KEYS([1-3 2-1], [none|first|second], [3], [both], [0])
735 AT_CHECK_KEYS([-3], [none|first|second], [3], [both], [0])
736 AT_CHECK_KEYS([4-], [both], [1], [none|first|second], [0])
737 AT_CHECK_KEYS([-k second 4-], [second|both], [2], [none|first], [0])
739 AT_CHECK([$CONFIG_SHELL ./k 0], [1], [ignore], [ignore])
740 AT_CHECK([$CONFIG_SHELL ./k 0-], [1], [ignore], [ignore])
741 AT_CHECK([$CONFIG_SHELL ./k -0], [1], [ignore], [ignore])
742 AT_CHECK([$CONFIG_SHELL ./k 5], [1], [ignore], [ignore])
743 AT_CHECK([$CONFIG_SHELL ./k 5-], [1], [ignore], [ignore])
744 AT_CHECK([$CONFIG_SHELL ./k 1-5], [1], [ignore], [ignore])
745 AT_CHECK([$CONFIG_SHELL ./k -k nonexistent], [0], [ignore])
747 AT_CHECK_KEYS([--list -k nonexistent], [KEYWORDS], [1], [first|second|both], [0])
748 AT_CHECK_KEYS([--list 1], [none], [1], [first|second|both], [0])
749 AT_CHECK_KEYS([--list -k none -k first], [none|first], [2], [second|both], [0])
753 ## ------------------- ##
754 ## srcdir propagation. ##
755 ## ------------------- ##
757 AT_SETUP([srcdir propagation])
759 mkdir pkg vpath-outside vpath-abs
760 mkdir pkg/t pkg/vpath-inside
764 AT_DATA([pkg/configure.ac], [[AC_INIT
765 AC_CONFIG_TESTDIR([t])
768 cp "$abs_top_srcdir/build-aux/install-sh" pkg
774 AT_CHECK_AT_PREP([suite],
775 [[AT_INIT([suite to check srcdir])
776 AT_SETUP([my only test])
777 AT_CHECK([test -f "$top_srcdir"/a && test -f "$srcdir"/b])
779 ]], [], [], [], [pkg/t])
781 # Build directory totally outside source directory.
783 AT_CHECK([../pkg/configure], [0], [ignore])
785 AT_CHECK([../../pkg/t/suite], [0], [ignore])
788 # Build directory totally outside source directory (absolute).
791 AT_CHECK(["$my_srcdir"/configure], [0], [ignore])
793 AT_CHECK(["$my_srcdir"/t/suite], [0], [ignore])
796 # Build directory as subdirectory of source directory.
798 AT_CHECK([../configure], [0], [ignore])
800 AT_CHECK([../../t/suite], [0], [ignore])
803 # Build directory as parent of source directory.
804 AT_CHECK([pkg/configure], [0], [ignore])
806 AT_CHECK([../pkg/t/suite], [0], [ignore])
809 # Build directory as source directory.
813 AT_CHECK([./suite], [0], [ignore])
819 ## ------------------------------ ##
820 ## whitespace in absolute testdir ##
821 ## ------------------------------ ##
823 AT_SETUP([whitespace in absolute testdir])
825 dir='dir with whitespace'
831 AT_CHECK_AT_PREP([suite],
832 [[AT_INIT([suite to check srcdir])
833 AT_SETUP([my only test])
834 AT_CHECK([test -f "$top_srcdir"/a])
837 AT_CHECK([top_srcdir=$wd ./suite], [0], [ignore])
838 AT_CHECK([top_srcdir=$wd ./suite -d], [0], [ignore])
839 AT_CHECK([cd suite.dir/1 && ./run top_srcdir="$wd"], [0], [ignore], [ignore])
843 ## ------------------ ##
844 ## unusual file names ##
845 ## ------------------ ##
847 AT_SETUP([unusual file names])
849 AT_DATA_M4SUGAR([d@&t@nl.at],
850 [[AT@&t@_SETUP([test one])
851 m4_pattern_allow([^dnl$])
852 AT@&t@_CHECK([test "]m4_dquote(AT@&t@_LINE)[" = dn[]l.at:3])
857 AT_DATA_M4SUGAR([sub/"two spaces".at],
858 [[AT@&t@_SETUP([test two])
859 AT@&t@_CHECK([test "]m4_dquote(AT@&t@_LINE)[" = "two spaces.at:2"])
863 AT_CHECK_AT_PREP([suite],
864 [[AT_INIT([suite to check included file names])
865 m4@&t@_include([d][nl.at])
866 m4@&t@_include([sub/two spaces.at])
868 AT_CHECK([$CONFIG_SHELL ./suite], [0], [ignore])