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