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_035
32 # DESCRIPTION:
33 # If the service method being invoked does not return within the
34 # timeout period specified for the service then the service shall
35 # be transitioned into maintenance state and the method shall be
36 # terminated.
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 [[ $service_setup -ne 0 ]] && {
48 $service_app -s $test_service -i $test_instance -m force_stop
49 svcadm disable $test_FMRI
50 }
51 common_cleanup
52 }
53
54 trap cleanup 0 1 2 15
55
56 readonly ME=$(whence -p ${0})
57 readonly MYLOC=$(dirname ${ME})
58
59 DATA=$MYLOC
60
61 registration_template=$DATA/service_035.xml
62
63 extract_assertion_info $ME
64
65 # make sure that the svc.startd is running
66 verify_daemon
67 if [ $? -ne 0 ]; then
68 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
69 print -- " continue"
70 exit $STF_UNRESOLVED
71 fi
72
73 # feature testing
74 features=`feature_test TIMEOUT`
75 if [ $? -ne 0 ]; then
76 print -- "--DIAG: $assertion: $features missing from startd"
77 exit $STF_UNTESTED
78 fi
79
80 # Make sure the environment is clean - the test service isn't running
81 print -- "--INFO: Cleanup any old $test_FMRI state"
82 service_cleanup $test_service
83 rm -f $service_state
84 if [ $? -ne 0 ]; then
85 print -- "--DIAG: $assertion: unable to clean up any pre-existing state"
86 exit $STF_UNRESOLVED
87 fi
88
89 print -- "--INFO: generating manifest for importation into repository"
90 manifest_generate $registration_template \
91 TEST_SERVICE=$test_service \
92 TEST_INSTANCE=$test_instance \
93 SERVICE_APP=$service_app \
94 LOGFILE=$service_log \
95 STATEFILE=$service_state \
96 TIMEOUT=2 \
97 START_EVENT="dally 3000" \
98 > $registration_file
99
100 print -- "--INFO: Importing service into repository"
101 manifest_purgemd5 $registration_file
102 svccfg -v import $registration_file >$svccfg_errfile 2>&1
103 if [ $? -ne 0 ]; then
104 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
105 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
106 exit $STF_UNRESOLVED
107 fi
108 service_setup=1
109
110 print -- "--INFO: enabling $test_FMRI"
111 svcadm enable $test_FMRI
112 if [ $? -ne 0 ]; then
113 print -- "--DIAG: $assertion: enable command of $test_FMRI failed"
114 exit $STF_FAIL
115 fi
116
117 print -- "--INFO: waiting for execution of start method"
118 service_wait_method $test_FMRI start
119 if [ $? -ne 0 ]; then
120 print -- "--DIAG: $assertion: Service $test_FMRI didn't issue start"
121 exit $STF_UNRESOLVED
122 fi
123
124 print -- "--INFO: Validating service is in maintenance mode"
125 service_wait_state $test_FMRI maintenance
126 if [ $? -ne 0 ]; then
127 print -- "--DIAG: $assertion: Service $test_FMRI did not "
128 print -- " transition to maintenance mode"
129 exit $STF_FAIL
130 fi
131
132 print -- "--INFO: Validating multiple invocations of start method"
133 service_countcall -f $service_state -s $test_service -i $test_instance start
134 countstarts=$?
135 if [ $countstarts -lt $ERROR_THRESHOLD ]; then
136 print -- "--DIAG: $assertion: Service $test_FMRI did not "
137 print -- " call start method enough times"
138 exit $STF_FAIL
139 fi
140
141 print -- "--INFO: Cleaning up service"
142 cleanup
143
144 exit $STF_PASS