1 # Copyright (c) 2007 The NetBSD Foundation, Inc.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
7 # 1. Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # 2. Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
13 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
14 # CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
15 # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 # IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
18 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20 # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22 # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24 # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 atf_test_case runtime_warnings
27 runtime_warnings_head()
29 # The fact that this test case is in this test program is an abuse.
30 atf_set "descr" "Tests that the test case prints a warning because" \
31 "it is being run outside of a runtime engine"
33 runtime_warnings_body()
35 unset __RUNNING_INSIDE_ATF_RUN
36 srcdir="$(atf_get_srcdir)"
37 for h in $(get_helpers); do
38 atf_check -s eq:0 -o match:"passed" -e match:"WARNING.*kyua" \
39 "${h}" -s "${srcdir}" result_pass
43 atf_test_case result_on_stdout
44 result_on_stdout_head()
46 atf_set "descr" "Tests that the test case result is printed on stdout" \
49 result_on_stdout_body()
51 srcdir="$(atf_get_srcdir)"
52 for h in $(get_helpers); do
53 atf_check -s eq:0 -o match:"passed" -o match:"msg" \
54 -e ignore "${h}" -s "${srcdir}" result_pass
55 atf_check -s eq:1 -o match:"failed: Failure reason" -o match:"msg" \
56 -e ignore "${h}" -s "${srcdir}" result_fail
57 atf_check -s eq:0 -o match:"skipped: Skipped reason" -o match:"msg" \
58 -e ignore "${h}" -s "${srcdir}" result_skip
62 atf_test_case result_to_file
65 atf_set "descr" "Tests that the test case result is sent to a file if -r" \
70 srcdir="$(atf_get_srcdir)"
71 for h in $(get_helpers); do
72 atf_check -s eq:0 -o inline:"msg\n" -e ignore "${h}" -s "${srcdir}" \
73 -r resfile result_pass
74 atf_check -o inline:"passed\n" cat resfile
76 atf_check -s eq:1 -o inline:"msg\n" -e ignore "${h}" -s "${srcdir}" \
77 -r resfile result_fail
78 atf_check -o inline:"failed: Failure reason\n" cat resfile
80 atf_check -s eq:0 -o inline:"msg\n" -e ignore "${h}" -s "${srcdir}" \
81 -r resfile result_skip
82 atf_check -o inline:"skipped: Skipped reason\n" cat resfile
86 atf_test_case result_to_file_fail
87 result_to_file_fail_head()
89 atf_set "descr" "Tests controlled failure if the test program fails to" \
90 "create the results file"
91 atf_set "require.user" "unprivileged"
93 result_to_file_fail_body()
98 srcdir="$(atf_get_srcdir)"
100 for h in $(get_helpers c_helpers cpp_helpers); do
101 atf_check -s signal -o ignore \
102 -e match:"FATAL ERROR: Cannot create.*'dir/resfile'" \
103 "${h}" -s "${srcdir}" -r dir/resfile result_pass
106 for h in $(get_helpers sh_helpers); do
107 atf_check -s exit -o ignore \
108 -e match:"ERROR: Cannot create.*'dir/resfile'" \
109 "${h}" -s "${srcdir}" -r dir/resfile result_pass
113 atf_test_case result_exception
114 result_exception_head()
116 atf_set "descr" "Tests that an unhandled exception is correctly captured"
118 result_exception_body()
120 for h in $(get_helpers cpp_helpers); do
121 atf_check -s signal -o not-match:'failed: .*This is unhandled' \
122 -e ignore "${h}" -s "${srcdir}" result_exception
126 atf_init_test_cases()
128 atf_add_test_case runtime_warnings
129 atf_add_test_case result_on_stdout
130 atf_add_test_case result_to_file
131 atf_add_test_case result_to_file_fail
132 atf_add_test_case result_exception
135 # vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4