1 dnl Copyright 2010 The Kyua Authors.
2 dnl All rights reserved.
4 dnl Redistribution and use in source and binary forms, with or without
5 dnl modification, are permitted provided that the following conditions are
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.
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.
29 AT_INIT([bootstrapping tests])
32 m4_define([GUESS_TOPDIR], {
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
46 m4_define([CREATE_ATF_HELPERS], [
49 test_suite("bootstrap")
50 atf_test_program{name="atf_helpers"}
52 ln -s $(GUESS_TOPDIR)/bootstrap/atf_helpers atf_helpers
54 m4_define([RUN_ATF_HELPERS],
55 [HOME=$(pwd) TESTS="$1" kyua --config=none \
56 test --results-file=bootstrap.db $2])
59 m4_define([CREATE_PLAIN_HELPERS], [
62 test_suite("bootstrap")
63 atf_test_program{name="plain_helpers"}
65 ln -s $(GUESS_TOPDIR)/bootstrap/plain_helpers plain_helpers
67 m4_define([RUN_PLAIN_HELPER],
68 [HOME=$(pwd) HELPER="$1" kyua --config=none \
69 test --results-file=bootstrap.db])
72 AT_SETUP([test program crashes in test list])
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], [])
83 AT_SETUP([test program prints an empty test list])
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], [])
94 AT_SETUP([test program with zero test cases])
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], [])
105 AT_SETUP([run test case that passes])
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], [], [])
117 AT_SETUP([run test case that fails])
121 AT_CHECK([RUN_ATF_HELPERS([fails])], [1], [stdout], [])
122 AT_CHECK([grep "atf_helpers:fails.*failed.*Failed on purpose" stdout],
124 AT_CHECK([grep "atf_helpers:passes" stdout], [1], [], [])
125 AT_CHECK([grep "atf_helpers:skips" stdout], [1], [], [])
130 AT_SETUP([run test case that skips])
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],
143 AT_SETUP([run two test cases, success])
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],
156 AT_SETUP([run two test cases, failure])
160 AT_CHECK([RUN_ATF_HELPERS([fails passes])], [1], [stdout], [])
161 AT_CHECK([grep "atf_helpers:fails.*failure.*Failed on purpose" stdout],
163 AT_CHECK([grep "atf_helpers:passes.*passed" stdout], [0], [ignore], [])
164 AT_CHECK([grep "atf_helpers:skips" stdout], [1], [], [])
169 AT_SETUP([run mixed test cases])
173 AT_CHECK([RUN_ATF_HELPERS([fails passes skips])], [1], [stdout], [])
174 AT_CHECK([grep "atf_helpers:fails.*failure.*Failed on purpose" stdout],
176 AT_CHECK([grep "atf_helpers:passes.*passed" stdout], [0], [ignore], [])
177 AT_CHECK([grep "atf_helpers:skips.*skipped.*Skipped on purpose" stdout],
183 AT_SETUP([run tests from build directories])
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])],
194 AT_CHECK([grep "atf_helpers:fails.*failure.*Failed on purpose" stdout],
196 AT_CHECK([grep "atf_helpers:passes.*passed" stdout], [0], [ignore], [])
197 AT_CHECK([grep "atf_helpers:skips.*skipped.*Skipped on purpose" stdout],