Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / check12.test
1 #! /bin/sh
2 # Copyright (C) 2010 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
17 # Test to make sure dejagnu tests, automake-style tests, and check-local
18 # target can coexist.
19
20 required=runtest
21 . ./defs || Exit 1
22
23 set -e
24
25 cat >> configure.in << 'END'
26 AC_OUTPUT
27 END
28
29 cat > Makefile.am << 'END'
30 AUTOMAKE_OPTIONS =
31 EXTRA_DIST =
32 CLEANFILES =
33 END
34
35 ## Simple tests.
36
37 cat > a.test << 'END'
38 #!/bin/sh
39 exit ${A_EXIT_STATUS-0}
40 END
41 cat > b.test << 'END'
42 #!/bin/sh
43 exit ${B_EXIT_STATUS-0}
44 END
45 chmod +x a.test b.test
46
47 cat >> Makefile.am << 'END'
48 TESTS = a.test b.test
49 EXTRA_DIST += $(TESTS)
50 END
51
52 A_EXIT_STATUS=0; export A_EXIT_STATUS
53 B_EXIT_STATUS=0; export B_EXIT_STATUS
54
55 ## DejaGnu tests.
56
57 cat >> Makefile.am << 'END'
58 AUTOMAKE_OPTIONS += dejagnu
59 DEJATOOL = hammer spanner
60 AM_RUNTESTFLAGS = HAMMER=$(srcdir)/hammer SPANNER=$(srcdir)/spanner
61 EXTRA_DIST += hammer.test/hammer.exp
62 EXTRA_DIST += spanner.test/spanner.exp
63 END
64
65 cat > hammer << 'END'
66 #! /bin/sh
67 echo "Everything looks like a ${NAIL-nail} to me!"
68 END
69
70 NAIL=nail; export NAIL
71
72 cat > spanner << 'END'
73 #! /bin/sh
74 echo "I'm a right spanner!"
75 END
76 chmod +x hammer spanner
77
78 mkdir hammer.test spanner.test
79
80 cat > hammer.test/hammer.exp << 'END'
81 set test test_hammer
82 spawn $HAMMER
83 expect {
84     "Everything looks like a nail to me!" { pass "$test" }
85     default { fail "$test" }
86 }
87 END
88
89 cat > spanner.test/spanner.exp << 'END'
90 set test test_spanner
91 spawn $SPANNER
92 expect {
93     "I'm a right spanner!" { pass "$test" }
94     default { fail "$test" }
95 }
96 END
97
98 ## User-defined extra tests.
99
100 cat >> Makefile.am <<'END'
101 check-local:
102         case $$CHECKLOCAL_EXIT_STATUS in \
103           0) echo 'check-local succeded :-)';; \
104           *) echo 'check-local failed :-(';; \
105         esac >local.log
106         exit $$CHECKLOCAL_EXIT_STATUS
107 CLEANFILES += local.log
108 END
109 CHECKLOCAL_EXIT_STATUS=0; export CHECKLOCAL_EXIT_STATUS
110
111 ## Go with the testcase execution.
112
113 $ACLOCAL
114 $AUTOCONF
115 $AUTOMAKE --add-missing
116
117 for vpath in : false; do
118
119   if $vpath; then
120     srcdir=..
121     mkdir build_
122     cd build_
123   else
124     srcdir=.
125   fi
126
127   if test -f config.status; then
128     $MAKE distclean
129   fi
130
131   $srcdir/configure
132
133   $MAKE check
134   test -f hammer.log
135   test -f hammer.sum
136   test -f spanner.log
137   test -f spanner.sum
138   # This checks will be run only by the autogenerated `check12-p.test'.
139   if test x"$parallel_tests" = x"yes"; then
140     cat test-suite.log
141     grep '^PASS: a\.test (exit: 0)' a.log
142     grep '^PASS: b\.test (exit: 0)' b.log
143   else
144     :
145   fi
146   grep 'check-local succeded :-)' local.log
147
148   cp -f config.status config-status.sav
149
150   $MAKE distclean
151   test ! -r hammer.log
152   test ! -r hammer.sum
153   test ! -r spanner.log
154   test ! -r spanner.sum
155   test ! -r test-suite.log
156   test ! -r a.log
157   test ! -r b.log
158   test ! -r local.log
159
160   mv -f config-status.sav config.status
161   ./config.status
162
163   NAIL=screw $MAKE check && Exit 1
164   test -f hammer.log
165   test -f hammer.sum
166   test -f spanner.log
167   test -f spanner.sum
168   grep 'FAIL: test_hammer' hammer.sum
169   grep 'FAIL:' spanner.sum && Exit 1
170
171   B_EXIT_STATUS=1 $MAKE check && Exit 1
172   # This checks will be run only by the autogenerated `check12-p.test'.
173   if test x"$parallel_tests" = x"yes"; then
174     cat test-suite.log
175     grep '^PASS: a\.test (exit: 0)' a.log
176     grep '^FAIL: b\.test (exit: 1)' b.log
177     grep '^FAIL: b\.test (exit: 1)' test-suite.log
178   else :; fi
179
180   CHECKLOCAL_EXIT_STATUS=1 $MAKE check && Exit 1
181   grep 'check-local failed :-(' local.log
182
183   # Do not trust the exit status of `make -k'.
184   NAIL=screw B_EXIT_STATUS=23 CHECKLOCAL_EXIT_STATUS=1 $MAKE -k check || :
185   test -f hammer.log
186   test -f hammer.sum
187   test -f spanner.log
188   test -f spanner.sum
189   grep 'FAIL: test_hammer' hammer.sum
190   grep 'FAIL:' spanner.sum && Exit 1
191   # This checks will be run only by the autogenerated `check12-p.test'.
192   if test x"$parallel_tests" = x"yes"; then
193     cat test-suite.log
194     grep '^PASS: a\.test (exit: 0)' a.log
195     grep '^FAIL: b\.test (exit: 23)' b.log
196     grep '^FAIL: b\.test (exit: 23)' test-suite.log
197   else :; fi
198   grep 'check-local failed :-(' local.log
199
200   cd $srcdir
201
202 done
203
204 $MAKE distcheck
205
206 :