2 # Copyright (C) 2011-2012 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 # 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).
119 $MAKE -k check >stdout 2>stderr || st=$?
124 test $st -gt 0 || exit 1
126 # Don't trust exit status of "make -k" for non-GNU make.
127 $MAKE check && exit 1
128 : For shells with busted 'set -e'.
131 # Files that should have been created, with the expected content.
133 grep foofoofoo foo.log
134 grep barbarbar bar.log
135 grep yepyepyep baz.log
136 # Files that shouldn't have been created.
138 test ! -e test-suite.log
139 # Expected testsuite progress output.
140 grep '^PASS: baz\.test$' stdout
141 # Don't anchor the end of the next two patterns, to allow for non-empty
143 grep '^PASS: foo\.bin' stdout
144 grep '^PASS: bar\.bin' stdout
145 # Expected error messages from make. Some make implementations (e.g.,
146 # FreeBSD make) seem to print the error on stdout instead, so check for
148 $EGREP 'none\.(bin|o|c)' stderr stdout
151 # 1. if we make the last EXTRA_PROGRAM buildable, the failed tests
153 # 2. on a lazy re-run, the passed tests are not re-run, and
154 # 3. their log files are not updated or touched.
159 echo 'int main (void) { return 0; }' > none.c
162 RECHECK_LOGS= $MAKE -e check >stdout || st=$?
165 test $st -eq 0 || exit 1
168 stat stamp foo.log bar.log baz.log || :
170 # Files that shouldn't have been updated or otherwise touched.
171 is_newest stamp foo.log bar.log baz.log
172 # Files that should have been created now.
174 test -f test-suite.log
175 # Tests that shouldn't have been re-run.
176 $EGREP '(foo|bar)\.bin|baz\.test$' stdout && exit 1
177 # Tests that should have been run. Again, we don't anchor the end
178 # of the next pattern, to allow for non-empty $(EXEEXT).
179 grep '^PASS: none\.bin' stdout