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: depends_011
32 # DESCRIPTION:
33 # A service with a single dependency in an "exclude_all" grouping
34 # set in the service's definition. If any of the dependencies
35 # come online then the service will be transitioned into the offline
36 # state.
37 # Services: a, b; b specifies exclude_all of (a)
38 #
39 # end __stf_assertion__
40 #
41
42 . ${STF_TOOLS}/include/stf.kshlib
43 . ${STF_SUITE}/include/gltest.kshlib
44 . ${STF_SUITE}/include/svc.startd_config.kshlib
45 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
46
47 typeset service_setup=0
48 function cleanup {
49 common_cleanup
50 rm -f $service_state1 $service_state2
51 }
52
53 trap cleanup 0 1 2 15
54
55 readonly ME=$(whence -p ${0})
56 readonly MYLOC=$(dirname ${ME})
57
58 DATA=$MYLOC
59
60 readonly registration_template=$DATA/service_011.xml
61
62 extract_assertion_info $ME
63
64 # make sure that the svc.startd is running
65 verify_daemon
66 if [ $? -ne 0 ]; then
67 echo "--DIAG: $assertion: svc.startd is not executing. Cannot "
68 echo " continue"
69 exit $STF_UNRESOLVED
70 fi
71
72 # Make sure the environment is clean - the test service isn't running
73 echo "--INFO: Cleanup any old $test_FMRI1, $test_FMRI2 state"
74 service_cleanup $test_service
75 if [ $? -ne 0 ]; then
76 echo "--DIAG: $assertion: cleanup of a previous instance failed"
77 exit $STF_UNRESOLVED
78 fi
79
80 echo "--INFO: generating manifest for importation into repository"
81 manifest_generate $registration_template \
82 TEST_SERVICE=$test_service \
83 TEST_INSTANCE1=$test_instance1 \
84 TEST_INSTANCE2=$test_instance2 \
85 SERVICE_APP=$service_app \
86 LOGFILE=$service_log \
87 STATEFILE1=$service_state1 \
88 STATEFILE2=$service_state2 > $registration_file
89
90 echo "--INFO: Importing service into repository"
91 manifest_purgemd5 $registration_file
92 svccfg -v import $registration_file >$svccfg_errfile 2>&1
93
94 if [ $? -ne 0 ]; then
95 echo "--DIAG: $assertion: Unable to import the services $test_FMRI1"
96 echo " and $test_FMRI2 error messages from svccfg: "
97 echo " \"$(cat $svccfg_errfile)\""
98 exit $STF_UNRESOLVED
99 fi
100 service_setup=1
101
102 echo "--INFO: Wait for $test_FMRI1 to come online"
103 service_wait_state $test_FMRI1 online
104 if [ $? -ne 0 ]; then
105 echo "--DIAG: $assertion: Service $test_FMRI1 didn't come online"
106 echo " services state:"
107 svcs -l $test_service\*
108 exit $STF_FAIL
109 fi
110
111 echo "--INFO: Enabling service $test_FMRI2"
112 svcadm enable $test_FMRI2
113 if [ $? -ne 0 ]; then
114 echo "--DIAG: $assertion: Service $test_FMRI2 did not enable"
115 exit $STF_FAIL
116 fi
117
118 echo "--INFO: Waiting for $test_FMRI2 to come online - it should not"
119 service_wait_state $test_FMRI2 online
120 if [ $? -eq 0 ]; then
121 echo "--DIAG: $assertion: Service $test_FMRI2 came online"
122 echo " services state:"
123 svcs -l $test_service\*
124 exit $STF_FAIL
125 fi
126
127 echo "--INFO: Disabling $test_FMRI1"
128 svcadm disable $test_FMRI1
129 if [ $? -ne 0 ]; then
130 echo "--DIAG: $assertion: Service $test_FMRI1 did not disable"
131 exit $STF_FAIL
132 fi
133
134 echo "--INFO: Verifying that $test_FMRI1 goes to disabled"
135 service_wait_state $test_FMRI1 disabled
136 if [ $? -ne 0 ]; then
137 echo "--DIAG: $assertion: Service $test_FMRI1 didn't go to disabled"
138 exit $STF_FAIL
139 fi
140
141 echo "--INFO: Waiting for $test_FMRI2 to come online"
142 service_wait_state $test_FMRI2 online
143 if [ $? -ne 0 ]; then
144 echo "--DIAG: $assertion: Service $test_FMRI2 did not come online"
145 echo " services state:"
146 svcs -l $test_service\*
147 exit $STF_FAIL
148 fi
149
150 echo "--INFO: Enabling service $test_FMRI1"
151 svcadm enable $test_FMRI1
152 if [ $? -ne 0 ]; then
153 echo "--DIAG: $assertion: Service $test_FMRI1 wouldn't enable"
154 exit $STF_FAIL
155 fi
156
157 echo "--INFO: Wait for $test_FMRI1 to come online"
158 service_wait_state $test_FMRI1 online
159 if [ $? -ne 0 ]; then
160 echo "--DIAG: $assertion: Service $test_FMRI1 didn't come online"
161 exit $STF_FAIL
162 fi
163
164 echo "--INFO: Verify that $test_FMRI2 goes offline"
165 service_wait_state $test_FMRI2 offline
166 if [ $? -ne 0 ]; then
167 echo "--DIAG: $assertion: Service $test_FMRI1 didn't go offline"
168 echo " services state:"
169 svcs -l $test_service\*
170 exit $STF_FAIL
171 fi
172
173 echo "--INFO: Disabling $test_FMRI1"
174 svcadm disable $test_FMRI1
175 if [ $? -ne 0 ]; then
176 echo "--DIAG: $assertion: Service $test_FMRI1 did not disable"
177 exit $STF_FAIL
178 fi
179
180 echo "--INFO: Verifying that $test_FMRI1 goes to disabled"
181 service_wait_state $test_FMRI1 disabled
182 if [ $? -ne 0 ]; then
183 echo "--DIAG: $assertion: Service $test_FMRI1 didn't go to disabled"
184 exit $STF_FAIL
185 fi
186
187 echo "--INFO: Waiting for $test_FMRI2 to come online"
188 service_wait_state $test_FMRI2 online
189 if [ $? -ne 0 ]; then
190 echo "--DIAG: $assertion: Service $test_FMRI2 did not come online"
191 echo " services state:"
192 svcs -l $test_service\*
193 exit $STF_FAIL
194 fi
195
196 echo "--INFO: Cleaning up service"
197 cleanup
198
199 exit $STF_PASS