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_listpg_004
32 #
33 # DESCRIPTION:
34 # If the glob pattern passed through the 'listpg [pattern]'
35 # subcommand does not match an property group of the currently
36 # select entity then nothing is displayed to stdout and the
37 # command will exit with a status of 0.
38 #
39 #
40 # end __stf_assertion__
41 ###############################################################################
42
43 # First STF library
44 . ${STF_TOOLS}/include/stf.kshlib
45
46 # Load GL library
47 . ${STF_SUITE}/include/gltest.kshlib
48
49
50 readonly ME=$(whence -p ${0})
51 readonly MYLOC=$(dirname ${ME})
52
53 # Initialize test result
54 typeset -i RESULT=$STF_PASS
55
56
57 function cleanup {
58
59 # Note that $TEST_SERVICE may or may not exist so don't check
60 # results. Just make sure the service is gone.
61 service_delete $TEST_SERVICE
62
63 service_exists ${TEST_SERVICE}
64 [[ $? -eq 0 ]] && {
65 echo "--DIAG: [${assertion}, cleanup]
66 service ${TEST_SERVICE} should not exist in
67 repository after being deleted, but does"
68
69 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
70 }
71
72 rm -f $OUTFILE $ERRFILE $CMDFILE
73
74 exit $RESULT
75 }
76
77 trap cleanup 0 1 2 15
78
79 # make sure that the environment is sane - svc.configd is up and running
80 check_gl_env
81 [[ $? -ne 0 ]] && {
82 echo "--DIAG:
83 Invalid test environment - svc.configd is not available"
84
85 RESULT=$STF_UNRESOLVED
86 exit $RESULT
87 }
88
89 # extract and print assertion information from this source script.
90 extract_assertion_info $ME
91
92 assertion=svccfg_listpg_004
93
94
95 # Before starting make sure that the test service doesn't already exist.
96 # If it does then consider it a fatal error.
97 service_exists $TEST_SERVICE
98 [[ $? -eq 0 ]] && {
99 echo "--DIAG: [${assertion}, test 1]
100 service $TEST_SERVICE should not exist in
101 repository but does"
102
103 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
104 exit $RESULT
105 }
106
107
108 #
109 # Add the service. If this fails consider it a fatal error
110 #
111 svccfg add $TEST_SERVICE > $OUTFILE 2>$ERRFILE
112 ret=$?
113 [[ $ret -ne 0 ]] && {
114 echo "--DIAG: [${assertion}]
115 error adding service $TEST_SERVICE needed for test
116 error output is $(cat $ERRFILE)"
117
118 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
119 exit $RESULT
120 }
121
122 #
123 # Test #1: Test with no property groups
124 #
125
126 echo "--INFO: Starting $assertion, test 1 (glob pattern no property groups)"
127
128 typeset -i TEST_RESULT=$STF_PASS
129
130 cat << EOF > $CMDFILE
131 select ${TEST_SERVICE}
132 listpg *foo*
133 end
134 EOF
135
136 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
137 ret=$?
138
139 # Verify that the return value is as expected - non-fatal error
140 [[ $ret -ne 0 ]] && {
141 echo "--DIAG: [${assertion}, test 1]
142 svccfg expected to return 0, got $ret"
143 TEST_RESULT=$STF_FAIL
144 }
145
146 # Verify that nothing in stdout - non-fatal error
147 [[ -s $OUTFILE ]] && {
148 echo "--DIAG: [${assertion}, test 1]
149 stdout not expected, but got $(cat $OUTFILE)"
150
151 TEST_RESULT=$STF_FAIL
152 }
153
154 # Verify that nothing in stderr - non-fatal error
155 [[ -s $ERRFILE ]] && {
156 echo "--DIAG: [${assertion}, test 1]
157 stdout not expected, but got $(cat $OUTFILE)"
158
159 TEST_RESULT=$STF_FAIL
160 }
161
162 rm -f $ERRFILE $OUTFILE $CMDFILE
163
164 print_result $TEST_RESULT
165 RESULT=$(update_result $TEST_RESULT $RESULT)
166
167
168 #
169 # Test #2: Test with property groups
170 #
171
172 echo "--INFO: Starting $assertion, test 2 (glob pattern with property groups)"
173
174 typeset -i TEST_RESULT=$STF_PASS
175
176 # Load up property groups
177 cat << EOF > $CMDFILE
178 select ${TEST_SERVICE}
179 addpg ${TEST_PROPERTY}_1 astring
180 addpg ${TEST_PROPERTY}_2 astring
181 addpg ${TEST_PROPERTY}_3 astring
182 addpg ${TEST_PROPERTY}_4 astring
183 EOF
184
185 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
186 ret=$?
187
188 # Verify that the return value is as expected - fatal error
189 [[ $ret -ne 0 ]] && {
190 echo "--DIAG: [${assertion}, test 2]
191 svccfg adding prop groups failed to return 0, got $ret
192 error output is $(cat $ERRFILE)"
193
194 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
195 exit $RESULT
196 }
197
198 cat << EOF > $CMDFILE
199 select ${TEST_SERVICE}
200 listpg *x_*
201 end
202 EOF
203
204 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
205 ret=$?
206
207 # Verify that the return value is as expected - non-fatal error
208 [[ $ret -ne 0 ]] && {
209 echo "--DIAG: [${assertion}, test 2]
210 svccfg expected to return 0, got $ret"
211 TEST_RESULT=$STF_FAIL
212 }
213
214 # Verify that nothing in stdout - non-fatal error
215 [[ -s $OUTFILE ]] && {
216 echo "--DIAG: [${assertion}, test 2]
217 stdout not expected, but got $(cat $OUTFILE)"
218
219 TEST_RESULT=$STF_FAIL
220 }
221
222 # Verify that nothing in stderr - non-fatal error
223 [[ -s $ERRFILE ]] && {
224 echo "--DIAG: [${assertion}, test 2]
225 stdout not expected, but got $(cat $OUTFILE)"
226
227 TEST_RESULT=$STF_FAIL
228 }
229
230 rm -f $ERRFILE $OUTFILE $CMDFILE
231
232 print_result $TEST_RESULT
233 RESULT=$(update_result $TEST_RESULT $RESULT)
234
235
236 exit $RESULT