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.
29 atf_check -s eq:0 -o match:"${*}" -e empty cat "${file}"
33 atf_test_case expect_pass
35 for h in $(get_helpers); do
36 atf_check -s eq:0 -e ignore "${h}" -r result expect_pass_and_pass
37 check_result result "passed"
39 atf_check -s eq:1 -e ignore "${h}" -r result \
40 expect_pass_but_fail_requirement
41 check_result result "failed: Some reason"
43 # atf-sh does not support non-fatal failures yet; skip checks for
45 case "${h}" in *sh_helpers*) continue ;; esac
47 atf_check -s eq:1 -o empty -e match:"Some reason" \
48 "${h}" -r result expect_pass_but_fail_check
49 check_result result "failed: 1 checks failed"
53 atf_test_case expect_fail
55 for h in $(get_helpers c_helpers cpp_helpers); do
56 atf_check -s eq:0 "${h}" -r result expect_fail_and_fail_requirement
57 check_result result "expected_failure: Fail reason: The failure"
59 atf_check -s eq:1 -e match:"Expected check failure: Fail first: abc" \
60 -e not-match:"And fail again" "${h}" -r result expect_fail_but_pass
61 check_result result "failed: .*expecting a failure"
63 # atf-sh does not support non-fatal failures yet; skip checks for
65 case "${h}" in *sh_helpers*) continue ;; esac
67 atf_check -s eq:0 -e match:"Expected check failure: Fail first: abc" \
68 -e match:"Expected check failure: And fail again: def" \
69 "${h}" -r result expect_fail_and_fail_check
70 check_result result "expected_failure: And fail again: 2 checks" \
74 # atf-sh does not support non-fatal failures yet; skip checks for
76 for h in $(get_helpers sh_helpers); do
77 atf_check -s eq:0 -e ignore "${h}" -r result \
78 expect_fail_and_fail_requirement
79 check_result result "expected_failure: Fail reason: The failure"
81 atf_check -s eq:1 -e ignore "${h}" -r result expect_fail_but_pass
82 check_result result "failed: .*expecting a failure"
86 atf_test_case expect_exit
88 for h in $(get_helpers); do
89 atf_check -s eq:0 -e ignore "${h}" -r result expect_exit_any_and_exit
90 check_result result "expected_exit: Call will exit"
92 atf_check -s eq:123 -e ignore "${h}" -r result expect_exit_code_and_exit
93 check_result result "expected_exit\(123\): Call will exit"
95 atf_check -s eq:1 -e ignore "${h}" -r result expect_exit_but_pass
96 check_result result "failed: .*expected to exit"
100 atf_test_case expect_signal
101 expect_signal_body() {
102 for h in $(get_helpers); do
103 atf_check -s signal:9 -e ignore "${h}" -r result \
104 expect_signal_any_and_signal
105 check_result result "expected_signal: Call will signal"
107 atf_check -s signal:hup -e ignore "${h}" -r result \
108 expect_signal_no_and_signal
109 check_result result "expected_signal\(1\): Call will signal"
111 atf_check -s eq:1 -e ignore "${h}" -r result \
112 expect_signal_but_pass
113 check_result result "failed: .*termination signal"
117 atf_test_case expect_death
118 expect_death_body() {
119 for h in $(get_helpers); do
120 atf_check -s eq:123 -e ignore "${h}" -r result expect_death_and_exit
121 check_result result "expected_death: Exit case"
123 atf_check -s signal:kill -e ignore "${h}" -r result \
124 expect_death_and_signal
125 check_result result "expected_death: Signal case"
127 atf_check -s eq:1 -e ignore "${h}" -r result expect_death_but_pass
128 check_result result "failed: .*terminate abruptly"
132 atf_test_case expect_timeout
133 expect_timeout_body() {
134 for h in $(get_helpers); do
135 atf_check -s eq:1 -e ignore "${h}" -r result expect_timeout_but_pass
136 check_result result "failed: Test case was expected to hang but it" \
137 "continued execution"
141 atf_init_test_cases()
143 atf_add_test_case expect_pass
144 atf_add_test_case expect_fail
145 atf_add_test_case expect_exit
146 atf_add_test_case expect_signal
147 atf_add_test_case expect_death
148 atf_add_test_case expect_timeout
151 # vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4