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_009
32 # DESCRIPTION:
33 # A service with multiple dependencies in an "exclude_all" grouping
34 # property is set in the service's definition If none of the
35 # dependencies are satisfied then the service will be transitioned
36 # into the online state.
37 # Service a, b, c; c is specified exclude_all of (a, b)
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 $service_state3
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_009.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, $test_FMRI3 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 TEST_INSTANCE3=$test_instance3 \
86 SERVICE_APP=$service_app \
87 LOGFILE=$service_log \
88 STATEFILE1=$service_state1 \
89 STATEFILE2=$service_state2 \
90 STATEFILE3=$service_state3 \
91 > $registration_file
92
93 echo "--INFO: Importing service into repository"
94 manifest_purgemd5 $registration_file
95 svccfg -v import $registration_file >$svccfg_errfile 2>&1
96
97 if [ $? -ne 0 ]; then
98 echo "--DIAG: $assertion: Unable to import the services $test_FMRI1"
99 echo " $test_FMRI2 and $test_FMRI3 error messages from svccfg: "
100 echo " \"$(cat $svccfg_errfile)\""
101 exit $STF_UNRESOLVED
102 fi
103 service_setup=1
104
105 echo "--INFO: Wait for $test_FMRI3 to go offline"
106 service_wait_state $test_FMRI3 offline
107 if [ $? -ne 0 ]; then
108 echo "--DIAG: $assertion: $test_FMRI3 did not go offline before timeout"
109 echo " State of services:"
110 svcs -l $test_service\*
111 exit $STF_FAIL
112 fi
113
114 echo "--INFO: Disabling service $test_FMRI1"
115 svcadm disable $test_FMRI1
116 if [ $? -ne 0 ]; then
117 echo "--DIAG: $assertion: Service $test_FMRI1 did not disable"
118 exit $STF_FAIL
119 fi
120
121 echo "--INFO: Waiting for $test_FMRI1 to go to disabled"
122 service_wait_state $test_FMRI1 disabled
123 if [ $? -ne 0 ]; then
124 echo "--DIAG: $assertion: Service $test_FMRI1 did not get disabled
125 Current state: $(svcprop -p restarter/state $test_FMRI1)"
126 exit $STF_FAIL
127 fi
128
129 echo "--INFO: Wait for $test_FMRI3 to come online - it should not"
130 service_wait_state $test_FMRI3 online
131 if [ $? -eq 0 ]; then
132 echo "--DIAG: $assertion: Service $test_FMRI3 came online"
133 echo " state of services:"
134 svcs -l $test_service\*
135 exit $STF_FAIL
136 fi
137
138 echo "--INFO: Disabling service $test_FMRI2"
139 svcadm disable $test_FMRI2
140 if [ $? -ne 0 ]; then
141 echo "--DIAG: $assertion: Service $test_FMRI2 did not disable"
142 exit $STF_FAIL
143 fi
144
145 echo "--INFO: Waiting for $test_FMRI2 to go to disabled"
146 service_wait_state $test_FMRI2 disabled
147 if [ $? -ne 0 ]; then
148 echo "--DIAG: $assertion: Service $test_FMRI2 did not get disabled
149 Current state: $(svcprop -p restarter/state $test_FMRI2)"
150 exit $STF_FAIL
151 fi
152
153 echo "--INFO: Waiting for $test_FMRI3 to come online"
154 service_wait_state $test_FMRI3 online
155 if [ $? -ne 0 ]; then
156 echo "--DIAG: $assertion: Service $test_FMRI3 did not come online"
157 echo " state of services:"
158 svcs -l $test_service\*
159 exit $STF_FAIL
160 fi
161
162 echo "--INFO: Cleaning up service"
163 cleanup
164
165 exit $STF_PASS