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_cleanup".
28 # -------------------------------------------------------------------------
30 atf_test_case cleanup_pass cleanup
33 atf_set "descr" "Helper test case for the t_cleanup test program"
37 touch $(atf_config_get tmpfile)
39 cleanup_pass_cleanup()
41 if [ $(atf_config_get cleanup no) = yes ]; then
42 rm $(atf_config_get tmpfile)
46 atf_test_case cleanup_fail cleanup
49 atf_set "descr" "Helper test case for the t_cleanup test program"
53 touch $(atf_config_get tmpfile)
56 cleanup_fail_cleanup()
58 if [ $(atf_config_get cleanup no) = yes ]; then
59 rm $(atf_config_get tmpfile)
63 atf_test_case cleanup_skip cleanup
66 atf_set "descr" "Helper test case for the t_cleanup test program"
70 touch $(atf_config_get tmpfile)
73 cleanup_skip_cleanup()
75 if [ $(atf_config_get cleanup no) = yes ]; then
76 rm $(atf_config_get tmpfile)
80 atf_test_case cleanup_curdir cleanup
83 atf_set "descr" "Helper test case for the t_cleanup test program"
89 cleanup_curdir_cleanup()
91 test -f oldvalue && echo "Old value: $(cat oldvalue)"
94 atf_test_case cleanup_sigterm cleanup
95 cleanup_sigterm_head()
97 atf_set "descr" "Helper test case for the t_cleanup test program"
99 cleanup_sigterm_body()
101 touch $(atf_config_get tmpfile)
103 touch $(atf_config_get tmpfile).no
105 cleanup_sigterm_cleanup()
107 rm $(atf_config_get tmpfile)
110 # -------------------------------------------------------------------------
111 # Helper tests for "t_config".
112 # -------------------------------------------------------------------------
114 atf_test_case config_unset
117 atf_set "descr" "Helper test case for the t_config test program"
121 if atf_config_has 'test'; then
122 atf_fail "Test variable already defined"
126 atf_test_case config_empty
129 atf_set "descr" "Helper test case for the t_config test program"
133 atf_check_equal "$(atf_config_get 'test')" ""
136 atf_test_case config_value
139 atf_set "descr" "Helper test case for the t_config test program"
143 atf_check_equal "$(atf_config_get 'test')" "foo"
146 atf_test_case config_multi_value
147 config_multi_value_head()
149 atf_set "descr" "Helper test case for the t_config test program"
151 config_multi_value_body()
153 atf_check_equal "$(atf_config_get 'test')" "foo bar"
156 # -------------------------------------------------------------------------
157 # Helper tests for "t_expect".
158 # -------------------------------------------------------------------------
160 atf_test_case expect_pass_and_pass
161 expect_pass_and_pass_body()
166 atf_test_case expect_pass_but_fail_requirement
167 expect_pass_but_fail_requirement_body()
170 atf_fail "Some reason"
173 atf_test_case expect_pass_but_fail_check
174 expect_pass_but_fail_check_body()
176 atf_fail "Non-fatal failures not implemented"
179 atf_test_case expect_fail_and_fail_requirement
180 expect_fail_and_fail_requirement_body()
182 atf_expect_fail "Fail reason"
183 atf_fail "The failure"
187 atf_test_case expect_fail_and_fail_check
188 expect_fail_and_fail_check_body()
190 atf_fail "Non-fatal failures not implemented"
193 atf_test_case expect_fail_but_pass
194 expect_fail_but_pass_body()
196 atf_expect_fail "Fail first"
200 atf_test_case expect_exit_any_and_exit
201 expect_exit_any_and_exit_body()
203 atf_expect_exit -1 "Call will exit"
207 atf_test_case expect_exit_code_and_exit
208 expect_exit_code_and_exit_body()
210 atf_expect_exit 123 "Call will exit"
214 atf_test_case expect_exit_but_pass
215 expect_exit_but_pass_body()
217 atf_expect_exit -1 "Call won't exit"
220 atf_test_case expect_signal_any_and_signal
221 expect_signal_any_and_signal_body()
223 atf_expect_signal -1 "Call will signal"
227 atf_test_case expect_signal_no_and_signal
228 expect_signal_no_and_signal_body()
230 atf_expect_signal 1 "Call will signal"
234 atf_test_case expect_signal_but_pass
235 expect_signal_but_pass_body()
237 atf_expect_signal -1 "Call won't signal"
240 atf_test_case expect_death_and_exit
241 expect_death_and_exit_body()
243 atf_expect_death "Exit case"
247 atf_test_case expect_death_and_signal
248 expect_death_and_signal_body()
250 atf_expect_death "Signal case"
254 atf_test_case expect_death_but_pass
255 expect_death_but_pass_body()
257 atf_expect_death "Call won't die"
260 atf_test_case expect_timeout_and_hang
261 expect_timeout_and_hang_head()
263 atf_set "timeout" "1"
265 expect_timeout_and_hang_body()
267 atf_expect_timeout "Will overrun"
271 atf_test_case expect_timeout_but_pass
272 expect_timeout_but_pass_head()
274 atf_set "timeout" "1"
276 expect_timeout_but_pass_body()
278 atf_expect_timeout "Will just exit"
281 # -------------------------------------------------------------------------
282 # Helper tests for "t_meta_data".
283 # -------------------------------------------------------------------------
285 atf_test_case metadata_no_descr
286 metadata_no_descr_head()
290 metadata_no_descr_body()
295 atf_test_case metadata_no_head
296 metadata_no_head_body()
301 # -------------------------------------------------------------------------
302 # Helper tests for "t_srcdir".
303 # -------------------------------------------------------------------------
305 atf_test_case srcdir_exists
308 atf_set "descr" "Helper test case for the t_srcdir test program"
312 [ -f "$(atf_get_srcdir)/datafile" ] || atf_fail "Cannot find datafile"
315 # -------------------------------------------------------------------------
316 # Helper tests for "t_result".
317 # -------------------------------------------------------------------------
319 atf_test_case result_pass
325 atf_test_case result_fail
329 atf_fail "Failure reason"
332 atf_test_case result_skip
336 atf_skip "Skipped reason"
339 # -------------------------------------------------------------------------
341 # -------------------------------------------------------------------------
343 atf_init_test_cases()
345 # Add helper tests for t_cleanup.
346 atf_add_test_case cleanup_pass
347 atf_add_test_case cleanup_fail
348 atf_add_test_case cleanup_skip
349 atf_add_test_case cleanup_curdir
350 atf_add_test_case cleanup_sigterm
352 # Add helper tests for t_config.
353 atf_add_test_case config_unset
354 atf_add_test_case config_empty
355 atf_add_test_case config_value
356 atf_add_test_case config_multi_value
358 # Add helper tests for t_expect.
359 atf_add_test_case expect_pass_and_pass
360 atf_add_test_case expect_pass_but_fail_requirement
361 atf_add_test_case expect_pass_but_fail_check
362 atf_add_test_case expect_fail_and_fail_requirement
363 atf_add_test_case expect_fail_and_fail_check
364 atf_add_test_case expect_fail_but_pass
365 atf_add_test_case expect_exit_any_and_exit
366 atf_add_test_case expect_exit_code_and_exit
367 atf_add_test_case expect_exit_but_pass
368 atf_add_test_case expect_signal_any_and_signal
369 atf_add_test_case expect_signal_no_and_signal
370 atf_add_test_case expect_signal_but_pass
371 atf_add_test_case expect_death_and_exit
372 atf_add_test_case expect_death_and_signal
373 atf_add_test_case expect_death_but_pass
374 atf_add_test_case expect_timeout_and_hang
375 atf_add_test_case expect_timeout_but_pass
377 # Add helper tests for t_meta_data.
378 atf_add_test_case metadata_no_descr
379 atf_add_test_case metadata_no_head
381 # Add helper tests for t_srcdir.
382 atf_add_test_case srcdir_exists
384 # Add helper tests for t_result.
385 atf_add_test_case result_pass
386 atf_add_test_case result_fail
387 atf_add_test_case result_skip
390 # vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4