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_034
32 # DESCRIPTION:
33 # If the service stop method is not executable then the svc.startd
34 # shall transition the service into maintenance state.
35 # end __stf_assertion__
36 #
37
38 . ${STF_TOOLS}/include/stf.kshlib
39 . ${STF_SUITE}/include/gltest.kshlib
40 . ${STF_SUITE}/include/svc.startd_config.kshlib
41 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
42
43 typeset service_setup=0
44 function cleanup {
45 rm -f $stop_nonexec
46 [[ $service_setup -ne 0 ]] && \
47 $service_app -s $test_service -i $test_instance -m force_stop
48 common_cleanup
49 return $?
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_034.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: creating non-executable stop-program"
81 echo "" > $stop_nonexec
82 if [ $? -ne 0 ]; then
83 print -- "--DIAG: $assertion: unable to create file $stop_nonexec"
84 exit $STF_UNRESOLVED
85 fi
86 chmod a+r,a-x $stop_nonexec
87 if [ $? -ne 0 ]; then
88 print -- "--DIAG: $assertion: unable to chmod file $stop_nonexec"
89 exit $STF_UNRESOLVED
90 fi
91
92 print -- "--INFO: generating manifest for importation into repository"
93 manifest_generate $registration_template \
94 TEST_SERVICE=$test_service \
95 TEST_INSTANCE=$test_instance \
96 SERVICE_APP=$service_app \
97 LOGFILE=$service_log \
98 STATEFILE=$service_state \
99 STOP_NONEXEC=$stop_nonexec \
100 > $registration_file
101
102 print -- "--INFO: Importing service into repository"
103 manifest_purgemd5 $registration_file
104 svccfg -v import $registration_file >$svccfg_errfile 2>&1
105 if [ $? -ne 0 ]; then
106 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
107 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
108 exit $STF_UNRESOLVED
109 fi
110 service_setup=1
111
112 print -- "--INFO: Wait for $test_FMRI to come online"
113 service_wait_state $test_FMRI online
114 if [ $? -ne 0 ]; then
115 print -- "--DIAG: $assertion: Service $test_FMRI didn't go online"
116 exit $STF_FAIL
117 fi
118
119 print -- "--INFO: disabling service"
120 svcadm disable $test_FMRI
121 if [ $? -ne 0 ]; then
122 print -- "--DIAG: $assertion: disable command for Service "
123 print -- " $test_FMRI didn't succeed"
124 exit $STF_UNRESOLVED
125 fi
126
127 print -- "--INFO: Validating service is in maintenance mode"
128 service_wait_state $test_FMRI maintenance
129 if [ $? -ne 0 ]; then
130 print -- "--DIAG: $assertion: Service $test_FMRI did not "
131 print -- " transition to maintenance mode"
132 exit $STF_FAIL
133 fi
134
135 print -- "--INFO: Cleaning up service"
136 cleanup
137
138 exit $STF_PASS