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 # Check parallel-tests features:
20 # - stdout and stderr of a test script go in its log file
21 # - TEST_SUITE_LOG redefinition, at either automake or make time
22 # - VERBOSE environment variable support
23 # Keep in sync with 'tap-log.sh'.
27 cat >> configure.ac
<<END
31 cat > Makefile.am
<< 'END'
32 TESTS
= pass.
test skip.
test xfail.
test fail.
test xpass.
test error.
test
33 XFAIL_TESTS
= xpass.
test xfail.
test
34 TEST_SUITE_LOG
= global.log
37 # Custom markers, for use in grepping checks.
38 cmarker
=::: # comment marker
39 pmarker
=%%% # plain maker
43 echo "$pmarker pass $pmarker" >&2
44 echo "# $cmarker pass $cmarker" >&2
50 echo "$pmarker skip $pmarker"
51 echo "# $cmarker skip $cmarker"
55 cat > xfail.
test <<END
57 echo "$pmarker xfail $pmarker" >&2
58 echo "# $cmarker xfail $cmarker" >&2
64 echo "$pmarker fail $pmarker"
65 echo "# $cmarker fail $cmarker"
69 cat > xpass.
test <<END
71 echo "$pmarker xpass $pmarker" >&2
72 echo "# $cmarker xpass $cmarker" >&2
76 cat > error.
test <<END
78 echo "$pmarker error $pmarker"
79 echo "# $cmarker error $cmarker"
91 TEST_SUITE_LOG
=my.log
$MAKE -e check
&& exit 1
92 ls -l # For debugging.
93 test ! -e test-suite.log
97 for result
in pass fail xfail xpass skip error
; do
98 cat $result.log
# For debugging.
99 $FGREP "$pmarker $result $pmarker" $result.log || st
=1
100 $FGREP "$cmarker $result $cmarker" $result.log || st
=1
102 test $st -eq 0 ||
exit 1
103 cat my.log
# For debugging.
104 for result
in xfail fail xpass skip error
; do
105 cat $result.log
# For debugging.
106 $FGREP "$pmarker $result $pmarker" my.log || st
=1
107 $FGREP "$cmarker $result $cmarker" my.log || st
=1
109 test $
($FGREP -c "$pmarker" my.log
) -eq 5
110 test $
($FGREP -c "$cmarker" my.log
) -eq 5
114 eqeq
=$
(echo "$1" |
sed 's/./=/g')
115 # Assume $1 contains no RE metacharacters.
116 sed -n "/^$1$/,/^$eqeq$/p" $2 > got
117 (echo "$1" && echo "$eqeq") > exp
123 # Passed test scripts shouldn't be mentioned in the global log.
124 $EGREP ':.*[^x]pass' my.log
&& exit 1
125 # But failing (expectedly or not) and skipped ones should.
126 have_rst_section
'SKIP: skip' my.log
127 have_rst_section
'FAIL: fail' my.log
128 have_rst_section
'XFAIL: xfail' my.log
129 have_rst_section
'XPASS: xpass' my.log
130 have_rst_section
'ERROR: error' my.log
132 touch error2.log test-suite.log global.log
133 TEST_SUITE_LOG
=my.log
$MAKE -e mostlyclean
134 ls -l # For debugging.
142 # "make mostlyclean" shouldn't remove unrelated log files.
144 test -f test-suite.log
149 VERBOSE
=yes $MAKE check
>stdout
&& { cat stdout
; exit 1; }
153 test ! -e test-suite.log
154 # Check that VERBOSE causes the global testsuite log to be
157 log
=$
(cat global.log
)
158 case $out in *"$log"*) ;; *) exit 1;; esac
160 touch error2.log test-suite.log my.log
162 ls -l # For debugging.
170 # "make clean" shouldn't remove unrelated log files.
172 test -f test-suite.log