1 #! /usr/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 ###############################################################################
29 # start __stf_assertion__
30 #
31 # ASSERTION: svccfg_delprop_003
32 #
33 # DESCRIPTION:
34 # If the property group, 'pg', specified in the
35 # 'delprop pg' subcommand does not exist in the selected
36 # entity then a diagnostic message is sent to stderr and
37 # the subcommand will exit with a status of 1.
38 #
39 #
40 # STRATEGY:
41 # Verify with the following conditions:
42 # #1: delete a property group that was never defined
43 # #2: delete a property group that was already deleted within the svccfg
44 # sessions.
45 # #3: delete a property group that was already deleted within
46 # another session.
47 #
48 # end __stf_assertion__
49 ###############################################################################
50
51
52 # First STF library
53 . ${STF_TOOLS}/include/stf.kshlib
54
55 # Load GL library
56 . ${STF_SUITE}/include/gltest.kshlib
57
58 # Assertion ID
59 readonly assertion=svccfg_delprop_003
60
61 readonly ME=$(whence -p ${0})
62 readonly MYLOC=$(dirname ${ME})
63
64 # Initialize test result
65 typeset -i RESULT=$STF_PASS
66
67 function cleanup {
68
69 # Note that $TEST_SERVICE may or may not exist so don't check
70 # results. Just make sure the service is gone.
71 service_delete $TEST_SERVICE > /dev/null 2>&1
72
73 service_exists ${TEST_SERVICE}
74 [[ $? -eq 0 ]] && {
75 echo "--DIAG: [${assertion}, cleanup]
76 service ${TEST_SERVICE} should not exist in
77 repository after being deleted, but does"
78
79 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
80 }
81
82 rm -f $OUTFILE $ERRFILE $CMDFILE
83 exit $RESULT
84 }
85
86 trap cleanup 0 1 2 15
87
88 # make sure that the environment is sane - svc.configd is up and running
89 check_gl_env
90 [[ $? -ne 0 ]] && {
91 echo "--DIAG:
92 Invalid test environment - svc.configd not available"
93
94 RESULT=$STF_UNRESOLVED
95 exit $RESULT
96 }
97
98 # extract and print assertion information from this source script.
99 extract_assertion_info $ME
100
101
102 cat << EOF > $CMDFILE
103 add $TEST_SERVICE
104 select $TEST_SERVICE
105 EOF
106
107 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
108 ret=$?
109 [[ $ret -ne 0 ]] && {
110 echo "--DIAG: [${assertion}, setup]
111 svccfg expected to return 0, got $ret
112 error output is $(cat $ERRFILE)"
113
114 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
115 exit $RESULT
116 }
117
118
119 #
120 # Test #1: delete a property that was never defined
121 #
122
123 echo "--INFO: Starting $assertion, test 1 (delete undefined property)"
124
125 typeset -i TEST_RESULT=$STF_PASS
126
127 # Call delprop with extra options
128
129 cat << EOF > $CMDFILE
130 select $TEST_SERVICE
131 delprop $TEST_PROPERTY
132 EOF
133
134
135 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
136 ret=$?
137
138 # Verify that the return value is as expected
139 [[ $ret -ne 1 ]] && {
140 echo "--DIAG: [${assertion}, test 1]
141 svccfg expected to return 1, got $ret"
142
143 TEST_RESULT=$STF_FAIL
144 }
145
146 # Verify that nothing in stdout
147 [[ -s $OUTFILE ]] && {
148 echo "--DIAG: [${assertion}, test 1]
149 did not expect stdout, but got:
150 $(cat $OUTFILE)"
151
152 TEST_RESULT=$STF_FAIL
153 }
154
155 # Verify that message in stderr - non-fatal error
156 if ! egrep -s "$NO_PROPGRP_ERRMSG" $ERRFILE
157 then
158 echo "--DIAG: [${assertion}, test 1]
159 Expected error message \"$NO_PROPGRP_ERRMSG\"
160 but got \"$(cat $ERRFILE)\""
161
162 TEST_RESULT=$STF_FAIL
163 fi
164
165
166 rm -f $OUTFILE $ERRFILE $CMDFILE
167
168 print_result $TEST_RESULT
169 RESULT=$(update_result $TEST_RESULT $RESULT)
170
171 #
172 # Test #2: delete a property that was already deleted within the
173 # svccfg sessions.
174 #
175
176 echo "--INFO: Starting $assertion, test 2 (delete already deleted "
177 echo "property in same session"
178
179 typeset -i TEST_RESULT=$STF_PASS
180
181 cat << EOF > $CMDFILE
182 select $TEST_SERVICE
183 addpg $TEST_PROPERTY framework
184 EOF
185
186 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
187 ret=$?
188 [[ $ret -ne 0 ]] && {
189 echo "--DIAG: [${assertion}, test 2]
190 svccfg expected to return 0, got $ret
191 error output is $(cat $ERRFILE)"
192
193 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
194 exit $RESULT
195 }
196
197 cat << EOF > $CMDFILE
198 select $TEST_SERVICE
199 delprop $TEST_PROPERTY
200 delprop $TEST_PROPERTY
201 EOF
202
203 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
204 ret=$?
205
206 # Verify that the return value is as expected
207 [[ $ret -ne 1 ]] && {
208 echo "--DIAG: [${assertion}, test 2]
209 svccfg expected to return 1, got $ret"
210
211 TEST_RESULT=$STF_FAIL
212 }
213
214 # Verify that nothing in stdout
215 [[ -s $OUTFILE ]] && {
216 echo "--DIAG: [${assertion}, test 2]
217 did not expect stdout, but got:
218 $(cat $OUTFILE)"
219
220 TEST_RESULT=$STF_FAIL
221 }
222
223 # Verify that message in stderr - non-fatal error
224 if ! egrep -s "$NO_PROPGRP_ERRMSG" $ERRFILE
225 then
226 echo "--DIAG: [${assertion}, test 2]
227 Expected error message \"$NO_PROPGRP_ERRMSG\"
228 but got \"$(cat $ERRFILE)\""
229
230 TEST_RESULT=$STF_FAIL
231 fi
232
233
234 rm -f $OUTFILE $ERRFILE $CMDFILE
235
236 print_result $TEST_RESULT
237 RESULT=$(update_result $TEST_RESULT $RESULT)
238
239
240 #
241 # Test #3: delete a property that was already deleted within another session.
242 #
243
244 typeset -i TEST_RESULT=$STF_PASS
245
246 echo "--INFO: Starting $assertion, test 3 (delete already deleted"
247 echo "property in different sessions"
248
249 cat << EOF > $CMDFILE
250 select $TEST_SERVICE
251 addpg $TEST_PROPERTY framework
252 EOF
253
254 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
255 ret=$?
256
257 # Verify that the return value is as expected
258 [[ $ret -ne 0 ]] && {
259 echo "--DIAG: [${assertion}, test 3]
260 svccfg expected to return 0, got $ret
261 error output is $(cat $ERRFILE)"
262
263 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
264 exit $RESULT
265 }
266
267 # Delete added property in this svccfg call.
268
269 cat << EOF > $CMDFILE
270 select $TEST_SERVICE
271 delprop $TEST_PROPERTY
272 EOF
273
274 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
275 ret=$?
276
277 # Verify that the return value is as expected
278 [[ $ret -ne 0 ]] && {
279 echo "--DIAG: [${assertion}, test 3]
280 svccfg expected to return 0, got $ret
281 error output is $(cat $ERRFILE)"
282
283 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
284 exit $RESULT
285 }
286
287
288 # Delete pg that was deleted in previous invocation
289 cat << EOF > $CMDFILE
290 select $TEST_SERVICE
291 delprop $TEST_PROPERTY
292 EOF
293
294 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
295 ret=$?
296
297 # Verify that the return value is as expected
298 [[ $ret -ne 1 ]] && {
299 echo "--DIAG: [${assertion}, test 3]
300 svccfg expected to return 1, got $ret"
301
302 TEST_RESULT=$STF_FAIL
303 }
304
305
306 # Verify that nothing in stdout
307 [[ -s $OUTFILE ]] && {
308 echo "--DIAG: [${assertion}, test 3]
309 did not expect stdout, but got:
310 $(cat $OUTFILE)"
311
312 TEST_RESULT=$STF_FAIL
313 }
314
315 # Verify that message in stderr - non-fatal error
316 if ! egrep -s "$NO_PROPGRP_ERRMSG" $ERRFILE
317 then
318 echo "--DIAG: [${assertion}, test 3]
319 Expected error message \"$NO_PROPGRP_ERRMSG\"
320 but got \"$(cat $ERRFILE)\""
321
322 TEST_RESULT=$STF_FAIL
323 fi
324
325
326 rm -f $OUTFILE $ERRFILE $CMDFILE
327
328 print_result $TEST_RESULT
329 RESULT=$(update_result $TEST_RESULT $RESULT)
330
331 exit $RESULT
332
333
334