tools/llvm: Do not build with symbols
[minix3.git] / external / bsd / atf / dist / atf-sh / misc_helpers.sh
blob8b72f0ae2b754785d1ee7fb9cf827123d1d146b6
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 # -------------------------------------------------------------------------
31 # Helper tests for "t_atf_check".
32 # -------------------------------------------------------------------------
34 atf_test_case atf_check_info_ok
35 atf_check_info_ok_head()
37 atf_set "descr" "Helper test case for the t_atf_check test program"
39 atf_check_info_ok_body()
41 atf_check -s eq:0 -o empty -e empty true
44 atf_test_case atf_check_info_fail
45 atf_check_info_fail_head()
47 atf_set "descr" "Helper test case for the t_atf_check test program"
49 atf_check_info_fail_body()
51 # In Solaris, /usr/bin/false returns 255 rather than 1. Use the
52 # built-in version for the check.
53 atf_check -s eq:1 -o empty -e empty sh -c "false"
56 atf_test_case atf_check_expout_mismatch
57 atf_check_expout_mismatch_head()
59 atf_set "descr" "Helper test case for the t_atf_check test program"
61 atf_check_expout_mismatch_body()
63 cat >expout <<SECONDEOF
64 foo
65 SECONDEOF
66 atf_check -s eq:0 -o file:expout -e empty echo bar
69 atf_test_case atf_check_experr_mismatch
70 atf_check_experr_mismatch_head()
72 atf_set "descr" "Helper test case for the t_atf_check test program"
74 atf_check_experr_mismatch_body()
76 cat >experr <<SECONDEOF
77 foo
78 SECONDEOF
79 atf_check -s eq:0 -o empty -e file:experr -x 'echo bar 1>&2'
82 atf_test_case atf_check_null_stdout
83 atf_check_null_stdout_head()
85 atf_set "descr" "Helper test case for the t_atf_check test program"
87 atf_check_null_stdout_body()
89 atf_check -s eq:0 -o empty -e empty echo "These are the contents"
92 atf_test_case atf_check_null_stderr
93 atf_check_null_stderr_head()
95 atf_set "descr" "Helper test case for the t_atf_check test program"
97 atf_check_null_stderr_body()
99 atf_check -s eq:0 -o empty -e empty -x 'echo "These are the contents" 1>&2'
102 atf_test_case atf_check_equal_ok
103 atf_check_equal_ok_head()
105 atf_set "descr" "Helper test case for the t_atf_check test program"
107 atf_check_equal_ok_body()
109 atf_check_equal a a
112 atf_test_case atf_check_equal_fail
113 atf_check_equal_fail_head()
115 atf_set "descr" "Helper test case for the t_atf_check test program"
117 atf_check_equal_fail_body()
119 atf_check_equal a b
122 atf_test_case atf_check_equal_eval_ok
123 atf_check_equal_eval_ok_head()
125 atf_set "descr" "Helper test case for the t_atf_check test program"
127 atf_check_equal_eval_ok_body()
131 atf_check_equal '${x}' '${y}'
134 atf_test_case atf_check_equal_eval_fail
135 atf_check_equal_eval_fail_head()
137 atf_set "descr" "Helper test case for the t_atf_check test program"
139 atf_check_equal_eval_fail_body()
143 atf_check_equal '${x}' '${y}'
146 # -------------------------------------------------------------------------
147 # Helper tests for "t_config".
148 # -------------------------------------------------------------------------
150 atf_test_case config_get
151 config_get_head()
153 atf_set "descr" "Helper test case for the t_config test program"
155 config_get_body()
157 if atf_config_has ${TEST_VARIABLE}; then
158 echo "${TEST_VARIABLE} = $(atf_config_get ${TEST_VARIABLE})"
162 atf_test_case config_has
163 config_has_head()
165 atf_set "descr" "Helper test case for the t_config test program"
167 config_has_body()
169 if atf_config_has ${TEST_VARIABLE}; then
170 echo "${TEST_VARIABLE} found"
171 else
172 echo "${TEST_VARIABLE} not found"
176 # -------------------------------------------------------------------------
177 # Helper tests for "t_normalize".
178 # -------------------------------------------------------------------------
180 atf_test_case normalize
181 normalize_head()
183 atf_set "descr" "Helper test case for the t_normalize test program"
184 atf_set "a.b" "test value 1"
185 atf_set "c-d" "test value 2"
187 normalize_body()
189 echo "a.b: $(atf_get a.b)"
190 echo "c-d: $(atf_get c-d)"
193 # -------------------------------------------------------------------------
194 # Helper tests for "t_tc".
195 # -------------------------------------------------------------------------
197 atf_test_case tc_pass_true
198 tc_pass_true_head()
200 atf_set "descr" "Helper test case for the t_tc test program"
202 tc_pass_true_body()
204 true
207 atf_test_case tc_pass_false
208 tc_pass_false_head()
210 atf_set "descr" "Helper test case for the t_tc test program"
212 tc_pass_false_body()
214 false
217 atf_test_case tc_pass_return_error
218 tc_pass_return_error_head()
220 atf_set "descr" "Helper test case for the t_tc test program"
222 tc_pass_return_error_body()
224 return 1
227 atf_test_case tc_fail
228 tc_fail_head()
230 atf_set "descr" "Helper test case for the t_tc test program"
232 tc_fail_body()
234 echo "An error" 1>&2
235 exit 1
238 atf_test_case tc_missing_body
239 tc_missing_body_head()
241 atf_set "descr" "Helper test case for the t_tc test program"
244 # -------------------------------------------------------------------------
245 # Helper tests for "t_tp".
246 # -------------------------------------------------------------------------
248 atf_test_case tp_srcdir
249 tp_srcdir_head()
251 atf_set "descr" "Helper test case for the t_tp test program"
253 tp_srcdir_body()
255 echo "Calling helper"
256 helper_subr || atf_fail "Could not call helper subroutine"
259 # -------------------------------------------------------------------------
260 # Main.
261 # -------------------------------------------------------------------------
263 atf_init_test_cases()
265 # Add helper tests for t_atf_check.
266 atf_add_test_case atf_check_info_ok
267 atf_add_test_case atf_check_info_fail
268 atf_add_test_case atf_check_expout_mismatch
269 atf_add_test_case atf_check_experr_mismatch
270 atf_add_test_case atf_check_null_stdout
271 atf_add_test_case atf_check_null_stderr
272 atf_add_test_case atf_check_equal_ok
273 atf_add_test_case atf_check_equal_fail
274 atf_add_test_case atf_check_equal_eval_ok
275 atf_add_test_case atf_check_equal_eval_fail
277 # Add helper tests for t_config.
278 atf_add_test_case config_get
279 atf_add_test_case config_has
281 # Add helper tests for t_normalize.
282 atf_add_test_case normalize
284 # Add helper tests for t_tc.
285 atf_add_test_case tc_pass_true
286 atf_add_test_case tc_pass_false
287 atf_add_test_case tc_pass_return_error
288 atf_add_test_case tc_fail
289 atf_add_test_case tc_missing_body
291 # Add helper tests for t_tp.
292 [ -f $(atf_get_srcdir)/subrs ] && . $(atf_get_srcdir)/subrs
293 atf_add_test_case tp_srcdir
296 # vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4