Remove building with NOCRYPTO option
[minix.git] / external / bsd / atf / dist / atf-sh / atf_check_test.sh
blob2460344f40a56e311af432043b0a2a046a50bb79
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 # TODO: Bring in the checks in the bootstrap testsuite for atf_check.
32 atf_test_case info_ok
33 info_ok_head()
35 atf_set "descr" "Verifies that atf_check prints an informative" \
36 "message even when the command is successful"
38 info_ok_body()
40 h="$(atf_get_srcdir)/misc_helpers -s $(atf_get_srcdir)"
42 atf_check -s eq:0 -o save:stdout -e save:stderr -x \
43 "${h} atf_check_info_ok"
44 grep 'Executing command.*true' stdout >/dev/null || \
45 atf_fail "atf_check does not print an informative message"
47 atf_check -s eq:0 -o save:stdout -e save:stderr -x \
48 "${h} atf_check_info_fail"
49 grep 'Executing command.*false' stdout >/dev/null || \
50 atf_fail "atf_check does not print an informative message"
53 atf_test_case expout_mismatch
54 expout_mismatch_head()
56 atf_set "descr" "Verifies that atf_check prints a diff of the" \
57 "stdout and the expected stdout if the two do not" \
58 "match"
60 expout_mismatch_body()
62 h="$(atf_get_srcdir)/misc_helpers -s $(atf_get_srcdir)"
64 atf_check -s eq:1 -o save:stdout -e save:stderr -x \
65 "${h} atf_check_expout_mismatch"
66 grep 'Executing command.*echo bar' stdout >/dev/null || \
67 atf_fail "atf_check does not print an informative message"
68 grep 'stdout does not match golden output' stderr >/dev/null || \
69 atf_fail "atf_check does not print the stdout header"
70 grep 'stderr' stderr >/dev/null && \
71 atf_fail "atf_check prints the stderr header"
72 grep '^-foo' stderr >/dev/null || \
73 atf_fail "atf_check does not print the stdout's diff"
74 grep '^+bar' stderr >/dev/null || \
75 atf_fail "atf_check does not print the stdout's diff"
78 atf_test_case experr_mismatch
79 experr_mismatch_head()
81 atf_set "descr" "Verifies that atf_check prints a diff of the" \
82 "stderr and the expected stderr if the two do not" \
83 "match"
85 experr_mismatch_body()
87 h="$(atf_get_srcdir)/misc_helpers -s $(atf_get_srcdir)"
89 atf_check -s eq:1 -o save:stdout -e save:stderr -x \
90 "${h} atf_check_experr_mismatch"
91 grep 'Executing command.*echo bar' stdout >/dev/null || \
92 atf_fail "atf_check does not print an informative message"
93 grep 'stdout' stderr >/dev/null && \
94 atf_fail "atf_check prints the stdout header"
95 grep 'stderr does not match golden output' stderr >/dev/null || \
96 atf_fail "atf_check does not print the stderr header"
97 grep '^-foo' stderr >/dev/null || \
98 atf_fail "atf_check does not print the stderr's diff"
99 grep '^+bar' stderr >/dev/null || \
100 atf_fail "atf_check does not print the stderr's diff"
103 atf_test_case null_stdout
104 null_stdout_head()
106 atf_set "descr" "Verifies that atf_check prints a the stdout it got" \
107 "when it was supposed to be null"
109 null_stdout_body()
111 h="$(atf_get_srcdir)/misc_helpers -s $(atf_get_srcdir)"
113 atf_check -s eq:1 -o save:stdout -e save:stderr -x \
114 "${h} atf_check_null_stdout"
115 grep 'Executing command.*echo.*These.*contents' stdout >/dev/null || \
116 atf_fail "atf_check does not print an informative message"
117 grep 'stdout not empty' stderr >/dev/null || \
118 atf_fail "atf_check does not print the stdout header"
119 grep 'stderr' stderr >/dev/null && \
120 atf_fail "atf_check prints the stderr header"
121 grep 'These are the contents' stderr >/dev/null || \
122 atf_fail "atf_check does not print stdout's contents"
125 atf_test_case null_stderr
126 null_stderr_head()
128 atf_set "descr" "Verifies that atf_check prints a the stderr it got" \
129 "when it was supposed to be null"
131 null_stderr_body()
133 h="$(atf_get_srcdir)/misc_helpers -s $(atf_get_srcdir)"
135 atf_check -s eq:1 -o save:stdout -e save:stderr -x \
136 "${h} atf_check_null_stderr"
137 grep 'Executing command.*echo.*These.*contents' stdout >/dev/null || \
138 atf_fail "atf_check does not print an informative message"
139 grep 'stdout' stderr >/dev/null && \
140 atf_fail "atf_check prints the stdout header"
141 grep 'stderr not empty' stderr >/dev/null || \
142 atf_fail "atf_check does not print the stderr header"
143 grep 'These are the contents' stderr >/dev/null || \
144 atf_fail "atf_check does not print stderr's contents"
147 atf_test_case equal
148 equal_head()
150 atf_set "descr" "Verifies that atf_check_equal works"
152 equal_body()
154 h="$(atf_get_srcdir)/misc_helpers -s $(atf_get_srcdir)"
156 atf_check -s eq:0 -o ignore -e ignore -x "${h} atf_check_equal_ok"
158 atf_check -s eq:1 -o ignore -e ignore -x \
159 "${h} -r resfile atf_check_equal_fail"
160 atf_check -s eq:0 -o ignore -e empty grep '^failed: a != b (a != b)$' \
161 resfile
163 atf_check -s eq:0 -o ignore -e ignore -x "${h} atf_check_equal_eval_ok"
165 atf_check -s eq:1 -o ignore -e ignore -x \
166 "${h} -r resfile atf_check_equal_eval_fail"
167 atf_check -s eq:0 -o ignore -e empty \
168 grep '^failed: \${x} != \${y} (a != b)$' resfile
171 atf_test_case flush_stdout_on_timeout
172 flush_stdout_on_timeout_body()
174 "$(atf_get_srcdir)/misc_helpers" -s "$(atf_get_srcdir)" atf_check_timeout \
175 >out 2>err &
176 pid="${!}"
177 sleep 10
178 kill "${pid}"
180 grep 'Executing command.*true' out \
181 || atf_fail 'First command not in output'
182 grep 'Executing command.*sleep 42' out \
183 || atf_fail 'Second command not in output'
186 atf_init_test_cases()
188 atf_add_test_case info_ok
189 atf_add_test_case expout_mismatch
190 atf_add_test_case experr_mismatch
191 atf_add_test_case null_stdout
192 atf_add_test_case null_stderr
193 atf_add_test_case equal
194 atf_add_test_case flush_stdout_on_timeout
197 # vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4