1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 2001-2013 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)
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 <http://www.gnu.org/licenses/>.
17 am__tty_colors_dummy = \
18 mgn= red= grn= lgn= blu= brg= std=; \
22 $(am__tty_colors_dummy); \
23 if test "X$(AM_COLOR_TESTS)" = Xno; then \
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; \
33 if test $$am__color_tests = yes; then \
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
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.
69 while ((rc = (getline line < ($$0 ".trs"))) != 0) \
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
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) \
91 else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
92 ## A directive explicitly specifying the test is *not* to be re-run.
97 else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
99 ## A directive explicitly specifying the test *is* to be re-run.
102 ## else continue with the next iteration.
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) \
117 print "fatal: making $@: " msg | "cat >&2"; \
120 function rst_section(header) \
123 len = length(header); \
124 for (i = 1; i <= len; i = i + 1) \
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) \
137 fatal("failed to read from " $$0 ".trs"); \
138 if (line ~ /$(am__global_test_result_rx)/) \
140 sub("$(am__global_test_result_rx)", "", line); \
141 sub("[ ]*$$", "", line); \
142 global_test_result = line; \
144 else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
145 copy_in_global_log = 0; \
147 if (copy_in_global_log) \
149 rst_section(global_test_result ": " $$0); \
150 while ((rc = (getline line < ($$0 ".log"))) != 0) \
153 fatal("failed to read from " $$0 ".log"); \
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
187 $(am__vpath_adj_setup) $(am__vpath_adj) \
189 srcdir=$(srcdir); export srcdir; \
191 */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \
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; \
203 am__enable_hard_errors=yes; \
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;; \
211 am__expect_failure=no;; \
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".
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".
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)
246 $(TEST_SUITE_LOG): $(TEST_LOGS)
247 @$(am__set_TESTS_bases); \
248 ## Helper shell function, tells whether a path refers to an existing,
249 ## regular, readable file.
250 am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
251 ## We need to ensures that all the required '.trs' and '.log' files will
252 ## be present and readable. The direct dependencies of $(TEST_SUITE_LOG)
253 ## only ensure that all the '.log' files exists; they don't ensure that
254 ## the '.log' files are readable, and worse, they don't ensure that the
255 ## '.trs' files even exist.
256 redo_bases=`for i in $$bases; do \
257 am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
259 if test -n "$$redo_bases"; then \
260 ## Uh-oh, either some '.log' files were unreadable, or some '.trs' files
261 ## were missing (or unreadable). We need to re-run the corresponding
262 ## tests in order to re-create them.
263 redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
264 redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
265 if $(am__make_dryrun); then :; else \
266 ## Break "rm -f" into two calls to minimize the possibility of exceeding
267 ## command line length limits.
268 rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
271 ## Use a trick to to ensure that we don't go into an infinite recursion
272 ## in case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG).
273 ## Yes, this has already happened in practice. Sigh!
274 if test -n "$$am__remaking_logs"; then \
275 echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
276 "recursion detected" >&2; \
278 am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
280 if $(am__make_dryrun); then :; else \
281 ## Sanity check: each unreadable or non-existent test result file should
282 ## has been properly remade at this point, as should the corresponding log
285 errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
286 for i in $$redo_bases; do \
287 test -f $$i.trs && test -r $$i.trs \
288 || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
289 test -f $$i.log && test -r $$i.log \
290 || { echo "$$errmsg $$i.log" >&2; st=1; }; \
292 test $$st -eq 0 || exit 1; \
294 ## We need a new subshell to work portably with "make -n", since the
295 ## previous part of the recipe contained a $(MAKE) invocation.
296 @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
298 ## List of test result files.
299 results=`for b in $$bases; do echo $$b.trs; done`; \
300 test -n "$$results" || results=/dev/null; \
301 ## Prepare data for the test suite summary. These do not take into account
302 ## unreadable test results, but they'll be appropriately updated later if
304 all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
305 pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
306 fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
307 skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
308 xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
309 xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
310 error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
311 ## Whether the testsuite was successful or not.
312 if test `expr $$fail + $$xpass + $$error` -eq 0; then \
317 ## Make $br a line of exactly 76 '=' characters, that will be used to
318 ## enclose the testsuite summary report when displayed on the console.
319 br='==================='; br=$$br$$br$$br$$br; \
320 ## When writing the test summary to the console, we want to color a line
321 ## reporting the count of some result *only* if at least one test
322 ## experienced such a result. This function is handy in this regard.
325 if test x"$$1" = x"--maybe-color"; then \
326 maybe_colorize=yes; \
327 elif test x"$$1" = x"--no-color"; then \
330 echo "$@: invalid 'result_count' usage" >&2; exit 4; \
333 desc=$$1 count=$$2; \
334 if test $$maybe_colorize = yes && test $$count -gt 0; then \
335 color_start=$$3 color_end=$$std; \
337 color_start= color_end=; \
339 echo "$${color_start}# $$desc $$count$${color_end}"; \
341 ## A shell function that creates the testsuite summary. We need it
342 ## because we have to create *two* summaries, one for test-suite.log,
343 ## and a possibly-colorized one for console output.
344 create_testsuite_report () \
346 result_count $$1 "TOTAL:" $$all "$$brg"; \
347 result_count $$1 "PASS: " $$pass "$$grn"; \
348 result_count $$1 "SKIP: " $$skip "$$blu"; \
349 result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
350 result_count $$1 "FAIL: " $$fail "$$red"; \
351 result_count $$1 "XPASS:" $$xpass "$$red"; \
352 result_count $$1 "ERROR:" $$error "$$mgn"; \
354 ## Write "global" testsuite log.
356 echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
358 create_testsuite_report --no-color; \
360 echo ".. contents:: :depth: 2"; \
362 for b in $$bases; do echo $$b; done \
363 | $(am__create_global_log); \
364 } >$(TEST_SUITE_LOG).tmp || exit 1; \
365 mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
366 ## Emit the test summary on the console.
371 test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
373 ## Multi line coloring is problematic with "less -R", so we really need
374 ## to color each line individually.
375 echo "$${col}$$br$${std}"; \
376 echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
377 echo "$${col}$$br$${std}"; \
378 ## This is expected to go to the console, so it might have to be colorized.
379 create_testsuite_report --maybe-color; \
380 echo "$$col$$br$$std"; \
381 if $$success; then :; else \
382 echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
383 if test -n "$(PACKAGE_BUGREPORT)"; then \
384 echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
386 echo "$$col$$br$$std"; \
388 ## Be sure to exit with the proper exit status. The use of "exit 1" below
389 ## is required to work around a FreeBSD make bug (present only when running
390 ## in concurrent mode). See automake bug#9245:
391 ## <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9245>
392 ## and FreeBSD PR bin/159730:
393 ## <http://www.freebsd.org/cgi/query-pr.cgi?pr=159730>.
396 RECHECK_LOGS = $(TEST_LOGS)
398 ## ------------------------------------------ ##
399 ## Running all tests, or rechecking failures. ##
400 ## ------------------------------------------ ##
403 @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
404 @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
405 ## We always have to remove $(TEST_SUITE_LOG), to ensure its rule is run
406 ## in any case even in lazy mode: otherwise, if no test needs rerunning,
407 ## or a prior run plus reruns all happen within the same timestamp (can
408 ## happen with a prior "make TESTS=<subset>"), then we get no log output.
409 ## OTOH, this means that, in the rule for '$(TEST_SUITE_LOG)', we
410 ## cannot use '$?' to compute the set of lazily rerun tests, lest
411 ## we rely on .PHONY to work portably.
412 @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
413 @set +e; $(am__set_TESTS_bases); \
414 log_list=`for i in $$bases; do echo $$i.log; done`; \
415 trs_list=`for i in $$bases; do echo $$i.trs; done`; \
416 ## Remove newlines and normalize whitespace. Trailing (and possibly
417 ## leading) whitespace is known to cause segmentation faults on
418 ## Solaris 10 XPG4 make.
419 log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
420 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
421 ## Be sure to exit with the proper exit status (automake bug#9245). See
422 ## comments in the recipe of $(TEST_SUITE_LOG) above for more information.
425 ## Recheck must depend on $(check_SCRIPTS), $(check_PROGRAMS), etc.
426 ## It must also depend on the 'all' target. See automake bug#11252.
427 recheck: all %CHECK_DEPS%
428 ## See comments above in the check-TESTS recipe for why remove
429 ## $(TEST_SUITE_LOG) here.
430 @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
431 @set +e; $(am__set_TESTS_bases); \
432 ## We must only consider tests that had an unexpected outcome (FAIL
433 ## or XPASS) in the earlier run.
434 bases=`for i in $$bases; do echo $$i; done \
435 | $(am__list_recheck_tests)` || exit 1; \
436 log_list=`for i in $$bases; do echo $$i.log; done`; \
437 ## Remove newlines and normalize whitespace. Trailing (and possibly
438 ## leading) whitespace is known to cause segmentation faults on
439 ## Solaris 10 XPG4 make.
440 log_list=`echo $$log_list`; \
441 ## Move the '.log' and '.trs' files associated with the tests to be
442 ## re-run out of the way, so that those tests will be re-run by the
443 ## "make test-suite.log" recursive invocation below.
444 ## Two tricky requirements:
445 ## - we must avoid extra files removal when running under "make -n";
446 ## - in case the test is a compiled program whose compilation fails,
447 ## we must ensure that any '.log' and '.trs' file referring to such
448 ## test are preserved, so that future "make recheck" invocations
449 ## will still try to re-compile and re-run it (automake bug#11791).
450 ## The tricky recursive make invocation below should cater to such
452 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
453 am__force_recheck=am--force-recheck \
454 TEST_LOGS="$$log_list"; \
455 ## Be sure to exit with the proper exit status (automake bug#9245). See
456 ## comments in the recipe of $(TEST_SUITE_LOG) above for more information.
459 AM_RECURSIVE_TARGETS += check recheck
465 ## Obsolescent serial testsuite driver.
467 check-TESTS: $(TESTS)
468 @failed=0; all=0; xfail=0; xpass=0; skip=0; \
469 srcdir=$(srcdir); export srcdir; \
470 ## Make sure Solaris VPATH-expands all members of this list, even
471 ## the first and the last one; thus the spaces around $(TESTS)
474 if test -n "$$list"; then \
475 for tst in $$list; do \
476 if test -f ./$$tst; then dir=./; \
477 ## Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
478 ## why we also try 'dir='.
479 elif test -f $$tst; then dir=; \
480 else dir="$(srcdir)/"; fi; \
481 if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \
483 all=`expr $$all + 1`; \
484 case " $(XFAIL_TESTS) " in \
485 *[\ \ ]$$tst[\ \ ]*) \
486 xpass=`expr $$xpass + 1`; \
487 failed=`expr $$failed + 1`; \
488 col=$$red; res=XPASS; \
491 col=$$grn; res=PASS; \
494 elif test $$? -ne 77; then \
496 all=`expr $$all + 1`; \
497 case " $(XFAIL_TESTS) " in \
498 *[\ \ ]$$tst[\ \ ]*) \
499 xfail=`expr $$xfail + 1`; \
500 col=$$lgn; res=XFAIL; \
503 failed=`expr $$failed + 1`; \
504 col=$$red; res=FAIL; \
509 skip=`expr $$skip + 1`; \
510 col=$$blu; res=SKIP; \
512 echo "$${col}$$res$${std}: $$tst"; \
514 ## Prepare the banner
515 if test "$$all" -eq 1; then \
522 if test "$$failed" -eq 0; then \
523 if test "$$xfail" -eq 0; then \
524 banner="$$All$$all $$tests passed"; \
526 if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
527 banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
530 if test "$$xpass" -eq 0; then \
531 banner="$$failed of $$all $$tests failed"; \
533 if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
534 banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
537 ## DASHES should contain the largest line of the banner.
540 if test "$$skip" -ne 0; then \
541 if test "$$skip" -eq 1; then \
542 skipped="($$skip test was not run)"; \
544 skipped="($$skip tests were not run)"; \
546 test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
547 dashes="$$skipped"; \
550 if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
551 report="Please report to $(PACKAGE_BUGREPORT)"; \
552 test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
555 dashes=`echo "$$dashes" | sed s/./=/g`; \
556 if test "$$failed" -eq 0; then \
561 ## Multi line coloring is problematic with "less -R", so we really need
562 ## to color each line individually.
563 echo "$${col}$$dashes$${std}"; \
564 echo "$${col}$$banner$${std}"; \
565 test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
566 test -z "$$report" || echo "$${col}$$report$${std}"; \
567 echo "$${col}$$dashes$${std}"; \
568 test "$$failed" -eq 0; \
571 endif %?SERIAL_TESTS%