Drop main() prototype. Syncs with NetBSD-8
[minix.git] / external / bsd / kyua-atf-compat / dist / atf-report_test.sh
blob70870a7fbd4cd531c0eead4bdf6e6ecf1b96d3ef
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 ticker__no_tests
35 ticker__no_tests_body() {
36 cat >Kyuafile <<EOF
37 syntax('kyuafile', 1)
38 EOF
40 atf_check -s exit:0 -o save:run.log -e ignore atf-run
42 cat >expout <<EOF
43 ===> Summary
44 Action: 1
45 Test cases: 0 total, 0 skipped, 0 expected failures, 0 broken, 0 failed
46 Total time: X.XXXs
47 EOF
48 atf_check -s exit:0 -o save:report.log -e empty atf-report <run.log
49 strip_timestamps report.log
50 atf_check -s exit:0 -o file:expout cat report.log
54 atf_test_case ticker__some_tests
55 ticker__some_tests_body() {
56 create_test_program program1 skip
57 create_test_program program2 fail skip pass
58 cat >Kyuafile <<EOF
59 syntax('kyuafile', 1)
60 test_suite('foo')
61 atf_test_program{name='program1'}
62 atf_test_program{name='program2'}
63 EOF
64 atf_check -s exit:1 -o save:run.log -e ignore atf-run
66 cat >expout <<EOF
67 program1:skip -> skipped: Skipped reason [X.XXXs]
68 program2:fail -> failed: On purpose [X.XXXs]
69 program2:skip -> skipped: Skipped reason [X.XXXs]
70 program2:pass -> passed [X.XXXs]
71 ===> Skipped tests
72 program1:skip -> skipped: Skipped reason [X.XXXs]
73 program2:skip -> skipped: Skipped reason [X.XXXs]
74 ===> Failed tests
75 program2:fail -> failed: On purpose [X.XXXs]
76 ===> Summary
77 Action: 1
78 Test cases: 4 total, 2 skipped, 0 expected failures, 0 broken, 1 failed
79 Total time: X.XXXs
80 EOF
81 atf_check -s exit:0 -o save:report.log -e empty atf-report <run.log
82 strip_timestamps report.log
83 atf_check -s exit:0 -o file:expout cat report.log
87 atf_test_case ticker__explicit
88 ticker__explicit_body() {
89 cat >Kyuafile <<EOF
90 syntax('kyuafile', 1)
91 EOF
93 atf_check -s exit:0 -o save:run.log -e ignore atf-run
95 cat >expout <<EOF
96 ===> Summary
97 Action: 1
98 Test cases: 0 total, 0 skipped, 0 expected failures, 0 broken, 0 failed
99 Total time: X.XXXs
101 atf_check -s exit:0 -o empty -e empty \
102 atf-report -o ticker:my-report.log <run.log
103 strip_timestamps my-report.log
104 atf_check -s exit:0 -o file:expout cat my-report.log
108 atf_test_case html__no_tests
109 html__no_tests_body() {
110 cat >Kyuafile <<EOF
111 syntax('kyuafile', 1)
113 atf_check -s exit:0 -o save:run.log -e ignore atf-run
114 atf_check -s exit:0 -o ignore -e empty \
115 atf-report -o html:report.html <run.log
117 echo "All generated files"
118 ls -l report.html report.files
120 for file in index.html context.html report.css; do
121 test -f report.files/"${file}" || \
122 atf_fail "Expected file ${file} not found"
123 done
125 test report.html -ef report.files/index.html || \
126 atf_fail "Index file link not created properly"
130 atf_test_case html__some_tests
131 html__some_tests_body() {
132 create_test_program program1 skip
133 create_test_program program2 fail skip pass
134 cat >Kyuafile <<EOF
135 syntax('kyuafile', 1)
136 test_suite('foo')
137 atf_test_program{name='program1'}
138 atf_test_program{name='program2'}
140 atf_check -s exit:1 -o save:run.log -e ignore atf-run
141 atf_check -s exit:0 -o ignore -e empty \
142 atf-report -o html:report.html <run.log
144 echo "All generated files"
145 ls -l report.html report.files
147 for file in index.html context.html report.css \
148 program1_skip.html program2_fail.html program2_skip.html \
149 program2_pass.html
151 test -f report.files/"${file}" || \
152 atf_fail "Expected file ${file} not found"
153 done
155 test report.html -ef report.files/index.html || \
156 atf_fail "Index file link not created properly"
160 atf_test_case html__other_directory
161 html__other_directory_body() {
162 cat >Kyuafile <<EOF
163 syntax('kyuafile', 1)
165 atf_check -s exit:0 -o save:run.log -e ignore atf-run
166 mkdir -p a/b/c
167 atf_check -s exit:0 -o ignore -e empty \
168 atf-report -o html:$(pwd)/a/b/c/report.html <run.log
170 echo "All generated files"
171 ls -l a/b/c/*
173 for file in index.html context.html report.css; do
174 test -f a/b/c/report.files/"${file}" || \
175 atf_fail "Expected file ${file} not found"
176 done
178 test a/b/c/report.html -ef a/b/c/report.files/index.html || \
179 atf_fail "Index file link not created properly"
183 atf_test_case html__to_stdout
184 html__to_stdout_body() {
185 atf_check -s exit:1 -o empty \
186 -e match:'E: Cannot write HTML reports to stdout' \
187 atf-report -o html:-
188 atf_check -s exit:1 -o empty \
189 -e match:'E: Cannot write HTML reports to stdout' \
190 atf-report -o html:/dev/stdout
194 atf_test_case xml_is_html
195 xml_is_html_body() {
196 cat >Kyuafile <<EOF
197 syntax('kyuafile', 1)
199 atf_check -s exit:0 -o save:run.log -e ignore atf-run
200 atf_check -s exit:0 -o ignore \
201 -e match:'XML.*not supported.*generating HTML' \
202 atf-report -o xml:report.html <run.log
204 for file in index.html context.html report.css; do
205 test -f report.files/"${file}" || \
206 atf_fail "Expected file ${file} not found"
207 done
209 test report.html -ef report.files/index.html || \
210 atf_fail "Index file link not created properly"
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-report -Z -A
221 atf_test_case too_many_arguments
222 too_many_arguments_body() {
223 atf_check -s exit:1 -o empty -e match:'E: No arguments allowed' \
224 atf-report first
228 atf_test_case unknown_format
229 unknown_format_body() {
230 atf_check -s exit:1 -o empty -e match:"E: Unknown output format 'csv'" \
231 atf-report -o csv:file.csv
235 atf_init_test_cases() {
236 atf_add_test_case ticker__no_tests
237 atf_add_test_case ticker__some_tests
238 atf_add_test_case ticker__explicit
240 atf_add_test_case html__no_tests
241 atf_add_test_case html__some_tests
242 atf_add_test_case html__other_directory
243 atf_add_test_case html__to_stdout
245 atf_add_test_case xml_is_html
247 atf_add_test_case unknown_option
248 atf_add_test_case too_many_arguments
249 atf_add_test_case unknown_format