etc/protocols - sync with NetBSD-8
[minix.git] / tests / sys / rc / t_rc_d_cli.sh
blobd97f8cca66386d62f0592c829f67a655eb1501a3
1 # $NetBSD: t_rc_d_cli.sh,v 1.4 2010/11/07 17:51:21 jmmv Exp $
3 # Copyright (c) 2010 The NetBSD Foundation, Inc.
4 # All rights reserved.
6 # This code is derived from software contributed to The NetBSD Foundation
7 # by Julio Merino.
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
11 # are met:
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 # POSSIBILITY OF SUCH DAMAGE.
31 atf_test_case no_command
32 no_command_head() {
33 atf_set "descr" "Tests that the lack of a command errors out"
35 no_command_body() {
36 export h_simple=YES
37 rc_helper=$(atf_get_srcdir)/h_simple
39 atf_check -s eq:1 -o empty -e ignore ${rc_helper}
42 atf_test_case default_start_no_args
43 default_start_no_args_head() {
44 atf_set "descr" "Tests that running the default 'start' without" \
45 "arguments does not error out"
47 default_start_no_args_body() {
48 export h_simple=YES
49 rc_helper=$(atf_get_srcdir)/h_simple
51 atf_check -s eq:0 -o ignore -e empty ${rc_helper} start
52 ${rc_helper} forcestop
55 atf_test_case default_start_with_args
56 default_start_with_args_head() {
57 atf_set "descr" "Tests that running the default 'start' with" \
58 "arguments errors out"
60 default_start_with_args_body() {
61 export h_simple=YES
62 rc_helper=$(atf_get_srcdir)/h_simple
64 atf_check -s eq:1 -o ignore -e ignore ${rc_helper} start foo
65 if ${rc_helper} status >/dev/null; then
66 ${rc_helper} forcestop
67 atf_fail 'extra argument to start did not error out'
71 atf_test_case default_stop_no_args
72 default_stop_no_args_head() {
73 atf_set "descr" "Tests that running the default 'stop' without" \
74 "arguments does not error out"
76 default_stop_no_args_body() {
77 export h_simple=YES
78 rc_helper=$(atf_get_srcdir)/h_simple
80 ${rc_helper} start
81 atf_check -s eq:0 -o ignore -e empty ${rc_helper} stop
84 atf_test_case default_stop_with_args
85 default_stop_with_args_head() {
86 atf_set "descr" "Tests that running the default 'stop' with" \
87 "arguments errors out"
89 default_stop_with_args_body() {
90 export h_simple=YES
91 rc_helper=$(atf_get_srcdir)/h_simple
93 ${rc_helper} start
94 atf_check -s eq:1 -o ignore -e ignore ${rc_helper} stop foo
95 if ${rc_helper} status >/dev/null; then
96 ${rc_helper} forcestop
97 else
98 atf_fail 'extra argument to stop did not error out'
102 atf_test_case default_restart_no_args
103 default_restart_no_args_head() {
104 atf_set "descr" "Tests that running the default 'restart' without" \
105 "arguments does not error out"
107 default_restart_no_args_body() {
108 export h_simple=YES
109 rc_helper=$(atf_get_srcdir)/h_simple
111 ${rc_helper} start
112 atf_check -s eq:0 -o ignore -e empty ${rc_helper} restart
113 ${rc_helper} forcestop
116 atf_test_case default_restart_with_args
117 default_restart_with_args_head() {
118 atf_set "descr" "Tests that running the default 'restart' with" \
119 "arguments errors out"
121 default_restart_with_args_body() {
122 export h_simple=YES
123 rc_helper=$(atf_get_srcdir)/h_simple
125 ${rc_helper} start
126 atf_check -s eq:1 -o ignore -e ignore ${rc_helper} restart foo
127 ${rc_helper} forcestop
130 do_overriden_no_args() {
131 local command="${1}"; shift
133 export h_args=YES
134 rc_helper=$(atf_get_srcdir)/h_args
136 cat >expout <<EOF
137 pre${command}:.
138 ${command}:.
139 post${command}:.
141 atf_check -s eq:0 -o file:expout -e empty ${rc_helper} ${command}
144 do_overriden_with_args() {
145 local command="${1}"; shift
147 export h_args=YES
148 rc_helper=$(atf_get_srcdir)/h_args
150 cat >expout <<EOF
151 pre${command}:.
152 ${command}: >arg1< > arg 2 < >arg3< >*<.
153 post${command}:.
155 atf_check -s eq:0 -o file:expout -e empty ${rc_helper} ${command} \
156 'arg1' ' arg 2 ' 'arg3' '*'
159 atf_test_case overriden_start_no_args
160 overriden_start_no_args_head() {
161 atf_set "descr" "Tests that running a custom 'start' without" \
162 "arguments does not pass any parameters to the command"
164 overriden_start_no_args_body() {
165 do_overriden_no_args start
168 atf_test_case overriden_start_with_args
169 overriden_start_with_args_head() {
170 atf_set "descr" "Tests that running a custom 'start' with" \
171 "arguments passes those arguments as parameters to the command"
173 overriden_start_with_args_body() {
174 do_overriden_with_args start
177 atf_test_case overriden_stop_no_args
178 overriden_stop_no_args_head() {
179 atf_set "descr" "Tests that running a custom 'stop' without" \
180 "arguments does not pass any parameters to the command"
182 overriden_stop_no_args_body() {
183 do_overriden_no_args stop
186 atf_test_case overriden_stop_with_args
187 overriden_stop_with_args_head() {
188 atf_set "descr" "Tests that running a custom 'stop' with" \
189 "arguments passes those arguments as parameters to the command"
191 overriden_stop_with_args_body() {
192 do_overriden_with_args stop
195 atf_test_case overriden_restart_no_args
196 overriden_restart_no_args_head() {
197 atf_set "descr" "Tests that running a custom 'restart' without" \
198 "arguments does not pass any parameters to the command"
200 overriden_restart_no_args_body() {
201 do_overriden_no_args restart
204 atf_test_case overriden_restart_with_args
205 overriden_restart_with_args_head() {
206 atf_set "descr" "Tests that running a custom 'restart' with" \
207 "arguments passes those arguments as parameters to the command"
209 overriden_restart_with_args_body() {
210 do_overriden_with_args restart
213 atf_test_case overriden_custom_no_args
214 overriden_custom_no_args_head() {
215 atf_set "descr" "Tests that running a custom command without" \
216 "arguments does not pass any parameters to the command"
218 overriden_custom_no_args_body() {
219 do_overriden_no_args custom
222 atf_test_case overriden_custom_with_args
223 overriden_custom_with_args_head() {
224 atf_set "descr" "Tests that running a custom command with" \
225 "arguments passes those arguments as parameters to the command"
227 overriden_custom_with_args_body() {
228 do_overriden_with_args custom
231 atf_init_test_cases()
233 atf_add_test_case no_command
235 atf_add_test_case default_start_no_args
236 atf_add_test_case default_start_with_args
237 atf_add_test_case default_stop_no_args
238 atf_add_test_case default_stop_with_args
239 atf_add_test_case default_restart_no_args
240 atf_add_test_case default_restart_with_args
242 atf_add_test_case overriden_start_no_args
243 atf_add_test_case overriden_start_with_args
244 atf_add_test_case overriden_stop_no_args
245 atf_add_test_case overriden_stop_with_args
246 atf_add_test_case overriden_restart_no_args
247 atf_add_test_case overriden_restart_with_args
248 atf_add_test_case overriden_custom_no_args
249 atf_add_test_case overriden_custom_with_args