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_024
32 # DESCRIPTION:
33 # If a service instance in the online state dies due to receipt of
34 # a fatal signal from another process then the svc.startd should
35 # attempt to restart the service. The instance possesses more than
36 # one sub-process.
37 #
38 # end __stf_assertion__
39 #
40
41 . ${STF_TOOLS}/include/stf.kshlib
42 . ${STF_SUITE}/include/gltest.kshlib
43 . ${STF_SUITE}/include/svc.startd_config.kshlib
44 . ${STF_SUITE}/tests/include/svc.startd_fileops.kshlib
45 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
46
47 typeset service_setup=0
48 function cleanup {
49 common_cleanup
50 }
51
52 trap cleanup 0 1 2 15
53
54 readonly ME=$(whence -p ${0})
55 readonly MYLOC=$(dirname ${ME})
56
57 DATA=$MYLOC
58
59 registration_template=$DATA/service_024.xml
60
61 extract_assertion_info $ME
62
63 # make sure that the svc.startd is running
64 verify_daemon
65 if [ $? -ne 0 ]; then
66 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
67 print -- " continue"
68 exit $STF_UNRESOLVED
69 fi
70
71 # Make sure the environment is clean - the test service isn't running
72 print -- "--INFO: Cleanup any old $test_FMRI state"
73 service_cleanup $test_service
74 rm -f $service_state
75 if [ $? -ne 0 ]; then
76 print -- "--DIAG: $assertion: unable to clean up any pre-existing state"
77 exit $STF_UNRESOLVED
78 fi
79
80 print -- "--INFO: generating manifest for importation into repository"
81 manifest_generate $registration_template \
82 TEST_SERVICE=$test_service \
83 TEST_INSTANCE=$test_instance \
84 SERVICE_APP=$service_app \
85 LOGFILE=$service_log \
86 STATEFILE=$service_state \
87 > $registration_file
88
89 print -- "--INFO: Importing service into repository"
90 manifest_purgemd5 $registration_file
91 svccfg -v import $registration_file >$svccfg_errfile 2>&1
92 if [ $? -ne 0 ]; then
93 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
94 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
95 exit $STF_UNRESOLVED
96 fi
97 service_setup=1
98
99 print -- "--INFO: enabling $test_FMRI"
100 svcadm enable $test_FMRI
101 if [ $? -ne 0 ]; then
102 print -- "--DIAG: $assertion: enable command of $test_FMRI failed"
103 exit $STF_FAIL
104 fi
105
106 print -- "--INFO: waiting for execution of start method"
107 service_wait_method $test_FMRI start
108 if [ $? -ne 0 ]; then
109 print -- "--DIAG: $assertion: Service $test_FMRI didn't issue start"
110 exit $STF_UNRESOLVED
111 fi
112
113 print -- "--INFO: Validating service reaches online mode"
114 service_wait_state $test_FMRI online
115 if [ $? -ne 0 ]; then
116 print -- "--DIAG: $assertion: Service $test_FMRI didn't"
117 print -- " transition to online mode"
118 exit $STF_FAIL
119 fi
120
121 print -- "--INFO: get the services to generate core files into log dir"
122 PIDS=`service_getpids -s $test_service -i $test_instance -f $service_state`
123 print -- "--INFO: child pids are: $PIDS"
124 coreadm -p "$RUNDIR/core.%p" $PIDS
125
126 echo $PIDS | read pid1 pid2
127
128 # pad run log
129 $service_app -s $test_service -i $test_instance -l $service_log -m "blank"
130
131 print -- "--INFO: issue a kill to the service pid $pid2"
132 kill $pid2
133 if [ $? -ne 0 ]; then
134 print "--DIAG: $assertion: could not issue kill to $pid2"
135 exit $STF_UNRESOLVED
136 fi
137
138 print -- "--INFO: Waiting for service's start method"
139 service_wait_method $test_FMRI start
140 if [ $? -ne 0 ]; then
141 print -- "--DIAG: $assertion: didn't issue start method"
142 exit $STF_FAIL
143 fi
144
145 print -- "--INFO: verify that process $pid1 is no longer executing"
146 kill -0 $pid1
147 if [ $? -eq 0 ]; then
148 print -- "--DIAG: service $pid1 is still executing"
149 exit $STF_FAIL
150 fi
151
152 print -- "--INFO: Waiting for service to reach online state"
153 service_wait_state $test_FMRI online
154 if [ $? -ne 0 ]; then
155 print -- "--DIAG: $assertion: service $test_FMRI didn't"
156 print -- " come online"
157 exit $STF_FAIL
158 fi
159
160 print -- "--INFO: Cleaning up service"
161 cleanup
162
163 exit $STF_PASS