blob: 68e0dc37442973d65a331525c21833a667456797 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
init_tests \
rc_service_usage \
rc_service_not_exists \
rc_service_exists \
rc_service_start \
rc_service_start_quiet \
rc_service_already_started \
rc_service_stop \
rc_service_stop_quiet \
rc_service_already_stopped \
rc_service_ifstarted_stop \
rc_service_ifstarted_start \
rc_service_ifstopped_start \
rc_service_ifstopped_stop \
rc_service_restart_stopped \
rc_service_restart_started \
rc_service_status_stopped \
rc_service_status_started
test_started() {
test -e run/started/$1 || atf_fail "$1 was not started"
}
test_stopped() {
! test -e run/started/$1 || atf_fail "$1 was not stopped"
}
rc_service_usage_body() {
test_usage rc-service
}
rc_service_not_exists_body() {
init_env
atf_check -s exit:1 \
-o empty \
-e empty \
rc-service --exist foo
}
rc_service_exists_body() {
init_env
mkdir -p etc/init.d
touch etc/init.d/foo
atf_check -s exit:0 \
-o empty \
-e empty \
rc-service --exist foo
}
rc_service_start_body() {
init_env
atf_check -s exit:0 \
-o match:"Starting foo" \
-e empty \
rc-service foo start
test_started foo
}
rc_service_start_quiet_body() {
init_env
atf_check -s exit:0 \
-o empty \
-e empty \
rc-service --quiet foo start
test_started foo
}
rc_service_already_started_body() {
init_env
rc-service --quiet foo start
atf_check -s exit:0 \
-o empty \
-e match:"WARNING: foo has already been started" \
rc-service foo start
atf_check -s exit:0 \
-o empty \
-e empty \
rc-service --quiet foo start
}
rc_service_stop_body() {
init_env
rc-service --quiet foo start
atf_check -s exit:0 \
-o match:"Stopping foo" \
-e empty \
rc-service foo stop
test_stopped foo
}
rc_service_stop_quiet_body() {
init_env
rc-service --quiet foo start
atf_check -s exit:0 \
-o empty \
-e empty \
rc-service --quiet foo stop
test_stopped foo
}
rc_service_already_stopped_body() {
init_env
atf_check -s exit:0 \
-o empty \
-e match:"WARNING: foo is already stopped" \
rc-service foo stop
atf_check -s exit:0 \
-o empty \
-e empty \
rc-service --quiet foo stop
}
rc_service_ifstarted_stop_body() {
init_env
atf_check -s exit:0 \
-o empty \
-e empty \
rc-service --ifstarted foo stop
rc-service --quiet foo start
atf_check -s exit:0 \
-o match:"Stopping foo" \
-e empty \
rc-service --ifstarted foo stop
}
rc_service_ifstarted_start_body() {
init_env
atf_check -s exit:0 \
-o empty \
-e empty \
rc-service --ifstarted foo start
rc-service --quiet foo start
atf_check -s exit:0 \
-o empty \
-e match:"WARNING: foo has already been started" \
rc-service --ifstarted foo start
}
rc_service_ifstopped_start_body() {
init_env
atf_check -s exit:0 \
-o match:"Starting foo" \
-e empty \
rc-service --ifstopped foo start
atf_check -s exit:0 \
-o empty \
-e empty \
rc-service --ifstopped foo start
}
rc_service_ifstopped_stop_body() {
init_env
atf_check -s exit:0 \
-o empty \
-e match:"WARNING: foo is already stopped" \
rc-service --ifstopped foo stop
rc-service --quiet foo start
atf_check -s exit:0 \
-o empty \
-e empty \
rc-service --ifstopped foo stop
}
rc_service_restart_started_body() {
init_env
rc-service --quiet foo start
atf_check -s exit:0 \
-o match:"Stopping foo" \
-o match:"Starting foo" \
-e empty \
rc-service foo restart
test_started foo
}
rc_service_restart_stopped_body() {
init_env
atf_check -s exit:0 \
-o match:"Starting foo" \
-e empty \
rc-service foo restart
test_started foo
}
rc_service_status_stopped_body() {
init_env
atf_check -s exit:3 \
-o match:"status: stopped" \
-e empty \
rc-service foo status
}
rc_service_status_started_body() {
init_env
rc-service --quiet foo start
atf_check -s exit:0 \
-o match:"status: started" \
-e empty \
rc-service foo status
}
|