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_042
32 # DESCRIPTION:
33 # A service possessing a disable method will have that method executed
34 # upon the issuing of 'svcadm disable'
35 # end __stf_assertion__
36 #
37
38 . ${STF_TOOLS}/include/stf.kshlib
39 . ${STF_SUITE}/include/gltest.kshlib
40 . ${STF_SUITE}/include/svc.startd_config.kshlib
41 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
42
43 typeset service_setup=0
44 function cleanup {
45 common_cleanup
46 }
47
48 trap cleanup 0 1 2 15
49
50 readonly ME=$(whence -p ${0})
51 readonly MYLOC=$(dirname ${ME})
52
53 DATA=$MYLOC
54
55 registration_template=$DATA/service_042.xml
56
57 extract_assertion_info $ME
58
59 # make sure that the svc.startd is running
60 verify_daemon
61 if [ $? -ne 0 ]; then
62 print -- "--DIAG: $assertion: svc.startd is not executing. "
63 print -- " Cannot continue"
64 exit $STF_UNRESOLVED
65 fi
66
67 # feature testing
68 features=`feature_test METH_ENABLE`
69 if [ $? -ne 0 ]; then
70 print -- "--DIAG: $assertion: $features missing from startd"
71 exit $STF_UNTESTED
72 fi
73
74 # Make sure the environment is clean - the test service isn't running
75 print -- "--INFO: Cleanup any old $test_FMRI state"
76 service_cleanup $test_service
77 if [ $? -ne 0 ]; then
78 print -- "--DIAG: $assertion: cleanup of previous service state failed"
79 exit $STF_UNRESOLVED
80 fi
81
82 print -- "--INFO: generating manifest for importation into repository"
83 manifest_generate $registration_template \
84 TEST_SERVICE=$test_service \
85 TEST_INSTANCE=$test_instance \
86 SERVICE_APP=$service_app \
87 LOGFILE=$service_log \
88 STATEFILE=$service_state \
89 > $registration_file
90
91 print -- "--INFO: Importing service into repository"
92 manifest_purgemd5 $registration_file
93 svccfg -v import $registration_file >$svccfg_errfile 2>&1
94 if [ $? -ne 0 ]; then
95 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
96 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
97 exit $STF_UNRESOLVED
98 fi
99 service_setup=1
100
101 print -- "--INFO: Wait for $test_FMRI to come online ... it should not!"
102 service_wait_state $test_FMRI online
103 if [ $? -eq 0 ]; then
104 print -- "--DIAG: $assertion: Service $test_FMRI went online"
105 exit $STF_FAIL
106 fi
107
108 print -- "--INFO: Enabling service"
109 svcadm enable $test_FMRI
110 if [ $? -ne 0 ]; then
111 print -- "--DIAG: $assertion: Service $test_FMRI didn't enable"
112 exit $STF_UNRESOLVED
113 fi
114
115 print -- "--INFO: Waiting for transition of $test_FMRI to online"
116 service_wait_state $test_FMRI online
117 if [ $? -ne 0 ]; then
118 print -- "--DIAG: $assertion: Service $test_FMRI didn't go online"
119 exit $STF_FAIL
120 fi
121
122 print -- "--INFO: disabling service $test_FMRI"
123 svcadm disable $test_FMRI
124
125 print -- "--INFO: Waiting for invocation of disable method"
126 service_wait_method $test_FMRI disable
127 if [ $? -ne 0 ]; then
128 print -- "--DIAG: $assertion: $test_FMRI didn't execute disable method"
129 exit $STF_FAIL
130 fi
131
132 print -- "--INFO: Cleaning up service"
133 cleanup
134
135 exit $STF_PASS