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: methods_006
32 # DESCRIPTION:
33 # A service that is online is disabled. It's stop method fails with
34 # the defined straight to maintenance rv. The service transitions to
35 # maintenance mode immediately, without issuing any more calls to stop
36 #
37 # end __stf_assertion__
38 #
39
40 . ${STF_TOOLS}/include/stf.kshlib
41 . ${STF_SUITE}/include/gltest.kshlib
42 . ${STF_SUITE}/include/svc.startd_config.kshlib
43 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
44
45 typeset service_setup=0
46 function cleanup {
47 common_cleanup
48 ret=$?
49
50 # Forcibly kill the start/stop method process
51 pkill -9 -z `zonename` service_app
52
53 return $ret
54 }
55
56 trap cleanup 0 1 2 15
57
58 readonly ME=$(whence -p ${0})
59 readonly MYLOC=$(dirname ${ME})
60
61 DATA=$MYLOC
62
63 registration_template=$DATA/service_006.xml
64
65 extract_assertion_info $ME
66
67 # make sure that the svc.startd is running
68 verify_daemon
69 if [ $? -ne 0 ]; then
70 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
71 print -- " continue"
72 exit $STF_UNRESOLVED
73 fi
74
75 # feature testing
76 features=`feature_test TOMAINT`
77 if [ $? -ne 0 ]; then
78 print -- "--DIAG: $assertion: $features missing from startd"
79 exit $STF_UNTESTED
80 fi
81
82 # Make sure the environment is clean - the test service isn't running
83 print -- "--INFO: Cleanup any old $test_FMRI state"
84 service_cleanup $test_service
85 rm -f $service_state
86 if [ $? -ne 0 ]; then
87 print -- "--DIAG: $assertion: unable to clean up any pre-existing state"
88 exit $STF_UNRESOLVED
89 fi
90
91 print -- "--INFO: generating manifest for importation into repository"
92 manifest_generate $registration_template \
93 TEST_SERVICE=$test_service \
94 TEST_INSTANCE=$test_instance \
95 SERVICE_APP=$service_app \
96 LOGFILE=$service_log \
97 STATEFILE=$service_state \
98 STOP_EVENT="returncode $SVC_METHOD_MAINTEXIT" \
99 > $registration_file
100
101 print -- "--INFO: Importing service into repository"
102 manifest_purgemd5 $registration_file
103 svccfg -v import $registration_file >$svccfg_errfile 2>&1
104 if [ $? -ne 0 ]; then
105 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
106 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
107 exit $STF_UNRESOLVED
108 fi
109 service_setup=1
110
111 print -- "--INFO: Wait for $test_FMRI to come online"
112 service_wait_state $test_FMRI online
113 if [ $? -ne 0 ]; then
114 print -- "--DIAG: $assertion: Service $test_FMRI didn't go online"
115 exit $STF_FAIL
116 fi
117
118 print -- "--INFO: disabling service"
119 svcadm disable $test_FMRI
120 if [ $? -ne 0 ]; then
121 print -- "--DIAG: $assertion: disable command for Service "
122 print -- " $test_FMRI didn't succeed"
123 exit $STF_UNRESOLVED
124 fi
125
126 print -- "--INFO: Waiting for issue of $test_FMRI stop method"
127 service_wait_method $test_FMRI stop
128 if [ $? -ne 0 ]; then
129 print -- "--DIAG: $assertion: Service $test_FMRI didn't issue stop"
130 exit $STF_FAIL
131 fi
132
133 print -- "--INFO: Validating service is in maintenance mode"
134 service_wait_state $test_FMRI maintenance
135 if [ $? -ne 0 ]; then
136 print -- "--DIAG: $assertion: Service $test_FMRI did not "
137 print -- " transition to maintenance mode"
138 exit $STF_FAIL
139 fi
140
141 print -- "--INFO: Validating no extra invocation of stop method"
142 service_countcall -f $service_state -s $test_service -i $test_instance stop
143 countstops=$?
144 if [ $countstops -ne 1 ]; then
145 print -- "--DIAG: $assertion: Service $test_FMRI called stop method"
146 print -- " more than once when it shouldn't have"
147 exit $STF_FAIL
148 fi
149
150 print -- "--INFO: Cleaning up service"
151 cleanup
152
153 exit $STF_PASS