tools/llvm: Do not build with symbols
[minix3.git] / external / bsd / kyua-atf-compat / dist / atf2kyua_test.sh
blob530b5dd55c31f993513ab47af3c7c082ad1d033a
1 #! __ATF_SH__
2 # Copyright 2012 Google Inc.
3 # All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
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
37 # exist.
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.
41 one_level_test() {
42 local source_root="${1}"; shift
43 local target_root="${1}"; shift
45 cd "${source_root}"
46 create_test_program p1 pass
47 create_test_program p2 pass
48 create_atffile "Atffile" 'prop: test-suite = "foo"' 'tp: p1' 'tp: p2'
49 cd -
51 atf_check -s exit:0 -e ignore atf2kyua "${@}"
53 cd "${target_root}"
54 cat >expected <<EOF
55 syntax('kyuafile', 1)
57 test_suite('foo')
59 atf_test_program{name='p1'}
60 atf_test_program{name='p2'}
61 EOF
62 atf_check -s exit:0 -o file:expected cat "Kyuafile"
63 cd -
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
70 # exist.
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
78 cd "${source_root}"
79 create_test_program prog1 pass
81 mkdir dir1
82 create_test_program dir1/ignore-me pass
83 create_test_program dir1/prog2 fail
85 mkdir dir1/dir2
86 create_test_program dir1/dir2/prog3 skip
87 create_test_program dir1/dir2/prog4 pass
89 mkdir dir3
90 create_test_program dir3/prog1 fail
92 create_atffile Atffile 'prop: test-suite = "foo"' 'tp: prog1' 'tp: dir1'
93 create_atffile dir1/Atffile 'prop: test-suite = "bar"' 'tp-glob: [pd]*'
94 create_atffile dir1/dir2/Atffile 'prop: test-suite = "foo"' 'tp: prog3' \
95 'tp: prog4'
96 create_atffile dir3/Atffile 'prop: test-suite = "foo"' 'tp: prog1'
97 cd -
99 atf_check -s exit:0 -e ignore atf2kyua "${@}"
101 cd "${target_root}"
102 cat >expected <<EOF
103 syntax('kyuafile', 1)
105 test_suite('foo')
107 include('dir1/Kyuafile')
109 atf_test_program{name='prog1'}
111 atf_check -s exit:0 -o file:expected cat Kyuafile
113 cat >expected <<EOF
114 syntax('kyuafile', 1)
116 test_suite('bar')
118 include('dir2/Kyuafile')
120 atf_test_program{name='prog2'}
122 atf_check -s exit:0 -o file:expected cat dir1/Kyuafile
124 cat >expected <<EOF
125 syntax('kyuafile', 1)
127 test_suite('foo')
129 atf_test_program{name='prog3'}
130 atf_test_program{name='prog4'}
132 atf_check -s exit:0 -o file:expected cat dir1/dir2/Kyuafile
134 cat >expected <<EOF
135 syntax('kyuafile', 1)
137 test_suite('foo')
139 atf_test_program{name='prog1'}
141 atf_check -s exit:0 -o file:expected cat dir3/Kyuafile
142 cd -
146 atf_test_case default__one_level
147 default__one_level_body() {
148 one_level_test . .
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() {
160 mkdir root
161 one_level_test root root -s root
165 atf_test_case sflag__multiple_levels
166 sflag__multiple_levels_body() {
167 mkdir root
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() {
186 mkdir source
187 one_level_test source target -s source -t target
191 atf_test_case sflag_tflag__multiple_levels
192 sflag_tflag__multiple_levels_body() {
193 mkdir source
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
202 chmod +x p1 p2
203 create_atffile Atffile 'prop: test-suite = "foo"' 'tp: p1' 'tp: p2'
205 mkdir subdir
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' \
218 atf2kyua -Z -A
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' \
225 atf2kyua first
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