Drop main() prototype. Syncs with NetBSD-8
[minix.git] / external / bsd / kyua-atf-compat / dist / atf-run_test.sh
blob665800a1cc40635938099cdc6bed32635aac220f
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 atf_test_case all_pass
35 all_pass_body() {
36 create_test_program program1 pass skip
37 create_atffile Atffile 'prop: test-suite = "suite"' \
38 'tp: program1' 'tp: subdir'
40 mkdir subdir
41 create_test_program subdir/program2 skip
42 create_atffile subdir/Atffile 'prop: test-suite = "suite"' \
43 'tp: program2'
45 atf_check -s exit:0 -e ignore \
46 -o match:'program1:pass -> passed' \
47 -o match:'program1:skip -> skipped' \
48 -o match:'subdir/program2:skip -> skipped' \
49 -o match:'Committed action 1' \
50 atf-run
54 atf_test_case some_fail
55 some_fail_body() {
56 create_test_program program1 pass skip
57 create_atffile Atffile 'prop: test-suite = "suite"' \
58 'tp: program1' 'tp: subdir'
60 mkdir subdir
61 create_atffile subdir/Atffile 'tp-glob: *'
63 mkdir subdir/nested
64 create_test_program subdir/nested/program2 skip fail
65 create_atffile subdir/nested/Atffile 'prop: test-suite = "suite"' \
66 'tp-glob: program2*'
68 atf_check -s exit:1 -e ignore \
69 -o match:'program1:pass -> passed' \
70 -o match:'program1:skip -> skipped' \
71 -o match:'subdir/nested/program2:fail -> failed' \
72 -o match:'subdir/nested/program2:skip -> skipped' \
73 -o match:'Committed action 1' \
74 atf-run
77 atf_test_case prefer_kyuafiles
78 prefer_kyuafiles_body() {
79 create_test_program program1 pass skip
80 cat >Kyuafile <<EOF
81 syntax('kyuafile', 1)
82 test_suite('foo')
83 atf_test_program{name='program1'}
84 EOF
85 echo "This file is invalid" >Atffile
87 atf_check -s exit:0 -e ignore \
88 -o match:'program1:pass -> passed' \
89 -o match:'program1:skip -> skipped' \
90 atf-run
94 atf_test_case selectors
95 selectors_body() {
96 create_test_program program1 pass skip
97 create_atffile Atffile 'prop: test-suite = "suite"' \
98 'tp: program1' 'tp: subdir'
100 mkdir subdir
101 create_atffile subdir/Atffile 'tp-glob: *'
103 mkdir subdir/nested
104 create_test_program subdir/nested/program2 skip fail
105 create_atffile subdir/nested/Atffile 'prop: test-suite = "suite"' \
106 'tp-glob: program2*'
108 atf_check -s exit:1 -e ignore \
109 -o match:'program1:pass -> passed' \
110 -o match:'program1:skip -> skipped' \
111 -o match:'subdir/nested/program2:fail -> failed' \
112 -o match:'subdir/nested/program2:skip -> skipped' \
113 -o match:'Committed action 1' \
114 atf-run
116 atf_check -s exit:0 -e ignore \
117 -o match:'program1:pass -> passed' \
118 -o not-match:'program1:skip -> skipped' \
119 -o not-match:'subdir/nested/program2:fail -> failed' \
120 -o match:'subdir/nested/program2:skip -> skipped' \
121 -o match:'Committed action 2' \
122 atf-run program1:pass subdir/nested/program2:skip
124 atf_check -s exit:1 -e ignore \
125 -o not-match:'program1:pass -> passed' \
126 -o not-match:'program1:skip -> skipped' \
127 -o match:'subdir/nested/program2:fail -> failed' \
128 -o match:'subdir/nested/program2:skip -> skipped' \
129 -o match:'Committed action 3' \
130 atf-run subdir/nested/program2
134 atf_test_case config__priorities
135 config__priorities_body()
137 mkdir system
138 export ATF_CONFDIR="$(pwd)/system"
139 mkdir user
140 mkdir user/.atf
141 export HOME="$(pwd)/user"
143 create_test_program helper config
144 create_atffile Atffile 'prop: test-suite = "irrelevant"' 'tp: helper'
146 echo "Checking system-wide configuration only"
147 create_config system/common.conf ' unprivileged-user = "nobody"'
148 atf_check -s exit:0 -o 'match:helper:config -> passed' -e ignore atf-run
149 atf_check -s exit:0 -o 'inline:unprivileged-user = nobody\n' \
150 cat config.out
152 echo "Checking user-specific overrides"
153 create_config user/.atf/common.conf ' unprivileged-user = "root"'
154 atf_check -s exit:0 -o 'match:helper:config -> passed' -e ignore atf-run
155 atf_check -s exit:0 -o 'inline:unprivileged-user = root\n' \
156 cat config.out
158 echo "Checking command-line overrides"
159 atf_check -s exit:0 -o 'match:helper:config -> passed' -e ignore atf-run \
160 -v"unprivileged-user=$(id -u -n)"
161 atf_check -s exit:0 -o "inline:unprivileged-user = $(id -u -n)\n" \
162 cat config.out
166 atf_test_case config__test_suites__files
167 config__test_suites__files_body()
169 mkdir system
170 export ATF_CONFDIR="$(pwd)/system"
172 create_config system/suite1.conf 'var1 = "var1-for-suite1"' \
173 'var2 = "var2-for-suite1"'
174 create_config system/suite2.conf 'var1 = "var1-for-suite2"' \
175 'var2 = "var2-for-suite2"'
177 create_test_program helper1 config
178 create_atffile Atffile 'prop: test-suite = "suite1"' 'tp: helper1' \
179 'tp: subdir'
180 mkdir subdir
181 create_test_program subdir/helper2 config
182 create_atffile subdir/Atffile 'prop: test-suite = "suite2"' 'tp: helper2'
184 atf_check -s exit:0 -o ignore -e ignore atf-run helper1
185 atf_check -s exit:0 -o 'match:var1 = var1-for-suite1' \
186 -o 'match:var2 = var2-for-suite1' -o 'not-match:suite2' \
187 cat config.out
189 atf_check -s exit:0 -o ignore -e ignore atf-run subdir/helper2
190 atf_check -s exit:0 -o 'match:var1 = var1-for-suite2' \
191 -o 'match:var2 = var2-for-suite2' -o 'not-match:suite1' \
192 cat config.out
196 atf_test_case config__test_suites__vflags
197 config__test_suites__vflags_body()
199 create_test_program helper1 config
200 create_atffile Atffile 'prop: test-suite = "suite1"' 'tp: helper1' \
201 'tp: subdir'
202 mkdir subdir
203 create_test_program subdir/helper2 config
204 create_atffile subdir/Atffile 'prop: test-suite = "suite2"' 'tp: helper2'
206 atf_check -s exit:0 -o ignore -e ignore atf-run -v var1=foo helper1
207 atf_check -s exit:0 -o 'match:var1 = foo' cat config.out
209 atf_check -s exit:0 -o ignore -e ignore atf-run -v var1=bar helper1
210 atf_check -s exit:0 -o 'match:var1 = bar' cat config.out
214 atf_test_case unknown_option
215 unknown_option_body() {
216 atf_check -s exit:1 -o empty -e match:'E: Unknown option -Z' \
217 atf-run -Z -A
221 atf_init_test_cases() {
222 atf_add_test_case all_pass
223 atf_add_test_case some_fail
224 atf_add_test_case selectors
226 atf_add_test_case prefer_kyuafiles
228 atf_add_test_case config__priorities
229 atf_add_test_case config__test_suites__files
230 atf_add_test_case config__test_suites__vflags
232 atf_add_test_case unknown_option