Merge branch 'maint'
[platform/upstream/automake.git] / lib / am / check.am
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 2001-2012 Free Software Foundation, Inc.
3
4 ## This program is free software; you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
7 ## any later version.
8
9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ## GNU General Public License for more details.
13
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 am__tty_colors_dummy = \
18   mgn= red= grn= lgn= blu= brg= std=; \
19   am__color_tests=no
20 if %?COLOR%
21 am__tty_colors = { \
22   $(am__tty_colors_dummy); \
23   if test "X$(AM_COLOR_TESTS)" = Xno; then \
24     am__color_tests=no; \
25   elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
26     am__color_tests=yes; \
27 ## If stdout is a non-dumb tty, use colors.  If test -t is not supported,
28 ## then this check fails; a conservative approach.  Of course do not
29 ## redirect stdout here, just stderr.
30   elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
31     am__color_tests=yes; \
32   fi; \
33   if test $$am__color_tests = yes; then \
34     red='\e[0;31m'; \
35     grn='\e[0;32m'; \
36     lgn='\e[1;32m'; \
37     blu='\e[1;34m'; \
38     mgn='\e[0;35m'; \
39     brg='\e[1m'; \
40     std='\e[m'; \
41   fi; \
42 }
43 else !%?COLOR%
44 am__tty_colors = $(am__tty_colors_dummy)
45 endif !%?COLOR%
46
47 .PHONY: check-TESTS
48
49 if !%?SERIAL_TESTS%
50
51 include inst-vars.am
52
53 ## New parallel test driver.
54 ##
55 ## The first version of the code here was adapted from check.mk, which was
56 ## originally written at EPITA/LRDE, further developed at Gostai, then made
57 ## its way from GNU coreutils to end up, largely rewritten, in Automake.
58 ## The current version is an heavy rewrite of that, to allow for support
59 ## of more test metadata, and the use of custom test drivers and protocols
60 ## (among them, TAP).
61
62 am__recheck_rx = ^[     ]*:recheck:[    ]*
63 am__global_test_result_rx = ^[  ]*:global-test-result:[         ]*
64 am__copy_in_global_log_rx = ^[  ]*:copy-in-global-log:[         ]*
65
66 # A command that, given a newline-separated list of test names on the
67 # standard input, print the name of the tests that are to be re-run
68 # upon "make recheck".
69 am__list_recheck_tests = $(AWK) '{ \
70 ## By default, we assume the test is to be re-run.
71   recheck = 1; \
72   while ((rc = (getline line < ($$0 ".trs"))) != 0) \
73     { \
74       if (rc < 0) \
75         { \
76 ## If we've encountered an I/O error here, there are three possibilities:
77 ##
78 ##  [1] The '.log' file exists, but the '.trs' does not; in this case,
79 ##      we "gracefully" recover by assuming the corresponding test is
80 ##      to be re-run (which will re-create the missing '.trs' file).
81 ##
82 ##  [2] Both the '.log' and '.trs' files are missing; this means that
83 ##      the corresponding test has not been run, and is thus *not* to
84 ##      be re-run.
85 ##
86 ##  [3] We have encountered some corner-case problem (e.g., a '.log' or
87 ##      '.trs' files somehow made unreadable, or issues with a bad NFS
88 ##      connection, or whatever); we don't handle such corner cases.
89 ##
90           if ((getline line2 < ($$0 ".log")) < 0) \
91             recheck = 0; \
92           break; \
93         } \
94       else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
95 ## A directive explicitly specifying the test is *not* to be re-run.
96         { \
97           recheck = 0; \
98           break; \
99         } \
100       else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
101         { \
102 ## A directive explicitly specifying the test *is* to be re-run.
103           break; \
104         } \
105 ## else continue with the next iteration.
106     }; \
107   if (recheck) \
108     print $$0; \
109 ## Don't leak open file descriptors, as this could cause serious
110 ## problems when there are many tests (yes, even on Linux).
111   close ($$0 ".trs"); \
112   close ($$0 ".log"); \
113 }'
114
115 # A command that, given a newline-separated list of test names on the
116 # standard input, create the global log from their .trs and .log files.
117 am__create_global_log = $(AWK) ' \
118 function fatal(msg) \
119 { \
120   print "fatal: making $@: " msg | "cat >&2"; \
121   exit 1; \
122 } \
123 function rst_section(header) \
124 { \
125   print header; \
126   len = length(header); \
127   for (i = 1; i <= len; i = i + 1) \
128     printf "="; \
129   printf "\n\n"; \
130 } \
131 { \
132 ## By default, we assume the test log is to be copied in the global log,
133 ## and that its result is simply "RUN" (i.e., we still don't know what
134 ## it outcome was, but we know that at least it has run).
135   copy_in_global_log = 1; \
136   global_test_result = "RUN"; \
137   while ((rc = (getline line < ($$0 ".trs"))) != 0) \
138     { \
139       if (rc < 0) \
140          fatal("failed to read from " $$0 ".trs"); \
141       if (line ~ /$(am__global_test_result_rx)/) \
142         { \
143           sub("$(am__global_test_result_rx)", "", line); \
144           sub("[        ]*$$", "", line); \
145           global_test_result = line; \
146         } \
147       else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
148         copy_in_global_log = 0; \
149     }; \
150   if (copy_in_global_log) \
151     { \
152       rst_section(global_test_result ": " $$0); \
153       while ((rc = (getline line < ($$0 ".log"))) != 0) \
154       { \
155         if (rc < 0) \
156           fatal("failed to read from " $$0 ".log"); \
157         print line; \
158       }; \
159       printf "\n"; \
160     }; \
161 ## Don't leak open file descriptors, as this could cause serious
162 ## problems when there are many tests (yes, even on Linux).
163   close ($$0 ".trs"); \
164   close ($$0 ".log"); \
165 }'
166
167 # Restructured Text title.
168 am__rst_title = { sed 's/.*/   &   /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
169
170 # Solaris 10 'make', and several other traditional 'make' implementations,
171 # pass "-e" to $(SHELL), and POSIX 2008 even requires this.  Work around it
172 # by disabling -e (using the XSI extension "set +e") if it's set.
173 am__sh_e_setup = case $$- in *e*) set +e;; esac
174
175 # Default flags passed to test drivers.
176 am__common_driver_flags = \
177   --color-tests "$$am__color_tests" \
178   --enable-hard-errors "$$am__enable_hard_errors" \
179   --expect-failure "$$am__expect_failure"
180
181 # To be inserted before the command running the test.  Creates the
182 # directory for the log if needed.  Stores in $dir the directory
183 # containing $f, in $tst the test, in $log the log.  Executes the
184 # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
185 # passes TESTS_ENVIRONMENT.  Set up options for the wrapper that
186 # will run the test scripts (or their associated LOG_COMPILER, if
187 # thy have one).
188 am__check_pre =                                         \
189 $(am__sh_e_setup);                                      \
190 $(am__vpath_adj_setup) $(am__vpath_adj)                 \
191 $(am__tty_colors);                                      \
192 srcdir=$(srcdir); export srcdir;                        \
193 case "$@" in                                            \
194   */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;;    \
195     *) am__odir=.;;                                     \
196 esac;                                                   \
197 test "x$$am__odir" = x"." || test -d "$$am__odir"       \
198   || $(MKDIR_P) "$$am__odir" || exit $$?;               \
199 if test -f "./$$f"; then dir=./;                        \
200 elif test -f "$$f"; then dir=;                          \
201 else dir="$(srcdir)/"; fi;                              \
202 tst=$$dir$$f; log='$@';                                 \
203 if test -n '$(DISABLE_HARD_ERRORS)'; then               \
204   am__enable_hard_errors=no;                            \
205 else                                                    \
206   am__enable_hard_errors=yes;                           \
207 fi;                                                     \
208 ## The use of $dir below is required to account for VPATH
209 ## rewriting done by Sun make.
210 case " $(XFAIL_TESTS) " in                              \
211   *[\ \ ]$$f[\ \        ]* | *[\ \      ]$$dir$$f[\ \   ]*) \
212     am__expect_failure=yes;;                            \
213   *)                                                    \
214     am__expect_failure=no;;                             \
215 esac;                                                   \
216 $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
217
218 # A shell command to get the names of the tests scripts with any registered
219 # extension removed (i.e., equivalently, the names of the test logs, with
220 # the '.log' extension removed).  The result is saved in the shell variable
221 # '$bases'.  This honors runtime overriding of TESTS and TEST_LOGS.  Sadly,
222 # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
223 # since that might cause problem with VPATH rewrites for suffix-less tests.
224 # See also 'test-harness-vpath-rewrite.test' and 'test-trs-basic.test'.
225 am__set_TESTS_bases = \
226   bases='$(TEST_LOGS)'; \
227   bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
228 ## Trim away any extra whitespace.  This has already proved useful
229 ## in avoiding weird bug on lesser make implementations.  It also
230 ## works around the GNU make 3.80 bug where trailing whitespace in
231 ## "TESTS = foo.test $(empty)" causes $(TESTS_LOGS)  to erroneously
232 ## expand to "foo.log .log".
233   bases=`echo $$bases`
234
235 # Recover from deleted '.trs' file; this should ensure that
236 # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
237 # both 'foo.log' and 'foo.trs'.  Break the recipe in two subshells
238 # to avoid problems with "make -n".
239 .log.trs:
240         rm -f $< $@
241         $(MAKE) $(AM_MAKEFLAGS) $<
242
243 $(TEST_SUITE_LOG): $(TEST_LOGS)
244         @$(am__set_TESTS_bases); \
245 ## Helper shell function, tells whether a path refers to an existing,
246 ## regular, readable file.
247         am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
248 ## We need to ensures that all the required '.trs' and '.log' files will
249 ## be present and readable.  The direct dependencies of $(TEST_SUITE_LOG)
250 ## only ensure that all the '.log' files exists; they don't ensure that
251 ## the '.log' files are readable, and worse, they don't ensure that the
252 ## '.trs' files even exist.
253         redo_bases=`for i in $$bases; do \
254                       am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
255                     done`; \
256         if test -n "$$redo_bases"; then \
257 ## Uh-oh, either some '.log' files were unreadable, or some '.trs' files
258 ## were missing (or unreadable).  We need to re-run the corresponding
259 ## tests in order to re-create them.
260           redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
261           redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
262           if $(am__make_dryrun); then :; else \
263 ## Break "rm -f" into two calls to minimize the possibility of exceeding
264 ## command line length limits.
265             rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
266           fi; \
267         fi; \
268 ## Use a trick to to ensure that we don't go into an infinite recursion
269 ## in case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG).
270 ## Yes, this has already happened in practice.  Sigh!
271         if test -n "$$am__remaking_logs"; then \
272           echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
273                "recursion detected" >&2; \
274         else \
275           am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
276         fi; \
277         if $(am__make_dryrun); then :; else \
278 ## Sanity check: each unreadable or non-existent test result file should
279 ## has been properly remade at this point, as should the corresponding log
280 ## file.
281           st=0;  \
282           errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
283           for i in $$redo_bases; do \
284             test -f $$i.trs && test -r $$i.trs \
285               || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
286             test -f $$i.log && test -r $$i.log \
287               || { echo "$$errmsg $$i.log" >&2; st=1; }; \
288           done; \
289           test $$st -eq 0 || exit 1; \
290         fi
291 ## We need a new subshell to work portably with "make -n", since the
292 ## previous part of the recipe contained a $(MAKE) invocation.
293         @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
294         ws='[   ]'; \
295 ## List of test result files.
296         results=`for b in $$bases; do echo $$b.trs; done`; \
297         test -n "$$results" || results=/dev/null; \
298 ## Prepare data for the test suite summary.  These do not take into account
299 ## unreadable test results, but they'll be appropriately updated later if
300 ## needed.
301         all=`  grep "^$$ws*:test-result:"           $$results | wc -l`; \
302         pass=` grep "^$$ws*:test-result:$$ws*PASS"  $$results | wc -l`; \
303         fail=` grep "^$$ws*:test-result:$$ws*FAIL"  $$results | wc -l`; \
304         skip=` grep "^$$ws*:test-result:$$ws*SKIP"  $$results | wc -l`; \
305         xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
306         xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
307         error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
308 ## Whether the testsuite was successful or not.
309         if test `expr $$fail + $$xpass + $$error` -eq 0; then \
310           success=true; \
311         else \
312           success=false; \
313         fi; \
314 ## Make $br a line of exactly 76 '=' characters, that will be used to
315 ## enclose the testsuite summary report when displayed on the console.
316         br='==================='; br=$$br$$br$$br$$br; \
317 ## When writing the test summary to the console, we want to color a line
318 ## reporting the count of some result *only* if at least one test
319 ## experienced such a result.  This function is handy in this regard.
320         result_count () \
321         { \
322             if test x"$$1" = x"--maybe-color"; then \
323               maybe_colorize=yes; \
324             elif test x"$$1" = x"--no-color"; then \
325               maybe_colorize=no; \
326             else \
327               echo "$@: invalid 'result_count' usage" >&2; exit 4; \
328             fi; \
329             shift; \
330             desc=$$1 count=$$2; \
331             if test $$maybe_colorize = yes && test $$count -gt 0; then \
332               color_start=$$3 color_end=$$std; \
333             else \
334               color_start= color_end=; \
335             fi; \
336             echo "$${color_start}# $$desc $$count$${color_end}"; \
337         }; \
338 ## A shell function that creates the testsuite summary.  We need it
339 ## because we have to create *two* summaries, one for test-suite.log,
340 ## and a possibly-colorized one for console output.
341         create_testsuite_report () \
342         { \
343           result_count $$1 "TOTAL:" $$all   "$$brg"; \
344           result_count $$1 "PASS: " $$pass  "$$grn"; \
345           result_count $$1 "SKIP: " $$skip  "$$blu"; \
346           result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
347           result_count $$1 "FAIL: " $$fail  "$$red"; \
348           result_count $$1 "XPASS:" $$xpass "$$red"; \
349           result_count $$1 "ERROR:" $$error "$$mgn"; \
350         }; \
351 ## Write "global" testsuite log.
352         {                                                               \
353           echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" |       \
354             $(am__rst_title);                                           \
355           create_testsuite_report --no-color;                           \
356           echo;                                                         \
357           echo ".. contents:: :depth: 2";                               \
358           echo;                                                         \
359           for b in $$bases; do echo $$b; done                           \
360             | $(am__create_global_log);                                 \
361         } >$(TEST_SUITE_LOG).tmp || exit 1;                             \
362         mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG);                     \
363 ## Emit the test summary on the console.
364         if $$success; then                                              \
365           col="$$grn";                                                  \
366          else                                                           \
367           col="$$red";                                                  \
368           test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG);               \
369         fi;                                                             \
370 ## Multi line coloring is problematic with "less -R", so we really need
371 ## to color each line individually.
372         echo "$${col}$$br$${std}";                                      \
373         echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}";   \
374         echo "$${col}$$br$${std}";                                      \
375 ## This is expected to go to the console, so it might have to be colorized.
376         create_testsuite_report --maybe-color;                          \
377         echo "$$col$$br$$std";                                          \
378         if $$success; then :; else                                      \
379           echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}";         \
380           if test -n "$(PACKAGE_BUGREPORT)"; then                       \
381             echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
382           fi;                                                           \
383           echo "$$col$$br$$std";                                        \
384         fi;                                                             \
385 ## Be sure to exit with the proper exit status.  The use of "exit 1" below
386 ## is required to work around a FreeBSD make bug (present only when running
387 ## in concurrent mode).  See automake bug#9245:
388 ##  <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9245>
389 ## and FreeBSD PR bin/159730:
390 ##  <http://www.freebsd.org/cgi/query-pr.cgi?pr=159730>.
391         $$success || exit 1
392
393 RECHECK_LOGS = $(TEST_LOGS)
394
395 ## ------------------------------------------ ##
396 ## Running all tests, or rechecking failures. ##
397 ## ------------------------------------------ ##
398
399 check-TESTS:
400         list='$(RECHECK_LOGS)';           test -z "$$list" || rm -f $$list
401         list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
402 ## We always have to remove $(TEST_SUITE_LOG), to ensure its rule is run
403 ## in any case even in lazy mode: otherwise, if no test needs rerunning,
404 ## or a prior run plus reruns all happen within the same timestamp (can
405 ## happen with a prior "make TESTS=<subset>"), then we get no log output.
406 ## OTOH, this means that, in the rule for '$(TEST_SUITE_LOG)', we
407 ## cannot use '$?' to compute the set of lazily rerun tests, lest
408 ## we rely on .PHONY to work portably.
409         @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
410         @set +e; $(am__set_TESTS_bases); \
411         log_list=`for i in $$bases; do echo $$i.log; done`; \
412         trs_list=`for i in $$bases; do echo $$i.trs; done`; \
413 ## Remove newlines and normalize whitespace.  Trailing (and possibly
414 ## leading) whitespace is known to cause segmentation faults on
415 ## Solaris 10 XPG4 make.
416         log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
417         $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
418 ## Be sure to exit with the proper exit status (automake bug#9245).  See
419 ## comments in the recipe of $(TEST_SUITE_LOG) above for more information.
420         exit $$?;
421
422 ## Recheck must depend on $(check_SCRIPTS), $(check_PROGRAMS), etc.
423 ## It must also depend on the 'all' target.  See automake bug#11252.
424 recheck: all %CHECK_DEPS%
425 ## See comments above in the check-TESTS recipe for why remove
426 ## $(TEST_SUITE_LOG) here.
427         @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
428         @set +e; $(am__set_TESTS_bases); \
429 ## We must only consider tests that had an unexpected outcome (FAIL
430 ## or XPASS) in the earlier run.
431         bases=`for i in $$bases; do echo $$i; done \
432                  | $(am__list_recheck_tests)` || exit 1; \
433         log_list=`for i in $$bases; do echo $$i.log; done`; \
434         trs_list=`for i in $$bases; do echo $$i.trs; done`; \
435 ## Remove newlines and normalize whitespace.  Trailing (and possibly
436 ## leading) whitespace is known to cause segmentation faults on
437 ## Solaris 10 XPG4 make.
438         log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
439 ## Move the '.log' and '.trs' files associated with the tests to be
440 ## re-run out of the way, so that those tests will be re-run by the
441 ## "make test-suite.log" recursive invocation below.
442 ## Two tricky requirements:
443 ##   - we must avoid extra files removal when running under "make -n";
444 ##   - in case the test is a compiled program whose compilation fails,
445 ##     we must ensure that any '.log' and '.trs' file referring to such
446 ##     test are preserved, so that future "make recheck" invocations
447 ##     will still try to re-compile and re-run it (automake bug#11791).
448 ## The extra contortions below cater to such requirements.
449         am_backupdir=.am-recheck; \
450         if $(am__make_dryrun); then :; else \
451           if test -n "$$trs_list$$log_list"; then \
452             { test ! -d $$am_backupdir || rm -rf $$am_backupdir; } \
453               && $(MKDIR_P) $$am_backupdir || exit 1; \
454             test -z "$$log_list" \
455               || mv -f $$log_list $$am_backupdir 2>/dev/null; \
456             test -z "$$trs_list" \
457               || mv -f $$trs_list $$am_backupdir 2>/dev/null; \
458           fi; \
459         fi; \
460         $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
461         st=$$?; \
462         if $(am__make_dryrun) || test ! -d $$am_backupdir; then :; else \
463           for f in $$log_list $$trs_list; do \
464             test -f $$f || mv $$am_backupdir/$$f . || exit 1; \
465           done; \
466           rm -rf $$am_backupdir || exit 1; \
467         fi; \
468         exit $$st;
469
470 AM_RECURSIVE_TARGETS += check recheck
471
472 .PHONY: recheck
473
474 else %?SERIAL_TESTS%
475
476 ## Obsolescent serial testsuite driver.
477
478 check-TESTS: $(TESTS)
479         @failed=0; all=0; xfail=0; xpass=0; skip=0; \
480         srcdir=$(srcdir); export srcdir; \
481 ## Make sure Solaris VPATH-expands all members of this list, even
482 ## the first and the last one; thus the spaces around $(TESTS)
483         list=' $(TESTS) '; \
484         $(am__tty_colors); \
485         if test -n "$$list"; then \
486           for tst in $$list; do \
487             if test -f ./$$tst; then dir=./; \
488 ## Note: Solaris 2.7 seems to expand TESTS using VPATH.  That's
489 ## why we also try 'dir='.
490             elif test -f $$tst; then dir=; \
491             else dir="$(srcdir)/"; fi; \
492             if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \
493 ## Success
494               all=`expr $$all + 1`; \
495               case " $(XFAIL_TESTS) " in \
496               *[\ \     ]$$tst[\ \      ]*) \
497                 xpass=`expr $$xpass + 1`; \
498                 failed=`expr $$failed + 1`; \
499                 col=$$red; res=XPASS; \
500               ;; \
501               *) \
502                 col=$$grn; res=PASS; \
503               ;; \
504               esac; \
505             elif test $$? -ne 77; then \
506 ## Failure
507               all=`expr $$all + 1`; \
508               case " $(XFAIL_TESTS) " in \
509               *[\ \     ]$$tst[\ \      ]*) \
510                 xfail=`expr $$xfail + 1`; \
511                 col=$$lgn; res=XFAIL; \
512               ;; \
513               *) \
514                 failed=`expr $$failed + 1`; \
515                 col=$$red; res=FAIL; \
516               ;; \
517               esac; \
518             else \
519 ## Skipped
520               skip=`expr $$skip + 1`; \
521               col=$$blu; res=SKIP; \
522             fi; \
523             echo "$${col}$$res$${std}: $$tst"; \
524           done; \
525 ## Prepare the banner
526           if test "$$all" -eq 1; then \
527             tests="test"; \
528             All=""; \
529           else \
530             tests="tests"; \
531             All="All "; \
532           fi; \
533           if test "$$failed" -eq 0; then \
534             if test "$$xfail" -eq 0; then \
535               banner="$$All$$all $$tests passed"; \
536             else \
537               if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
538               banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
539             fi; \
540           else \
541             if test "$$xpass" -eq 0; then \
542               banner="$$failed of $$all $$tests failed"; \
543             else \
544               if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
545               banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
546             fi; \
547           fi; \
548 ## DASHES should contain the largest line of the banner.
549           dashes="$$banner"; \
550           skipped=""; \
551           if test "$$skip" -ne 0; then \
552             if test "$$skip" -eq 1; then \
553               skipped="($$skip test was not run)"; \
554             else \
555               skipped="($$skip tests were not run)"; \
556             fi; \
557             test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
558               dashes="$$skipped"; \
559           fi; \
560           report=""; \
561           if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
562             report="Please report to $(PACKAGE_BUGREPORT)"; \
563             test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
564               dashes="$$report"; \
565           fi; \
566           dashes=`echo "$$dashes" | sed s/./=/g`; \
567           if test "$$failed" -eq 0; then \
568             col="$$grn"; \
569           else \
570             col="$$red"; \
571           fi; \
572 ## Multi line coloring is problematic with "less -R", so we really need
573 ## to color each line individually.
574           echo "$${col}$$dashes$${std}"; \
575           echo "$${col}$$banner$${std}"; \
576           test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
577           test -z "$$report" || echo "$${col}$$report$${std}"; \
578           echo "$${col}$$dashes$${std}"; \
579           test "$$failed" -eq 0; \
580         else :; fi
581
582 endif %?SERIAL_TESTS%