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).
24 cat >> configure.ac << 'END'
29 # Will be extended later.
30 cat > Makefile.am << 'END'
31 TEST_EXTENSIONS = .bin .test
37 # Now try various kinds of test dependencies ...
40 # 1. A program that is also a test, and whose source files
43 cat >> Makefile.am <<'END'
44 EXTRA_PROGRAMS += foo.bin
46 foo_bin_SOURCES = foo.c
53 printf ("foofoofoo\n");
58 # 2. A program that is also a test, and whose source files
59 # are buildable by make.
60 cat >> Makefile.am <<'END'
61 EXTRA_PROGRAMS += bar.bin
63 bar_bin_SOURCES = bar.c
65 sed -e 's/foofoofoo/barbarbar/' foo.c > $@
68 # 3. A test script that already exists, whose execution depends
69 # on a program whose source files already exist and which is
71 cat >> Makefile.am <<'END'
77 cat > baz.test <<'END'
79 $srcdir/y "$@" | sed 's/.*/&ep&ep&ep/'
92 # 4. A program that is also a test, but whose source files
93 # do not exit and are not buildable by make.
95 cat >> Makefile.am <<'END'
96 EXTRA_PROGRAMS += none.bin
98 none_bin_SOURCES = none.c
102 # Setup done, go with the tests.
112 # 1. even if we cannot build the 'none.bin' program, all the other
113 # test programs should be built, and all the other tests should
115 # 2. still, since we cannot create the 'none.log' file, the
116 # 'test-suite.log' file shouldn't be created (as it depends
117 # on *all* the test logs).
120 $MAKE -k check >stdout 2>stderr || st=$?
125 test $st -gt 0 || Exit 1
127 # Don't trust exit status of "make -k" for non-GNU make.
128 $MAKE check && Exit 1
129 : For shells with busted 'set -e'.
132 # Files that should have been created, with the expected content.
134 grep foofoofoo foo.log
135 grep barbarbar bar.log
136 grep yepyepyep baz.log
137 # Files that shouldn't have been created.
139 test ! -f test-suite.log
140 # Expected testsuite progress output.
141 grep '^PASS: baz\.test$' stdout
142 # Don't anchor the end of the next two patterns, to allow for non-empty
144 grep '^PASS: foo\.bin' stdout
145 grep '^PASS: bar\.bin' stdout
146 # Expected error messages from make. Some make implementations (e.g.,
147 # FreeBSD make) seem to print the error on stdout instead, so check for
149 $EGREP 'none\.(bin|o|c)' stderr stdout
152 # 1. if we make the last EXTRA_PROGRAM buildable, the failed tests
154 # 2. on a lazy re-run, the passed tests are not re-run, and
155 # 3. their log files are not updated or touched.
160 echo 'int main (void) { return 0; }' > none.c
163 RECHECK_LOGS= $MAKE -e check >stdout || st=$?
166 test $st -eq 0 || Exit 1
169 stat stamp foo.log bar.log baz.log || :
171 # Files that shouldn't have been updated or otherwise touched.
172 is_newest stamp foo.log bar.log baz.log
173 # Files that should have been created now.
175 test -f test-suite.log
176 # Tests that shouldn't have been re-run.
177 $EGREP '(foo|bar)\.bin|baz\.test$' stdout && Exit 1
178 # Tests that should have been run. Again, we don't anchor the end
179 # of the next pattern, to allow for non-empty $(EXEEXT).
180 grep '^PASS: none\.bin' stdout