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