xref: /minix3/external/bsd/atf/dist/tools/atf-report_test.sh (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc#
2*0a6a1f1dSLionel Sambuc# Automated Testing Framework (atf)
3*0a6a1f1dSLionel Sambuc#
4*0a6a1f1dSLionel Sambuc# Copyright (c) 2007 The NetBSD Foundation, Inc.
5*0a6a1f1dSLionel Sambuc# All rights reserved.
6*0a6a1f1dSLionel Sambuc#
7*0a6a1f1dSLionel Sambuc# Redistribution and use in source and binary forms, with or without
8*0a6a1f1dSLionel Sambuc# modification, are permitted provided that the following conditions
9*0a6a1f1dSLionel Sambuc# are met:
10*0a6a1f1dSLionel Sambuc# 1. Redistributions of source code must retain the above copyright
11*0a6a1f1dSLionel Sambuc#    notice, this list of conditions and the following disclaimer.
12*0a6a1f1dSLionel Sambuc# 2. Redistributions in binary form must reproduce the above copyright
13*0a6a1f1dSLionel Sambuc#    notice, this list of conditions and the following disclaimer in the
14*0a6a1f1dSLionel Sambuc#    documentation and/or other materials provided with the distribution.
15*0a6a1f1dSLionel Sambuc#
16*0a6a1f1dSLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17*0a6a1f1dSLionel Sambuc# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18*0a6a1f1dSLionel Sambuc# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19*0a6a1f1dSLionel Sambuc# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20*0a6a1f1dSLionel Sambuc# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21*0a6a1f1dSLionel Sambuc# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*0a6a1f1dSLionel Sambuc# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23*0a6a1f1dSLionel Sambuc# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24*0a6a1f1dSLionel Sambuc# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25*0a6a1f1dSLionel Sambuc# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26*0a6a1f1dSLionel Sambuc# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27*0a6a1f1dSLionel Sambuc# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*0a6a1f1dSLionel Sambuc#
29*0a6a1f1dSLionel Sambuc
30*0a6a1f1dSLionel Sambuccreate_helpers()
31*0a6a1f1dSLionel Sambuc{
32*0a6a1f1dSLionel Sambuc    mkdir dir1
33*0a6a1f1dSLionel Sambuc    cp $(atf_get_srcdir)/pass_helper dir1/tp1
34*0a6a1f1dSLionel Sambuc    cp $(atf_get_srcdir)/fail_helper dir1/tp2
35*0a6a1f1dSLionel Sambuc    cp $(atf_get_srcdir)/pass_helper tp3
36*0a6a1f1dSLionel Sambuc    cp $(atf_get_srcdir)/fail_helper tp4
37*0a6a1f1dSLionel Sambuc
38*0a6a1f1dSLionel Sambuc    cat >tp5 <<EOF
39*0a6a1f1dSLionel Sambuc#! $(atf-config -t atf_shell)
40*0a6a1f1dSLionel Sambucecho foo
41*0a6a1f1dSLionel SambucEOF
42*0a6a1f1dSLionel Sambuc    chmod +x tp5
43*0a6a1f1dSLionel Sambuc
44*0a6a1f1dSLionel Sambuc    cat >Atffile <<EOF
45*0a6a1f1dSLionel SambucContent-Type: application/X-atf-atffile; version="1"
46*0a6a1f1dSLionel Sambuc
47*0a6a1f1dSLionel Sambucprop: test-suite = atf
48*0a6a1f1dSLionel Sambuc
49*0a6a1f1dSLionel Sambuctp: dir1
50*0a6a1f1dSLionel Sambuctp: tp3
51*0a6a1f1dSLionel Sambuctp: tp4
52*0a6a1f1dSLionel Sambuctp: tp5
53*0a6a1f1dSLionel SambucEOF
54*0a6a1f1dSLionel Sambuc
55*0a6a1f1dSLionel Sambuc    cat >dir1/Atffile <<EOF
56*0a6a1f1dSLionel SambucContent-Type: application/X-atf-atffile; version="1"
57*0a6a1f1dSLionel Sambuc
58*0a6a1f1dSLionel Sambucprop: test-suite = atf
59*0a6a1f1dSLionel Sambuc
60*0a6a1f1dSLionel Sambuctp: tp1
61*0a6a1f1dSLionel Sambuctp: tp2
62*0a6a1f1dSLionel SambucEOF
63*0a6a1f1dSLionel Sambuc}
64*0a6a1f1dSLionel Sambuc
65*0a6a1f1dSLionel Sambucrun_helpers()
66*0a6a1f1dSLionel Sambuc{
67*0a6a1f1dSLionel Sambuc    mkdir etc
68*0a6a1f1dSLionel Sambuc    cat >etc/atf-run.hooks <<EOF
69*0a6a1f1dSLionel Sambuc#! $(atf-config -t atf_shell)
70*0a6a1f1dSLionel Sambuc
71*0a6a1f1dSLionel Sambucinfo_start_hook()
72*0a6a1f1dSLionel Sambuc{
73*0a6a1f1dSLionel Sambuc    atf_tps_writer_info "startinfo" "A value"
74*0a6a1f1dSLionel Sambuc}
75*0a6a1f1dSLionel Sambuc
76*0a6a1f1dSLionel Sambucinfo_end_hook()
77*0a6a1f1dSLionel Sambuc{
78*0a6a1f1dSLionel Sambuc    atf_tps_writer_info "endinfo" "Another value"
79*0a6a1f1dSLionel Sambuc}
80*0a6a1f1dSLionel SambucEOF
81*0a6a1f1dSLionel Sambuc    echo "Using atf-run to run helpers"
82*0a6a1f1dSLionel Sambuc    ATF_CONFDIR=$(pwd)/etc atf-run >tps.out 2>/dev/null
83*0a6a1f1dSLionel Sambuc    rm -rf etc
84*0a6a1f1dSLionel Sambuc}
85*0a6a1f1dSLionel Sambuc
86*0a6a1f1dSLionel Sambucatf_test_case default
87*0a6a1f1dSLionel Sambucdefault_head()
88*0a6a1f1dSLionel Sambuc{
89*0a6a1f1dSLionel Sambuc    atf_set "descr" "Checks that the default output uses the ticker" \
90*0a6a1f1dSLionel Sambuc                    "format"
91*0a6a1f1dSLionel Sambuc}
92*0a6a1f1dSLionel Sambucdefault_body()
93*0a6a1f1dSLionel Sambuc{
94*0a6a1f1dSLionel Sambuc    create_helpers
95*0a6a1f1dSLionel Sambuc    run_helpers
96*0a6a1f1dSLionel Sambuc
97*0a6a1f1dSLionel Sambuc    # Check that the default output uses the ticker format.
98*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o match:'test cases' -o match:'Failed test cases' \
99*0a6a1f1dSLionel Sambuc        -o match:'Summary for' -e empty -x 'atf-report <tps.out'
100*0a6a1f1dSLionel Sambuc}
101*0a6a1f1dSLionel Sambuc
102*0a6a1f1dSLionel Sambuc# XXX The test for all expect_ values should be intermixed with the other
103*0a6a1f1dSLionel Sambuc# tests.  However, to do that, we need to migrate to using C helpers for
104*0a6a1f1dSLionel Sambuc# simplicity in raising signals...
105*0a6a1f1dSLionel Sambucatf_test_case expect
106*0a6a1f1dSLionel Sambucexpect_body()
107*0a6a1f1dSLionel Sambuc{
108*0a6a1f1dSLionel Sambuc    ln -s "$(atf_get_srcdir)/expect_helpers" .
109*0a6a1f1dSLionel Sambuc    cat >Atffile <<EOF
110*0a6a1f1dSLionel SambucContent-Type: application/X-atf-atffile; version="1"
111*0a6a1f1dSLionel Sambuc
112*0a6a1f1dSLionel Sambucprop: test-suite = atf
113*0a6a1f1dSLionel Sambuc
114*0a6a1f1dSLionel Sambuctp: expect_helpers
115*0a6a1f1dSLionel SambucEOF
116*0a6a1f1dSLionel Sambuc    run_helpers
117*0a6a1f1dSLionel Sambuc
118*0a6a1f1dSLionel Sambuc# NO_CHECK_STYLE_BEGIN
119*0a6a1f1dSLionel Sambuc    cat >expout <<EOF
120*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, death_and_exit, expected_death, Exit case
121*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, death_and_signal, expected_death, Signal case
122*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, death_but_pass, failed, Test case was expected to terminate abruptly but it continued execution
123*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, exit_any_and_exit, expected_exit, Call will exit
124*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, exit_but_pass, failed, Test case was expected to exit cleanly but it continued execution
125*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, exit_code_and_exit, expected_exit, Call will exit
126*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, fail_and_fail_check, expected_failure, And fail again: 2 checks failed as expected; see output for more details
127*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, fail_and_fail_requirement, expected_failure, Fail reason: The failure
128*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, fail_but_pass, failed, Test case was expecting a failure but none were raised
129*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, pass_and_pass, passed
130*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, pass_but_fail_check, failed, 1 checks failed; see output for more details
131*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, pass_but_fail_requirement, failed, Some reason
132*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, signal_any_and_signal, expected_signal, Call will signal
133*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, signal_but_pass, failed, Test case was expected to receive a termination signal but it continued execution
134*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, signal_no_and_signal, expected_signal, Call will signal
135*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, timeout_and_hang, expected_timeout, Will overrun
136*0a6a1f1dSLionel Sambuctc, #.#, expect_helpers, timeout_but_pass, failed, Test case was expected to hang but it continued execution
137*0a6a1f1dSLionel Sambuctp, #.#, expect_helpers, failed
138*0a6a1f1dSLionel SambucEOF
139*0a6a1f1dSLionel Sambuc# NO_CHECK_STYLE_END
140*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o file:expout -e empty -x \
141*0a6a1f1dSLionel Sambuc        "atf-report -o csv:- <tps.out | " \
142*0a6a1f1dSLionel Sambuc        "sed -E -e 's/[0-9]+.[0-9]{6}, /#.#, /'"
143*0a6a1f1dSLionel Sambuc
144*0a6a1f1dSLionel Sambuc# NO_CHECK_STYLE_BEGIN
145*0a6a1f1dSLionel Sambuc    cat >expout <<EOF
146*0a6a1f1dSLionel Sambucexpect_helpers (1/1): 17 test cases
147*0a6a1f1dSLionel Sambuc    death_and_exit: [#.#s] Expected failure: Exit case
148*0a6a1f1dSLionel Sambuc    death_and_signal: [#.#s] Expected failure: Signal case
149*0a6a1f1dSLionel Sambuc    death_but_pass: [#.#s] Failed: Test case was expected to terminate abruptly but it continued execution
150*0a6a1f1dSLionel Sambuc    exit_any_and_exit: [#.#s] Expected failure: Call will exit
151*0a6a1f1dSLionel Sambuc    exit_but_pass: [#.#s] Failed: Test case was expected to exit cleanly but it continued execution
152*0a6a1f1dSLionel Sambuc    exit_code_and_exit: [#.#s] Expected failure: Call will exit
153*0a6a1f1dSLionel Sambuc    fail_and_fail_check: [#.#s] Expected failure: And fail again: 2 checks failed as expected; see output for more details
154*0a6a1f1dSLionel Sambuc    fail_and_fail_requirement: [#.#s] Expected failure: Fail reason: The failure
155*0a6a1f1dSLionel Sambuc    fail_but_pass: [#.#s] Failed: Test case was expecting a failure but none were raised
156*0a6a1f1dSLionel Sambuc    pass_and_pass: [#.#s] Passed.
157*0a6a1f1dSLionel Sambuc    pass_but_fail_check: [#.#s] Failed: 1 checks failed; see output for more details
158*0a6a1f1dSLionel Sambuc    pass_but_fail_requirement: [#.#s] Failed: Some reason
159*0a6a1f1dSLionel Sambuc    signal_any_and_signal: [#.#s] Expected failure: Call will signal
160*0a6a1f1dSLionel Sambuc    signal_but_pass: [#.#s] Failed: Test case was expected to receive a termination signal but it continued execution
161*0a6a1f1dSLionel Sambuc    signal_no_and_signal: [#.#s] Expected failure: Call will signal
162*0a6a1f1dSLionel Sambuc    timeout_and_hang: [#.#s] Expected failure: Will overrun
163*0a6a1f1dSLionel Sambuc    timeout_but_pass: [#.#s] Failed: Test case was expected to hang but it continued execution
164*0a6a1f1dSLionel Sambuc[#.#s]
165*0a6a1f1dSLionel Sambuc
166*0a6a1f1dSLionel SambucTest cases for known bugs:
167*0a6a1f1dSLionel Sambuc    expect_helpers:death_and_exit: Exit case
168*0a6a1f1dSLionel Sambuc    expect_helpers:death_and_signal: Signal case
169*0a6a1f1dSLionel Sambuc    expect_helpers:exit_any_and_exit: Call will exit
170*0a6a1f1dSLionel Sambuc    expect_helpers:exit_code_and_exit: Call will exit
171*0a6a1f1dSLionel Sambuc    expect_helpers:fail_and_fail_check: And fail again: 2 checks failed as expected; see output for more details
172*0a6a1f1dSLionel Sambuc    expect_helpers:fail_and_fail_requirement: Fail reason: The failure
173*0a6a1f1dSLionel Sambuc    expect_helpers:signal_any_and_signal: Call will signal
174*0a6a1f1dSLionel Sambuc    expect_helpers:signal_no_and_signal: Call will signal
175*0a6a1f1dSLionel Sambuc    expect_helpers:timeout_and_hang: Will overrun
176*0a6a1f1dSLionel Sambuc
177*0a6a1f1dSLionel SambucFailed test cases:
178*0a6a1f1dSLionel Sambuc    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
179*0a6a1f1dSLionel Sambuc
180*0a6a1f1dSLionel SambucSummary for 1 test programs:
181*0a6a1f1dSLionel Sambuc    1 passed test cases.
182*0a6a1f1dSLionel Sambuc    7 failed test cases.
183*0a6a1f1dSLionel Sambuc    9 expected failed test cases.
184*0a6a1f1dSLionel Sambuc    0 skipped test cases.
185*0a6a1f1dSLionel SambucEOF
186*0a6a1f1dSLionel Sambuc# NO_CHECK_STYLE_END
187*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o file:expout -e empty -x \
188*0a6a1f1dSLionel Sambuc        "atf-report -o ticker:- <tps.out | " \
189*0a6a1f1dSLionel Sambuc        "sed -E -e 's/[0-9]+.[0-9]{6}/#.#/'"
190*0a6a1f1dSLionel Sambuc
191*0a6a1f1dSLionel Sambuc    # Just ensure that this does not crash for now...
192*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o ignore -e empty -x "atf-report -o xml:- <tps.out"
193*0a6a1f1dSLionel Sambuc}
194*0a6a1f1dSLionel Sambuc
195*0a6a1f1dSLionel Sambucatf_test_case oflag
196*0a6a1f1dSLionel Sambucoflag_head()
197*0a6a1f1dSLionel Sambuc{
198*0a6a1f1dSLionel Sambuc    atf_set "descr" "Checks that the -o flag works"
199*0a6a1f1dSLionel Sambuc}
200*0a6a1f1dSLionel Sambucoflag_body()
201*0a6a1f1dSLionel Sambuc{
202*0a6a1f1dSLionel Sambuc    create_helpers
203*0a6a1f1dSLionel Sambuc    run_helpers
204*0a6a1f1dSLionel Sambuc
205*0a6a1f1dSLionel Sambuc    # Get the default output.
206*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o save:stdout -e empty -x 'atf-report <tps.out'
207*0a6a1f1dSLionel Sambuc    mv stdout defout
208*0a6a1f1dSLionel Sambuc
209*0a6a1f1dSLionel Sambuc    # Check that changing the stdout output works.
210*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o save:stdout -e empty -x 'atf-report -o csv:- <tps.out'
211*0a6a1f1dSLionel Sambuc    atf_check -s eq:1 -o empty -e empty cmp -s defout stdout
212*0a6a1f1dSLionel Sambuc    cp stdout expcsv
213*0a6a1f1dSLionel Sambuc
214*0a6a1f1dSLionel Sambuc    # Check that sending the output to a file does not write to stdout.
215*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o empty -e empty -x 'atf-report -o csv:fmt.out <tps.out'
216*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o empty -e empty cmp -s expcsv fmt.out
217*0a6a1f1dSLionel Sambuc    rm -f fmt.out
218*0a6a1f1dSLionel Sambuc
219*0a6a1f1dSLionel Sambuc    # Check that defining two outputs using the same format works.
220*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o empty -e empty -x \
221*0a6a1f1dSLionel Sambuc              'atf-report -o csv:fmt.out -o csv:fmt2.out <tps.out'
222*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o empty -e empty cmp -s expcsv fmt.out
223*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o empty -e empty cmp -s fmt.out fmt2.out
224*0a6a1f1dSLionel Sambuc    rm -f fmt.out fmt2.out
225*0a6a1f1dSLionel Sambuc
226*0a6a1f1dSLionel Sambuc    # Check that defining two outputs using different formats works.
227*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o empty -e empty -x \
228*0a6a1f1dSLionel Sambuc              'atf-report -o csv:fmt.out -o ticker:fmt2.out <tps.out'
229*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o empty -e empty cmp -s expcsv fmt.out
230*0a6a1f1dSLionel Sambuc    atf_check -s eq:1 -o empty -e empty cmp -s fmt.out fmt2.out
231*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o ignore -e empty grep "test cases" fmt2.out
232*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o ignore -e empty grep "Failed test cases" fmt2.out
233*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o ignore -e empty grep "Summary for" fmt2.out
234*0a6a1f1dSLionel Sambuc    rm -f fmt.out fmt2.out
235*0a6a1f1dSLionel Sambuc
236*0a6a1f1dSLionel Sambuc    # Check that defining two outputs over the same file does not work.
237*0a6a1f1dSLionel Sambuc    atf_check -s eq:1 -o empty -e match:'more than once' -x \
238*0a6a1f1dSLionel Sambuc              'atf-report -o csv:fmt.out -o ticker:fmt.out <tps.out'
239*0a6a1f1dSLionel Sambuc    rm -f fmt.out
240*0a6a1f1dSLionel Sambuc
241*0a6a1f1dSLionel Sambuc    # Check that defining two outputs over stdout (but using different
242*0a6a1f1dSLionel Sambuc    # paths) does not work.
243*0a6a1f1dSLionel Sambuc    atf_check -s eq:1 -o empty -e match:'more than once' -x \
244*0a6a1f1dSLionel Sambuc              'atf-report -o csv:- -o ticker:/dev/stdout <tps.out'
245*0a6a1f1dSLionel Sambuc    rm -f fmt.out
246*0a6a1f1dSLionel Sambuc}
247*0a6a1f1dSLionel Sambuc
248*0a6a1f1dSLionel Sambucatf_test_case output_csv
249*0a6a1f1dSLionel Sambucoutput_csv_head()
250*0a6a1f1dSLionel Sambuc{
251*0a6a1f1dSLionel Sambuc    atf_set "descr" "Checks the CSV output format"
252*0a6a1f1dSLionel Sambuc}
253*0a6a1f1dSLionel Sambucoutput_csv_body()
254*0a6a1f1dSLionel Sambuc{
255*0a6a1f1dSLionel Sambuc    create_helpers
256*0a6a1f1dSLionel Sambuc    run_helpers
257*0a6a1f1dSLionel Sambuc
258*0a6a1f1dSLionel Sambuc# NO_CHECK_STYLE_BEGIN
259*0a6a1f1dSLionel Sambuc    cat >expout <<EOF
260*0a6a1f1dSLionel Sambuctc, #.#, dir1/tp1, main, passed
261*0a6a1f1dSLionel Sambuctp, #.#, dir1/tp1, passed
262*0a6a1f1dSLionel Sambuctc, #.#, dir1/tp2, main, failed, This always fails
263*0a6a1f1dSLionel Sambuctp, #.#, dir1/tp2, failed
264*0a6a1f1dSLionel Sambuctc, #.#, tp3, main, passed
265*0a6a1f1dSLionel Sambuctp, #.#, tp3, passed
266*0a6a1f1dSLionel Sambuctc, #.#, tp4, main, failed, This always fails
267*0a6a1f1dSLionel Sambuctp, #.#, tp4, failed
268*0a6a1f1dSLionel Sambuctp, #.#, tp5, bogus, Invalid format for test case list: 1: Unexpected token \`<<NEWLINE>>'; expected \`:'
269*0a6a1f1dSLionel SambucEOF
270*0a6a1f1dSLionel Sambuc# NO_CHECK_STYLE_END
271*0a6a1f1dSLionel Sambuc
272*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o file:expout -e empty -x \
273*0a6a1f1dSLionel Sambuc        "atf-report -o csv:- <tps.out | sed -E -e 's/[0-9]+.[0-9]{6}, /#.#, /'"
274*0a6a1f1dSLionel Sambuc}
275*0a6a1f1dSLionel Sambuc
276*0a6a1f1dSLionel Sambucatf_test_case output_ticker
277*0a6a1f1dSLionel Sambucoutput_ticker_head()
278*0a6a1f1dSLionel Sambuc{
279*0a6a1f1dSLionel Sambuc    atf_set "descr" "Checks the ticker output format"
280*0a6a1f1dSLionel Sambuc}
281*0a6a1f1dSLionel Sambucoutput_ticker_body()
282*0a6a1f1dSLionel Sambuc{
283*0a6a1f1dSLionel Sambuc    create_helpers
284*0a6a1f1dSLionel Sambuc    run_helpers
285*0a6a1f1dSLionel Sambuc
286*0a6a1f1dSLionel Sambuc# NO_CHECK_STYLE_BEGIN
287*0a6a1f1dSLionel Sambuc    cat >expout <<EOF
288*0a6a1f1dSLionel Sambucdir1/tp1 (1/5): 1 test cases
289*0a6a1f1dSLionel Sambuc    main: [#.#s] Passed.
290*0a6a1f1dSLionel Sambuc[#.#s]
291*0a6a1f1dSLionel Sambuc
292*0a6a1f1dSLionel Sambucdir1/tp2 (2/5): 1 test cases
293*0a6a1f1dSLionel Sambuc    main: [#.#s] Failed: This always fails
294*0a6a1f1dSLionel Sambuc[#.#s]
295*0a6a1f1dSLionel Sambuc
296*0a6a1f1dSLionel Sambuctp3 (3/5): 1 test cases
297*0a6a1f1dSLionel Sambuc    main: [#.#s] Passed.
298*0a6a1f1dSLionel Sambuc[#.#s]
299*0a6a1f1dSLionel Sambuc
300*0a6a1f1dSLionel Sambuctp4 (4/5): 1 test cases
301*0a6a1f1dSLionel Sambuc    main: [#.#s] Failed: This always fails
302*0a6a1f1dSLionel Sambuc[#.#s]
303*0a6a1f1dSLionel Sambuc
304*0a6a1f1dSLionel Sambuctp5 (5/5): 0 test cases
305*0a6a1f1dSLionel Sambuctp5: BOGUS TEST PROGRAM: Cannot trust its results because of \`Invalid format for test case list: 1: Unexpected token \`<<NEWLINE>>'; expected \`:''
306*0a6a1f1dSLionel Sambuc[#.#s]
307*0a6a1f1dSLionel Sambuc
308*0a6a1f1dSLionel SambucFailed (bogus) test programs:
309*0a6a1f1dSLionel Sambuc    tp5
310*0a6a1f1dSLionel Sambuc
311*0a6a1f1dSLionel SambucFailed test cases:
312*0a6a1f1dSLionel Sambuc    dir1/tp2:main, tp4:main
313*0a6a1f1dSLionel Sambuc
314*0a6a1f1dSLionel SambucSummary for 5 test programs:
315*0a6a1f1dSLionel Sambuc    2 passed test cases.
316*0a6a1f1dSLionel Sambuc    2 failed test cases.
317*0a6a1f1dSLionel Sambuc    0 expected failed test cases.
318*0a6a1f1dSLionel Sambuc    0 skipped test cases.
319*0a6a1f1dSLionel SambucEOF
320*0a6a1f1dSLionel Sambuc
321*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o file:expout -e empty -x \
322*0a6a1f1dSLionel Sambuc        "atf-report -o ticker:- <tps.out | sed -E -e 's/[0-9]+.[0-9]{6}/#.#/'"
323*0a6a1f1dSLionel Sambuc}
324*0a6a1f1dSLionel Sambuc# NO_CHECK_STYLE_END
325*0a6a1f1dSLionel Sambuc
326*0a6a1f1dSLionel Sambucatf_test_case output_xml
327*0a6a1f1dSLionel Sambucoutput_xml_head()
328*0a6a1f1dSLionel Sambuc{
329*0a6a1f1dSLionel Sambuc    atf_set "descr" "Checks the XML output format"
330*0a6a1f1dSLionel Sambuc}
331*0a6a1f1dSLionel Sambucoutput_xml_body()
332*0a6a1f1dSLionel Sambuc{
333*0a6a1f1dSLionel Sambuc    create_helpers
334*0a6a1f1dSLionel Sambuc    run_helpers
335*0a6a1f1dSLionel Sambuc
336*0a6a1f1dSLionel Sambuc# NO_CHECK_STYLE_BEGIN
337*0a6a1f1dSLionel Sambuc    cat >expout <<EOF
338*0a6a1f1dSLionel Sambuc<?xml version="1.0" encoding="ISO-8859-1"?>
339*0a6a1f1dSLionel Sambuc<!DOCTYPE tests-results PUBLIC "-//NetBSD//DTD ATF Tests Results 0.1//EN" "http://www.NetBSD.org/XML/atf/tests-results.dtd">
340*0a6a1f1dSLionel Sambuc
341*0a6a1f1dSLionel Sambuc<tests-results>
342*0a6a1f1dSLionel Sambuc<info class="startinfo">A value</info>
343*0a6a1f1dSLionel Sambuc<tp id="dir1/tp1">
344*0a6a1f1dSLionel Sambuc<tc id="main">
345*0a6a1f1dSLionel Sambuc<passed />
346*0a6a1f1dSLionel Sambuc<tc-time>#.#</tc-time></tc>
347*0a6a1f1dSLionel Sambuc<tp-time>#.#</tp-time></tp>
348*0a6a1f1dSLionel Sambuc<tp id="dir1/tp2">
349*0a6a1f1dSLionel Sambuc<tc id="main">
350*0a6a1f1dSLionel Sambuc<failed>This always fails</failed>
351*0a6a1f1dSLionel Sambuc<tc-time>#.#</tc-time></tc>
352*0a6a1f1dSLionel Sambuc<tp-time>#.#</tp-time></tp>
353*0a6a1f1dSLionel Sambuc<tp id="tp3">
354*0a6a1f1dSLionel Sambuc<tc id="main">
355*0a6a1f1dSLionel Sambuc<passed />
356*0a6a1f1dSLionel Sambuc<tc-time>#.#</tc-time></tc>
357*0a6a1f1dSLionel Sambuc<tp-time>#.#</tp-time></tp>
358*0a6a1f1dSLionel Sambuc<tp id="tp4">
359*0a6a1f1dSLionel Sambuc<tc id="main">
360*0a6a1f1dSLionel Sambuc<failed>This always fails</failed>
361*0a6a1f1dSLionel Sambuc<tc-time>#.#</tc-time></tc>
362*0a6a1f1dSLionel Sambuc<tp-time>#.#</tp-time></tp>
363*0a6a1f1dSLionel Sambuc<tp id="tp5">
364*0a6a1f1dSLionel Sambuc<failed>Invalid format for test case list: 1: Unexpected token \`&lt;&lt;NEWLINE&gt;&gt;'; expected \`:'</failed>
365*0a6a1f1dSLionel Sambuc<tp-time>#.#</tp-time></tp>
366*0a6a1f1dSLionel Sambuc<info class="endinfo">Another value</info>
367*0a6a1f1dSLionel Sambuc</tests-results>
368*0a6a1f1dSLionel SambucEOF
369*0a6a1f1dSLionel Sambuc# NO_CHECK_STYLE_END
370*0a6a1f1dSLionel Sambuc
371*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o file:expout -e empty -x \
372*0a6a1f1dSLionel Sambuc        "atf-report -o xml:- < tps.out | sed -E -e 's/>[0-9]+.[0-9]{6}</>#.#</'"
373*0a6a1f1dSLionel Sambuc}
374*0a6a1f1dSLionel Sambuc
375*0a6a1f1dSLionel Sambucatf_test_case output_xml_space
376*0a6a1f1dSLionel Sambucoutput_xml_space_head()
377*0a6a1f1dSLionel Sambuc{
378*0a6a1f1dSLionel Sambuc    atf_set "descr" "Checks that the XML output format properly preserves" \
379*0a6a1f1dSLionel Sambuc                    "leading and trailing whitespace in stdout and stderr" \
380*0a6a1f1dSLionel Sambuc                    "lines"
381*0a6a1f1dSLionel Sambuc}
382*0a6a1f1dSLionel Sambucoutput_xml_space_body()
383*0a6a1f1dSLionel Sambuc{
384*0a6a1f1dSLionel Sambuc    export TESTCASE=diff
385*0a6a1f1dSLionel Sambuc    cp $(atf_get_srcdir)/misc_helpers .
386*0a6a1f1dSLionel Sambuc    cat >Atffile <<EOF
387*0a6a1f1dSLionel SambucContent-Type: application/X-atf-atffile; version="1"
388*0a6a1f1dSLionel Sambuc
389*0a6a1f1dSLionel Sambucprop: test-suite = atf
390*0a6a1f1dSLionel Sambuc
391*0a6a1f1dSLionel Sambuctp: misc_helpers
392*0a6a1f1dSLionel SambucEOF
393*0a6a1f1dSLionel Sambuc
394*0a6a1f1dSLionel Sambuc# NO_CHECK_STYLE_BEGIN
395*0a6a1f1dSLionel Sambuc    cat >expout <<EOF
396*0a6a1f1dSLionel Sambuc<?xml version="1.0" encoding="ISO-8859-1"?>
397*0a6a1f1dSLionel Sambuc<!DOCTYPE tests-results PUBLIC "-//NetBSD//DTD ATF Tests Results 0.1//EN" "http://www.NetBSD.org/XML/atf/tests-results.dtd">
398*0a6a1f1dSLionel Sambuc
399*0a6a1f1dSLionel Sambuc<tests-results>
400*0a6a1f1dSLionel Sambuc<info class="startinfo">A value</info>
401*0a6a1f1dSLionel Sambuc<tp id="misc_helpers">
402*0a6a1f1dSLionel Sambuc<tc id="diff">
403*0a6a1f1dSLionel Sambuc<so>--- a	2007-11-04 14:00:41.000000000 +0100</so>
404*0a6a1f1dSLionel Sambuc<so>+++ b	2007-11-04 14:00:48.000000000 +0100</so>
405*0a6a1f1dSLionel Sambuc<so>@@ -1,7 +1,7 @@</so>
406*0a6a1f1dSLionel Sambuc<so> This test is meant to simulate a diff.</so>
407*0a6a1f1dSLionel Sambuc<so> Blank space at beginning of context lines must be preserved.</so>
408*0a6a1f1dSLionel Sambuc<so> </so>
409*0a6a1f1dSLionel Sambuc<so>-First original line.</so>
410*0a6a1f1dSLionel Sambuc<so>-Second original line.</so>
411*0a6a1f1dSLionel Sambuc<so>+First modified line.</so>
412*0a6a1f1dSLionel Sambuc<so>+Second modified line.</so>
413*0a6a1f1dSLionel Sambuc<so> </so>
414*0a6a1f1dSLionel Sambuc<so> EOF</so>
415*0a6a1f1dSLionel Sambuc<passed />
416*0a6a1f1dSLionel Sambuc<tc-time>#.#</tc-time></tc>
417*0a6a1f1dSLionel Sambuc<tp-time>#.#</tp-time></tp>
418*0a6a1f1dSLionel Sambuc<info class="endinfo">Another value</info>
419*0a6a1f1dSLionel Sambuc</tests-results>
420*0a6a1f1dSLionel SambucEOF
421*0a6a1f1dSLionel Sambuc# NO_CHECK_STYLE_END
422*0a6a1f1dSLionel Sambuc
423*0a6a1f1dSLionel Sambuc    run_helpers
424*0a6a1f1dSLionel Sambuc    atf_check -s eq:0 -o file:expout -e empty -x \
425*0a6a1f1dSLionel Sambuc        "atf-report -o xml:- <tps.out | sed -E -e 's/>[0-9]+.[0-9]{6}</>#.#</'"
426*0a6a1f1dSLionel Sambuc}
427*0a6a1f1dSLionel Sambuc
428*0a6a1f1dSLionel Sambucatf_test_case too_many_args
429*0a6a1f1dSLionel Sambuctoo_many_args_body()
430*0a6a1f1dSLionel Sambuc{
431*0a6a1f1dSLionel Sambuc    cat >experr <<EOF
432*0a6a1f1dSLionel Sambucatf-report: ERROR: No arguments allowed
433*0a6a1f1dSLionel SambucEOF
434*0a6a1f1dSLionel Sambuc    atf_check -s eq:1 -o empty -e file:experr atf-report foo
435*0a6a1f1dSLionel Sambuc}
436*0a6a1f1dSLionel Sambuc
437*0a6a1f1dSLionel Sambucatf_init_test_cases()
438*0a6a1f1dSLionel Sambuc{
439*0a6a1f1dSLionel Sambuc    atf_add_test_case default
440*0a6a1f1dSLionel Sambuc    atf_add_test_case expect
441*0a6a1f1dSLionel Sambuc    atf_add_test_case oflag
442*0a6a1f1dSLionel Sambuc    atf_add_test_case output_csv
443*0a6a1f1dSLionel Sambuc    atf_add_test_case output_ticker
444*0a6a1f1dSLionel Sambuc    atf_add_test_case output_xml
445*0a6a1f1dSLionel Sambuc    atf_add_test_case output_xml_space
446*0a6a1f1dSLionel Sambuc    atf_add_test_case too_many_args
447*0a6a1f1dSLionel Sambuc}
448*0a6a1f1dSLionel Sambuc
449*0a6a1f1dSLionel Sambuc# vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4
450