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: context_015
32 # DESCRIPTION:
33 # svc.startd will start a method using the profile specified by the
34 # name attribute of the method_profile.
35 #
36 # end __stf_assertion__
37 #
38
39 . ${STF_TOOLS}/include/stf.kshlib
40 . ${STF_SUITE}/include/gltest.kshlib
41 . ${STF_SUITE}/include/svc.startd_config.kshlib
42 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
43
44 typeset service_setup=0
45 function cleanup {
46 common_cleanup
47 }
48
49 trap cleanup 0 1 2 15
50
51 readonly ME=$(whence -p ${0})
52 readonly MYLOC=$(dirname ${ME})
53
54 DATA=$MYLOC
55
56 readonly registration_template=$DATA/service_015.xml
57
58 extract_assertion_info $ME
59
60 # make sure that the svc.startd is running
61 verify_daemon
62 if [ $? -ne 0 ]; then
63 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
64 print -- " continue"
65 exit $STF_UNRESOLVED
66 fi
67
68 # Make sure the environment is clean - the test service isn't running
69 print -- "--INFO: Cleanup any old $test_FMRI state"
70 service_cleanup $test_service
71 if [ $? -ne 0 ]; then
72 print -- "--DIAG: $assertion: cleanup of a previous instance failed"
73 exit $STF_UNRESOLVED
74 fi
75
76 print -- "--INFO: create world read/writeable log file for the service"
77 rm -f $service_log
78 touch $service_log
79 if [ $? -ne 0 ]; then
80 print -- "--DIAG: $assertion: could not create log file"
81 exit $STF_UNRESOLVED
82 fi
83 chmod a+rw $service_log
84 if [ $? -ne 0 ]; then
85 print -- "--DIAG: $assertion: could not make log file world writeable"
86 exit $STF_UNRESOLVED
87 fi
88 chmod a+rwx $RUNDIR
89 if [ $? -ne 0 ]; then
90 print -- "--DIAG: $assertion: could not make $RUNDIR world rwx"
91 exit $STF_UNRESOLVED
92 fi
93
94 print -- "--INFO: initializing service_statefile"
95 $service_app -s $test_service -i $test_instance -f $service_state -m init
96 if [ ! -f $service_state ]; then
97 print -- "--DIAG: Could not create service state"
98 exit $STF_UNRESOLVED
99 fi
100 chmod a+rw $service_state
101
102 print -- "--INFO: generating manifest for importation into repository"
103 manifest_generate $registration_template \
104 TEST_SERVICE=$test_service \
105 TEST_INSTANCE=$test_instance \
106 SERVICE_APP=$service_app \
107 LOGFILE=$service_log \
108 TEST_PROFILENAME="$ctx_profilename" \
109 STATEFILE=$service_state > $registration_file
110
111 print -- "--INFO: Importing service into repository"
112 manifest_purgemd5 $registration_file
113 svccfg -v import $registration_file >$svccfg_errfile 2>&1
114
115 if [ $? -ne 0 ]; then
116 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
117 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
118 exit $STF_UNRESOLVED
119 fi
120 service_setup=1
121
122 print -- "--INFO: Wait for $test_FMRI to come online"
123 service_wait_state $test_FMRI online
124 if [ $? -ne 0 ]; then
125 print -- "--DIAG: $assertion: Service $test_FMRI did not go online"
126 exit $STF_FAIL
127 fi
128
129 print -- "--INFO: Checking start method's profile"
130 line=`grep_logline_entry $test_service $test_instance start groupname`
131 if [ $? -ne 0 ]; then
132 print -- "--DIAG: Could not find groupname line from "
133 print -- " start method '${line}'"
134 exit $STF_FAIL
135 fi
136 if [ "$line" != $ctx_group ]; then
137 print -- "--DIAG: Did not have groupname==$ctx_group in '$line'"
138 exit $STF_FAIL
139 fi
140 line=`grep_logline_entry $test_service $test_instance start username`
141 if [ $? -ne 0 ]; then
142 print -- "--DIAG: Could not find username line from "
143 print -- " start method '${line}'"
144 exit $STF_FAIL
145 fi
146 if [ "$line" != $ctx_user ]; then
147 print -- "--DIAG: Did not have username==$ctx_user in '$line'"
148 exit $STF_FAIL
149 fi
150 line=`grep_logline_entry $test_service $test_instance start privileges`
151 if [ $? -ne 0 ]; then
152 print -- "--DIAG: Could not find privileges line in start method"
153 exit $STF_FAIL
154 fi
155 if [ "${line%file_dac_write*}" = "${line}" ]; then
156 print -- "--DIAG: Did not have file_dac_write privilege in set '$line'"
157 exit $STF_FAIL
158 fi
159
160 print -- "--INFO: Cleaning up service"
161 cleanup
162
163 exit $STF_PASS