c7959cd42c1a41ad070b826f862eac5b74bead5d
[platform/upstream/automake.git] / t / test-driver-custom-multitest.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
17 # Custom test drivers: check that we can easily support test protocols
18 # that allow multiple testcases in a single test script.  This test not
19 # only checks implementation details in Automake's custom test drivers
20 # support, but also serves as a "usability test" for our APIs.
21
22 am_parallel_tests=yes
23 . ./defs || Exit 1
24
25 cp "$am_testauxdir"/trivial-test-driver . \
26   || fatal_ "failed to fetch auxiliary script trivial-test-driver"
27
28 cat >> configure.ac << 'END'
29 AC_OUTPUT
30 END
31
32 cat > Makefile.am << 'END'
33 TEST_EXTENSIONS = .t
34 T_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
35
36 TESTS = \
37   pass.t \
38   fail.t \
39   fail2.t \
40   pass-fail.t \
41   pass4-skip.t \
42   pass3-skip2-xfail.t \
43   pass-xpass-fail-xfail-skip-error.t
44 END
45
46 cat > pass.t << 'END'
47 echo %% pass %%
48 echo PASS: pass
49 END
50
51 cat > fail.t << 'END'
52 echo %% fail %%
53 echo FAIL: fail
54 END
55
56 cat > fail2.t << 'END'
57 echo %% fail2 %%
58 echo FAIL: stdout >&1
59 echo FAIL: stderr >&2
60 echo :PASS: this should be ignored
61 END
62
63 cat > pass-fail.t << 'END'
64 echo %% pass-fail %%
65 echo 'FAIL: this fails :-('
66 echo 'some randome message'
67 echo 'some randome warning' >&2
68 echo 'PASS: this passes :-)'
69 echo 'INFO: blah'
70 echo 'WARNING: blah blah' >&2
71 END
72
73 cat > pass4-skip.t << 'END'
74 echo %% pass4-skip %%
75 echo PASS: on stdout >&1
76 echo PASS: on stderr >&2
77 echo PASS: 3
78 echo PASS: 4
79 echo SKIP: 1
80 echo this FAIL: should be ignored
81 echo FAIL as should this
82 exit 99
83 END
84
85 cat > pass3-skip2-xfail.t << 'END'
86 echo %% pass4-skip2-xfail %%
87 echo 'PASS: -v'
88 echo 'PASS: --verbose'
89 echo 'SKIP: Oops, unsupported system.'
90 echo 'PASS: -#-#-#-'
91 cp || echo "SKIP: cp cannot read users' mind" >&2
92 mv || echo "XFAIL: mv cannot read users' mind yet"
93 exit 127
94 END
95
96 cat > pass-xpass-fail-xfail-skip-error.t << 'END'
97 echo PASS:
98 echo FAIL:
99 echo XFAIL:
100 echo XPASS:
101 echo SKIP:
102 echo ERROR:
103 echo %% pass-xpass-fail-xfail-skip-error %%
104 END
105
106 chmod a+x *.t
107
108 $ACLOCAL
109 $AUTOCONF
110 $AUTOMAKE
111
112 for vpath in : false; do
113   if $vpath; then
114     mkdir build
115     cd build
116     srcdir=..
117   else
118     srcdir=.
119   fi
120
121   $srcdir/configure
122
123   $MAKE check >stdout && { cat stdout; cat test-suite.log; Exit 1; }
124   cat stdout
125   cat test-suite.log
126   # Couple of sanity checks.  These might need to be updated if the
127   # 'trivial-test-driver' script is changed.
128   $FGREP INVALID.NAME stdout test-suite.log && Exit 1
129   test -f BAD.LOG && Exit 1
130   test -f BAD.TRS && Exit 1
131   # These log files must all have been created by the testsuite.
132   cat pass.log
133   cat fail.log
134   cat fail2.log
135   cat pass-fail.log
136   cat pass4-skip.log
137   cat pass3-skip2-xfail.log
138   cat pass-xpass-fail-xfail-skip-error.log
139
140   count_test_results total=23 pass=10 fail=5 skip=4 xfail=2 xpass=1 error=1
141
142   tst=pass-xpass-fail-xfail-skip-error
143   grep  "^PASS: $tst\.t, testcase 1" stdout
144   grep  "^FAIL: $tst\.t, testcase 2" stdout
145   grep "^XFAIL: $tst\.t, testcase 3" stdout
146   grep "^XPASS: $tst\.t, testcase 4" stdout
147   grep  "^SKIP: $tst\.t, testcase 5" stdout
148   grep "^ERROR: $tst\.t, testcase 6" stdout
149
150   # Check that the content of, and only of, the test logs with at least
151   # one failing test case has been copied into 'test-suite.log'.  Note
152   # that test logs containing skipped or xfailed test cases are *not*
153   # copied into 'test-suite.log' -- a behaviour that deliberately differs
154   # from the one of the built-in Automake test drivers.
155   grep '%%' test-suite.log # For debugging.
156   grep '%% fail %%' test-suite.log
157   grep '%% fail2 %%' test-suite.log
158   grep '%% pass-fail %%' test-suite.log
159   grep '%% pass-xpass-fail-xfail-skip-error %%' test-suite.log
160   test `grep -c '%% ' test-suite.log` -eq 4
161
162   TESTS='pass.t pass3-skip2-xfail.t' $MAKE -e check >stdout \
163     || { cat stdout; cat test-suite.log; Exit 1; }
164   cat test-suite.log
165   cat stdout
166   count_test_results total=7 pass=4 fail=0 skip=2 xfail=1 xpass=0 error=0
167
168   cd $srcdir
169
170 done
171
172 :