2 # Copyright 2012 Google Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # * Neither the name of Google Inc. nor the names of its contributors
15 # may be used to endorse or promote products derived from this software
16 # without specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 .
"${KYUA_ATF_COMPAT_PKGDATADIR:-__PKGDATADIR__}/tests_lib.subr"
34 # Performs a conversion test of an Atffile without recursion.
36 # \param source_root The directory in which to create the fake test suite. Must
38 # \param target_root The directory in which the generated Kyuafiles will be
39 # stored. May not exist.
40 # \param ... Additional parameters to pass to atf2kyua.
42 local source_root
="${1}"; shift
43 local target_root
="${1}"; shift
46 create_test_program p1 pass
47 create_test_program p2 pass
48 create_atffile
"Atffile" 'prop: test-suite = "foo"' 'tp: p1' 'tp: p2'
51 atf_check
-s exit:0 -e ignore atf2kyua
"${@}"
59 atf_test_program{name='p1'}
60 atf_test_program{name='p2'}
62 atf_check
-s exit:0 -o file:expected
cat "Kyuafile"
67 # Performs a conversion test of an Atffile with recursion.
69 # \param source_root The directory in which to create the fake test suite. Must
71 # \param target_root The directory in which the generated Kyuafiles will be
72 # stored. May not exist.
73 # \param ... Additional parameters to pass to atf2kyua.
74 multiple_levels_test
() {
75 local source_root
="${1}"; shift
76 local target_root
="${1}"; shift
79 create_test_program prog1 pass
82 create_test_program dir
1/ignore-me pass
83 create_test_program dir
1/prog2 fail
86 create_test_program dir
1/dir
2/prog3 skip
87 create_test_program dir
1/dir
2/prog4 pass
90 create_test_program dir
3/prog1 fail
92 create_atffile Atffile
'prop: test-suite = "foo"' 'tp: prog1' 'tp: dir1'
93 create_atffile dir
1/Atffile
'prop: test-suite = "bar"' 'tp-glob: [pd]*'
94 create_atffile dir
1/dir
2/Atffile
'prop: test-suite = "foo"' 'tp: prog3' \
96 create_atffile dir
3/Atffile
'prop: test-suite = "foo"' 'tp: prog1'
99 atf_check
-s exit:0 -e ignore atf2kyua
"${@}"
103 syntax('kyuafile', 1)
107 include('dir1/Kyuafile')
109 atf_test_program{name='prog1'}
111 atf_check
-s exit:0 -o file:expected
cat Kyuafile
114 syntax('kyuafile', 1)
118 include('dir2/Kyuafile')
120 atf_test_program{name='prog2'}
122 atf_check
-s exit:0 -o file:expected
cat dir
1/Kyuafile
125 syntax('kyuafile', 1)
129 atf_test_program{name='prog3'}
130 atf_test_program{name='prog4'}
132 atf_check
-s exit:0 -o file:expected
cat dir
1/dir
2/Kyuafile
135 syntax('kyuafile', 1)
139 atf_test_program{name='prog1'}
141 atf_check
-s exit:0 -o file:expected
cat dir
3/Kyuafile
146 atf_test_case default__one_level
147 default__one_level_body
() {
152 atf_test_case default__multiple_levels
153 default__multiple_levels_body
() {
154 multiple_levels_test . .
158 atf_test_case sflag__one_level
159 sflag__one_level_body
() {
161 one_level_test root root
-s root
165 atf_test_case sflag__multiple_levels
166 sflag__multiple_levels_body
() {
168 multiple_levels_test root root
-s root
172 atf_test_case tflag__one_level
173 tflag__one_level_body
() {
174 one_level_test . target
-t target
178 atf_test_case tflag__multiple_levels
179 tflag__multiple_levels_body
() {
180 multiple_levels_test . target
-t target
184 atf_test_case sflag_tflag__one_level
185 sflag_tflag__one_level_body
() {
187 one_level_test
source target
-s source -t target
191 atf_test_case sflag_tflag__multiple_levels
192 sflag_tflag__multiple_levels_body
() {
194 multiple_levels_test
source target
-s source -t target
198 atf_test_case prune_stale_kyuafiles
199 prune_stale_kyuafiles_body
() {
200 create_test_program p1 fail
201 create_test_program p2 skip
203 create_atffile Atffile
'prop: test-suite = "foo"' 'tp: p1' 'tp: p2'
206 touch subdir
/Kyuafile
208 atf_check
-s exit:0 -e ignore atf2kyua
210 test -f Kyuafile || atf_fail
"Kyuafiles not created as expected"
211 test \
! -f subdir
/Kyuafile || atf_fail
"Stale kyuafiles not removed"
215 atf_test_case unknown_option
216 unknown_option_body
() {
217 atf_check
-s exit:1 -o empty
-e match
:'E: Unknown option -Z' \
222 atf_test_case too_many_arguments
223 too_many_arguments_body
() {
224 atf_check
-s exit:1 -o empty
-e match
:'E: No arguments allowed' \
229 atf_init_test_cases
() {
230 atf_add_test_case default__one_level
231 atf_add_test_case default__multiple_levels
233 atf_add_test_case sflag__one_level
234 atf_add_test_case sflag__multiple_levels
236 atf_add_test_case tflag__one_level
237 atf_add_test_case tflag__multiple_levels
239 atf_add_test_case sflag_tflag__one_level
240 atf_add_test_case sflag_tflag__multiple_levels
242 atf_add_test_case prune_stale_kyuafiles
244 atf_add_test_case unknown_option
245 atf_add_test_case too_many_arguments