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