]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/kyua/bootstrap/testsuite.at
Upgrade to version 3.1.5
[FreeBSD/FreeBSD.git] / contrib / kyua / bootstrap / testsuite.at
1 dnl Copyright 2010 The Kyua Authors.
2 dnl All rights reserved.
3 dnl
4 dnl Redistribution and use in source and binary forms, with or without
5 dnl modification, are permitted provided that the following conditions are
6 dnl met:
7 dnl
8 dnl * Redistributions of source code must retain the above copyright
9 dnl   notice, this list of conditions and the following disclaimer.
10 dnl * Redistributions in binary form must reproduce the above copyright
11 dnl   notice, this list of conditions and the following disclaimer in the
12 dnl   documentation and/or other materials provided with the distribution.
13 dnl * Neither the name of Google Inc. nor the names of its contributors
14 dnl   may be used to endorse or promote products derived from this software
15 dnl   without specific prior written permission.
16 dnl
17 dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 AT_INIT([bootstrapping tests])
30
31
32 m4_define([GUESS_TOPDIR], {
33     old=$(pwd)
34     cd "$(dirname ${as_myself})"
35     # We need to locate a build product, not a source file, because the
36     # test suite may be run outside of the source tree (think distcheck).
37     while test $(pwd) != '/' -a ! -e bootstrap/plain_helpers; do
38         cd ..
39     done
40     topdir=$(pwd)
41     cd ${old}
42     echo ${topdir}
43 })
44
45
46 m4_define([CREATE_ATF_HELPERS], [
47     AT_DATA([Kyuafile], [
48 syntax(2)
49 test_suite("bootstrap")
50 atf_test_program{name="atf_helpers"}
51 ])
52     ln -s $(GUESS_TOPDIR)/bootstrap/atf_helpers atf_helpers
53 ])
54 m4_define([RUN_ATF_HELPERS],
55     [HOME=$(pwd) TESTS="$1" kyua --config=none \
56         test --results-file=bootstrap.db $2])
57
58
59 m4_define([CREATE_PLAIN_HELPERS], [
60     AT_DATA([Kyuafile], [
61 syntax(2)
62 test_suite("bootstrap")
63 atf_test_program{name="plain_helpers"}
64 ])
65     ln -s $(GUESS_TOPDIR)/bootstrap/plain_helpers plain_helpers
66 ])
67 m4_define([RUN_PLAIN_HELPER],
68     [HOME=$(pwd) HELPER="$1" kyua --config=none \
69         test --results-file=bootstrap.db])
70
71
72 AT_SETUP([test program crashes in test list])
73 AT_TESTED([kyua])
74
75 CREATE_PLAIN_HELPERS
76 AT_CHECK([RUN_PLAIN_HELPER([abort_test_cases_list])], [1], [stdout], [])
77 re='plain_helpers:__test_cases_list__.*broken.*Test program received signal'
78 AT_CHECK([grep "${re}" stdout], [0], [ignore], [])
79
80 AT_CLEANUP
81
82
83 AT_SETUP([test program prints an empty test list])
84 AT_TESTED([kyua])
85
86 CREATE_PLAIN_HELPERS
87 AT_CHECK([RUN_PLAIN_HELPER([empty_test_cases_list])], [1], [stdout], [])
88 re="plain_helpers:__test_cases_list__.*broken.*Invalid header.*got ''"
89 AT_CHECK([grep "${re}" stdout], [0], [ignore], [])
90
91 AT_CLEANUP
92
93
94 AT_SETUP([test program with zero test cases])
95 AT_TESTED([kyua])
96
97 CREATE_PLAIN_HELPERS
98 AT_CHECK([RUN_PLAIN_HELPER([zero_test_cases])], [1], [stdout], [])
99 re='plain_helpers:__test_cases_list__.*broken.*No test cases'
100 AT_CHECK([grep "${re}" stdout], [0], [ignore], [])
101
102 AT_CLEANUP
103
104
105 AT_SETUP([run test case that passes])
106 AT_TESTED([kyua])
107
108 CREATE_ATF_HELPERS
109 AT_CHECK([RUN_ATF_HELPERS([passes])], [0], [stdout], [])
110 AT_CHECK([grep "atf_helpers:fails" stdout], [1], [], [])
111 AT_CHECK([grep "atf_helpers:passes.*passed" stdout], [0], [ignore], [])
112 AT_CHECK([grep "atf_helpers:skips" stdout], [1], [], [])
113
114 AT_CLEANUP
115
116
117 AT_SETUP([run test case that fails])
118 AT_TESTED([kyua])
119
120 CREATE_ATF_HELPERS
121 AT_CHECK([RUN_ATF_HELPERS([fails])], [1], [stdout], [])
122 AT_CHECK([grep "atf_helpers:fails.*failed.*Failed on purpose" stdout],
123          [0], [ignore], [])
124 AT_CHECK([grep "atf_helpers:passes" stdout], [1], [], [])
125 AT_CHECK([grep "atf_helpers:skips" stdout], [1], [], [])
126
127 AT_CLEANUP
128
129
130 AT_SETUP([run test case that skips])
131 AT_TESTED([kyua])
132
133 CREATE_ATF_HELPERS
134 AT_CHECK([RUN_ATF_HELPERS([skips])], [0], [stdout], [])
135 AT_CHECK([grep "atf_helpers:fails" stdout], [1], [], [])
136 AT_CHECK([grep "atf_helpers:passes" stdout], [1], [], [])
137 AT_CHECK([grep "atf_helpers:skips.*skipped.*Skipped on purpose" stdout],
138          [0], [ignore], [])
139
140 AT_CLEANUP
141
142
143 AT_SETUP([run two test cases, success])
144 AT_TESTED([kyua])
145
146 CREATE_ATF_HELPERS
147 AT_CHECK([RUN_ATF_HELPERS([passes skips])], [0], [stdout], [])
148 AT_CHECK([grep "atf_helpers:fails" stdout], [1], [], [])
149 AT_CHECK([grep "atf_helpers:passes.*passed" stdout], [0], [ignore], [])
150 AT_CHECK([grep "atf_helpers:skips.*skipped.*Skipped on purpose" stdout],
151          [0], [ignore], [])
152
153 AT_CLEANUP
154
155
156 AT_SETUP([run two test cases, failure])
157 AT_TESTED([kyua])
158
159 CREATE_ATF_HELPERS
160 AT_CHECK([RUN_ATF_HELPERS([fails passes])], [1], [stdout], [])
161 AT_CHECK([grep "atf_helpers:fails.*failure.*Failed on purpose" stdout],
162          [1], [], [])
163 AT_CHECK([grep "atf_helpers:passes.*passed" stdout], [0], [ignore], [])
164 AT_CHECK([grep "atf_helpers:skips" stdout], [1], [], [])
165
166 AT_CLEANUP
167
168
169 AT_SETUP([run mixed test cases])
170 AT_TESTED([kyua])
171
172 CREATE_ATF_HELPERS
173 AT_CHECK([RUN_ATF_HELPERS([fails passes skips])], [1], [stdout], [])
174 AT_CHECK([grep "atf_helpers:fails.*failure.*Failed on purpose" stdout],
175          [1], [], [])
176 AT_CHECK([grep "atf_helpers:passes.*passed" stdout], [0], [ignore], [])
177 AT_CHECK([grep "atf_helpers:skips.*skipped.*Skipped on purpose" stdout],
178          [0], [ignore], [])
179
180 AT_CLEANUP
181
182
183 AT_SETUP([run tests from build directories])
184 AT_TESTED([kyua])
185
186 CREATE_ATF_HELPERS
187 AT_CHECK([mkdir src], [0], [], [])
188 AT_CHECK([mv Kyuafile src], [0], [], [])
189 AT_CHECK([mkdir obj], [0], [], [])
190 AT_CHECK([mv atf_helpers obj], [0], [], [])
191 AT_CHECK([RUN_ATF_HELPERS([fails passes skips],
192                           [--kyuafile=src/Kyuafile --build-root=obj])],
193          [1], [stdout], [])
194 AT_CHECK([grep "atf_helpers:fails.*failure.*Failed on purpose" stdout],
195          [1], [], [])
196 AT_CHECK([grep "atf_helpers:passes.*passed" stdout], [0], [ignore], [])
197 AT_CHECK([grep "atf_helpers:skips.*skipped.*Skipped on purpose" stdout],
198          [0], [ignore], [])
199
200 AT_CLEANUP