1 | # This file is part of Autoconf. -*- Autoconf -*-
|
---|
2 | # M4 macros used in building test suites.
|
---|
3 |
|
---|
4 | # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
|
---|
5 | # Foundation, Inc.
|
---|
6 |
|
---|
7 | # This program is free software; you can redistribute it and/or modify
|
---|
8 | # it under the terms of the GNU General Public License as published by
|
---|
9 | # the Free Software Foundation; either version 2, or (at your option)
|
---|
10 | # any later version.
|
---|
11 | #
|
---|
12 | # This program is distributed in the hope that it will be useful,
|
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | # GNU General Public License for more details.
|
---|
16 | #
|
---|
17 | # You should have received a copy of the GNU General Public License
|
---|
18 | # along with this program; if not, write to the Free Software
|
---|
19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
---|
20 | # 02110-1301, USA.
|
---|
21 |
|
---|
22 | # As a special exception, the Free Software Foundation gives unlimited
|
---|
23 | # permission to copy, distribute and modify the configure scripts that
|
---|
24 | # are the output of Autoconf. You need not follow the terms of the GNU
|
---|
25 | # General Public License when using or distributing such scripts, even
|
---|
26 | # though portions of the text of Autoconf appear in them. The GNU
|
---|
27 | # General Public License (GPL) does govern all other use of the material
|
---|
28 | # that constitutes the Autoconf program.
|
---|
29 | #
|
---|
30 | # Certain portions of the Autoconf source text are designed to be copied
|
---|
31 | # (in certain cases, depending on the input) into the output of
|
---|
32 | # Autoconf. We call these the "data" portions. The rest of the Autoconf
|
---|
33 | # source text consists of comments plus executable code that decides which
|
---|
34 | # of the data portions to output in any given case. We call these
|
---|
35 | # comments and executable code the "non-data" portions. Autoconf never
|
---|
36 | # copies any of the non-data portions into its output.
|
---|
37 | #
|
---|
38 | # This special exception to the GPL applies to versions of Autoconf
|
---|
39 | # released by the Free Software Foundation. When you make and
|
---|
40 | # distribute a modified version of Autoconf, you may extend this special
|
---|
41 | # exception to the GPL to apply to your modified version as well, *unless*
|
---|
42 | # your modified version has the potential to copy into its output some
|
---|
43 | # of the text that was the non-data portion of the version that you started
|
---|
44 | # with. (In other words, unless your change moves or copies text from
|
---|
45 | # the non-data portions to the data portions.) If your modification has
|
---|
46 | # such potential, you must delete any notice of this special exception
|
---|
47 | # to the GPL from your modified version.
|
---|
48 |
|
---|
49 | # _m4_divert(DIVERSION-NAME)
|
---|
50 | # --------------------------
|
---|
51 | # Convert a diversion name into its number. Otherwise, return
|
---|
52 | # DIVERSION-NAME which is supposed to be an actual diversion number.
|
---|
53 | # Of course it would be nicer to use m4_case here, instead of zillions
|
---|
54 | # of little macros, but it then takes twice longer to run `autoconf'!
|
---|
55 | #
|
---|
56 | # From M4sugar:
|
---|
57 | # -1. KILL
|
---|
58 | # 10000. GROW
|
---|
59 | #
|
---|
60 | # From M4sh:
|
---|
61 | # 0. BINSH
|
---|
62 | # 1. HEADER-REVISION
|
---|
63 | # 2. HEADER-COMMENT
|
---|
64 | # 3. HEADER-COPYRIGHT
|
---|
65 | # 4. M4SH-SANITIZE
|
---|
66 | # 5. M4SH-INIT
|
---|
67 | # 1000. BODY
|
---|
68 | #
|
---|
69 | # Defined below:
|
---|
70 | # - DEFAULTS
|
---|
71 | # Overall initialization, value of $at_groups_all.
|
---|
72 | # - PARSE_ARGS_BEGIN
|
---|
73 | # Setup defaults required for option processing.
|
---|
74 | # - PARSE_ARGS
|
---|
75 | # Option processing. After AT_INIT, user options can be entered here as
|
---|
76 | # cases of a case statement.
|
---|
77 | # - PARSE_ARGS_END
|
---|
78 | # Finish up the option processing.
|
---|
79 | #
|
---|
80 | # - HELP
|
---|
81 | # Start printing the help message.
|
---|
82 | # - HELP_MODES
|
---|
83 | # Modes help text. Additional modes can be appended as self-contained
|
---|
84 | # cat'd here-docs as generated by AS_HELP_STRING.
|
---|
85 | # - HELP_TUNING
|
---|
86 | # Tuning help text. Additional tuning options can be appended as
|
---|
87 | # self-contained cat'd here-docs as generated by AS_HELP_STRING.
|
---|
88 | # - HELP_OTHER
|
---|
89 | # User help can be appended to this as self-contained cat'd here-docs.
|
---|
90 | # - HELP_END
|
---|
91 | # Finish up the help texts.
|
---|
92 | #
|
---|
93 | # - VERSION
|
---|
94 | # Head of the handling of --version.
|
---|
95 | # - VERSION_NOTICES
|
---|
96 | # Copyright notices for --version.
|
---|
97 | # - VERSION_END
|
---|
98 | # Tail of the handling of --version.
|
---|
99 | #
|
---|
100 | # - PREPARE_TESTS
|
---|
101 | # Like DEFAULTS but run after argument processing for purposes of
|
---|
102 | # optimization. Do anything else that needs to be done to prepare for
|
---|
103 | # tests. Sets up verbose and log file descriptors. Sets and logs PATH.
|
---|
104 | # - TESTS
|
---|
105 | # The core of the test suite.
|
---|
106 | # - TESTS_END
|
---|
107 | # tail of the core for;case, overall wrap up, generation of debugging
|
---|
108 | # scripts and statistics.
|
---|
109 | # - TEST_SCRIPT
|
---|
110 | # The code for each test, the ``normal'' diversion
|
---|
111 |
|
---|
112 | m4_define([_m4_divert(DEFAULTS)], 100)
|
---|
113 | m4_define([_m4_divert(PARSE_ARGS_BEGIN)], 200)
|
---|
114 | m4_define([_m4_divert(PARSE_ARGS)], 201)
|
---|
115 | m4_define([_m4_divert(PARSE_ARGS_END)], 202)
|
---|
116 | m4_define([_m4_divert(HELP)], 300)
|
---|
117 | m4_define([_m4_divert(HELP_MODES)], 301)
|
---|
118 | m4_define([_m4_divert(HELP_TUNING)], 302)
|
---|
119 | m4_define([_m4_divert(HELP_OTHER)], 303)
|
---|
120 | m4_define([_m4_divert(HELP_END)], 304)
|
---|
121 | m4_define([_m4_divert(VERSION)], 350)
|
---|
122 | m4_define([_m4_divert(VERSION_NOTICES)], 351)
|
---|
123 | m4_define([_m4_divert(VERSION_END)], 352)
|
---|
124 | m4_define([_m4_divert(PREPARE_TESTS)], 400)
|
---|
125 | m4_define([_m4_divert(TESTS)], 401)
|
---|
126 | m4_define([_m4_divert(TESTS_END)], 402)
|
---|
127 | m4_define([_m4_divert(TEST_SCRIPT)], 403)
|
---|
128 |
|
---|
129 |
|
---|
130 | # AT_LINE
|
---|
131 | # -------
|
---|
132 | # Return the current file sans directory, a colon, and the current
|
---|
133 | # line. Be sure to return a _quoted_ file name, so if, for instance,
|
---|
134 | # the user is lunatic enough to have a file named `dnl' (and I, for
|
---|
135 | # one, love to be brainless and stubborn sometimes), then we return a
|
---|
136 | # quoted name.
|
---|
137 | #
|
---|
138 | # Gee, we can't use simply
|
---|
139 | #
|
---|
140 | # m4_bpatsubst(__file__, [^.*/\(.*\)], [[\1]])
|
---|
141 | #
|
---|
142 | # since then, since `dnl' doesn't match the pattern, it is returned
|
---|
143 | # with once quotation level less, so you lose! And since GNU M4
|
---|
144 | # is one of the biggest junk in the whole universe wrt regexp, don't
|
---|
145 | # even think about using `?' or `\?'. Bah, `*' will do.
|
---|
146 | # Pleeeeeeeease, Gary, provide us with dirname and ERE!
|
---|
147 | m4_define([AT_LINE],
|
---|
148 | [m4_bpatsubst(__file__, [^\(.*/\)*\(.*\)], [[\2]]):__line__])
|
---|
149 |
|
---|
150 |
|
---|
151 | # _AT_NORMALIZE_TEST_GROUP_NUMBER(SHELL-VAR)
|
---|
152 | # ------------------------------------------
|
---|
153 | # Normalize SHELL-VAR so that its value has the same number of digits as
|
---|
154 | # all the other test group numbers.
|
---|
155 | m4_define([_AT_NORMALIZE_TEST_GROUP_NUMBER],
|
---|
156 | [
|
---|
157 | while :; do
|
---|
158 | case $$1 in #(
|
---|
159 | $at_format*) break;;
|
---|
160 | esac
|
---|
161 | $1=0$$1
|
---|
162 | done
|
---|
163 | ])
|
---|
164 |
|
---|
165 | # _AT_CREATE_DEBUGGING_SCRIPT
|
---|
166 | # ---------------------------
|
---|
167 | # Create the debugging script $at_group_dir/run which will reproduce the
|
---|
168 | # current test group.
|
---|
169 | m4_define([_AT_CREATE_DEBUGGING_SCRIPT],
|
---|
170 | [ {
|
---|
171 | echo "#! /bin/sh"
|
---|
172 | echo 'test "${ZSH_VERSION+set}" = set && alias -g '\''${1+"$[@]"}'\''='\''"$[@]"'\'''
|
---|
173 | echo "cd '$at_dir'"
|
---|
174 | echo 'exec ${CONFIG_SHELL-'"$SHELL"'}' "$[0]" \
|
---|
175 | '-v -d' "$at_debug_args" "$at_group" '${1+"$[@]"}'
|
---|
176 | echo 'exit 1'
|
---|
177 | } >$at_group_dir/run
|
---|
178 | chmod +x $at_group_dir/run
|
---|
179 | ])# _AT_CREATE_DEBUGGING_SCRIPT
|
---|
180 |
|
---|
181 |
|
---|
182 | # AT_INIT([TESTSUITE-NAME])
|
---|
183 | # -------------------------
|
---|
184 | # Begin test suite.
|
---|
185 | m4_define([AT_INIT],
|
---|
186 | [m4_pattern_forbid([^_?AT_])
|
---|
187 | m4_define([AT_TESTSUITE_NAME],
|
---|
188 | m4_defn([AT_PACKAGE_STRING])[ test suite]m4_ifval([$1], [: $1]))
|
---|
189 | m4_define([AT_ordinal], 0)
|
---|
190 | m4_define([AT_banner_ordinal], 0)
|
---|
191 | m4_define([AT_groups_all], [])
|
---|
192 | m4_define([AT_help_all], [])
|
---|
193 | AS_INIT
|
---|
194 | AT_COPYRIGHT(
|
---|
195 | [Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
|
---|
196 | Foundation, Inc.
|
---|
197 | This test suite is free software; the Free Software Foundation gives
|
---|
198 | unlimited permission to copy, distribute and modify it.])
|
---|
199 | AS_PREPARE
|
---|
200 | m4_divert_push([DEFAULTS])dnl
|
---|
201 |
|
---|
202 | SHELL=${CONFIG_SHELL-/bin/sh}
|
---|
203 |
|
---|
204 | # How were we run?
|
---|
205 | at_cli_args="$[@]"
|
---|
206 |
|
---|
207 | # Load the config file.
|
---|
208 | for at_file in atconfig atlocal
|
---|
209 | do
|
---|
210 | test -r $at_file || continue
|
---|
211 | . ./$at_file || AS_ERROR([invalid content: $at_file])
|
---|
212 | done
|
---|
213 |
|
---|
214 | # Autoconf <=2.59b set at_top_builddir instead of at_top_build_prefix:
|
---|
215 | : ${at_top_build_prefix=$at_top_builddir}
|
---|
216 |
|
---|
217 | # atconfig delivers names relative to the directory the test suite is
|
---|
218 | # in, but the groups themselves are run in testsuite-dir/group-dir.
|
---|
219 | if test -n "$at_top_srcdir"; then
|
---|
220 | builddir=../..
|
---|
221 | for at_dir in srcdir top_srcdir top_build_prefix
|
---|
222 | do
|
---|
223 | at_val=AS_VAR_GET([at_$at_dir])
|
---|
224 | AS_VAR_SET([$at_dir], [$at_val/../..])
|
---|
225 | done
|
---|
226 | fi
|
---|
227 |
|
---|
228 | # Not all shells have the 'times' builtin; the subshell is needed to make
|
---|
229 | # sure we discard the 'times: not found' message from the shell.
|
---|
230 | at_times_p=false
|
---|
231 | (times) >/dev/null 2>&1 && at_times_p=:
|
---|
232 |
|
---|
233 | # CLI Arguments to pass to the debugging scripts.
|
---|
234 | at_debug_args=
|
---|
235 | # -e sets to true
|
---|
236 | at_errexit_p=false
|
---|
237 | # Shall we be verbose?
|
---|
238 | at_verbose=:
|
---|
239 | at_quiet=echo
|
---|
240 |
|
---|
241 | # Shall we keep the debug scripts? Must be `:' when the suite is
|
---|
242 | # run by a debug script, so that the script doesn't remove itself.
|
---|
243 | at_debug_p=false
|
---|
244 | # Display help message?
|
---|
245 | at_help_p=false
|
---|
246 | # Display the version message?
|
---|
247 | at_version_p=false
|
---|
248 | # List test groups?
|
---|
249 | at_list_p=false
|
---|
250 | # Test groups to run
|
---|
251 | at_groups=
|
---|
252 |
|
---|
253 | # The directory we are in.
|
---|
254 | at_dir=`pwd`
|
---|
255 | # The directory the whole suite works in.
|
---|
256 | # Should be absolutely to let the user `cd' at will.
|
---|
257 | at_suite_dir=$at_dir/$as_me.dir
|
---|
258 | # The file containing the suite.
|
---|
259 | at_suite_log=$at_dir/$as_me.log
|
---|
260 | # The file containing the location of the last AT_CHECK.
|
---|
261 | at_check_line_file=$at_suite_dir/at-check-line
|
---|
262 | # The file containing the exit status of the last command.
|
---|
263 | at_status_file=$at_suite_dir/at-status
|
---|
264 | # The files containing the output of the tested commands.
|
---|
265 | at_stdout=$at_suite_dir/at-stdout
|
---|
266 | at_stder1=$at_suite_dir/at-stder1
|
---|
267 | at_stderr=$at_suite_dir/at-stderr
|
---|
268 | # The file containing dates.
|
---|
269 | at_times_file=$at_suite_dir/at-times
|
---|
270 | m4_divert_pop([DEFAULTS])dnl
|
---|
271 | m4_wrap([m4_divert_text([DEFAULTS],
|
---|
272 | [
|
---|
273 | # List of the tested programs.
|
---|
274 | at_tested='m4_ifdef([AT_tested], [AT_tested])'
|
---|
275 | # List of the all the test groups.
|
---|
276 | at_groups_all='AT_groups_all'
|
---|
277 | # As many question marks as there are digits in the last test group number.
|
---|
278 | # Used to normalize the test group numbers so that `ls' lists them in
|
---|
279 | # numerical order.
|
---|
280 | at_format='m4_bpatsubst(m4_defn([AT_ordinal]), [.], [?])'
|
---|
281 | # Description of all the test groups.
|
---|
282 | at_help_all="AS_ESCAPE(m4_defn([AT_help_all]))"])])dnl
|
---|
283 | m4_divert_push([PARSE_ARGS])dnl
|
---|
284 |
|
---|
285 | at_prev=
|
---|
286 | for at_option
|
---|
287 | do
|
---|
288 | # If the previous option needs an argument, assign it.
|
---|
289 | if test -n "$at_prev"; then
|
---|
290 | at_option=$at_prev=$at_option
|
---|
291 | at_prev=
|
---|
292 | fi
|
---|
293 |
|
---|
294 | case $at_option in
|
---|
295 | *=*) at_optarg=`expr "x$at_option" : 'x[[^=]]*=\(.*\)'` ;;
|
---|
296 | *) at_optarg= ;;
|
---|
297 | esac
|
---|
298 |
|
---|
299 | # Accept the important Cygnus configure options, so we can diagnose typos.
|
---|
300 |
|
---|
301 | case $at_option in
|
---|
302 | --help | -h )
|
---|
303 | at_help_p=:
|
---|
304 | ;;
|
---|
305 |
|
---|
306 | --list | -l )
|
---|
307 | at_list_p=:
|
---|
308 | ;;
|
---|
309 |
|
---|
310 | --version | -V )
|
---|
311 | at_version_p=:
|
---|
312 | ;;
|
---|
313 |
|
---|
314 | --clean | -c )
|
---|
315 | test -d "$at_suite_dir" &&
|
---|
316 | find "$at_suite_dir" -type d ! -perm -700 -exec chmod u+rwx \{\} \;
|
---|
317 | rm -f -r "$at_suite_dir" "$at_suite_log"
|
---|
318 | exit 0
|
---|
319 | ;;
|
---|
320 |
|
---|
321 | --debug | -d )
|
---|
322 | at_debug_p=:
|
---|
323 | ;;
|
---|
324 |
|
---|
325 | --errexit | -e )
|
---|
326 | at_debug_p=:
|
---|
327 | at_errexit_p=:
|
---|
328 | ;;
|
---|
329 |
|
---|
330 | --verbose | -v )
|
---|
331 | at_verbose=echo; at_quiet=:
|
---|
332 | ;;
|
---|
333 |
|
---|
334 | --trace | -x )
|
---|
335 | at_traceon='set -x'; at_traceoff='set +x'
|
---|
336 | ;;
|
---|
337 |
|
---|
338 | [[0-9] | [0-9][0-9] | [0-9][0-9][0-9] | [0-9][0-9][0-9][0-9]])
|
---|
339 | at_groups="$at_groups$at_option "
|
---|
340 | ;;
|
---|
341 |
|
---|
342 | # Ranges
|
---|
343 | [[0-9]- | [0-9][0-9]- | [0-9][0-9][0-9]- | [0-9][0-9][0-9][0-9]-])
|
---|
344 | at_range_start=`echo $at_option |tr -d X-`
|
---|
345 | at_range=`echo " $at_groups_all " | \
|
---|
346 | sed -e 's/^.* \('$at_range_start' \)/\1/'`
|
---|
347 | at_groups="$at_groups$at_range "
|
---|
348 | ;;
|
---|
349 |
|
---|
350 | [-[0-9] | -[0-9][0-9] | -[0-9][0-9][0-9] | -[0-9][0-9][0-9][0-9]])
|
---|
351 | at_range_end=`echo $at_option |tr -d X-`
|
---|
352 | at_range=`echo " $at_groups_all " | \
|
---|
353 | sed -e 's/\( '$at_range_end'\) .*$/\1/'`
|
---|
354 | at_groups="$at_groups$at_range "
|
---|
355 | ;;
|
---|
356 |
|
---|
357 | [[0-9]-[0-9] | [0-9]-[0-9][0-9] | [0-9]-[0-9][0-9][0-9]] | \
|
---|
358 | [[0-9]-[0-9][0-9][0-9][0-9] | [0-9][0-9]-[0-9][0-9]] | \
|
---|
359 | [[0-9][0-9]-[0-9][0-9][0-9] | [0-9][0-9]-[0-9][0-9][0-9][0-9]] | \
|
---|
360 | [[0-9][0-9][0-9]-[0-9][0-9][0-9]] | \
|
---|
361 | [[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]] | \
|
---|
362 | [[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]] )
|
---|
363 | at_range_start=`expr $at_option : '\(.*\)-'`
|
---|
364 | at_range_end=`expr $at_option : '.*-\(.*\)'`
|
---|
365 | if test $at_range_start -gt $at_range_end; then
|
---|
366 | at_tmp=$at_range_end
|
---|
367 | at_range_end=$at_range_start
|
---|
368 | at_range_start=$at_tmp
|
---|
369 | fi
|
---|
370 | at_range=`echo " $at_groups_all " | \
|
---|
371 | sed -e 's/^.*\( '$at_range_start' \)/\1/' \
|
---|
372 | -e 's/\( '$at_range_end'\) .*$/\1/'`
|
---|
373 | at_groups="$at_groups$at_range "
|
---|
374 | ;;
|
---|
375 |
|
---|
376 | # Keywords.
|
---|
377 | --keywords | -k )
|
---|
378 | at_prev=--keywords
|
---|
379 | ;;
|
---|
380 | --keywords=* )
|
---|
381 | at_groups_selected=$at_help_all
|
---|
382 | at_save_IFS=$IFS
|
---|
383 | IFS=,
|
---|
384 | set X $at_optarg
|
---|
385 | shift
|
---|
386 | IFS=$at_save_IFS
|
---|
387 | for at_keyword
|
---|
388 | do
|
---|
389 | at_invert=
|
---|
390 | case $at_keyword in
|
---|
391 | '!'*)
|
---|
392 | at_invert="-v"
|
---|
393 | at_keyword=`expr "X$at_keyword" : 'X!\(.*\)'`
|
---|
394 | ;;
|
---|
395 | esac
|
---|
396 | # It is on purpose that we match the test group titles too.
|
---|
397 | at_groups_selected=`echo "$at_groups_selected" |
|
---|
398 | grep -i $at_invert ["^[1-9][^;]*;.*[; ]$at_keyword[ ;]"]`
|
---|
399 | done
|
---|
400 | at_groups_selected=`echo "$at_groups_selected" | sed 's/;.*//'`
|
---|
401 | # Smash the newlines.
|
---|
402 | at_groups="$at_groups`echo $at_groups_selected` "
|
---|
403 | ;;
|
---|
404 | m4_divert_pop([PARSE_ARGS])dnl
|
---|
405 | dnl Process *=* last to allow for user specified --option=* type arguments.
|
---|
406 | m4_divert_push([PARSE_ARGS_END])dnl
|
---|
407 |
|
---|
408 | *=*)
|
---|
409 | at_envvar=`expr "x$at_option" : 'x\([[^=]]*\)='`
|
---|
410 | # Reject names that are not valid shell variable names.
|
---|
411 | expr "x$at_envvar" : "[.*[^_$as_cr_alnum]]" >/dev/null &&
|
---|
412 | AS_ERROR([invalid variable name: $at_envvar])
|
---|
413 | at_value=`echo "$at_optarg" | sed "s/'/'\\\\\\\\''/g"`
|
---|
414 | eval "$at_envvar='$at_value'"
|
---|
415 | export $at_envvar
|
---|
416 | # Propagate to debug scripts.
|
---|
417 | at_debug_args="$at_debug_args $at_envvar='$at_value'"
|
---|
418 | ;;
|
---|
419 |
|
---|
420 | *) echo "$as_me: invalid option: $at_option" >&2
|
---|
421 | echo "Try \`$[0] --help' for more information." >&2
|
---|
422 | exit 1
|
---|
423 | ;;
|
---|
424 | esac
|
---|
425 | done
|
---|
426 |
|
---|
427 | # Selected test groups.
|
---|
428 | if test -z "$at_groups"; then
|
---|
429 | at_groups=$at_groups_all
|
---|
430 | else
|
---|
431 | # Sort the tests, removing duplicates:
|
---|
432 | at_groups=`echo $at_groups | tr ' ' "$as_nl" | sort -nu`
|
---|
433 | # and add banners. (Passing at_groups_all is tricky--see the comment
|
---|
434 | # starting with "Passing at_groups is tricky.")
|
---|
435 | at_groups=`echo "$at_groups$as_nl $at_groups_all" |
|
---|
436 | awk ['BEGIN { FS = "@" } # Effectively switch off field splitting.
|
---|
437 | /^$/ { next } # Ignore the empty line.
|
---|
438 | !/ / { groups++; selected[$ 0] = 1; next }
|
---|
439 | # The last line, containing at_groups_all.
|
---|
440 | {
|
---|
441 | n = split($ 0, a, " ")
|
---|
442 | # If there are several tests, select their banners:
|
---|
443 | if (groups > 1) {
|
---|
444 | for (i = 1; i <= n; i++) {
|
---|
445 | if (a[i] ~ /^banner-/)
|
---|
446 | banner = a[i]
|
---|
447 | else if (banner != "" && selected[a[i]] == 1)
|
---|
448 | selected[banner] = 1
|
---|
449 | }
|
---|
450 | }
|
---|
451 | for (i = 1; i <= n; i++)
|
---|
452 | if (selected[a[i]] == 1)
|
---|
453 | list = list " " a[i]
|
---|
454 | print list
|
---|
455 | }']`
|
---|
456 | fi
|
---|
457 | m4_divert_pop([PARSE_ARGS_END])dnl
|
---|
458 | m4_divert_push([HELP])dnl
|
---|
459 |
|
---|
460 | # Help message.
|
---|
461 | if $at_help_p; then
|
---|
462 | cat <<_ATEOF
|
---|
463 | Usage: $[0] [[OPTION]... [VARIABLE=VALUE]... [TESTS]]
|
---|
464 |
|
---|
465 | Run all the tests, or the selected TESTS, given by numeric ranges, and
|
---|
466 | save a detailed log file. Upon failure, create debugging scripts.
|
---|
467 |
|
---|
468 | You should not change environment variables unless explicitly passed
|
---|
469 | as command line arguments. Set \`AUTOTEST_PATH' to select the executables
|
---|
470 | to exercise. Each relative directory is expanded as build and source
|
---|
471 | directories relatively to the top level of this distribution. E.g.,
|
---|
472 |
|
---|
473 | $ $[0] AUTOTEST_PATH=bin
|
---|
474 |
|
---|
475 | possibly amounts into
|
---|
476 |
|
---|
477 | PATH=/tmp/foo-1.0/bin:/src/foo-1.0/bin:\$PATH
|
---|
478 | _ATEOF
|
---|
479 | m4_divert_pop([HELP])dnl
|
---|
480 | m4_divert_push([HELP_MODES])dnl
|
---|
481 | cat <<_ATEOF
|
---|
482 |
|
---|
483 | Operation modes:
|
---|
484 | -h, --help print the help message, then exit
|
---|
485 | -V, --version print version number, then exit
|
---|
486 | -c, --clean remove all the files this test suite might create and exit
|
---|
487 | -l, --list describes all the tests, or the selected TESTS
|
---|
488 | _ATEOF
|
---|
489 | m4_divert_pop([HELP_MODES])dnl
|
---|
490 | m4_divert_push([HELP_TUNING])dnl
|
---|
491 | cat <<_ATEOF
|
---|
492 |
|
---|
493 | Execution tuning:
|
---|
494 | -k, --keywords=KEYWORDS
|
---|
495 | select the tests matching all the comma-separated KEYWORDS
|
---|
496 | multiple \`-k' accumulate; prefixed \`!' negates a KEYWORD
|
---|
497 | -e, --errexit abort as soon as a test fails; implies --debug
|
---|
498 | -v, --verbose force more detailed output
|
---|
499 | default for debugging scripts
|
---|
500 | -d, --debug inhibit clean up and top-level logging
|
---|
501 | default for debugging scripts
|
---|
502 | -x, --trace enable tests shell tracing
|
---|
503 | _ATEOF
|
---|
504 | m4_divert_pop([HELP_TUNING])dnl
|
---|
505 | m4_divert_push([HELP_END])dnl
|
---|
506 | cat <<_ATEOF
|
---|
507 |
|
---|
508 | Report bugs to <AT_PACKAGE_BUGREPORT>.
|
---|
509 | _ATEOF
|
---|
510 | exit 0
|
---|
511 | fi
|
---|
512 |
|
---|
513 | # List of tests.
|
---|
514 | if $at_list_p; then
|
---|
515 | cat <<_ATEOF
|
---|
516 | AT_TESTSUITE_NAME test groups:
|
---|
517 |
|
---|
518 | NUM: FILE-NAME:LINE TEST-GROUP-NAME
|
---|
519 | KEYWORDS
|
---|
520 |
|
---|
521 | _ATEOF
|
---|
522 | # Passing at_groups is tricky. We cannot use it to form a literal string
|
---|
523 | # or regexp because of the limitation of AIX awk. And Solaris' awk
|
---|
524 | # doesn't grok more than 99 fields in a record, so we have to use `split'.
|
---|
525 | echo "$at_groups$as_nl$at_help_all" |
|
---|
526 | awk 'BEGIN { FS = ";" }
|
---|
527 | NR == 1 {
|
---|
528 | for (n = split($ 0, a, " "); n; n--) selected[[a[n]]] = 1
|
---|
529 | next
|
---|
530 | }
|
---|
531 | {
|
---|
532 | if (selected[[$ 1]]) {
|
---|
533 | printf " %3d: %-18s %s\n", $ 1, $ 2, $ 3
|
---|
534 | if ($ 4) printf " %s\n", $ 4
|
---|
535 | }
|
---|
536 | }'
|
---|
537 | exit 0
|
---|
538 | fi
|
---|
539 | m4_divert_pop([HELP_END])dnl
|
---|
540 | m4_divert_push([VERSION])dnl
|
---|
541 | if $at_version_p; then
|
---|
542 | echo "$as_me (AT_PACKAGE_STRING)"
|
---|
543 | cat <<\_ACEOF
|
---|
544 | m4_divert_pop([VERSION])dnl
|
---|
545 | m4_divert_push([VERSION_END])dnl
|
---|
546 | _ACEOF
|
---|
547 | exit 0
|
---|
548 | fi
|
---|
549 | m4_divert_pop([VERSION_END])dnl
|
---|
550 | m4_divert_push([PREPARE_TESTS])dnl
|
---|
551 |
|
---|
552 | # Don't take risks: use only absolute directories in PATH.
|
---|
553 | #
|
---|
554 | # For stand-alone test suites, AUTOTEST_PATH is relative to `.'.
|
---|
555 | #
|
---|
556 | # For embedded test suites, AUTOTEST_PATH is relative to the top level
|
---|
557 | # of the package. Then expand it into build/src parts, since users
|
---|
558 | # may create executables in both places.
|
---|
559 | AUTOTEST_PATH=`echo $AUTOTEST_PATH | sed "s&:&$PATH_SEPARATOR&g"`
|
---|
560 | at_path=
|
---|
561 | _AS_PATH_WALK([$AUTOTEST_PATH $PATH],
|
---|
562 | [test -n "$at_path" && at_path=$at_path$PATH_SEPARATOR
|
---|
563 | case $as_dir in
|
---|
564 | [[\\/]]* | ?:[[\\/]]* )
|
---|
565 | at_path=$at_path$as_dir
|
---|
566 | ;;
|
---|
567 | * )
|
---|
568 | if test -z "$at_top_build_prefix"; then
|
---|
569 | # Stand-alone test suite.
|
---|
570 | at_path=$at_path$as_dir
|
---|
571 | else
|
---|
572 | # Embedded test suite.
|
---|
573 | at_path=$at_path$at_top_build_prefix$as_dir$PATH_SEPARATOR
|
---|
574 | at_path=$at_path$at_top_srcdir/$as_dir
|
---|
575 | fi
|
---|
576 | ;;
|
---|
577 | esac])
|
---|
578 |
|
---|
579 | # Now build and simplify PATH.
|
---|
580 | #
|
---|
581 | # There might be directories that don't exist, but don't redirect
|
---|
582 | # builtins' (eg., cd) stderr directly: Ultrix's sh hates that.
|
---|
583 | PATH=
|
---|
584 | _AS_PATH_WALK([$at_path],
|
---|
585 | [as_dir=`(cd "$as_dir" && pwd) 2>/dev/null`
|
---|
586 | test -d "$as_dir" || continue
|
---|
587 | case $PATH in
|
---|
588 | $as_dir | \
|
---|
589 | $as_dir$PATH_SEPARATOR* | \
|
---|
590 | *$PATH_SEPARATOR$as_dir | \
|
---|
591 | *$PATH_SEPARATOR$as_dir$PATH_SEPARATOR* ) ;;
|
---|
592 |
|
---|
593 | '') PATH=$as_dir ;;
|
---|
594 | *) PATH=$PATH$PATH_SEPARATOR$as_dir ;;
|
---|
595 | esac])
|
---|
596 | export PATH
|
---|
597 |
|
---|
598 | # Setting up the FDs.
|
---|
599 | # 5 is the log file. Not to be overwritten if `-d'.
|
---|
600 | m4_define([AS_MESSAGE_LOG_FD], [5])
|
---|
601 | if $at_debug_p; then
|
---|
602 | at_suite_log=/dev/null
|
---|
603 | else
|
---|
604 | : >"$at_suite_log"
|
---|
605 | fi
|
---|
606 | exec AS_MESSAGE_LOG_FD>>"$at_suite_log"
|
---|
607 |
|
---|
608 | # Banners and logs.
|
---|
609 | AS_BOX(m4_defn([AT_TESTSUITE_NAME])[.])
|
---|
610 | {
|
---|
611 | AS_BOX(m4_defn([AT_TESTSUITE_NAME])[.])
|
---|
612 | echo
|
---|
613 |
|
---|
614 | echo "$as_me: command line was:"
|
---|
615 | echo " $ $[0] $at_cli_args"
|
---|
616 | echo
|
---|
617 |
|
---|
618 | # Try to find a few ChangeLogs in case it might help determining the
|
---|
619 | # exact version. Use the relative dir: if the top dir is a symlink,
|
---|
620 | # find will not follow it (and options to follow the links are not
|
---|
621 | # portable), which would result in no output here.
|
---|
622 | if test -n "$at_top_srcdir"; then
|
---|
623 | AS_BOX([ChangeLogs.])
|
---|
624 | echo
|
---|
625 | for at_file in `find "$at_top_srcdir" -name ChangeLog -print`
|
---|
626 | do
|
---|
627 | echo "$as_me: $at_file:"
|
---|
628 | sed 's/^/| /;10q' $at_file
|
---|
629 | echo
|
---|
630 | done
|
---|
631 |
|
---|
632 | AS_UNAME
|
---|
633 | echo
|
---|
634 | fi
|
---|
635 |
|
---|
636 | # Contents of the config files.
|
---|
637 | for at_file in atconfig atlocal
|
---|
638 | do
|
---|
639 | test -r $at_file || continue
|
---|
640 | echo "$as_me: $at_file:"
|
---|
641 | sed 's/^/| /' $at_file
|
---|
642 | echo
|
---|
643 | done
|
---|
644 |
|
---|
645 | AS_BOX([Tested programs.])
|
---|
646 | echo
|
---|
647 | } >&AS_MESSAGE_LOG_FD
|
---|
648 |
|
---|
649 | # Report what programs are being tested.
|
---|
650 | for at_program in : $at_tested
|
---|
651 | do
|
---|
652 | test "$at_program" = : && continue
|
---|
653 | _AS_PATH_WALK([$PATH], [test -f "$as_dir/$at_program" && break])
|
---|
654 | if test -f "$as_dir/$at_program"; then
|
---|
655 | {
|
---|
656 | echo "$at_srcdir/AT_LINE: $as_dir/$at_program --version"
|
---|
657 | "$as_dir/$at_program" --version
|
---|
658 | echo
|
---|
659 | } >&AS_MESSAGE_LOG_FD 2>&1
|
---|
660 | else
|
---|
661 | # On OS/2 we must check for .exe as well.
|
---|
662 | _AS_PATH_WALK([$PATH], [test -f "$as_dir/${at_program}.exe" && break])
|
---|
663 | if test -f "$as_dir/${at_program}.exe"; then
|
---|
664 | {
|
---|
665 | echo "$at_srcdir/AT_LINE: $as_dir/$at_program --version"
|
---|
666 | "$as_dir/$at_program" --version
|
---|
667 | echo
|
---|
668 | } >&AS_MESSAGE_LOG_FD 2>&1
|
---|
669 | else
|
---|
670 | AS_ERROR([cannot find $at_program])
|
---|
671 | fi
|
---|
672 | fi
|
---|
673 | done
|
---|
674 |
|
---|
675 | {
|
---|
676 | AS_BOX([Running the tests.])
|
---|
677 | } >&AS_MESSAGE_LOG_FD
|
---|
678 |
|
---|
679 | at_start_date=`date`
|
---|
680 | at_start_time=`date +%s 2>/dev/null`
|
---|
681 | echo "$as_me: starting at: $at_start_date" >&AS_MESSAGE_LOG_FD
|
---|
682 | at_xpass_list=
|
---|
683 | at_xfail_list=
|
---|
684 | at_pass_list=
|
---|
685 | at_fail_list=
|
---|
686 | at_skip_list=
|
---|
687 | at_group_count=0
|
---|
688 | m4_divert_pop([PREPARE_TESTS])dnl
|
---|
689 | m4_divert_push([TESTS])dnl
|
---|
690 |
|
---|
691 | # Create the master directory if it doesn't already exist.
|
---|
692 | test -d "$at_suite_dir" ||
|
---|
693 | mkdir "$at_suite_dir" ||
|
---|
694 | AS_ERROR([cannot create '$at_suite_dir'])
|
---|
695 |
|
---|
696 | # Can we diff with `/dev/null'? DU 5.0 refuses.
|
---|
697 | if diff /dev/null /dev/null >/dev/null 2>&1; then
|
---|
698 | at_devnull=/dev/null
|
---|
699 | else
|
---|
700 | at_devnull=$at_suite_dir/devnull
|
---|
701 | >"$at_devnull"
|
---|
702 | fi
|
---|
703 |
|
---|
704 | # Use `diff -u' when possible.
|
---|
705 | if at_diff=`diff -u "$at_devnull" "$at_devnull" 2>&1` && test -z "$at_diff"
|
---|
706 | then
|
---|
707 | at_diff='diff -u'
|
---|
708 | else
|
---|
709 | at_diff=diff
|
---|
710 | fi
|
---|
711 |
|
---|
712 |
|
---|
713 | for at_group in $at_groups
|
---|
714 | do
|
---|
715 | # Be sure to come back to the top test directory.
|
---|
716 | cd "$at_suite_dir"
|
---|
717 |
|
---|
718 | case $at_group in
|
---|
719 | banner-*)
|
---|
720 | at_group_log=$at_suite_log
|
---|
721 | ;;
|
---|
722 |
|
---|
723 | *)
|
---|
724 | at_group_normalized=$at_group
|
---|
725 | _AT_NORMALIZE_TEST_GROUP_NUMBER(at_group_normalized)
|
---|
726 |
|
---|
727 | # Create a fresh directory for the next test group, and enter.
|
---|
728 | at_group_dir=$at_suite_dir/$at_group_normalized
|
---|
729 | at_group_log=$at_group_dir/$as_me.log
|
---|
730 | if test -d "$at_group_dir"; then
|
---|
731 | find "$at_group_dir" -type d ! -perm -700 -exec chmod u+rwx \{\} \;
|
---|
732 | rm -fr "$at_group_dir"
|
---|
733 | fi
|
---|
734 | # Be tolerant if the above `rm' was not able to remove the directory.
|
---|
735 | AS_MKDIR_P([$at_group_dir])
|
---|
736 | cd $at_group_dir
|
---|
737 | ;;
|
---|
738 | esac
|
---|
739 |
|
---|
740 | echo 0 > "$at_status_file"
|
---|
741 |
|
---|
742 | # Clearly separate the test groups when verbose.
|
---|
743 | test $at_group_count != 0 && $at_verbose
|
---|
744 |
|
---|
745 | # In verbose mode, append to the log file *and* show on
|
---|
746 | # the standard output; in quiet mode only write to the log
|
---|
747 | if test $at_verbose = echo; then
|
---|
748 | at_tee_pipe='tee -a "$at_group_log"'
|
---|
749 | else
|
---|
750 | at_tee_pipe='cat >> "$at_group_log"'
|
---|
751 | fi
|
---|
752 |
|
---|
753 | case $at_group in
|
---|
754 | dnl Test groups inserted here (TESTS).
|
---|
755 | m4_divert_pop([TESTS])[]dnl
|
---|
756 | m4_divert_push([TESTS_END])[]dnl
|
---|
757 |
|
---|
758 | * )
|
---|
759 | echo "$as_me: no such test group: $at_group" >&2
|
---|
760 | continue
|
---|
761 | ;;
|
---|
762 | esac
|
---|
763 |
|
---|
764 | # Be sure to come back to the suite directory, in particular
|
---|
765 | # since below we might `rm' the group directory we are in currently.
|
---|
766 | cd "$at_suite_dir"
|
---|
767 |
|
---|
768 | case $at_group in
|
---|
769 | banner-*) ;;
|
---|
770 | *)
|
---|
771 | if test ! -f "$at_check_line_file"; then
|
---|
772 | sed "s/^ */$as_me: warning: /" <<_ATEOF
|
---|
773 | A failure happened in a test group before any test could be
|
---|
774 | run. This means that test suite is improperly designed. Please
|
---|
775 | report this failure to <AT_PACKAGE_BUGREPORT>.
|
---|
776 | _ATEOF
|
---|
777 | echo "$at_setup_line" >"$at_check_line_file"
|
---|
778 | fi
|
---|
779 | at_group_count=`expr 1 + $at_group_count`
|
---|
780 | $at_verbose $ECHO_N "$at_group. $at_setup_line: $ECHO_C"
|
---|
781 | echo $ECHO_N "$at_group. $at_setup_line: $ECHO_C" >> "$at_group_log"
|
---|
782 | case $at_xfail:$at_status in
|
---|
783 | yes:0)
|
---|
784 | at_msg="UNEXPECTED PASS"
|
---|
785 | at_xpass_list="$at_xpass_list $at_group"
|
---|
786 | at_errexit=$at_errexit_p
|
---|
787 | ;;
|
---|
788 | no:0)
|
---|
789 | at_msg="ok"
|
---|
790 | at_pass_list="$at_pass_list $at_group"
|
---|
791 | at_errexit=false
|
---|
792 | ;;
|
---|
793 | *:77)
|
---|
794 | at_msg='skipped ('`cat "$at_check_line_file"`')'
|
---|
795 | at_skip_list="$at_skip_list $at_group"
|
---|
796 | at_errexit=false
|
---|
797 | ;;
|
---|
798 | yes:*)
|
---|
799 | at_msg='expected failure ('`cat "$at_check_line_file"`')'
|
---|
800 | at_xfail_list="$at_xfail_list $at_group"
|
---|
801 | at_errexit=false
|
---|
802 | ;;
|
---|
803 | no:*)
|
---|
804 | at_msg='FAILED ('`cat "$at_check_line_file"`')'
|
---|
805 | at_fail_list="$at_fail_list $at_group"
|
---|
806 | at_errexit=$at_errexit_p
|
---|
807 | ;;
|
---|
808 | esac
|
---|
809 | # Make sure there is a separator even with long titles.
|
---|
810 | echo " $at_msg"
|
---|
811 | at_log_msg="$at_group. $at_desc ($at_setup_line): $at_msg"
|
---|
812 | case $at_status in
|
---|
813 | 0|77)
|
---|
814 | # $at_times_file is only available if the group succeeded.
|
---|
815 | # We're not including the group log, so the success message
|
---|
816 | # is written in the global log separately. But we also
|
---|
817 | # write to the group log in case they're using -d.
|
---|
818 | if test -f "$at_times_file"; then
|
---|
819 | at_log_msg="$at_log_msg ("`sed 1d "$at_times_file"`')'
|
---|
820 | rm -f "$at_times_file"
|
---|
821 | fi
|
---|
822 | echo "$at_log_msg" >> "$at_group_log"
|
---|
823 | echo "$at_log_msg" >&AS_MESSAGE_LOG_FD
|
---|
824 |
|
---|
825 | # Cleanup the group directory, unless the user wants the files.
|
---|
826 | if $at_debug_p ; then
|
---|
827 | _AT_CREATE_DEBUGGING_SCRIPT
|
---|
828 | elif test -d "$at_group_dir"; then
|
---|
829 | find "$at_group_dir" -type d ! -perm -700 -exec chmod u+rwx \{\} \;
|
---|
830 | rm -fr "$at_group_dir"
|
---|
831 | fi
|
---|
832 | ;;
|
---|
833 | *)
|
---|
834 | # Upon failure, include the log into the testsuite's global
|
---|
835 | # log. The failure message is written in the group log. It
|
---|
836 | # is later included in the global log.
|
---|
837 | echo "$at_log_msg" >> "$at_group_log"
|
---|
838 |
|
---|
839 | # Upon failure, keep the group directory for autopsy, and
|
---|
840 | # create the debugging script.
|
---|
841 | _AT_CREATE_DEBUGGING_SCRIPT
|
---|
842 | $at_errexit && break
|
---|
843 | ;;
|
---|
844 | esac
|
---|
845 | ;;
|
---|
846 | esac
|
---|
847 | done
|
---|
848 |
|
---|
849 | # Back to the top directory.
|
---|
850 | cd "$at_dir"
|
---|
851 |
|
---|
852 | # Compute the duration of the suite.
|
---|
853 | at_stop_date=`date`
|
---|
854 | at_stop_time=`date +%s 2>/dev/null`
|
---|
855 | echo "$as_me: ending at: $at_stop_date" >&AS_MESSAGE_LOG_FD
|
---|
856 | case $at_start_time,$at_stop_time in
|
---|
857 | [[0-9]*,[0-9]*])
|
---|
858 | at_duration_s=`expr $at_stop_time - $at_start_time`
|
---|
859 | at_duration_m=`expr $at_duration_s / 60`
|
---|
860 | at_duration_h=`expr $at_duration_m / 60`
|
---|
861 | at_duration_s=`expr $at_duration_s % 60`
|
---|
862 | at_duration_m=`expr $at_duration_m % 60`
|
---|
863 | at_duration="${at_duration_h}h ${at_duration_m}m ${at_duration_s}s"
|
---|
864 | echo "$as_me: test suite duration: $at_duration" >&AS_MESSAGE_LOG_FD
|
---|
865 | ;;
|
---|
866 | esac
|
---|
867 |
|
---|
868 | # Wrap up the test suite with summary statistics.
|
---|
869 | at_skip_count=`set dummy $at_skip_list; shift; echo $[@%:@]`
|
---|
870 | at_fail_count=`set dummy $at_fail_list; shift; echo $[@%:@]`
|
---|
871 | at_xpass_count=`set dummy $at_xpass_list; shift; echo $[@%:@]`
|
---|
872 | at_xfail_count=`set dummy $at_xfail_list; shift; echo $[@%:@]`
|
---|
873 |
|
---|
874 | at_run_count=`expr $at_group_count - $at_skip_count`
|
---|
875 | at_unexpected_count=`expr $at_xpass_count + $at_fail_count`
|
---|
876 | at_total_fail_count=`expr $at_xfail_count + $at_fail_count`
|
---|
877 |
|
---|
878 | echo
|
---|
879 | AS_BOX([Test results.])
|
---|
880 | echo
|
---|
881 | {
|
---|
882 | echo
|
---|
883 | AS_BOX([Test results.])
|
---|
884 | echo
|
---|
885 | } >&AS_MESSAGE_LOG_FD
|
---|
886 |
|
---|
887 | dnl
|
---|
888 | dnl FIXME: this code is as far from i18n-cleanness as man
|
---|
889 | dnl could imagine...
|
---|
890 | dnl
|
---|
891 | if test $at_run_count = 1; then
|
---|
892 | at_result="1 test"
|
---|
893 | at_were=was
|
---|
894 | else
|
---|
895 | at_result="$at_run_count tests"
|
---|
896 | at_were=were
|
---|
897 | fi
|
---|
898 | if $at_errexit_p && test $at_unexpected_count != 0; then
|
---|
899 | if test $at_xpass_count = 1; then
|
---|
900 | at_result="$at_result $at_were run, one passed"
|
---|
901 | else
|
---|
902 | at_result="$at_result $at_were run, one failed"
|
---|
903 | fi
|
---|
904 | at_result="$at_result unexpectedly and inhibited subsequent tests."
|
---|
905 | else
|
---|
906 | # Don't you just love exponential explosion of the number of cases?
|
---|
907 | case $at_xpass_count:$at_fail_count:$at_xfail_count in
|
---|
908 | # So far, so good.
|
---|
909 | 0:0:0) at_result="$at_result $at_were successful." ;;
|
---|
910 | 0:0:*) at_result="$at_result behaved as expected." ;;
|
---|
911 |
|
---|
912 | # Some unexpected failures
|
---|
913 | 0:*:0) at_result="$at_result $at_were run,
|
---|
914 | $at_fail_count failed unexpectedly." ;;
|
---|
915 |
|
---|
916 | # Some failures, both expected and unexpected
|
---|
917 | 0:*:1) at_result="$at_result $at_were run,
|
---|
918 | $at_total_fail_count failed ($at_xfail_count expected failure)." ;;
|
---|
919 | 0:*:*) at_result="$at_result $at_were run,
|
---|
920 | $at_total_fail_count failed ($at_xfail_count expected failures)." ;;
|
---|
921 |
|
---|
922 | # No unexpected failures, but some xpasses
|
---|
923 | *:0:*) at_result="$at_result $at_were run,
|
---|
924 | $at_xpass_count passed unexpectedly." ;;
|
---|
925 |
|
---|
926 | # No expected failures, but failures and xpasses
|
---|
927 | *:1:0) at_result="$at_result $at_were run,
|
---|
928 | $at_unexpected_count did not behave as expected ($at_fail_count unexpected failure)." ;;
|
---|
929 | *:*:0) at_result="$at_result $at_were run,
|
---|
930 | $at_unexpected_count did not behave as expected ($at_fail_count unexpected failures)." ;;
|
---|
931 |
|
---|
932 | # All of them.
|
---|
933 | *:*:1) at_result="$at_result $at_were run,
|
---|
934 | $at_xpass_count passed unexpectedly,
|
---|
935 | $at_total_fail_count failed ($at_xfail_count expected failure)." ;;
|
---|
936 | *:*:*) at_result="$at_result $at_were run,
|
---|
937 | $at_xpass_count passed unexpectedly,
|
---|
938 | $at_total_fail_count failed ($at_xfail_count expected failures)." ;;
|
---|
939 | esac
|
---|
940 |
|
---|
941 | if test $at_skip_count = 0 && test $at_run_count -gt 1; then
|
---|
942 | at_result="All $at_result"
|
---|
943 | fi
|
---|
944 | fi
|
---|
945 |
|
---|
946 | # Now put skips in the mix.
|
---|
947 | case $at_skip_count in
|
---|
948 | 0) ;;
|
---|
949 | 1) at_result="$at_result
|
---|
950 | 1 test was skipped." ;;
|
---|
951 | *) at_result="$at_result
|
---|
952 | $at_skip_count tests were skipped." ;;
|
---|
953 | esac
|
---|
954 |
|
---|
955 | if test $at_unexpected_count = 0; then
|
---|
956 | echo "$at_result"
|
---|
957 | echo "$at_result" >&AS_MESSAGE_LOG_FD
|
---|
958 | else
|
---|
959 | echo "ERROR: $at_result" >&2
|
---|
960 | echo "ERROR: $at_result" >&AS_MESSAGE_LOG_FD
|
---|
961 | {
|
---|
962 | echo
|
---|
963 | AS_BOX([Summary of the failures.])
|
---|
964 |
|
---|
965 | # Summary of failed and skipped tests.
|
---|
966 | if test $at_fail_count != 0; then
|
---|
967 | echo "Failed tests:"
|
---|
968 | $SHELL "$[0]" $at_fail_list --list
|
---|
969 | echo
|
---|
970 | fi
|
---|
971 | if test $at_skip_count != 0; then
|
---|
972 | echo "Skipped tests:"
|
---|
973 | $SHELL "$[0]" $at_skip_list --list
|
---|
974 | echo
|
---|
975 | fi
|
---|
976 | if test $at_xpass_count != 0; then
|
---|
977 | echo "Unexpected passes:"
|
---|
978 | $SHELL "$[0]" $at_xpass_list --list
|
---|
979 | echo
|
---|
980 | fi
|
---|
981 | if test $at_fail_count != 0; then
|
---|
982 | AS_BOX([Detailed failed tests.])
|
---|
983 | echo
|
---|
984 | for at_group in $at_fail_list
|
---|
985 | do
|
---|
986 | at_group_normalized=$at_group
|
---|
987 | _AT_NORMALIZE_TEST_GROUP_NUMBER(at_group_normalized)
|
---|
988 | cat "$at_suite_dir/$at_group_normalized/$as_me.log"
|
---|
989 | echo
|
---|
990 | done
|
---|
991 | echo
|
---|
992 | fi
|
---|
993 | if test -n "$at_top_srcdir"; then
|
---|
994 | AS_BOX([${at_top_build_prefix}config.log])
|
---|
995 | sed 's/^/| /' ${at_top_build_prefix}config.log
|
---|
996 | echo
|
---|
997 | fi
|
---|
998 | } >&AS_MESSAGE_LOG_FD
|
---|
999 |
|
---|
1000 | AS_BOX([$as_me.log was created.])
|
---|
1001 |
|
---|
1002 | echo
|
---|
1003 | echo "Please send \`${at_testdir+${at_testdir}/}$as_me.log' and all information you think might help:"
|
---|
1004 | echo
|
---|
1005 | echo " To: <AT_PACKAGE_BUGREPORT>"
|
---|
1006 | echo " Subject: @<:@AT_PACKAGE_STRING@:>@ $as_me:dnl
|
---|
1007 | $at_fail_list${at_fail_list:+ failed${at_xpass_list:+,}}dnl
|
---|
1008 | $at_xpass_list${at_xpass_list:+ passed unexpectedly}"
|
---|
1009 | echo
|
---|
1010 | if test $at_debug_p = false; then
|
---|
1011 | echo
|
---|
1012 | echo 'You may investigate any problem if you feel able to do so, in which'
|
---|
1013 | echo 'case the test suite provides a good starting point. Its output may'
|
---|
1014 | echo "be found below \`${at_testdir+${at_testdir}/}$as_me.dir'."
|
---|
1015 | echo
|
---|
1016 | fi
|
---|
1017 | exit 1
|
---|
1018 | fi
|
---|
1019 |
|
---|
1020 | exit 0
|
---|
1021 | m4_divert_pop([TESTS_END])dnl
|
---|
1022 | dnl End of AT_INIT: divert to KILL, only test groups are to be
|
---|
1023 | dnl output, the rest is ignored. Current diversion is BODY, inherited
|
---|
1024 | dnl from M4sh.
|
---|
1025 | m4_divert_pop([BODY])
|
---|
1026 | m4_divert_push([KILL])
|
---|
1027 | ])# AT_INIT
|
---|
1028 |
|
---|
1029 |
|
---|
1030 | # _AT_ARG_OPTION(OPTIONS,HELP-TEXT,[ARGS],[ACTION-IF-GIVEN],
|
---|
1031 | # [ACTION-IF-NOT-GIVEN])
|
---|
1032 | # ---------------------------------------------------------------------------
|
---|
1033 | # Internal implementation of AT_ARG_OPTION & AT_ARG_OPTION_ARG
|
---|
1034 | m4_defun([_AT_ARG_OPTION],
|
---|
1035 | [m4_divert_once([HELP_OTHER],
|
---|
1036 | [cat <<_ATEOF
|
---|
1037 |
|
---|
1038 | Other options:
|
---|
1039 | _ATEOF
|
---|
1040 | ])dnl m4_divert_once HELP_OTHER
|
---|
1041 | m4_divert_text([HELP_OTHER],
|
---|
1042 | [cat <<_ATEOF
|
---|
1043 | $2
|
---|
1044 | _ATEOF])dnl
|
---|
1045 | dnl Turn our options into our desired strings
|
---|
1046 | m4_ifdef([AT_first_option],[m4_undefine([AT_first_option])])dnl
|
---|
1047 | m4_ifdef([AT_case],[m4_undefine([AT_case])])dnl
|
---|
1048 | m4_ifdef([AT_case_no],[m4_undefine([AT_case_no])])dnl
|
---|
1049 | m4_ifdef([AT_case_arg],[m4_undefine([AT_case_arg])])dnl
|
---|
1050 | m4_foreach([AT_option], m4_split(m4_normalize([$1]),[[ \|]+]),
|
---|
1051 | [m4_define_default([AT_first_option],AT_option)dnl
|
---|
1052 | m4_append([AT_case],m4_if(m4_len(AT_option),1,[],[-])[-]AT_option, [ | ])dnl
|
---|
1053 | m4_append([AT_case_no],[--no]AT_option, [ | ])dnl
|
---|
1054 | m4_append([AT_case_arg],m4_if(m4_len(AT_option),1,[],[-])[-]AT_option[=*], [ | ])dnl
|
---|
1055 | ])dnl m4_foreach AT_option
|
---|
1056 | dnl keep track so we or the user may process ACTION-IF-NOT-GIVEN
|
---|
1057 | m4_divert_once([PARSE_ARGS_BEGIN],
|
---|
1058 | [
|
---|
1059 | ##
|
---|
1060 | ## Set up package specific options.
|
---|
1061 | ##
|
---|
1062 | ])dnl
|
---|
1063 | m4_divert_text([PARSE_ARGS_BEGIN],
|
---|
1064 | [dnl Provide a default value for options without arguments.
|
---|
1065 | m4_ifvaln([$3],,[at_arg_[]m4_bpatsubst([AT_first_option], -, _)=false])dnl
|
---|
1066 | at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=false
|
---|
1067 | ])dnl m4_divert_text DEFAULTS
|
---|
1068 | m4_ifval([$3],[m4_divert_once([PARSE_ARGS_END],
|
---|
1069 | [
|
---|
1070 | ##
|
---|
1071 | ## Verify our last option didn't require an argument
|
---|
1072 | ##
|
---|
1073 | AS_IF([test -n "$at_prev"],[AS_ERROR([`$at_prev' requires an argument.])])])])
|
---|
1074 | m4_divert_text([PARSE_ARGS],
|
---|
1075 | [dnl Parse the options and args when necessary.
|
---|
1076 | m4_ifvaln([$3],
|
---|
1077 | [ AT_case )
|
---|
1078 | at_prev=--m4_bpatsubst([AT_first_option], -, _)
|
---|
1079 | ;;
|
---|
1080 | AT_case_arg )
|
---|
1081 | at_arg_[]m4_bpatsubst([AT_first_option], -, _)=$at_optarg
|
---|
1082 | at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=:
|
---|
1083 | $4
|
---|
1084 | ;;],
|
---|
1085 | [ AT_case )
|
---|
1086 | at_optarg=:
|
---|
1087 | at_arg_[]m4_bpatsubst([AT_first_option], -, _)=:
|
---|
1088 | at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=:
|
---|
1089 | m4_ifval([$4],[$4])dnl
|
---|
1090 | ;;
|
---|
1091 | AT_case_no )
|
---|
1092 | at_optarg=false
|
---|
1093 | at_arg_[]m4_bpatsubst([AT_first_option], -, _)=false
|
---|
1094 | at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=:
|
---|
1095 | m4_ifval([$4],[$4])dnl
|
---|
1096 | ;;])dnl m4_ifvaln $3
|
---|
1097 | ])dnl m4_divert_text PARSE_ARGS
|
---|
1098 | m4_ifvaln([$5],
|
---|
1099 | [m4_divert_once([PARSE_ARGS_END],
|
---|
1100 | [
|
---|
1101 | ##
|
---|
1102 | ## Process package specific options when _not_ supplied.
|
---|
1103 | ##])dnl m4_divert_once PARSE_ARGS_END
|
---|
1104 | m4_divert_text([PARSE_ARGS_END],
|
---|
1105 | [
|
---|
1106 | AS_IF([$at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)],,[$5])dnl
|
---|
1107 | ])dnl m4_divert_text PARSE_ARGS_END
|
---|
1108 | ])dnl m4_ifvaln $5
|
---|
1109 | ])dnl _AT_ARG_OPTION
|
---|
1110 |
|
---|
1111 |
|
---|
1112 | # AT_ARG_OPTION(OPTIONS,HELP-TEXT,[ACTION-IF-GIVEN],[ACTION-IF-NOT-GIVEN])
|
---|
1113 | # ------------------------------------------------------------------------
|
---|
1114 | # Accept a set of OPTIONS with arguments. Add HELP-TEXT to the HELP_OTHER
|
---|
1115 | # diversion.
|
---|
1116 | #
|
---|
1117 | # Preceding dashes should not be passed into OPTIONS. Users will be required
|
---|
1118 | # to pass `--' before long options and `-' before single character options.
|
---|
1119 | #
|
---|
1120 | # $at_arg_OPTION will be set to `:' if this option is received, `false' if
|
---|
1121 | # if --noOPTION is received, and `false' by default.
|
---|
1122 | #
|
---|
1123 | # Run ACTION-IF-GIVEN each time an option in OPTIONS is encountered with
|
---|
1124 | # $at_optarg set to `:' or `false' as appropriate. $at_optarg is actually
|
---|
1125 | # just a copy of $at_arg_OPTION.
|
---|
1126 | #
|
---|
1127 | # ACTION-IF-NOT-GIVEN will be run once after option parsing is complete
|
---|
1128 | # if no option from OPTIONS was found.
|
---|
1129 | m4_defun([AT_ARG_OPTION],[_AT_ARG_OPTION([$1],[$2],,[$3],[$4])])
|
---|
1130 |
|
---|
1131 |
|
---|
1132 | # AT_ARG_OPTION_ARG(OPTIONS,HELP-TEXT,[ACTION-IF-GIVEN],[ACTION-IF-NOT-GIVEN])
|
---|
1133 | # ---------------------------------------------------------------------------
|
---|
1134 | # Accept a set of OPTIONS with arguments, seperated by commas. Add HELP-TEXT
|
---|
1135 | # to the HELP_OTHER diversion.
|
---|
1136 | #
|
---|
1137 | # Preceding dashes should not be passed into OPTIONS. Users will be required
|
---|
1138 | # to pass `--' before long options and `-' before single character options.
|
---|
1139 | #
|
---|
1140 | # By default, any argument to these options will be assigned to the shell
|
---|
1141 | # variable $at_arg_OPTION, where OPTION is the first option in OPTIONS with
|
---|
1142 | # any `-' characters replaced with `_'.
|
---|
1143 | #
|
---|
1144 | # Run ACTION-IF-GIVEN each time an option in OPTIONS is encountered with
|
---|
1145 | # $at_optarg set. $at_optarg is actually just a copy of $at_arg_OPTION.
|
---|
1146 | #
|
---|
1147 | # ACTION-IF-NOT-GIVEN will be run once after option parsing is complete
|
---|
1148 | # if no option from OPTIONS was found.
|
---|
1149 | m4_defun([AT_ARG_OPTION_ARG],[_AT_ARG_OPTION([$1],[$2],1,[$3],[$4])])
|
---|
1150 |
|
---|
1151 |
|
---|
1152 | # AT_TESTED(PROGRAMS)
|
---|
1153 | # -------------------
|
---|
1154 | # Specify the list of programs exercised by the test suite. Their
|
---|
1155 | # versions are logged, and in the case of embedded test suite, they
|
---|
1156 | # must correspond to the version of the package. PATH should be
|
---|
1157 | # already preset so the proper executable will be selected.
|
---|
1158 | m4_define([AT_TESTED],
|
---|
1159 | [m4_append_uniq([AT_tested], [$1], [
|
---|
1160 | ])])
|
---|
1161 |
|
---|
1162 |
|
---|
1163 | # AT_COPYRIGHT(TEXT)
|
---|
1164 | # ------------------
|
---|
1165 | # Emit TEXT, a copyright notice, in the top of the test suite and in
|
---|
1166 | # --version output. Macros in TEXT are evaluated once.
|
---|
1167 | m4_define([AT_COPYRIGHT],
|
---|
1168 | [AS_COPYRIGHT([$1])[]dnl
|
---|
1169 | m4_divert_text([VERSION_NOTICES],
|
---|
1170 | [
|
---|
1171 | $1])])# AT_COPYRIGHT
|
---|
1172 |
|
---|
1173 |
|
---|
1174 | # AT_SETUP(DESCRIPTION)
|
---|
1175 | # ---------------------
|
---|
1176 | # Start a group of related tests, all to be executed in the same subshell.
|
---|
1177 | # The group is testing what DESCRIPTION says.
|
---|
1178 | m4_define([AT_SETUP],
|
---|
1179 | [m4_ifdef([AT_keywords], [m4_undefine([AT_keywords])])
|
---|
1180 | m4_ifdef([AT_capture_files], [m4_undefine([AT_capture_files])])
|
---|
1181 | m4_define([AT_line], AT_LINE)
|
---|
1182 | m4_define([AT_xfail], [at_xfail=no])
|
---|
1183 | m4_define([AT_description], [$1])
|
---|
1184 | m4_define([AT_ordinal], m4_incr(AT_ordinal))
|
---|
1185 | m4_append([AT_groups_all], [ ]m4_defn([AT_ordinal]))
|
---|
1186 | m4_divert_push([TESTS])dnl
|
---|
1187 | AT_ordinal ) @%:@ AT_ordinal. m4_defn([AT_line]): $1
|
---|
1188 | at_setup_line='m4_defn([AT_line])'
|
---|
1189 | at_desc="AS_ESCAPE([$1])"
|
---|
1190 | $at_quiet $ECHO_N "m4_format([%3d: %-]m4_eval(47 - m4_qdelta([$1]))[s],
|
---|
1191 | AT_ordinal, AS_ESCAPE([[$1]]))[]$ECHO_C"
|
---|
1192 | m4_divert_push([TEST_SCRIPT])dnl
|
---|
1193 | ])
|
---|
1194 |
|
---|
1195 |
|
---|
1196 | # AT_XFAIL_IF(SHELL-EXPRESSION)
|
---|
1197 | # -----------------------------
|
---|
1198 | # Set up the test to be expected to fail if SHELL-EXPRESSION evaluates to
|
---|
1199 | # true (exitcode = 0).
|
---|
1200 | m4_define([AT_XFAIL_IF],
|
---|
1201 | [dnl
|
---|
1202 | dnl Try to limit the amount of conditionals that we emit.
|
---|
1203 | m4_case([$1],
|
---|
1204 | [], [],
|
---|
1205 | [false], [],
|
---|
1206 | [:], [m4_define([AT_xfail], [at_xfail=yes])],
|
---|
1207 | [true], [m4_define([AT_xfail], [at_xfail=yes])],
|
---|
1208 | [m4_append([AT_xfail], [
|
---|
1209 | $1 && at_xfail=yes])])])
|
---|
1210 |
|
---|
1211 |
|
---|
1212 | # AT_KEYWORDS(KEYWORDS)
|
---|
1213 | # ---------------------
|
---|
1214 | # Declare a list of keywords associated to the current test group.
|
---|
1215 | m4_define([AT_KEYWORDS],
|
---|
1216 | [m4_append_uniq([AT_keywords], [$1], [ ])])
|
---|
1217 |
|
---|
1218 |
|
---|
1219 | # AT_CAPTURE_FILE(FILE)
|
---|
1220 | # ---------------------
|
---|
1221 | # If the current test group does not behave as expected, save the contents of
|
---|
1222 | # FILE in the test suite log.
|
---|
1223 | m4_define([AT_CAPTURE_FILE],
|
---|
1224 | [m4_append_uniq([AT_capture_files], ["$1"], [ \
|
---|
1225 | ])])
|
---|
1226 |
|
---|
1227 |
|
---|
1228 | # AT_CLEANUP
|
---|
1229 | # ----------
|
---|
1230 | # Complete a group of related tests.
|
---|
1231 | m4_define([AT_CLEANUP],
|
---|
1232 | [m4_append([AT_help_all],
|
---|
1233 | m4_defn([AT_ordinal]);m4_defn([AT_line]);m4_defn([AT_description]);m4_ifdef([AT_keywords], [m4_defn([AT_keywords])]);
|
---|
1234 | )dnl
|
---|
1235 | m4_divert_pop([TEST_SCRIPT])dnl Back to TESTS
|
---|
1236 | AT_xfail
|
---|
1237 | echo "# -*- compilation -*-" >> "$at_group_log"
|
---|
1238 | (
|
---|
1239 | echo "AT_ordinal. m4_defn([AT_line]): testing $1..."
|
---|
1240 | $at_traceon
|
---|
1241 | m4_undivert([TEST_SCRIPT])dnl Insert the code here
|
---|
1242 | $at_traceoff
|
---|
1243 | $at_times_p && times >"$at_times_file"
|
---|
1244 | ) AS_MESSAGE_LOG_FD>&1 2>&1 | eval $at_tee_pipe
|
---|
1245 | at_status=`cat "$at_status_file"`
|
---|
1246 | ;;
|
---|
1247 |
|
---|
1248 | m4_divert_pop([TESTS])dnl Back to KILL.
|
---|
1249 | ])# AT_CLEANUP
|
---|
1250 |
|
---|
1251 |
|
---|
1252 | # AT_BANNER(TEXT)
|
---|
1253 | # ---------------
|
---|
1254 | # Output TEXT without any shell expansion.
|
---|
1255 | m4_define([AT_BANNER],
|
---|
1256 | [m4_define([AT_banner_ordinal], m4_incr(AT_banner_ordinal))
|
---|
1257 | m4_append([AT_groups_all], [ banner-]m4_defn([AT_banner_ordinal]))
|
---|
1258 | m4_divert_text([TESTS],
|
---|
1259 | [
|
---|
1260 | banner-AT_banner_ordinal ) @%:@ Banner AT_banner_ordinal. AT_LINE
|
---|
1261 | cat <<\_ATEOF
|
---|
1262 |
|
---|
1263 | $1
|
---|
1264 |
|
---|
1265 | _ATEOF
|
---|
1266 | ;;
|
---|
1267 | ])dnl
|
---|
1268 | ])# AT_BANNER
|
---|
1269 |
|
---|
1270 |
|
---|
1271 | # AT_DATA(FILE, CONTENTS)
|
---|
1272 | # -----------------------
|
---|
1273 | # Initialize an input data FILE with given CONTENTS, which should end with
|
---|
1274 | # an end of line.
|
---|
1275 | # This macro is not robust to active symbols in CONTENTS *on purpose*.
|
---|
1276 | # If you don't want CONTENTS to be evaluated, quote it twice.
|
---|
1277 | m4_define([AT_DATA],
|
---|
1278 | [cat >$1 <<'_ATEOF'
|
---|
1279 | $2[]_ATEOF
|
---|
1280 | ])
|
---|
1281 |
|
---|
1282 |
|
---|
1283 | # AT_CHECK(COMMANDS, [STATUS = 0], STDOUT, STDERR,
|
---|
1284 | # [RUN-IF-FAIL], [RUN-IF-PASS])
|
---|
1285 | # ------------------------------------------------
|
---|
1286 | # Execute a test by performing given shell COMMANDS. These commands
|
---|
1287 | # should normally exit with STATUS, while producing expected STDOUT and
|
---|
1288 | # STDERR contents. Shell metacharacters in STDOUT and STDERR are
|
---|
1289 | # _not_ processed by the shell, but are treated as string literals.
|
---|
1290 | #
|
---|
1291 | # STATUS, STDOUT, and STDERR are not checked if equal to `ignore'.
|
---|
1292 | #
|
---|
1293 | # If STDOUT is `expout', then stdout is compared to the content of the file
|
---|
1294 | # `expout'. Likewise for STDERR and `experr'.
|
---|
1295 | #
|
---|
1296 | # If STDOUT is `stdout', then the stdout is left in the file `stdout',
|
---|
1297 | # likewise for STDERR and `stderr'. Don't do this:
|
---|
1298 | #
|
---|
1299 | # AT_CHECK([command >out])
|
---|
1300 | # # Some checks on `out'
|
---|
1301 | #
|
---|
1302 | # do this instead:
|
---|
1303 | #
|
---|
1304 | # AT_CHECK([command], [], [stdout])
|
---|
1305 | # # Some checks on `stdout'
|
---|
1306 | #
|
---|
1307 | # This is an unfortunate limitation inherited from Ultrix which will not
|
---|
1308 | # let you redirect several times the same FD (see the Autoconf documentation).
|
---|
1309 | # If you use the `AT_CHECK([command >out])' be sure to get a test suite
|
---|
1310 | # that will show spurious failures.
|
---|
1311 | #
|
---|
1312 | # You might wonder why not just use `ignore' and directly use stdout and
|
---|
1313 | # stderr left by the test suite. Firstly because the names of these files
|
---|
1314 | # is an internal detail, and secondly, because
|
---|
1315 | #
|
---|
1316 | # AT_CHECK([command], [], [ignore])
|
---|
1317 | # AT_CHECK([check stdout])
|
---|
1318 | #
|
---|
1319 | # will use `stdout' both in input and output: undefined behavior would
|
---|
1320 | # certainly result. That's why the test suite will save them in `at-stdout'
|
---|
1321 | # and `at-stderr', and will provide you with `stdout' and `stderr'.
|
---|
1322 | #
|
---|
1323 | # Any line of stderr starting with leading blanks and a `+' are filtered
|
---|
1324 | # out, since most shells when tracing include subshell traces in stderr.
|
---|
1325 | # This may cause spurious failures when the test suite is run with `-x'.
|
---|
1326 | #
|
---|
1327 | m4_define([AT_CHECK],
|
---|
1328 | [_AT_CHECK([$1],[$2],[$3],[$4],[$5],[$6],1)])
|
---|
1329 |
|
---|
1330 | # AT_CHECK_NOESCAPE(COMMANDS, [STATUS = 0], STDOUT, STDERR,
|
---|
1331 | # [RUN-IF-FAIL], [RUN-IF-PASS])
|
---|
1332 | # ---------------------------------------------------------
|
---|
1333 | # Like AT_CHECK, but do not AS_ESCAPE shell metacharacters in the STDOUT
|
---|
1334 | # and STDERR arguments before running the comparison.
|
---|
1335 | m4_define([AT_CHECK_NOESCAPE],
|
---|
1336 | [_AT_CHECK([$1],[$2],[$3],[$4],[$5],[$6])])
|
---|
1337 |
|
---|
1338 |
|
---|
1339 | # _AT_DECIDE_TRACEABLE(COMMANDS)
|
---|
1340 | # ------------------------------
|
---|
1341 | # Worker for for _AT_CHECK that expands to shell code. If COMMANDS are safe to
|
---|
1342 | # trace with `set -x', the shell code will set `at_trace_this=yes'. Otherwise,
|
---|
1343 | # the shell code will print a message stating an aspect of COMMANDS that makes
|
---|
1344 | # tracing them unsafe.
|
---|
1345 | #
|
---|
1346 | # Tracing COMMANDS is not safe if they contain a command that spans multiple
|
---|
1347 | # lines. When the test suite user passes `-x' or `--trace', the test suite
|
---|
1348 | # precedes every command with a `set -x'. Since most tests expect a specific
|
---|
1349 | # stderr, if only to confirm that it is empty, the test suite filters ^+ from
|
---|
1350 | # the captured stderr before comparing with the expected stderr. If a command
|
---|
1351 | # spans multiple lines, so will its trace, but a `+' only prefixes the first
|
---|
1352 | # line of that trace:
|
---|
1353 | #
|
---|
1354 | # $ echo 'foo
|
---|
1355 | # bar'
|
---|
1356 | # => stdout
|
---|
1357 | # foo
|
---|
1358 | # bar
|
---|
1359 | # => stderr
|
---|
1360 | # + foo
|
---|
1361 | # bar
|
---|
1362 | #
|
---|
1363 | # In a subset of cases, one could filter such extended shell traces from stderr.
|
---|
1364 | # Since test commands spanning several lines are rare, I chose instead to simply
|
---|
1365 | # not trace COMMANDS that could yield multiple trace lines. Distinguishing such
|
---|
1366 | # COMMANDS became the task at hand.
|
---|
1367 | #
|
---|
1368 | # These features may cause a shell command to span multiple lines:
|
---|
1369 | #
|
---|
1370 | # (a) A quoted literal newline.
|
---|
1371 | # Example:
|
---|
1372 | # echo foo'
|
---|
1373 | # 'bar
|
---|
1374 | # M4 is a hostile language for the job of parsing COMMANDS to determine whether
|
---|
1375 | # each literal newline is quoted, so we simply disable tracing for all COMMANDS
|
---|
1376 | # that bear literal newlines.
|
---|
1377 | #
|
---|
1378 | # (b) A command substitution not subject to word splitting.
|
---|
1379 | # Example:
|
---|
1380 | # var=$(printf 'foo\nbar')
|
---|
1381 | # Example:
|
---|
1382 | # echo "`printf 'foo\\nbar`"
|
---|
1383 | # One cannot know in general the number of lines a command substitution will
|
---|
1384 | # yield without executing the substituted command. As such, we disable tracing
|
---|
1385 | # for all COMMANDS containing these constructs.
|
---|
1386 | #
|
---|
1387 | # (c) A parameter expansion not subject to word splitting.
|
---|
1388 | # Example:
|
---|
1389 | # var=foo'
|
---|
1390 | # 'bar
|
---|
1391 | # echo "$var"
|
---|
1392 | # Parameter expansions appear in COMMANDS with much greater frequency than do
|
---|
1393 | # newlines and command substitutions, so disabling tracing for all such COMMANDS
|
---|
1394 | # would much more substantially devalue `testsuite -x'. To determine which
|
---|
1395 | # parameter expansions yield multiple lines, we escape all ``', `"', and `\' in
|
---|
1396 | # a copy of COMMANDS and expand that string within double quotes at runtime. If
|
---|
1397 | # the result of that expansion contains multiple lines, the test suite disables
|
---|
1398 | # tracing for the command in question.
|
---|
1399 | #
|
---|
1400 | # This method leads the test suite to expand some parameters that the shell
|
---|
1401 | # itself will never expand due to single-quotes or backslash escapes. This is
|
---|
1402 | # not a problem for `$foo' expansions, which will simply yield the empty string
|
---|
1403 | # or some unrelated value. A `${...}' expansion could actually form invalid
|
---|
1404 | # shell code, however; consider `${=foo}'. Therefore, we disable tracing for
|
---|
1405 | # all COMMANDS containing `${...}'. This affects few COMMANDS.
|
---|
1406 | #
|
---|
1407 | # This macro falls in a very hot path; the Autoconf test suite expands it 1640
|
---|
1408 | # times as of this writing. To give a sense of the impact of the heuristics I
|
---|
1409 | # just described, the test suite preemptively disables tracing for 31 of those,
|
---|
1410 | # and 268 contain parameter expansions that require runtime evaluation. The
|
---|
1411 | # balance are always safe to trace.
|
---|
1412 | #
|
---|
1413 | # _AT_CHECK expands COMMANDS, but the Autoconf language does not provide a way
|
---|
1414 | # to safely expand arbitrary COMMANDS in an argument list, so the below tests
|
---|
1415 | # examine COMMANDS unexpanded.
|
---|
1416 | m4_define([_AT_DECIDE_TRACEABLE],
|
---|
1417 | [dnl Utility macros.
|
---|
1418 | m4_pushdef([at_lf], [
|
---|
1419 | ])[]dnl
|
---|
1420 | dnl
|
---|
1421 | dnl Examine COMMANDS for a reason to never trace COMMANDS.
|
---|
1422 | m4_pushdef([at_reason],
|
---|
1423 | m4_bmatch([$1],
|
---|
1424 | [`.*`], [[a `...` command substitution]],
|
---|
1425 | [\$(], [[a $(...) command substitution]],
|
---|
1426 | [\${], [[a ${...} parameter expansion]],
|
---|
1427 | at_lf, [[an embedded newline]],
|
---|
1428 | [[]]dnl No reason.
|
---|
1429 | ))dnl
|
---|
1430 | dnl
|
---|
1431 | m4_ifval(m4_defn([at_reason]),
|
---|
1432 | [echo 'Not enabling shell tracing (command contains ]m4_defn([at_reason])[)'],
|
---|
1433 | [m4_bmatch([$1], [\$],
|
---|
1434 | dnl COMMANDS may contain parameter expansions; expand them at runtime.
|
---|
1435 | [case "AS_ESCAPE([$1], [`"\])" in
|
---|
1436 | *'
|
---|
1437 | '*) echo 'Not enabling shell tracing (command contains an embedded newline)' ;;
|
---|
1438 | *) at_trace_this=yes ;;
|
---|
1439 | esac],
|
---|
1440 | dnl We know at build time that tracing COMMANDS is always safe.
|
---|
1441 | [at_trace_this=yes])])[]dnl
|
---|
1442 | m4_popdef([at_lf])[]dnl
|
---|
1443 | m4_popdef([at_reason])])
|
---|
1444 |
|
---|
1445 |
|
---|
1446 | # _AT_CHECK(COMMANDS, [STATUS = 0], STDOUT, STDERR,
|
---|
1447 | # [RUN-IF-FAIL], [RUN-IF-PASS], SHELL_ESCAPE_IO)
|
---|
1448 | # ---------------------------------------------------------
|
---|
1449 | # Worker for AT_CHECK & AT_CHECK_NOESCAPE. The final SHELL-ESCAPE-IO
|
---|
1450 | # argument determines whether the STDOUT & STDERR arguments will be escaped or
|
---|
1451 | # not.
|
---|
1452 | #
|
---|
1453 | #
|
---|
1454 | # Implementation Details
|
---|
1455 | # ----------------------
|
---|
1456 | # Ideally, we would like to run
|
---|
1457 | #
|
---|
1458 | # ( $at_traceon; COMMANDS >at-stdout 2> at-stderr )
|
---|
1459 | #
|
---|
1460 | # but we must group COMMANDS as it is not limited to a single command, and
|
---|
1461 | # then the shells will save the traces in at-stderr. So we have to filter
|
---|
1462 | # them out when checking stderr, and we must send them into the test suite's
|
---|
1463 | # stderr to honor -x properly. Since only the first line of the trace of a
|
---|
1464 | # multiline command starts with a `+', and I know of no straightforward way to
|
---|
1465 | # filter out the unadorned trace lines, we disable shell tracing entirely for
|
---|
1466 | # commands that could span multiple lines.
|
---|
1467 | #
|
---|
1468 | # Limiting COMMANDS to a single command is not good either, since them
|
---|
1469 | # the user herself would use {} or (), and then we face the same problem.
|
---|
1470 | #
|
---|
1471 | # But then, there is no point in running
|
---|
1472 | #
|
---|
1473 | # ( $at_traceon { $1 ; } >at-stdout 2>at-stder1 )
|
---|
1474 | #
|
---|
1475 | # instead of the simpler
|
---|
1476 | #
|
---|
1477 | # ( $at_traceon; $1 ) >at-stdout 2>at-stder1
|
---|
1478 | #
|
---|
1479 | m4_define([_AT_CHECK],
|
---|
1480 | [$at_traceoff
|
---|
1481 | echo "$at_srcdir/AT_LINE: AS_ESCAPE([$1])"
|
---|
1482 | echo AT_LINE >"$at_check_line_file"
|
---|
1483 |
|
---|
1484 | at_trace_this=
|
---|
1485 | if test -n "$at_traceon"; then
|
---|
1486 | _AT_DECIDE_TRACEABLE([$1])
|
---|
1487 | fi
|
---|
1488 |
|
---|
1489 | if test -n "$at_trace_this"; then
|
---|
1490 | ( $at_traceon; $1 ) >"$at_stdout" 2>"$at_stder1"
|
---|
1491 | at_status=$?
|
---|
1492 | grep '^ *+' "$at_stder1" >&2
|
---|
1493 | grep -v '^ *+' "$at_stder1" >"$at_stderr"
|
---|
1494 | else
|
---|
1495 | ( :; $1 ) >"$at_stdout" 2>"$at_stderr"
|
---|
1496 | at_status=$?
|
---|
1497 | fi
|
---|
1498 |
|
---|
1499 | at_failed=false
|
---|
1500 | dnl Check stderr.
|
---|
1501 | m4_case([$4],
|
---|
1502 | stderr, [echo stderr:; tee stderr <"$at_stderr"],
|
---|
1503 | ignore, [echo stderr:; cat "$at_stderr"],
|
---|
1504 | experr, [$at_diff experr "$at_stderr" || at_failed=:],
|
---|
1505 | [], [$at_diff "$at_devnull" "$at_stderr" || at_failed=:],
|
---|
1506 | [echo >>"$at_stderr"; echo "m4_ifval([$7],[AS_ESCAPE([$4])],[$4])" | $at_diff - "$at_stderr" || at_failed=:])
|
---|
1507 | dnl Check stdout.
|
---|
1508 | m4_case([$3],
|
---|
1509 | stdout, [echo stdout:; tee stdout <"$at_stdout"],
|
---|
1510 | ignore, [echo stdout:; cat "$at_stdout"],
|
---|
1511 | expout, [$at_diff expout "$at_stdout" || at_failed=:],
|
---|
1512 | [], [$at_diff "$at_devnull" "$at_stdout" || at_failed=:],
|
---|
1513 | [echo >>"$at_stdout"; echo "m4_ifval([$7],[AS_ESCAPE([$3])],[$3])" | $at_diff - "$at_stdout" || at_failed=:])
|
---|
1514 | dnl Check exit val. Don't `skip' if we are precisely checking $? = 77.
|
---|
1515 | case $at_status in
|
---|
1516 | m4_if([$2], [77],
|
---|
1517 | [],
|
---|
1518 | [ 77) echo 77 > "$at_status_file"; exit 77;;
|
---|
1519 | ])dnl
|
---|
1520 | m4_if([$2], [ignore],
|
---|
1521 | [ *);;],
|
---|
1522 | [ m4_default([$2], [0])) ;;
|
---|
1523 | *) echo "$at_srcdir/AT_LINE: exit code was $at_status, expected m4_default([$2], [0])"
|
---|
1524 | at_failed=:;;])
|
---|
1525 | esac
|
---|
1526 | AS_IF($at_failed, [$5
|
---|
1527 | m4_ifdef([AT_capture_files],
|
---|
1528 | [for file in AT_capture_files
|
---|
1529 | do echo "$file:"; sed 's/^/> /' "$file"; done])
|
---|
1530 | echo 1 > "$at_status_file"
|
---|
1531 | exit 1], [$6])
|
---|
1532 | $at_traceon
|
---|
1533 | ])# _AT_CHECK
|
---|