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_015
32 # DESCRIPTION:
33 # service with single process.
34 # If a service instance in the online state dumps core than svc.startd
35 # should attempt to restart the service.
36 #
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/include/svc.startd_fileops.kshlib
44 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
45
46 typeset service_setup=0
47 function cleanup {
48 [[ "$pps" = "disabled" ]] && coreadm -d proc-setid 2>/dev/null
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_015.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 pps=$(env LC_ALL=C coreadm | grep 'per-process setid' | awk '{print $NF }')
81
82 if [ -z "$pps" ]; then
83 print -- "--DIAG: could not get state from coreadm"
84 exit $STF_UNRESOLVED
85 fi
86
87 if [ "$pps" = "disabled" ]; then
88 print -- "--INFO: Enabling per-process setid coredumps"
89 coreadm -e proc-setid
90 if [ $? -ne 0 ]; then
91 print -- "--DIAG: Could not enable per-process setid coredumps"
92 exit $STF_UNRESOLVED
93 fi
94 fi
95
96 print -- "--INFO: generating manifest for importation into repository"
97 manifest_generate $registration_template \
98 TEST_SERVICE=$test_service \
99 TEST_INSTANCE=$test_instance \
100 SERVICE_APP=$service_app \
101 LOGFILE=$service_log \
102 STATEFILE=$service_state \
103 > $registration_file
104
105 print -- "--INFO: Importing service into repository"
106 manifest_purgemd5 $registration_file
107 svccfg -v import $registration_file >$svccfg_errfile 2>&1
108 if [ $? -ne 0 ]; then
109 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
110 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
111 exit $STF_UNRESOLVED
112 fi
113 service_setup=1
114
115 print -- "--INFO: enabling $test_FMRI"
116 svcadm enable $test_FMRI
117 if [ $? -ne 0 ]; then
118 print -- "--DIAG: $assertion: enable command of $test_FMRI failed"
119 exit $STF_FAIL
120 fi
121
122 print -- "--INFO: waiting for execution of start method"
123 service_wait_method $test_FMRI start
124 if [ $? -ne 0 ]; then
125 print -- "--DIAG: $assertion: Service $test_FMRI didn't issue start"
126 exit $STF_UNRESOLVED
127 fi
128
129 print -- "--INFO: Validating service reaches online mode"
130 service_wait_state $test_FMRI online
131 if [ $? -ne 0 ]; then
132 print -- "--DIAG: $assertion: Service $test_FMRI didn't"
133 print -- " transition to online mode"
134 exit $STF_FAIL
135 fi
136
137 print -- "--INFO: get the services to generate core files into log dir"
138 PIDS=`service_getpids -s $test_service -i $test_instance -f $service_state`
139 print -- "--INFO: child pids are: $PIDS"
140 coreadm -p "$RUNDIR/core.%p" $PIDS
141
142 print -- "--INFO: make the service core dump... use dummy method"
143 $service_app -s $test_service -i $test_instance \
144 -m trigger -r "triggerservicesegv"
145
146 print -- "--INFO: checking for core file"
147 for i in $PIDS; do
148 file_wait_exist $RUNDIR/core.$i
149 if [ $? -ne 0 ]; then
150 print -- "--DIAG: core file for service not found"
151 exit $STF_FAIL
152 fi
153 # blow it away... we actually don't care about the contents
154 rm -f $RUNDIR/core.$i
155 done
156
157 print -- "--INFO: Waiting for service's start method"
158 service_wait_method $test_FMRI start
159 if [ $? -ne 0 ]; then
160 print -- "--DIAG: $assertion: didn't issue start method"
161 exit $STF_FAIL
162 fi
163
164 print -- "--INFO: Waiting for service to reach online state"
165 service_wait_state $test_FMRI online
166 if [ $? -ne 0 ]; then
167 print -- "--DIAG: $assertion: service $test_FMRI didn't"
168 print -- " come online"
169 exit $STF_FAIL
170 fi
171
172 print -- "--INFO: Cleaning up service"
173 cleanup
174
175 exit $STF_PASS