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 # Custom test drivers: "abstract" XFAIL_TESTS support.
21 cat >> configure.ac <<'END'
23 AC_SUBST([ac_xfail_tests], ['x5.test x6$(test_suffix)'])
24 AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
28 cat > Makefile.am <<'END'
30 TEST_LOG_DRIVER = $(srcdir)/td
31 TESTS = pass.test xfail.test
32 XFAIL_TESTS = xfail.test
37 cat > sub1/Makefile.am <<END
40 TEST_LOG_DRIVER = \$(top_srcdir)/td
42 # XFAIL_TESTS should gracefully handle TAB characters, and multiple
44 XFAIL_TESTS =\$(empty)${tab}x1.test x2.test${tab}x3.test${tab}\
45 x4.test ${tab} x5.test x6.test${tab}\$(empty)
47 TESTS = pass.test x1.test x2.test x3.test x4.test x5.test x6.test
50 cat > sub2/Makefile.am <<'END'
51 AUTOMAKE_OPTIONS = -Wno-portability-recursive
53 TEST_LOG_DRIVER = $(srcdir)/../td
55 # XFAIL_TESTS should gracefully AC_SUBST @substitution@ and
56 # make variables indirections.
57 an_xfail_test = x1.test
62 XFAIL_TESTS = $(an_xfail_test) x2.test @nihil@ x3${test_suffix}
63 XFAIL_TESTS += $($(v1)$(v2)) x4.test @ac_xfail_tests@
65 TESTS = pass.test x1.test x2.test x3.test x4.test x5.test x6.test
68 cat > pass.test <<'END'
73 cat > xfail.test <<'END'
78 chmod a+x pass.test xfail.test
80 cp pass.test sub1/pass.test
81 cp pass.test sub2/pass.test
83 for i in 1 2 3 4 5 6; do
84 cp xfail.test sub1/x$i.test
85 cp xfail.test sub2/x$i.test
95 while test $# -gt 0; do
97 --test-name) test_name=$2; shift;;
98 --expect-failure) expect_failure=$2; shift;;
99 --log-file) log_file=$2; shift;;
100 --trs-file) trs_file=$2; shift;;
102 --color-tests) shift;;
103 --enable-hard-errors) shift;;
104 # Explicitly terminate option list.
107 *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
113 case $st,$expect_failure in
115 echo "PASS: $test_name" | tee "$log_file"
116 echo ":test-result: PASS" > "$trs_file"
119 echo "FAIL: $test_name" | tee "$log_file"
120 echo ":test-result: FAIL" > "$trs_file"
123 echo "XPASS: $test_name" | tee "$log_file"
124 echo ":test-result: XPASS" > "$trs_file"
127 echo "XFAIL: $test_name" | tee "$log_file"
128 echo ":test-result: XFAIL" > "$trs_file"
131 echo "INTERNAL ERROR" >&2
144 $MAKE check >stdout || { cat stdout; exit 1; }
146 test $(grep -c '^PASS:' stdout) -eq 3
147 test $(grep -c '^XFAIL:' stdout) -eq 13
149 for dir in sub1 sub2; do
153 $MAKE check >stdout && { cat stdout; exit 1; }
155 test "$(cat pass.trs)" = ":test-result: FAIL"
156 test "$(cat x1.trs)" = ":test-result: XPASS"
157 test "$(cat x2.trs)" = ":test-result: XFAIL"
158 grep '^FAIL: pass\.test$' stdout
159 grep '^XPASS: x1\.test$' stdout
160 grep '^XFAIL: x2\.test$' stdout
161 count_test_results total=7 pass=0 xpass=1 fail=1 xfail=5 skip=0 error=0