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 # More on TAP support:
18 # - more than one TAP-generating test script in $(TESTS)
20 # - use with parallel make (if supported)
21 # - basic use of diagnostic messages (lines beginning with "#")
22 # - flags for TAP driver defined through AC_SUBST in configure.ac
23 # - messages generated by the testsuite harness reference the
24 # correct test script(s)
25 # - "make distcheck" works
31 cat >> configure.ac <<END
32 AC_SUBST([AM_TEST_LOG_DRIVER_FLAGS], ['--comments'])
36 cat > Makefile.am << 'END'
37 TEST_LOG_DRIVER = $(srcdir)/tap-driver
38 TESTS = 1.test 2.test 3.test
39 EXTRA_DIST = $(TESTS) tap-driver
46 if test -f not-skip; then
47 echo "not ok 2 zardoz"
49 echo "ok 2 zardoz # SKIP"
57 echo "not ok # TODO not implemented"
64 echo ok - blah blah blah
65 echo '# Some diagnostic'
66 if test -f bail-out; then
67 echo 'Bail out! Kernel Panic'
79 # Try a VPATH and by default serial build first, and then an in-tree
80 # and by default parallel build.
83 if test $try -eq 0; then
89 elif test $try -eq 1; then
90 # In-tree parallel build.
94 # Degree of parallelism already specified by the user: do
99 # Some make implementations (e.g., HP-UX) don't grok '-j',
100 # some require no space between '-j' and the number of jobs
101 # (e.g., older GNU make versions), and some *do* require a
102 # space between '-j' and the number of jobs (e.g., Solaris
103 # dmake). We need a runtime test to see what works.
104 echo 'all:' > Makefile
105 for run_make in "$MAKE -j3" "$MAKE -j 3" "$MAKE"; do
112 fatal_ "internal error, invalid value of '$try' for \$try"
116 ls -l # For debugging.
120 # Use append mode here to avoid dropping output. See automake bug#11413.
121 # Also, use 'echo' here to "nullify" the previous contents of 'stdout',
122 # since Solaris 10 /bin/sh would try to optimize a ':' away after the
123 # first iteration, even if it is redirected.
125 $run_make check >>stdout || { cat stdout; exit 1; }
127 count_test_results total=6 pass=4 fail=0 xpass=0 xfail=1 skip=1 error=0
128 grep '^PASS: 1\.test 1 - mu$' stdout
129 grep '^SKIP: 1\.test 2 zardoz # SKIP$' stdout
130 test $(grep -c '1\.test' stdout) -eq 2
131 grep '^PASS: 2\.test 1$' stdout
132 grep '^XFAIL: 2\.test 2 # TODO not implemented$' stdout
133 grep '^PASS: 2\.test 3$' stdout
134 test $(grep -c '2\.test' stdout) -eq 3
135 grep '^PASS: 3\.test 1 - blah blah blah$' stdout
136 grep '^# 3\.test: Some diagnostic$' stdout
137 test $(grep -c '3\.test' stdout) -eq 2
141 # Use 'echo' here, since Solaris 10 /bin/sh would try to optimize
142 # a ':' away after the first iteration, even if it is redirected.
143 echo dummy > not-skip
144 echo dummy > bail-out
145 # Use append mode here to avoid dropping output. See automake bug#11413.
146 # Also, use 'echo' here to "nullify" the previous contents of 'stdout',
147 # since Solaris 10 /bin/sh would try to optimize a ':' away after the
148 # first iteration, even if it is redirected.
150 $run_make check >>stdout && { cat stdout; exit 1; }
152 count_test_results total=7 pass=4 fail=1 xpass=0 xfail=1 skip=0 error=1
153 grep '^PASS: 1\.test 1 - mu$' stdout
154 grep '^FAIL: 1\.test 2 zardoz$' stdout
155 test $(grep -c '1\.test' stdout) -eq 2
156 grep '^PASS: 2\.test 1$' stdout
157 grep '^XFAIL: 2\.test 2 # TODO not implemented$' stdout
158 grep '^PASS: 2\.test 3$' stdout
159 test $(grep -c '2\.test' stdout) -eq 3
160 grep '^PASS: 3\.test 1 - blah blah blah$' stdout
161 grep '^# 3\.test: Some diagnostic$' stdout
162 grep '^ERROR: 3\.test - Bail out! Kernel Panic$' stdout
163 test $(grep -c '3\.test' stdout) -eq 3