doc: update Vala documentation
[automake.git] / t / check12.sh
blobcf219bab4cdb26a158974f39ea1cadceceb644c8
1 #! /bin/sh
2 # Copyright (C) 2010-2024 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 # Test to make sure dejagnu tests, automake-style tests, and check-local
18 # target can coexist.
20 # For gen-testsuite-part: ==> try-with-serial-tests <==
21 required=runtest
22 . test-init.sh
24 cat >> configure.ac << 'END'
25 AC_CONFIG_FILES([testsuite/Makefile])
26 AC_OUTPUT
27 END
29 cat > Makefile.am << 'END'
30 AUTOMAKE_OPTIONS =
31 EXTRA_DIST =
32 CLEANFILES =
33 END
35 ## Simple tests.
37 cat > a.test << 'END'
38 #!/bin/sh
39 echo a.test: exit status: ${A_EXIT_STATUS-0}
40 exit ${A_EXIT_STATUS-0}
41 END
42 cat > b.test << 'END'
43 #!/bin/sh
44 echo b.test: exit status: ${B_EXIT_STATUS-0}
45 exit ${B_EXIT_STATUS-0}
46 END
47 chmod +x a.test b.test
49 cat >> Makefile.am << 'END'
50 TESTS = a.test b.test
51 EXTRA_DIST += $(TESTS)
52 END
54 A_EXIT_STATUS=0; export A_EXIT_STATUS
55 B_EXIT_STATUS=0; export B_EXIT_STATUS
57 ## DejaGnu tests.
59 cat >> Makefile.am << 'END'
60 SUBDIRS = testsuite
61 EXTRA_DIST += hammer spanner
62 END
64 mkdir testsuite
66 cat >> testsuite/Makefile.am << 'END'
67 AUTOMAKE_OPTIONS = dejagnu
68 DEJATOOL = hammer spanner
69 AM_RUNTESTFLAGS = HAMMER=$(top_srcdir)/hammer SPANNER=$(top_srcdir)/spanner
70 EXTRA_DIST = hammer.test/hammer.exp spanner.test/spanner.exp
71 END
73 cat > hammer << 'END'
74 #! /bin/sh
75 echo "Everything looks like a ${NAIL-nail} to me!"
76 END
78 NAIL=nail; export NAIL
80 cat > spanner << 'END'
81 #! /bin/sh
82 echo "I'm a right spanner!"
83 END
84 chmod +x hammer spanner
86 mkdir testsuite/hammer.test testsuite/spanner.test
88 cat > testsuite/hammer.test/hammer.exp << 'END'
89 set test test_hammer
90 spawn $HAMMER
91 expect {
92 "Everything looks like a nail to me!" { pass "$test" }
93 default { fail "$test" }
95 END
97 cat > testsuite/spanner.test/spanner.exp << 'END'
98 set test test_spanner
99 spawn $SPANNER
100 expect {
101 "I'm a right spanner!" { pass "$test" }
102 default { fail "$test" }
106 ## User-defined extra tests.
108 cat >> Makefile.am <<'END'
109 check-local:
110 case $$CHECKLOCAL_EXIT_STATUS in \
111 0) echo 'check-local succeeded :-)';; \
112 *) echo 'check-local failed :-(';; \
113 esac >local.log
114 exit $$CHECKLOCAL_EXIT_STATUS
115 CLEANFILES += local.log
117 CHECKLOCAL_EXIT_STATUS=0; export CHECKLOCAL_EXIT_STATUS
119 ## Go with the testcase execution.
121 $ACLOCAL
122 $AUTOCONF
123 $AUTOMAKE --add-missing
125 for vpath in : false; do
127 if $vpath; then
128 srcdir=..
129 mkdir build
130 cd build
131 else
132 srcdir=.
135 if test -f config.status; then
136 $MAKE distclean
139 $srcdir/configure
141 $MAKE check
142 test -f testsuite/hammer.log
143 test -f testsuite/hammer.sum
144 test -f testsuite/spanner.log
145 test -f testsuite/spanner.sum
146 if test x"$am_serial_tests" != x"yes"; then
147 test -f test-suite.log
148 test -f a.log
149 test -f b.log
151 grep 'check-local succeeded :-)' local.log
153 cp -f config.status config-status.sav
155 $MAKE distclean
156 test ! -e testsuite/hammer.log
157 test ! -e testsuite/hammer.sum
158 test ! -e testsuite/spanner.log
159 test ! -e testsuite/spanner.sum
160 test ! -e test-suite.log
161 test ! -e a.log
162 test ! -e b.log
163 test ! -e local.log
165 mv -f config-status.sav config.status
166 ./config.status
168 NAIL=screw $MAKE check && exit 1
169 test -f testsuite/hammer.log
170 test -f testsuite/hammer.sum
171 test -f testsuite/spanner.log
172 test -f testsuite/spanner.sum
173 grep 'FAIL: test_hammer' testsuite/hammer.sum
174 grep 'FAIL:' testsuite/spanner.sum && exit 1
176 B_EXIT_STATUS=1 $MAKE check && exit 1
177 if test x"$am_serial_tests" != x"yes"; then
178 cat test-suite.log
179 cat a.log
180 cat b.log
181 grep '^a\.test: exit status: 0$' a.log
182 grep '^b\.test: exit status: 1$' b.log
183 grep '^FAIL: b$' test-suite.log
184 grep '^b\.test: exit status: 1$' test-suite.log
185 grep '^a\.test' test-suite.log && exit 1
186 : For shells with busted 'set -e'.
189 CHECKLOCAL_EXIT_STATUS=1 $MAKE check && exit 1
190 grep 'check-local failed :-(' local.log
192 # Do not trust the exit status of 'make -k'.
193 NAIL=screw B_EXIT_STATUS=23 CHECKLOCAL_EXIT_STATUS=1 $MAKE -k check || :
194 test -f testsuite/hammer.log
195 test -f testsuite/hammer.sum
196 test -f testsuite/spanner.log
197 test -f testsuite/spanner.sum
198 grep 'FAIL: test_hammer' testsuite/hammer.sum
199 grep 'FAIL:' testsuite/spanner.sum && exit 1
200 if test x"$am_serial_tests" != x"yes"; then
201 cat test-suite.log
202 cat a.log
203 cat b.log
204 grep '^a\.test: exit status: 0$' a.log
205 grep '^b\.test: exit status: 23$' b.log
206 grep '^FAIL: b$' test-suite.log
207 grep '^b\.test: exit status: 23$' test-suite.log
208 grep '^a\.test' test-suite.log && exit 1
209 : For shells with busted 'set -e'.
211 grep 'check-local failed :-(' local.log
213 cd $srcdir
215 done
217 $MAKE distcheck