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_004
32 # DESCRIPTION:
33 # When a service that is online is disabled then it's stop method
34 # shall be called, and if successful, then it shall transition to
35 # the disabled state.
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/svc.startd/include/svc.startd_common.kshlib
44
45 typeset service_setup=0
46 function cleanup {
47 common_cleanup
48 return $?
49 }
50
51 trap cleanup 0 1 2 15
52
53 readonly ME=$(whence -p ${0})
54 readonly MYLOC=$(dirname ${ME})
55
56 DATA=$MYLOC
57
58 registration_template=$DATA/service_004.xml
59
60 extract_assertion_info $ME
61
62 # make sure that the svc.startd is running
63 verify_daemon
64 if [ $? -ne 0 ]; then
65 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
66 print -- "continue"
67 exit $STF_UNRESOLVED
68 fi
69
70 # Make sure the environment is clean - the test service isn't running
71 print -- "--INFO: Cleanup any old $test_FMRI state"
72 service_cleanup $test_service
73 if [ $? -ne 0 ]; then
74 print -- "--DIAG: $assertion: cleanup of previous service failed"
75 exit $STF_UNRESOLVED
76 fi
77
78 print -- "--INFO: generating manifest for importation into repository"
79 manifest_generate $registration_template \
80 TEST_SERVICE=$test_service \
81 TEST_INSTANCE=$test_instance \
82 SERVICE_APP=$service_app \
83 LOGFILE=$service_log \
84 STATEFILE=$service_state \
85 > $registration_file
86
87 print -- "--INFO: Importing service into repository"
88 manifest_purgemd5 $registration_file
89 svccfg -v import $registration_file >$svccfg_errfile 2>&1
90 if [ $? -ne 0 ]; then
91 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
92 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
93 exit $STF_UNRESOLVED
94 fi
95 service_setup=1
96
97 print -- "--INFO: Wait for $test_FMRI to come online"
98 service_wait_state $test_FMRI online
99 if [ $? -ne 0 ]; then
100 print -- "--DIAG: $assertion: Service $test_FMRI didn't go online"
101 exit $STF_FAIL
102 fi
103
104 print -- "--INFO: Disabling service"
105 svcadm disable $test_FMRI
106 if [ $? -ne 0 ]; then
107 print -- "--DIAG: $assertion: Service $test_FMRI didn't disable"
108 exit $STF_UNRESOLVED
109 fi
110
111 print -- "--INFO: Waiting for transition of $test_FMRI to disabled"
112 service_wait_state $test_FMRI disabled
113 if [ $? -ne 0 ]; then
114 print -- "--DIAG: $assertion: Service $test_FMRI didn't go disabled"
115 exit $STF_FAIL
116 fi
117
118 print -- "--INFO: Validating last invoked method was stop"
119 lastcalled=`service_lastcall -f $service_state -s $test_service \
120 -i $test_instance`
121 if [ "$lastcalled" != "stop" ]; then
122 print -- "--DIAG: $assertion: Service $test_FMRI didn't call start "
123 print -- " method. last called method was '$lastcalled' method"
124 exit $STF_FAIL
125 fi
126
127 print -- "--INFO: Cleaning up service"
128 cleanup
129
130 exit $STF_PASS