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_setprop_003
32 #
33 # DESCRIPTION:
34 # The 'setprop pg/name = [type:] value' subcommand expects
35 # the lhs of the argument to be a valid "pg/name" where pg
36 # is a valid property group and name is a valid property name.
37 # If "pg/name" is not a valid value then a diagnostic message
38 # will be sent to stderr and the subcommand will exit with a
39 # status of 1.
40 #
41 # STRATEGY:
42 # The test is performed through an expect script which is
43 # called from this script.
44 #
45 # end __stf_assertion__
46 ###############################################################################
47
48 ###############################################################################
49 # start __stf_assertion__
50 #
51 # ASSERTION: svccfg_setprop_004
52 #
53 # DESCRIPTION:
54 # The 'setprop pg/name = [type:] *' subcommand expects
55 # the rhs of the argument to be a valid "[type:] *. If
56 # 'type' is not valid then a diagnostic message will be sent
57 # to stderr and the subcommand will exit with a status of 1.
58 #
59 # STRATEGY:
60 # The test is performed through an expect script which is
61 # called from this script.
62 #
63 # end __stf_assertion__
64 ###############################################################################
65
66 ###############################################################################
67 # start __stf_assertion__
68 #
69 # ASSERTION: svccfg_setprop_005
70 #
71 # DESCRIPTION:
72 # The 'setprop pg/name = [type:] value' subcommand
73 # expects the rhs of the argument to be a valid "[type:]
74 # value". If 'values' is not valid for the corresponding
75 # 'type' then a diagnostic message will be sent to stderr
76 # and the subcommand will exit with a status of 1.
77 #
78 # STRATEGY:
79 # The test is performed through an expect script which is
80 # called from this script.
81 #
82 # end __stf_assertion__
83 ###############################################################################
84
85 ###############################################################################
86 # start __stf_assertion__
87 #
88 # ASSERTION: svccfg_setprop_006
89 #
90 # DESCRIPTION:
91 # The 'setprop pg/name = [type:] ([values . . . ])'
92 # subcommand expects the rhs of the argument to be a
93 # valid "type ([values . . .])". If 'values' is not
94 # enclosed in parenthesis then a diagnostic message will
95 # be sent to stderr and the subcommand will exit with a
96 # status of 1.
97 #
98 # STRATEGY:
99 # The test is performed through an expect script which is
100 # called from this script.
101 #
102 # end __stf_assertion__
103 ###############################################################################
104
105 ###############################################################################
106 # start __stf_assertion__
107 #
108 # ASSERTION: svccfg_setprop_007
109 #
110 # DESCRIPTION:
111 # The 'setprop pg/name = [type:] ([values . . . ])'
112 # subcommand expects an assignment 'lhs = rhs' as an
113 # argument. If an invalid argument is passed to setprop
114 # then a diagnostic message will be sent to stderr and
115 # the subcommand will exit with a status of 1. Invalid
116 # argument should include: no arguments, valid assignments
117 # without the '=' character, valid arguments with trailing
118 # members (e.g. 'lhs = rhs extra')
119 #
120 # STRATEGY:
121 # The test is performed through an expect script which is
122 # called from this script.
123 #
124 # end __stf_assertion__
125 ###############################################################################
126
127 ###############################################################################
128 # start __stf_assertion__
129 #
130 # ASSERTION: svccfg_setprop_008
131 #
132 # DESCRIPTION:
133 # If 'setprop pg/name = type ([values . . . ])' subcommand
134 # contains a pg/name value in which the property does not
135 # exist and the type specifier is not present will return
136 # a diagnostic message and a return value of 1.
137 #
138 # STRATEGY:
139 # The test is performed through an expect script which is
140 # called from this script.
141 #
142 # end __stf_assertion__
143 ###############################################################################
144
145 # First STF library
146 . ${STF_TOOLS}/include/stf.kshlib
147
148 # Load GL library
149 . ${STF_SUITE}/include/gltest.kshlib
150
151 readonly ME=$(whence -p ${0})
152 readonly MYLOC=$(dirname ${ME})
153
154 # Initialize test result
155 typeset -i RESULT=$STF_PASS
156
157
158 function cleanup {
159
160 # Note that $TEST_SERVICE may or may not exist so don't check
161 # results. Just make sure the service is gone.
162 service_delete $TEST_SERVICE
163
164 service_exists ${TEST_SERVICE}
165 [[ $? -eq 0 ]] && {
166 echo "--DIAG: [${assertion}, cleanup]
167 service ${TEST_SERVICE} should not exist in
168 repository after being deleted, but does"
169
170 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
171 }
172
173 rm -f $OUTFILE $ERRFILE $CMDFILE
174
175 exit $RESULT
176 }
177
178 trap cleanup 0 1 2 15
179
180 # make sure that the environment is sane - svc.configd is up and running
181 check_gl_env
182 [[ $? -ne 0 ]] && {
183 echo "--DIAG:
184 Invalid test environment - svc.configd is not available"
185
186 RESULT=$STF_UNRESOLVED
187 exit $RESULT
188 }
189
190 # extract and print assertion information from this source script.
191 extract_assertion_info $ME
192
193 assertion=svccfg_setprop_003-008
194
195
196 # Before starting make sure that the test service doesn't already exist.
197 # If it does then consider it a fatal error.
198 service_exists $TEST_SERVICE
199 [[ $? -eq 0 ]] && {
200 echo "--DIAG: [${assertion}]
201 service $TEST_SERVICE should not exist in
202 repository but does"
203
204 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
205 exit $RESULT
206 }
207
208
209 #
210 # Add the service. If this fails consider it a fatal error
211 #
212
213 svccfg add $TEST_SERVICE > $OUTFILE 2>$ERRFILE
214 ret=$?
215 [[ $ret -ne 0 ]] && {
216 echo "--DIAG: [${assertion}]
217 error adding service $TEST_SERVICE needed for test"
218
219 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
220 exit $RESULT
221 }
222
223
224 echo "--INFO: [${assertion}]
225 Running error tests on service entities"
226
227 # Run the error test on service entities
228
229 $MYLOC/test_003-008 $TEST_SERVICE
230 ret=$?
231 [[ $ret -ne 0 ]] && TEST_RESULT=$STF_FAIL
232
233
234 cat <<EOF>$CMDFILE
235 select ${TEST_SERVICE}
236 add ${TEST_INSTANCE}
237 EOF
238
239 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
240 ret=$?
241
242 # Verify that the return value is as expected - non-fatal error
243 [[ $ret -ne 0 ]] && {
244 echo "--DIAG: [${assertion}]
245 svccfg add expected to return 0, got $ret"
246
247 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
248 exit $RESULT
249 }
250
251
252 # Run the error test on instance entities
253
254 echo "--INFO: [${assertion}]
255 Running error tests on instance entities"
256
257 $MYLOC/setprop_003-008 $TEST_SERVICE $TEST_INSTANCE
258 ret=$?
259 [[ $ret -ne 0 ]] && TEST_RESULT=$STF_FAIL
260
261 RESULT=$(update_result $TEST_RESULT $RESULT)
262
263 # Test done
264
265 exit $RESULT