tools/llvm: Do not build with symbols
[minix3.git] / external / bsd / atf / dist / test-programs / result_test.sh
blobb2b325c4daeef79d0197f3a5fde109ed367fa082
2 # Automated Testing Framework (atf)
4 # Copyright (c) 2007 The NetBSD Foundation, Inc.
5 # All rights reserved.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
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.
30 atf_test_case atf_run_warnings
31 atf_run_warnings_head()
33 # The fact that this test case is in this test program is an abuse.
34 atf_set "descr" "Tests that the test case prints a warning because" \
35 "it is not being run by atf-run"
37 atf_run_warnings_body()
39 unset __RUNNING_INSIDE_ATF_RUN
40 srcdir="$(atf_get_srcdir)"
41 for h in $(get_helpers); do
42 atf_check -s eq:0 -o match:"passed" -e match:"WARNING.*atf-run" \
43 "${h}" -s "${srcdir}" result_pass
44 done
47 atf_test_case result_on_stdout
48 result_on_stdout_head()
50 atf_set "descr" "Tests that the test case result is printed on stdout" \
51 "by default"
53 result_on_stdout_body()
55 srcdir="$(atf_get_srcdir)"
56 for h in $(get_helpers); do
57 atf_check -s eq:0 -o match:"passed" -o match:"msg" \
58 -e ignore "${h}" -s "${srcdir}" result_pass
59 atf_check -s eq:1 -o match:"failed: Failure reason" -o match:"msg" \
60 -e ignore "${h}" -s "${srcdir}" result_fail
61 atf_check -s eq:0 -o match:"skipped: Skipped reason" -o match:"msg" \
62 -e ignore "${h}" -s "${srcdir}" result_skip
63 done
66 atf_test_case result_to_file
67 result_to_file_head()
69 atf_set "descr" "Tests that the test case result is sent to a file if -r" \
70 "is used"
72 result_to_file_body()
74 srcdir="$(atf_get_srcdir)"
75 for h in $(get_helpers); do
76 atf_check -s eq:0 -o inline:"msg\n" -e ignore "${h}" -s "${srcdir}" \
77 -r resfile result_pass
78 atf_check -o inline:"passed\n" cat resfile
80 atf_check -s eq:1 -o inline:"msg\n" -e ignore "${h}" -s "${srcdir}" \
81 -r resfile result_fail
82 atf_check -o inline:"failed: Failure reason\n" cat resfile
84 atf_check -s eq:0 -o inline:"msg\n" -e ignore "${h}" -s "${srcdir}" \
85 -r resfile result_skip
86 atf_check -o inline:"skipped: Skipped reason\n" cat resfile
87 done
90 atf_test_case result_to_file_fail
91 result_to_file_fail_head()
93 atf_set "descr" "Tests controlled failure if the test program fails to" \
94 "create the results file"
95 atf_set "require.user" "unprivileged"
97 result_to_file_fail_body()
99 mkdir dir
100 chmod 444 dir
102 srcdir="$(atf_get_srcdir)"
104 for h in $(get_helpers c_helpers cpp_helpers); do
105 atf_check -s signal -o ignore \
106 -e match:"FATAL ERROR: Cannot create.*'dir/resfile'" \
107 "${h}" -s "${srcdir}" -r dir/resfile result_pass
108 done
110 for h in $(get_helpers sh_helpers); do
111 atf_check -s exit -o ignore \
112 -e match:"ERROR: Cannot create.*'dir/resfile'" \
113 "${h}" -s "${srcdir}" -r dir/resfile result_pass
114 done
117 atf_test_case result_exception
118 result_exception_head()
120 atf_set "descr" "Tests that an unhandled exception is correctly captured"
122 result_exception_body()
124 for h in $(get_helpers cpp_helpers); do
125 atf_check -s exit:1 -o match:'failed: .*This is unhandled' \
126 "${h}" -s "${srcdir}" result_exception
127 done
130 atf_init_test_cases()
132 atf_add_test_case atf_run_warnings
133 atf_add_test_case result_on_stdout
134 atf_add_test_case result_to_file
135 atf_add_test_case result_to_file_fail
136 atf_add_test_case result_exception
139 # vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4