tests: Let 'ltorder.sh' run successfully with Guix dynamic loader
[automake.git] / t / check12.sh
blob34007896ce90f4e851f16c3ed4530b3f41e0a625
1 #! /bin/sh
2 # Copyright (C) 2010-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 # 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_OUTPUT
26 END
28 cat > Makefile.am << 'END'
29 AUTOMAKE_OPTIONS =
30 EXTRA_DIST =
31 CLEANFILES =
32 END
34 ## Simple tests.
36 cat > a.test << 'END'
37 #!/bin/sh
38 echo a.test: exit status: ${A_EXIT_STATUS-0}
39 exit ${A_EXIT_STATUS-0}
40 END
41 cat > b.test << 'END'
42 #!/bin/sh
43 echo b.test: exit status: ${B_EXIT_STATUS-0}
44 exit ${B_EXIT_STATUS-0}
45 END
46 chmod +x a.test b.test
48 cat >> Makefile.am << 'END'
49 TESTS = a.test b.test
50 EXTRA_DIST += $(TESTS)
51 END
53 A_EXIT_STATUS=0; export A_EXIT_STATUS
54 B_EXIT_STATUS=0; export B_EXIT_STATUS
56 ## DejaGnu tests.
58 cat >> Makefile.am << 'END'
59 AUTOMAKE_OPTIONS += dejagnu
60 DEJATOOL = hammer spanner
61 AM_RUNTESTFLAGS = HAMMER=$(srcdir)/hammer SPANNER=$(srcdir)/spanner
62 EXTRA_DIST += hammer.test/hammer.exp
63 EXTRA_DIST += spanner.test/spanner.exp
64 END
66 cat > hammer << 'END'
67 #! /bin/sh
68 echo "Everything looks like a ${NAIL-nail} to me!"
69 END
71 NAIL=nail; export NAIL
73 cat > spanner << 'END'
74 #! /bin/sh
75 echo "I'm a right spanner!"
76 END
77 chmod +x hammer spanner
79 mkdir hammer.test spanner.test
81 cat > hammer.test/hammer.exp << 'END'
82 set test test_hammer
83 spawn $HAMMER
84 expect {
85 "Everything looks like a nail to me!" { pass "$test" }
86 default { fail "$test" }
88 END
90 cat > spanner.test/spanner.exp << 'END'
91 set test test_spanner
92 spawn $SPANNER
93 expect {
94 "I'm a right spanner!" { pass "$test" }
95 default { fail "$test" }
97 END
99 ## User-defined extra tests.
101 cat >> Makefile.am <<'END'
102 check-local:
103 case $$CHECKLOCAL_EXIT_STATUS in \
104 0) echo 'check-local succeeded :-)';; \
105 *) echo 'check-local failed :-(';; \
106 esac >local.log
107 exit $$CHECKLOCAL_EXIT_STATUS
108 CLEANFILES += local.log
110 CHECKLOCAL_EXIT_STATUS=0; export CHECKLOCAL_EXIT_STATUS
112 ## Go with the testcase execution.
114 $ACLOCAL
115 $AUTOCONF
116 $AUTOMAKE --add-missing
118 for vpath in : false; do
120 if $vpath; then
121 srcdir=..
122 mkdir build
123 cd build
124 else
125 srcdir=.
128 if test -f config.status; then
129 $MAKE distclean
132 $srcdir/configure
134 $MAKE check
135 test -f hammer.log
136 test -f hammer.sum
137 test -f spanner.log
138 test -f spanner.sum
139 if test x"$am_serial_tests" != x"yes"; then
140 test -f test-suite.log
141 test -f a.log
142 test -f b.log
144 grep 'check-local succeeded :-)' local.log
146 cp -f config.status config-status.sav
148 $MAKE distclean
149 test ! -e hammer.log
150 test ! -e hammer.sum
151 test ! -e spanner.log
152 test ! -e spanner.sum
153 test ! -e test-suite.log
154 test ! -e a.log
155 test ! -e b.log
156 test ! -e local.log
158 mv -f config-status.sav config.status
159 ./config.status
161 NAIL=screw $MAKE check && exit 1
162 test -f hammer.log
163 test -f hammer.sum
164 test -f spanner.log
165 test -f spanner.sum
166 grep 'FAIL: test_hammer' hammer.sum
167 grep 'FAIL:' spanner.sum && exit 1
169 B_EXIT_STATUS=1 $MAKE check && exit 1
170 if test x"$am_serial_tests" != x"yes"; then
171 cat test-suite.log
172 cat a.log
173 cat b.log
174 grep '^a\.test: exit status: 0$' a.log
175 grep '^b\.test: exit status: 1$' b.log
176 grep '^FAIL: b$' test-suite.log
177 grep '^b\.test: exit status: 1$' test-suite.log
178 grep '^a\.test' test-suite.log && exit 1
179 : For shells with busted 'set -e'.
182 CHECKLOCAL_EXIT_STATUS=1 $MAKE check && exit 1
183 grep 'check-local failed :-(' local.log
185 # Do not trust the exit status of 'make -k'.
186 NAIL=screw B_EXIT_STATUS=23 CHECKLOCAL_EXIT_STATUS=1 $MAKE -k check || :
187 test -f hammer.log
188 test -f hammer.sum
189 test -f spanner.log
190 test -f spanner.sum
191 grep 'FAIL: test_hammer' hammer.sum
192 grep 'FAIL:' spanner.sum && exit 1
193 if test x"$am_serial_tests" != x"yes"; then
194 cat test-suite.log
195 cat a.log
196 cat b.log
197 grep '^a\.test: exit status: 0$' a.log
198 grep '^b\.test: exit status: 23$' b.log
199 grep '^FAIL: b$' test-suite.log
200 grep '^b\.test: exit status: 23$' test-suite.log
201 grep '^a\.test' test-suite.log && exit 1
202 : For shells with busted 'set -e'.
204 grep 'check-local failed :-(' local.log
206 cd $srcdir
208 done
210 $MAKE distcheck