2
# Automated Testing Framework (atf)
4
# Copyright (c) 2007, 2008, 2009, 2010 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 dir1/tp1
34
cp $(atf_get_srcdir)/fail_helper dir1/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 >dir1/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)/../atf-run/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 "atf-report -o csv:- <tps.out"
142
# NO_CHECK_STYLE_BEGIN
144
expect_helpers (1/1): 17 test cases
145
death_and_exit: Expected failure: Exit case
146
death_and_signal: Expected failure: Signal case
147
death_but_pass: Failed: Test case was expected to terminate abruptly but it continued execution
148
exit_any_and_exit: Expected failure: Call will exit
149
exit_but_pass: Failed: Test case was expected to exit cleanly but it continued execution
150
exit_code_and_exit: Expected failure: Call will exit
151
fail_and_fail_check: Expected failure: And fail again: 2 checks failed as expected; see output for more details
152
fail_and_fail_requirement: Expected failure: Fail reason: The failure
153
fail_but_pass: Failed: Test case was expecting a failure but none were raised
154
pass_and_pass: Passed.
155
pass_but_fail_check: Failed: 1 checks failed; see output for more details
156
pass_but_fail_requirement: Failed: Some reason
157
signal_any_and_signal: Expected failure: Call will signal
158
signal_but_pass: Failed: Test case was expected to receive a termination signal but it continued execution
159
signal_no_and_signal: Expected failure: Call will signal
160
timeout_and_hang: Expected failure: Will overrun
161
timeout_but_pass: Failed: Test case was expected to hang but it continued execution
163
Test cases for known bugs:
164
expect_helpers:death_and_exit: Exit case
165
expect_helpers:death_and_signal: Signal case
166
expect_helpers:exit_any_and_exit: Call will exit
167
expect_helpers:exit_code_and_exit: Call will exit
168
expect_helpers:fail_and_fail_check: And fail again: 2 checks failed as expected; see output for more details
169
expect_helpers:fail_and_fail_requirement: Fail reason: The failure
170
expect_helpers:signal_any_and_signal: Call will signal
171
expect_helpers:signal_no_and_signal: Call will signal
172
expect_helpers:timeout_and_hang: Will overrun
175
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
177
Summary for 1 test programs:
180
9 expected failed test cases.
181
0 skipped test cases.
184
atf_check -s eq:0 -o file:expout -e empty -x \
185
"atf-report -o ticker:- <tps.out"
187
# Just ensure that this does not crash for now...
188
atf_check -s eq:0 -o ignore -e empty -x "atf-report -o xml:- <tps.out"
194
atf_set "descr" "Checks that the -o flag works"
201
# Get the default output.
202
atf_check -s eq:0 -o save:stdout -e empty -x 'atf-report <tps.out'
205
# Check that changing the stdout output works.
206
atf_check -s eq:0 -o save:stdout -e empty -x 'atf-report -o csv:- <tps.out'
207
atf_check -s eq:1 -o empty -e empty cmp -s defout stdout
210
# Check that sending the output to a file does not write to stdout.
211
atf_check -s eq:0 -o empty -e empty -x 'atf-report -o csv:fmt.out <tps.out'
212
atf_check -s eq:0 -o empty -e empty cmp -s expcsv fmt.out
215
# Check that defining two outputs using the same format works.
216
atf_check -s eq:0 -o empty -e empty -x \
217
'atf-report -o csv:fmt.out -o csv:fmt2.out <tps.out'
218
atf_check -s eq:0 -o empty -e empty cmp -s expcsv fmt.out
219
atf_check -s eq:0 -o empty -e empty cmp -s fmt.out fmt2.out
220
rm -f fmt.out fmt2.out
222
# Check that defining two outputs using different formats works.
223
atf_check -s eq:0 -o empty -e empty -x \
224
'atf-report -o csv:fmt.out -o ticker:fmt2.out <tps.out'
225
atf_check -s eq:0 -o empty -e empty cmp -s expcsv fmt.out
226
atf_check -s eq:1 -o empty -e empty cmp -s fmt.out fmt2.out
227
atf_check -s eq:0 -o ignore -e empty grep "test cases" fmt2.out
228
atf_check -s eq:0 -o ignore -e empty grep "Failed test cases" fmt2.out
229
atf_check -s eq:0 -o ignore -e empty grep "Summary for" fmt2.out
230
rm -f fmt.out fmt2.out
232
# Check that defining two outputs over the same file does not work.
233
atf_check -s eq:1 -o empty -e match:'more than once' -x \
234
'atf-report -o csv:fmt.out -o ticker:fmt.out <tps.out'
237
# Check that defining two outputs over stdout (but using different
238
# paths) does not work.
239
atf_check -s eq:1 -o empty -e match:'more than once' -x \
240
'atf-report -o csv:- -o ticker:/dev/stdout <tps.out'
244
atf_test_case output_csv
247
atf_set "descr" "Checks the CSV output format"
254
# NO_CHECK_STYLE_BEGIN
256
tc, dir1/tp1, main, passed
258
tc, dir1/tp2, main, failed, This always fails
260
tc, tp3, main, passed
262
tc, tp4, main, failed, This always fails
264
tp, tp5, bogus, Invalid format for test case list: 1: Unexpected token \`<<NEWLINE>>'; expected \`:'
268
atf_check -s eq:0 -o file:expout -e empty -x 'atf-report -o csv:- <tps.out'
271
atf_test_case output_ticker
274
atf_set "descr" "Checks the ticker output format"
281
# NO_CHECK_STYLE_BEGIN
283
dir1/tp1 (1/5): 1 test cases
286
dir1/tp2 (2/5): 1 test cases
287
main: Failed: This always fails
289
tp3 (3/5): 1 test cases
292
tp4 (4/5): 1 test cases
293
main: Failed: This always fails
295
tp5 (5/5): 0 test cases
296
tp5: BOGUS TEST PROGRAM: Cannot trust its results because of \`Invalid format for test case list: 1: Unexpected token \`<<NEWLINE>>'; expected \`:''
298
Failed (bogus) test programs:
302
dir1/tp2:main, tp4:main
304
Summary for 5 test programs:
307
0 expected failed test cases.
308
0 skipped test cases.
311
atf_check -s eq:0 -o file:expout -e empty -x 'atf-report -o ticker:- <tps.out'
315
atf_test_case output_xml
318
atf_set "descr" "Checks the XML output format"
325
# NO_CHECK_STYLE_BEGIN
327
<?xml version="1.0"?>
328
<!DOCTYPE tests-results PUBLIC "-//NetBSD//DTD ATF Tests Results 0.1//EN" "http://www.NetBSD.org/XML/atf/tests-results.dtd">
331
<info class="startinfo">A value</info>
339
<failed>This always fails</failed>
349
<failed>This always fails</failed>
353
<failed>Invalid format for test case list: 1: Unexpected token \`<<NEWLINE>>'; expected \`:'</failed>
355
<info class="endinfo">Another value</info>
360
atf_check -s eq:0 -o file:expout -e empty -x 'atf-report -o xml:- <tps.out'
363
atf_test_case output_xml_space
364
output_xml_space_head()
366
atf_set "descr" "Checks that the XML output format properly preserves" \
367
"leading and trailing whitespace in stdout and stderr" \
370
output_xml_space_body()
372
cp $(atf_get_srcdir)/misc_helpers .
374
Content-Type: application/X-atf-atffile; version="1"
376
prop: test-suite = atf
381
# NO_CHECK_STYLE_BEGIN
383
<?xml version="1.0"?>
384
<!DOCTYPE tests-results PUBLIC "-//NetBSD//DTD ATF Tests Results 0.1//EN" "http://www.NetBSD.org/XML/atf/tests-results.dtd">
387
<info class="startinfo">A value</info>
388
<tp id="misc_helpers">
390
<so>--- a 2007-11-04 14:00:41.000000000 +0100</so>
391
<so>+++ b 2007-11-04 14:00:48.000000000 +0100</so>
392
<so>@@ -1,7 +1,7 @@</so>
393
<so> This test is meant to simulate a diff.</so>
394
<so> Blank space at beginning of context lines must be preserved.</so>
396
<so>-First original line.</so>
397
<so>-Second original line.</so>
398
<so>+First modified line.</so>
399
<so>+Second modified line.</so>
405
<info class="endinfo">Another value</info>
411
atf_check -s eq:0 -o file:expout -e empty -x 'atf-report -o xml:- <tps.out'
414
atf_init_test_cases()
416
atf_add_test_case default
417
atf_add_test_case expect
418
atf_add_test_case oflag
419
atf_add_test_case output_csv
420
atf_add_test_case output_ticker
421
atf_add_test_case output_xml
422
atf_add_test_case output_xml_space
425
# vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4