tests: give few aclocal tests more significant names
[automake.git] / t / parallel-tests-extra-programs.sh
blob75a34b7a23a5b271faf5699e3cde41e6cad0f9bd
1 #! /bin/sh
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)
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 <http://www.gnu.org/licenses/>.
17 # Parallel test harness: check that $(TESTS) can lazily depend on
18 # (or even be) $(EXTRA_PROGRAMS).
20 required='cc native'
21 . test-init.sh
23 cat >> configure.ac << 'END'
24 AC_PROG_CC
25 AC_OUTPUT
26 END
28 # Will be extended later.
29 cat > Makefile.am << 'END'
30 TEST_EXTENSIONS = .bin .test
31 EXTRA_PROGRAMS =
32 TESTS =
33 END
36 # Now try various kinds of test dependencies ...
39 # 1. A program that is also a test, and whose source files
40 # already exist.
42 cat >> Makefile.am <<'END'
43 EXTRA_PROGRAMS += foo.bin
44 TESTS += foo.bin
45 foo_bin_SOURCES = foo.c
46 END
48 cat > foo.c <<'END'
49 #include <stdio.h>
50 int main (void)
52 printf ("foofoofoo\n");
53 return 0;
55 END
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
61 TESTS += bar.bin
62 bar_bin_SOURCES = bar.c
63 bar.c: foo.c
64 sed -e 's/foofoofoo/barbarbar/' foo.c > $@
65 END
67 # 3. A test script that already exists, whose execution depends
68 # on a program whose source files already exist and which is
69 # not itself a test.
70 cat >> Makefile.am <<'END'
71 EXTRA_PROGRAMS += y
72 TESTS += baz.test
73 baz.log: y$(EXEEXT)
74 END
76 cat > baz.test <<'END'
77 #!/bin/sh
78 $srcdir/y "$@" | sed 's/.*/&ep&ep&ep/'
79 END
80 chmod a+x baz.test
82 cat > y.c <<'END'
83 #include <stdio.h>
84 int main (void)
86 printf ("y\n");
87 return 0;
89 END
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
96 TESTS += none.bin
97 none_bin_SOURCES = none.c
98 END
101 # Setup done, go with the tests.
104 $ACLOCAL
105 $AUTOCONF
106 $AUTOMAKE -a
108 ./configure
110 # What we check now:
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
113 # be run;
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 st=0
119 $MAKE -k check >stdout 2>stderr || st=$?
120 cat stdout
121 cat stderr >&2
122 ls -l
123 if using_gmake; then
124 test $st -gt 0 || exit 1
125 else
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.
132 cat bar.c
133 grep foofoofoo foo.log
134 grep barbarbar bar.log
135 grep yepyepyep baz.log
136 # Files that shouldn't have been created.
137 test ! -e none.log
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
142 # $(EXEEXT).
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
147 # it there as well.
148 $EGREP 'none\.(bin|o|c)' stderr stdout
150 # What we check now:
151 # 1. if we make the last EXTRA_PROGRAM buildable, the failed tests
152 # pass;
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.
156 : > stamp
157 $sleep
159 echo 'int main (void) { return 0; }' > none.c
161 st=0
162 RECHECK_LOGS= $MAKE -e check >stdout || st=$?
163 cat stdout
164 ls -l
165 test $st -eq 0 || exit 1
167 # For debugging.
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.
173 test -f none.log
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