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_013
32 #
33 # DESCRIPTION:
34 # The 'setprop pg/name = ([values . . . ])' subcommand
35 # accepts multiple values for the corresponding existing
36 # pg/name.
37 #
38 # STRATEGY:
39 # - Add a test service to the repository
40 # - Add a service propertygroup to the test service
41 # - Add a pair of multivalued properties to the newly added service pg
42 # - Add a test instance to the test service
43 # - Add a propertygroup to the test instance
44 # - Add a pair of multivalued properties to the newly added instance pg
45 # - Export the service.
46 # - Compare the exported manifest to an expected manifest containing
47 # the same multivalued properties added during the test
48 # - Verify that the manifests are identical
49 #
50 # end __stf_assertion__
51 ###############################################################################
52
53
54 # First STF library
55 . ${STF_TOOLS}/include/stf.kshlib
56
57 # Load GL library
58 . ${STF_SUITE}/include/gltest.kshlib
59
60 # Load svc.startd config library
61 . ${STF_SUITE}/include/svc.startd_config.kshlib
62
63
64 readonly ME=$(whence -p ${0})
65 readonly MYLOC=$(dirname ${ME})
66 readonly assertion=svccfg_setprop_013
67
68 # Initialize test result
69 typeset -i RESULT=$STF_PASS
70
71 function cleanup {
72 # Note that $TEST_SERVICE may or may not exist, so don't check
73 # results. Just make sure the service is gone.
74 service_delete $TEST_SERVICE
75
76 service_exists $TEST_SERVICE
77 [[ $? -eq 0 ]] && {
78 echo "--DIAG: [${assertion}, cleanup]
79 service $TEST_SERVICE should not exist in the repository
80 after being deleteed, but does"
81
82 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
83 }
84
85 rm -f $OUTFILE $ERRFILE $CMDFILE
86
87 exit $RESULT
88 }
89
90 trap cleanup 0 1 2 15
91
92 # Extract and print assertion information from this source script
93 extract_assertion_into $ME
94
95 # Make sure that the environment is sane - svc.configd is up and running
96 check_gl_env
97 [[ $? -ne 0 ]] && {
98 echo "--DIAG: [$assertion]
99 Invalid test environment -- svc.configd is not available"
100
101 RESULT=$STF_UNRESOLVED
102 exit $RESULT
103 }
104
105 # Before starting, make sure that the test service does not already exist.
106 # If it does, treat that as a fatal error.
107 export TEST_SERVICE=${assertion}_service
108 export TEST_INSTANCE=${assertion}_instance
109
110 service_exists $TEST_SERVICE
111 [[ $? -eq 0 ]] && {
112 echo "--DIAG: [$assertion]
113 service $TEST_SERVICE should not exist in the repository,
114 but does"
115
116 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
117 exit $RESULT
118 }
119
120 # Add the test service and instance to the repository and set up a
121 # test service pg and instace pg
122
123 typeset svcpg=${assertion}_svcpg
124 typeset instpg=${assertion}_instpg
125
126 cat <<EOF > $CMDFILE
127 add $TEST_SERVICE
128 select $TEST_SERVICE
129 addpg $svcpg application
130 add $TEST_INSTANCE
131 addpg $instpg application
132 EOF
133
134 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
135 ret=$?
136 [[ $ret -ne 0 ]] && {
137 echo "--DIAG: [$assertion]
138 error adding service $TEST_SERVICE needed for test
139 Error output is $(cat $ERRFILE)"
140
141 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
142 exit $RESULT
143 }
144
145 #
146 # Add a couple of multivalued properties to the servicepg. Treat all failures
147 # as fatal
148 #
149 typeset astringprop=${assertion}_astringprop
150 typeset countprop=${assertion}_countprop
151
152 svccfg -s $TEST_SERVICE <<EOF
153 setprop $svcpg/$astringprop = astring: ("first svc prop" "second svc prop")
154 setprop $svcpg/$countprop = count: (1 2 3 4 5)
155 EOF > $OUTFILE 2>$ERRFILE
156
157 ret=$?
158 [[ $ret -ne 0 ]] && {
159 echo "--DIAG: [$assertion]
160 error adding service pg $svcpg to $TEST_SERVICE
161 Error output is $(cat $ERRFILE)"
162
163 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
164 exit $RESULT
165 }
166
167 #
168 # Add a couple of multivalued properties to the instancepg. Treat all failures
169 # as fatal
170 #
171
172 svccfg -s ${TEST_SERVICE}:${TEST_INSTANCE} <<EOF
173 setprop $instpg/$astringprop = astring: ("first inst prop" "second inst prop")
174 setprop $instpg/$countprop = count: (11 12 13 14 15)
175 EOF > $OUTFILE 2>$ERRFILE
176
177 ret=$?
178 [[ $ret -ne 0 ]] && {
179 echo "--DIAG: [$assertion]
180 error adding instance pg $instpg to ${TEST_SERVICE}:${TEST_INSTANCE}
181 Error output is $(cat $ERRFILE)"
182
183 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
184 exit $RESULT
185 }
186
187 #
188 # Export the service manifest and capture it in $OUTFILE
189 #
190 svccfg export $TEST_SERVICE > $OUTFILE 2>$ERRFILE
191 ret=$?
192 [[ $ret -ne 0 ]] && {
193 echo "--DIAG: [$assertion]
194 error adding instance pg $instpg to ${TEST_SERVICE}:${TEST_INSTANCE}
195 Error output is $(cat $ERRFILE)"
196
197 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
198 exit $RESULT
199 }
200
201 #
202 # Compare the manifest with the expected manifest
203 #
204 expected_manifest=${MYLOC}/setprop_013.xml
205
206 cmp -s $OUTFILE $expected_manifest
207 ret=$?
208 [[ $ret -ne 0 ]] && {
209 echo "--DIAG: [${assertion}]
210 svccfg setprop failed. Expected service manifest is
211 $(cat $expected_manifest)
212 the actual output is:
213 $(cat ${OUTFILE})"
214
215 RESULT=$STF_FAIL
216 }
217
218 #
219 exit $RESULT