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 # -------------------------------------------------------------------------
27 # Helper tests for "t_atf_check".
28 # -------------------------------------------------------------------------
30 atf_test_case atf_check_info_ok
31 atf_check_info_ok_head()
33 atf_set "descr" "Helper test case for the t_atf_check test program"
35 atf_check_info_ok_body()
37 atf_check -s eq:0 -o empty -e empty true
40 atf_test_case atf_check_info_fail
41 atf_check_info_fail_head()
43 atf_set "descr" "Helper test case for the t_atf_check test program"
45 atf_check_info_fail_body()
47 # In Solaris, /usr/bin/false returns 255 rather than 1. Use the
48 # built-in version for the check.
49 atf_check -s eq:1 -o empty -e empty sh -c "false"
52 atf_test_case atf_check_expout_mismatch
53 atf_check_expout_mismatch_head()
55 atf_set "descr" "Helper test case for the t_atf_check test program"
57 atf_check_expout_mismatch_body()
59 cat >expout <<SECONDEOF
62 atf_check -s eq:0 -o file:expout -e empty echo bar
65 atf_test_case atf_check_experr_mismatch
66 atf_check_experr_mismatch_head()
68 atf_set "descr" "Helper test case for the t_atf_check test program"
70 atf_check_experr_mismatch_body()
72 cat >experr <<SECONDEOF
75 atf_check -s eq:0 -o empty -e file:experr -x 'echo bar 1>&2'
78 atf_test_case atf_check_null_stdout
79 atf_check_null_stdout_head()
81 atf_set "descr" "Helper test case for the t_atf_check test program"
83 atf_check_null_stdout_body()
85 atf_check -s eq:0 -o empty -e empty echo "These are the contents"
88 atf_test_case atf_check_null_stderr
89 atf_check_null_stderr_head()
91 atf_set "descr" "Helper test case for the t_atf_check test program"
93 atf_check_null_stderr_body()
95 atf_check -s eq:0 -o empty -e empty -x 'echo "These are the contents" 1>&2'
98 atf_test_case atf_check_equal_ok
99 atf_check_equal_ok_head()
101 atf_set "descr" "Helper test case for the t_atf_check test program"
103 atf_check_equal_ok_body()
108 atf_test_case atf_check_equal_fail
109 atf_check_equal_fail_head()
111 atf_set "descr" "Helper test case for the t_atf_check test program"
113 atf_check_equal_fail_body()
118 atf_test_case atf_check_equal_eval_ok
119 atf_check_equal_eval_ok_head()
121 atf_set "descr" "Helper test case for the t_atf_check test program"
123 atf_check_equal_eval_ok_body()
127 atf_check_equal '${x}' '${y}'
130 atf_test_case atf_check_equal_eval_fail
131 atf_check_equal_eval_fail_head()
133 atf_set "descr" "Helper test case for the t_atf_check test program"
135 atf_check_equal_eval_fail_body()
139 atf_check_equal '${x}' '${y}'
142 atf_test_case atf_check_timeout
143 atf_check_timeout_head()
145 atf_set "descr" "Helper test case for the t_atf_check test program"
148 atf_check_timeout_body()
154 # -------------------------------------------------------------------------
155 # Helper tests for "t_config".
156 # -------------------------------------------------------------------------
158 atf_test_case config_get
161 atf_set "descr" "Helper test case for the t_config test program"
165 if atf_config_has ${TEST_VARIABLE}; then
166 echo "${TEST_VARIABLE} = $(atf_config_get ${TEST_VARIABLE})"
170 atf_test_case config_has
173 atf_set "descr" "Helper test case for the t_config test program"
177 if atf_config_has ${TEST_VARIABLE}; then
178 echo "${TEST_VARIABLE} found"
180 echo "${TEST_VARIABLE} not found"
184 # -------------------------------------------------------------------------
185 # Helper tests for "t_normalize".
186 # -------------------------------------------------------------------------
188 atf_test_case normalize
191 atf_set "descr" "Helper test case for the t_normalize test program"
192 atf_set "a.b" "test value 1"
193 atf_set "c-d" "test value 2"
197 echo "a.b: $(atf_get a.b)"
198 echo "c-d: $(atf_get c-d)"
201 # -------------------------------------------------------------------------
202 # Helper tests for "t_tc".
203 # -------------------------------------------------------------------------
205 atf_test_case tc_pass_true
208 atf_set "descr" "Helper test case for the t_tc test program"
215 atf_test_case tc_pass_false
218 atf_set "descr" "Helper test case for the t_tc test program"
225 atf_test_case tc_pass_return_error
226 tc_pass_return_error_head()
228 atf_set "descr" "Helper test case for the t_tc test program"
230 tc_pass_return_error_body()
235 atf_test_case tc_fail
238 atf_set "descr" "Helper test case for the t_tc test program"
246 atf_test_case tc_missing_body
247 tc_missing_body_head()
249 atf_set "descr" "Helper test case for the t_tc test program"
252 # -------------------------------------------------------------------------
253 # Helper tests for "t_tp".
254 # -------------------------------------------------------------------------
256 atf_test_case tp_srcdir
259 atf_set "descr" "Helper test case for the t_tp test program"
263 echo "Calling helper"
264 helper_subr || atf_fail "Could not call helper subroutine"
267 # -------------------------------------------------------------------------
269 # -------------------------------------------------------------------------
271 atf_init_test_cases()
273 # Add helper tests for t_atf_check.
274 atf_add_test_case atf_check_info_ok
275 atf_add_test_case atf_check_info_fail
276 atf_add_test_case atf_check_expout_mismatch
277 atf_add_test_case atf_check_experr_mismatch
278 atf_add_test_case atf_check_null_stdout
279 atf_add_test_case atf_check_null_stderr
280 atf_add_test_case atf_check_equal_ok
281 atf_add_test_case atf_check_equal_fail
282 atf_add_test_case atf_check_equal_eval_ok
283 atf_add_test_case atf_check_equal_eval_fail
284 atf_add_test_case atf_check_timeout
286 # Add helper tests for t_config.
287 atf_add_test_case config_get
288 atf_add_test_case config_has
290 # Add helper tests for t_normalize.
291 atf_add_test_case normalize
293 # Add helper tests for t_tc.
294 atf_add_test_case tc_pass_true
295 atf_add_test_case tc_pass_false
296 atf_add_test_case tc_pass_return_error
297 atf_add_test_case tc_fail
298 atf_add_test_case tc_missing_body
300 # Add helper tests for t_tp.
301 [ -f $(atf_get_srcdir)/subrs ] && . $(atf_get_srcdir)/subrs
302 atf_add_test_case tp_srcdir
305 # vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4