2 # Copyright (C) 2011-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)
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 # Parallel test harness: check that $(TESTS) can lazily depend on
18 # (or even be) $(EXTRA_PROGRAMS).
23 cat >> configure.ac
<< 'END'
28 # Will be extended later.
29 cat > Makefile.am
<< 'END'
30 TEST_EXTENSIONS
= .bin .
test
36 # Now try various kinds of test dependencies ...
39 # 1. A program that is also a test, and whose source files
42 cat >> Makefile.am
<<'END'
43 EXTRA_PROGRAMS += foo.bin
45 foo_bin_SOURCES = foo.c
52 printf ("foofoofoo\n");
57 # 2. A program that is also a test, and whose source files
58 # are buildable by make.
59 cat >> Makefile.am
<<'END'
60 EXTRA_PROGRAMS += bar.bin
62 bar_bin_SOURCES = bar.c
64 sed -e 's/foofoofoo/barbarbar/' foo.c > $@
67 # 3. A test script that already exists, whose execution depends
68 # on a program whose source files already exist and which is
70 cat >> Makefile.am
<<'END'
76 cat > baz.
test <<'END'
78 $srcdir/y "$@" | sed 's/.*/&ep&ep&ep/'
91 # 4. A program that is also a test, but whose source files
92 # do not exit and are not buildable by make.
94 cat >> Makefile.am
<<'END'
95 EXTRA_PROGRAMS += none.bin
97 none_bin_SOURCES = none.c
101 # Setup done, go with the tests.
111 # 1. even if we cannot build the 'none.bin' program, all the other
112 # test programs should be built, and all the other tests should
114 # 2. still, since we cannot create the 'none.log' file, the
115 # 'test-suite.log' file shouldn't be created (as it depends
116 # on *all* the test logs).
118 run_make
-E -O -e IGNORE
-- -k check
121 test $am_make_rc -gt 0 ||
exit 1
123 # Don't trust exit status of "make -k" for non-GNU make.
124 $MAKE check
&& exit 1
125 : For shells with busted
'set -e'.
128 # Files that should have been created, with the expected content.
130 grep foofoofoo foo.log
131 grep barbarbar bar.log
132 grep yepyepyep baz.log
133 # Files that shouldn't have been created.
135 test ! -e test-suite.log
136 # Expected testsuite progress output.
137 grep '^PASS: baz\.test$' stdout
138 # Don't anchor the end of the next two patterns, to allow for non-empty
140 grep '^PASS: foo\.bin' stdout
141 grep '^PASS: bar\.bin' stdout
142 # Expected error messages from make. Some make implementations (e.g.,
143 # FreeBSD make) seem to print the error on stdout instead, so check for
145 $EGREP 'none\.(bin|o|c)' stderr stdout
148 # 1. if we make the last EXTRA_PROGRAM buildable, the failed tests
150 # 2. on a lazy re-run, the passed tests are not re-run, and
151 # 3. their log files are not updated or touched.
156 echo 'int main (void) { return 0; }' > none.c
158 run_make
-O -e IGNORE check RECHECK_LOGS
=
159 ls -l # For debugging.
160 test $am_make_rc -eq 0 ||
exit 1
163 stat stamp foo.log bar.log baz.log ||
:
165 # Files that shouldn't have been updated or otherwise touched.
166 is_newest stamp foo.log bar.log baz.log
167 # Files that should have been created now.
169 test -f test-suite.log
170 # Tests that shouldn't have been re-run.
171 $EGREP '(foo|bar)\.bin|baz\.test$' stdout
&& exit 1
172 # Tests that should have been run. Again, we don't anchor the end
173 # of the next pattern, to allow for non-empty $(EXEEXT).
174 grep '^PASS: none\.bin' stdout