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 atf_test_case ticker__no_tests
35 ticker__no_tests_body
() {
40 atf_check
-s exit:0 -o save
:run.log
-e ignore atf-run
45 Test cases: 0 total, 0 skipped, 0 expected failures, 0 broken, 0 failed
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
61 atf_test_program{name='program1'}
62 atf_test_program{name='program2'}
64 atf_check
-s exit:1 -o save
:run.log
-e ignore atf-run
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]
72 program1:skip -> skipped: Skipped reason [X.XXXs]
73 program2:skip -> skipped: Skipped reason [X.XXXs]
75 program2:fail -> failed: On purpose [X.XXXs]
78 Test cases: 4 total, 2 skipped, 0 expected failures, 0 broken, 1 failed
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
() {
93 atf_check
-s exit:0 -o save
:run.log
-e ignore atf-run
98 Test cases: 0 total, 0 skipped, 0 expected failures, 0 broken, 0 failed
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
() {
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"
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
135 syntax('kyuafile', 1)
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 \
151 test -f report.
files
/"${file}" || \
152 atf_fail
"Expected file ${file} not found"
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
() {
163 syntax('kyuafile', 1)
165 atf_check
-s exit:0 -o save
:run.log
-e ignore atf-run
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"
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"
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' \
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
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"
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' \
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' \
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