tests: Let 'ltorder.sh' run successfully with Guix dynamic loader
[automake.git] / t / test-driver-custom-xfail-tests.sh
blob4c415069ffc7fdb8b4f5f1eb9d6a1f33a27fca5a
1 #! /bin/sh
2 # Copyright (C) 2011-2018 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 <https://www.gnu.org/licenses/>.
17 # Custom test drivers: "abstract" XFAIL_TESTS support.
19 . test-init.sh
21 cat >> configure.ac <<'END'
22 AC_SUBST([nihil], [])
23 AC_SUBST([ac_xfail_tests], ['x5.test x6$(test_suffix)'])
24 AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
25 AC_OUTPUT
26 END
28 cat > Makefile.am <<'END'
29 SUBDIRS = . sub1 sub2
30 TEST_LOG_DRIVER = $(srcdir)/td
31 TESTS = pass.test xfail.test
32 XFAIL_TESTS = xfail.test
33 END
35 mkdir sub1 sub2
37 cat > sub1/Makefile.am <<END
38 empty =
40 TEST_LOG_DRIVER = \$(top_srcdir)/td
42 # XFAIL_TESTS should gracefully handle TAB characters, and multiple
43 # whitespaces.
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
48 END
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
58 test_suffix = .test
59 v0 = x3.test
60 v1 = v
61 v2 = 0
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
66 END
68 cat > pass.test <<'END'
69 #!/bin/sh
70 exit 0
71 END
73 cat > xfail.test <<'END'
74 #!/bin/sh
75 exit 1
76 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
86 done
88 cat > td <<'END'
89 #! /bin/sh
90 set -e; set -u
91 test_name=INVALID
92 log_file=/dev/null
93 trs_file=/dev/null
94 expect_failure=no
95 while test $# -gt 0; do
96 case $1 in
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;;
101 # Ignored.
102 --color-tests) shift;;
103 --enable-hard-errors) shift;;
104 # Explicitly terminate option list.
105 --) shift; break;;
106 # Shouldn't happen
107 *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
108 esac
109 shift
110 done
111 st=0
112 "$@" || st=$?
113 case $st,$expect_failure in
114 0,no)
115 echo "PASS: $test_name" | tee "$log_file"
116 echo ":test-result: PASS" > "$trs_file"
118 1,no)
119 echo "FAIL: $test_name" | tee "$log_file"
120 echo ":test-result: FAIL" > "$trs_file"
122 0,yes)
123 echo "XPASS: $test_name" | tee "$log_file"
124 echo ":test-result: XPASS" > "$trs_file"
126 1,yes)
127 echo "XFAIL: $test_name" | tee "$log_file"
128 echo ":test-result: XFAIL" > "$trs_file"
131 echo "INTERNAL ERROR" >&2
132 exit 99
134 esac
136 chmod a+x td
138 $ACLOCAL
139 $AUTOCONF
140 $AUTOMAKE
142 ./configure
144 run_make -O check
145 test $(grep -c '^PASS:' stdout) -eq 3
146 test $(grep -c '^XFAIL:' stdout) -eq 13
148 for dir in sub1 sub2; do
149 cd $dir
150 cp pass.test x1.test
151 cp x2.test pass.test
152 run_make -O -e FAIL check
153 test "$(cat pass.trs)" = ":test-result: FAIL"
154 test "$(cat x1.trs)" = ":test-result: XPASS"
155 test "$(cat x2.trs)" = ":test-result: XFAIL"
156 grep '^FAIL: pass\.test$' stdout
157 grep '^XPASS: x1\.test$' stdout
158 grep '^XFAIL: x2\.test$' stdout
159 count_test_results total=7 pass=0 xpass=1 fail=1 xfail=5 skip=0 error=0
160 cd ..
161 done