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)
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
20 # For gen-testsuite-part: ==> try-with-serial-tests <==
24 cat >> configure.ac
<< 'END'
25 AC_CONFIG_FILES
([testsuite
/Makefile
])
29 cat > Makefile.am
<< 'END'
39 echo a.
test: exit status
: ${A_EXIT_STATUS-0}
40 exit ${A_EXIT_STATUS-0}
44 echo b.
test: exit status
: ${B_EXIT_STATUS-0}
45 exit ${B_EXIT_STATUS-0}
47 chmod +x a.
test b.
test
49 cat >> Makefile.am
<< 'END'
51 EXTRA_DIST
+= $
(TESTS
)
54 A_EXIT_STATUS
=0; export A_EXIT_STATUS
55 B_EXIT_STATUS
=0; export B_EXIT_STATUS
59 cat >> Makefile.am
<< 'END'
61 EXTRA_DIST
+= hammer spanner
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
75 echo "Everything looks like a ${NAIL-nail} to me!"
78 NAIL
=nail
; export NAIL
80 cat > spanner
<< 'END'
82 echo "I'm a right spanner!"
84 chmod +x hammer spanner
86 mkdir testsuite
/hammer.
test testsuite
/spanner.
test
88 cat > testsuite
/hammer.test
/hammer.exp
<< 'END'
92 "Everything looks like a nail to me!" { pass
"$test" }
93 default
{ fail
"$test" }
97 cat > testsuite
/spanner.test
/spanner.exp
<< 'END'
101 "I'm a right spanner!" { pass
"$test" }
102 default
{ fail
"$test" }
106 ## User-defined extra tests.
108 cat >> Makefile.am
<<'END'
110 case $$CHECKLOCAL_EXIT_STATUS in \
111 0) echo 'check-local succeeded :-)';; \
112 *) echo 'check-local failed :-(';; \
114 exit $$CHECKLOCAL_EXIT_STATUS
115 CLEANFILES += local.log
117 CHECKLOCAL_EXIT_STATUS
=0; export CHECKLOCAL_EXIT_STATUS
119 ## Go with the testcase execution.
123 $AUTOMAKE --add-missing
125 for vpath
in : false
; do
135 if test -f config.status
; then
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
151 grep 'check-local succeeded :-)' local.log
153 cp -f config.status config-status.sav
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
165 mv -f config-status.sav 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
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
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