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_043
32 # DESCRIPTION:
33 # A service that does not leave any processes after returning from the
34 # start method will be repeatedly invoked until it is eventually placed
35 # in maintenance.
36 #
37 # The current invocation threshold is defined in $ERROR_THRESHOLD. The
38 # service will be restarted at least $ERROR_THRESHOLD times.
39 #
40 # end __stf_assertion__
41 #
42
43 . ${STF_TOOLS}/include/stf.kshlib
44 . ${STF_SUITE}/include/gltest.kshlib
45 . ${STF_SUITE}/include/svc.startd_config.kshlib
46 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
47
48 typeset service_setup=0
49 function cleanup {
50 common_cleanup
51 /bin/rm -f $START_COUNT_FILE
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 START_COUNT_FILE=/tmp/service_043_startcount
61
62 readonly registration_template=$DATA/service_043.xml
63
64 extract_assertion_info $ME
65
66 # make sure that the svc.startd is running
67 verify_daemon
68 if [ $? -ne 0 ]; then
69 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
70 print -- " continue"
71 exit $STF_UNRESOLVED
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 a previous instance 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 TEST_START_METHOD=$STF_SUITE/$STF_EXEC/service_043_startmethod \
87 SERVICE_APP=$service_app \
88 LOGFILE=$service_log \
89 STATEFILE=$service_state > $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
95 if [ $? -ne 0 ]; then
96 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
97 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
98 exit $STF_UNRESOLVED
99 fi
100 service_setup=1
101
102 # wait for service to enter maintenance state
103 print -- "--INFO: Check $test_FMRI is in maintenance"
104 service_wait_state $test_FMRI maintenance
105 if [[ $? -ne 0 ]]; then
106 print -- "--DIAG: $assertion: Service $test_FMRI is not in maintenance"
107 print -- " It is in $(svcprop -p restarter/state $test_FMRI) state"
108 exit $STF_FAIL
109 fi
110
111 typeset -i count=$(cat $START_COUNT_FILE)
112 if [[ $count -lt ${ERROR_THRESHOLD} ]]; then
113 print -- "--DIAG: $assertion: incorrect start method invocation count"
114 print -- " EXPECTED: service was restarted >= 3 times"
115 print -- " OBSERVED: service was restarted $count times"
116 exit $STF_FAIL
117 fi
118
119 print -- "--INFO: Cleaning up service"
120 cleanup
121
122 exit $STF_PASS