2 # Automated Testing Framework (atf)
4 # Copyright (c) 2007 The NetBSD Foundation, Inc.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 # CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 # IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 cp $
(atf_get_srcdir
)/pass_helper dir
1/tp1
34 cp $
(atf_get_srcdir
)/fail_helper dir
1/tp2
35 cp $
(atf_get_srcdir
)/pass_helper tp3
36 cp $
(atf_get_srcdir
)/fail_helper tp4
39 #! $(atf-config -t atf_shell)
45 Content-Type: application/X-atf-atffile; version="1"
47 prop: test-suite = atf
55 cat >dir
1/Atffile
<<EOF
56 Content-Type: application/X-atf-atffile; version="1"
58 prop: test-suite = atf
68 cat >etc
/atf-run.hooks
<<EOF
69 #! $(atf-config -t atf_shell)
73 atf_tps_writer_info "startinfo" "A value"
78 atf_tps_writer_info "endinfo" "Another value"
81 echo "Using atf-run to run helpers"
82 ATF_CONFDIR
=$
(pwd)/etc atf-run
>tps.out
2>/dev
/null
89 atf_set
"descr" "Checks that the default output uses the ticker" \
97 # Check that the default output uses the ticker format.
98 atf_check
-s eq
:0 -o match
:'test cases' -o match
:'Failed test cases' \
99 -o match
:'Summary for' -e empty
-x 'atf-report <tps.out'
102 # XXX The test for all expect_ values should be intermixed with the other
103 # tests. However, to do that, we need to migrate to using C helpers for
104 # simplicity in raising signals...
108 ln -s "$(atf_get_srcdir)/expect_helpers" .
110 Content-Type: application/X-atf-atffile; version="1"
112 prop: test-suite = atf
118 # NO_CHECK_STYLE_BEGIN
120 tc, #.#, expect_helpers, death_and_exit, expected_death, Exit case
121 tc, #.#, expect_helpers, death_and_signal, expected_death, Signal case
122 tc, #.#, expect_helpers, death_but_pass, failed, Test case was expected to terminate abruptly but it continued execution
123 tc, #.#, expect_helpers, exit_any_and_exit, expected_exit, Call will exit
124 tc, #.#, expect_helpers, exit_but_pass, failed, Test case was expected to exit cleanly but it continued execution
125 tc, #.#, expect_helpers, exit_code_and_exit, expected_exit, Call will exit
126 tc, #.#, expect_helpers, fail_and_fail_check, expected_failure, And fail again: 2 checks failed as expected; see output for more details
127 tc, #.#, expect_helpers, fail_and_fail_requirement, expected_failure, Fail reason: The failure
128 tc, #.#, expect_helpers, fail_but_pass, failed, Test case was expecting a failure but none were raised
129 tc, #.#, expect_helpers, pass_and_pass, passed
130 tc, #.#, expect_helpers, pass_but_fail_check, failed, 1 checks failed; see output for more details
131 tc, #.#, expect_helpers, pass_but_fail_requirement, failed, Some reason
132 tc, #.#, expect_helpers, signal_any_and_signal, expected_signal, Call will signal
133 tc, #.#, expect_helpers, signal_but_pass, failed, Test case was expected to receive a termination signal but it continued execution
134 tc, #.#, expect_helpers, signal_no_and_signal, expected_signal, Call will signal
135 tc, #.#, expect_helpers, timeout_and_hang, expected_timeout, Will overrun
136 tc, #.#, expect_helpers, timeout_but_pass, failed, Test case was expected to hang but it continued execution
137 tp, #.#, expect_helpers, failed
140 atf_check
-s eq
:0 -o file:expout
-e empty
-x \
141 "atf-report -o csv:- <tps.out | " \
142 "sed -E -e 's/[0-9]+.[0-9]{6}, /#.#, /'"
144 # NO_CHECK_STYLE_BEGIN
146 expect_helpers (1/1): 17 test cases
147 death_and_exit: [#.#s] Expected failure: Exit case
148 death_and_signal: [#.#s] Expected failure: Signal case
149 death_but_pass: [#.#s] Failed: Test case was expected to terminate abruptly but it continued execution
150 exit_any_and_exit: [#.#s] Expected failure: Call will exit
151 exit_but_pass: [#.#s] Failed: Test case was expected to exit cleanly but it continued execution
152 exit_code_and_exit: [#.#s] Expected failure: Call will exit
153 fail_and_fail_check: [#.#s] Expected failure: And fail again: 2 checks failed as expected; see output for more details
154 fail_and_fail_requirement: [#.#s] Expected failure: Fail reason: The failure
155 fail_but_pass: [#.#s] Failed: Test case was expecting a failure but none were raised
156 pass_and_pass: [#.#s] Passed.
157 pass_but_fail_check: [#.#s] Failed: 1 checks failed; see output for more details
158 pass_but_fail_requirement: [#.#s] Failed: Some reason
159 signal_any_and_signal: [#.#s] Expected failure: Call will signal
160 signal_but_pass: [#.#s] Failed: Test case was expected to receive a termination signal but it continued execution
161 signal_no_and_signal: [#.#s] Expected failure: Call will signal
162 timeout_and_hang: [#.#s] Expected failure: Will overrun
163 timeout_but_pass: [#.#s] Failed: Test case was expected to hang but it continued execution
166 Test cases for known bugs:
167 expect_helpers:death_and_exit: Exit case
168 expect_helpers:death_and_signal: Signal case
169 expect_helpers:exit_any_and_exit: Call will exit
170 expect_helpers:exit_code_and_exit: Call will exit
171 expect_helpers:fail_and_fail_check: And fail again: 2 checks failed as expected; see output for more details
172 expect_helpers:fail_and_fail_requirement: Fail reason: The failure
173 expect_helpers:signal_any_and_signal: Call will signal
174 expect_helpers:signal_no_and_signal: Call will signal
175 expect_helpers:timeout_and_hang: Will overrun
178 expect_helpers:death_but_pass, expect_helpers:exit_but_pass, expect_helpers:fail_but_pass, expect_helpers:pass_but_fail_check, expect_helpers:pass_but_fail_requirement, expect_helpers:signal_but_pass, expect_helpers:timeout_but_pass
180 Summary for 1 test programs:
183 9 expected failed test cases.
184 0 skipped test cases.
187 atf_check
-s eq
:0 -o file:expout
-e empty
-x \
188 "atf-report -o ticker:- <tps.out | " \
189 "sed -E -e 's/[0-9]+.[0-9]{6}/#.#/'"
191 # Just ensure that this does not crash for now...
192 atf_check
-s eq
:0 -o ignore
-e empty
-x "atf-report -o xml:- <tps.out"
198 atf_set
"descr" "Checks that the -o flag works"
205 # Get the default output.
206 atf_check
-s eq
:0 -o save
:stdout
-e empty
-x 'atf-report <tps.out'
209 # Check that changing the stdout output works.
210 atf_check
-s eq
:0 -o save
:stdout
-e empty
-x 'atf-report -o csv:- <tps.out'
211 atf_check
-s eq
:1 -o empty
-e empty
cmp -s defout stdout
214 # Check that sending the output to a file does not write to stdout.
215 atf_check
-s eq
:0 -o empty
-e empty
-x 'atf-report -o csv:fmt.out <tps.out'
216 atf_check
-s eq
:0 -o empty
-e empty
cmp -s expcsv
fmt.out
219 # Check that defining two outputs using the same format works.
220 atf_check
-s eq
:0 -o empty
-e empty
-x \
221 'atf-report -o csv:fmt.out -o csv:fmt2.out <tps.out'
222 atf_check
-s eq
:0 -o empty
-e empty
cmp -s expcsv
fmt.out
223 atf_check
-s eq
:0 -o empty
-e empty
cmp -s fmt.out fmt2.out
224 rm -f fmt.out fmt2.out
226 # Check that defining two outputs using different formats works.
227 atf_check
-s eq
:0 -o empty
-e empty
-x \
228 'atf-report -o csv:fmt.out -o ticker:fmt2.out <tps.out'
229 atf_check
-s eq
:0 -o empty
-e empty
cmp -s expcsv
fmt.out
230 atf_check
-s eq
:1 -o empty
-e empty
cmp -s fmt.out fmt2.out
231 atf_check
-s eq
:0 -o ignore
-e empty
grep "test cases" fmt2.out
232 atf_check
-s eq
:0 -o ignore
-e empty
grep "Failed test cases" fmt2.out
233 atf_check
-s eq
:0 -o ignore
-e empty
grep "Summary for" fmt2.out
234 rm -f fmt.out fmt2.out
236 # Check that defining two outputs over the same file does not work.
237 atf_check
-s eq
:1 -o empty
-e match
:'more than once' -x \
238 'atf-report -o csv:fmt.out -o ticker:fmt.out <tps.out'
241 # Check that defining two outputs over stdout (but using different
242 # paths) does not work.
243 atf_check
-s eq
:1 -o empty
-e match
:'more than once' -x \
244 'atf-report -o csv:- -o ticker:/dev/stdout <tps.out'
248 atf_test_case output_csv
251 atf_set
"descr" "Checks the CSV output format"
258 # NO_CHECK_STYLE_BEGIN
260 tc, #.#, dir1/tp1, main, passed
261 tp, #.#, dir1/tp1, passed
262 tc, #.#, dir1/tp2, main, failed, This always fails
263 tp, #.#, dir1/tp2, failed
264 tc, #.#, tp3, main, passed
266 tc, #.#, tp4, main, failed, This always fails
268 tp, #.#, tp5, bogus, Invalid format for test case list: 1: Unexpected token \`<<NEWLINE>>'; expected \`:'
272 atf_check
-s eq
:0 -o file:expout
-e empty
-x \
273 "atf-report -o csv:- <tps.out | sed -E -e 's/[0-9]+.[0-9]{6}, /#.#, /'"
276 atf_test_case output_ticker
279 atf_set
"descr" "Checks the ticker output format"
286 # NO_CHECK_STYLE_BEGIN
288 dir1/tp1 (1/5): 1 test cases
292 dir1/tp2 (2/5): 1 test cases
293 main: [#.#s] Failed: This always fails
296 tp3 (3/5): 1 test cases
300 tp4 (4/5): 1 test cases
301 main: [#.#s] Failed: This always fails
304 tp5 (5/5): 0 test cases
305 tp5: BOGUS TEST PROGRAM: Cannot trust its results because of \`Invalid format for test case list: 1: Unexpected token \`<<NEWLINE>>'; expected \`:''
308 Failed (bogus) test programs:
312 dir1/tp2:main, tp4:main
314 Summary for 5 test programs:
317 0 expected failed test cases.
318 0 skipped test cases.
321 atf_check
-s eq
:0 -o file:expout
-e empty
-x \
322 "atf-report -o ticker:- <tps.out | sed -E -e 's/[0-9]+.[0-9]{6}/#.#/'"
326 atf_test_case output_xml
329 atf_set
"descr" "Checks the XML output format"
336 # NO_CHECK_STYLE_BEGIN
338 <?xml version="1.0" encoding="ISO-8859-1"?>
339 <!DOCTYPE tests-results PUBLIC "-//NetBSD//DTD ATF Tests Results 0.1//EN" "http://www.NetBSD.org/XML/atf/tests-results.dtd">
342 <info class="startinfo">A value</info>
346 <tc-time>#.#</tc-time></tc>
347 <tp-time>#.#</tp-time></tp>
350 <failed>This always fails</failed>
351 <tc-time>#.#</tc-time></tc>
352 <tp-time>#.#</tp-time></tp>
356 <tc-time>#.#</tc-time></tc>
357 <tp-time>#.#</tp-time></tp>
360 <failed>This always fails</failed>
361 <tc-time>#.#</tc-time></tc>
362 <tp-time>#.#</tp-time></tp>
364 <failed>Invalid format for test case list: 1: Unexpected token \`<<NEWLINE>>'; expected \`:'</failed>
365 <tp-time>#.#</tp-time></tp>
366 <info class="endinfo">Another value</info>
371 atf_check
-s eq
:0 -o file:expout
-e empty
-x \
372 "atf-report -o xml:- < tps.out | sed -E -e 's/>[0-9]+.[0-9]{6}</>#.#</'"
375 atf_test_case output_xml_space
376 output_xml_space_head
()
378 atf_set
"descr" "Checks that the XML output format properly preserves" \
379 "leading and trailing whitespace in stdout and stderr" \
382 output_xml_space_body
()
385 cp $
(atf_get_srcdir
)/misc_helpers .
387 Content-Type: application/X-atf-atffile; version="1"
389 prop: test-suite = atf
394 # NO_CHECK_STYLE_BEGIN
396 <?xml version="1.0" encoding="ISO-8859-1"?>
397 <!DOCTYPE tests-results PUBLIC "-//NetBSD//DTD ATF Tests Results 0.1//EN" "http://www.NetBSD.org/XML/atf/tests-results.dtd">
400 <info class="startinfo">A value</info>
401 <tp id="misc_helpers">
403 <so>--- a 2007-11-04 14:00:41.000000000 +0100</so>
404 <so>+++ b 2007-11-04 14:00:48.000000000 +0100</so>
405 <so>@@ -1,7 +1,7 @@</so>
406 <so> This test is meant to simulate a diff.</so>
407 <so> Blank space at beginning of context lines must be preserved.</so>
409 <so>-First original line.</so>
410 <so>-Second original line.</so>
411 <so>+First modified line.</so>
412 <so>+Second modified line.</so>
416 <tc-time
>#.#</tc-time></tc>
417 <tp-time
>#.#</tp-time></tp>
418 <info class
="endinfo">Another value
</info
>
424 atf_check
-s eq
:0 -o file:expout
-e empty
-x \
425 "atf-report -o xml:- <tps.out | sed -E -e 's/>[0-9]+.[0-9]{6}</>#.#</'"
428 atf_test_case too_many_args
432 atf-report: ERROR: No arguments allowed
434 atf_check
-s eq
:1 -o empty
-e file:experr atf-report foo
437 atf_init_test_cases
()
439 atf_add_test_case default
440 atf_add_test_case expect
441 atf_add_test_case oflag
442 atf_add_test_case output_csv
443 atf_add_test_case output_ticker
444 atf_add_test_case output_xml
445 atf_add_test_case output_xml_space
446 atf_add_test_case too_many_args
449 # vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4