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_041
32 # DESCRIPTION:
33 # svc.startd will start a method in the projectid specified in
34 # the project attribute of the method_context.
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_041.xml
57
58 readonly context_projid=$(getent project $ctx_project | cut -d: -f 2,2)
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 a previous instance failed"
75 exit $STF_UNRESOLVED
76 fi
77
78 print -- "--INFO: create world read/writeable log file for the service"
79 rm -f $service_log
80 touch $service_log
81 if [ $? -ne 0 ]; then
82 print -- "--DIAG: $assertion: could not create log file"
83 exit $STF_UNRESOLVED
84 fi
85 chmod a+rw $service_log
86 if [ $? -ne 0 ]; then
87 print -- "--DIAG: $assertion: could not make log file world writeable"
88 exit $STF_UNRESOLVED
89 fi
90 chmod a+rwx $RUNDIR
91 if [ $? -ne 0 ]; then
92 print -- "--DIAG: $assertion: could not make $RUNDIR world rwx"
93 exit $STF_UNRESOLVED
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 PROJECT=$context_projid \
103 STATEFILE=$service_state > $registration_file
104 manifest_zone_clean $registration_file
105
106 print -- "--INFO: Importing service into repository"
107 manifest_purgemd5 $registration_file
108 svccfg -v import $registration_file >$svccfg_errfile 2>&1
109
110 if [ $? -ne 0 ]; then
111 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
112 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
113 exit $STF_UNRESOLVED
114 fi
115 service_setup=1
116
117 print -- "--INFO: Wait for $test_FMRI to come online"
118 service_wait_state $test_FMRI online
119 if [ $? -ne 0 ]; then
120 print -- "--DIAG: $assertion: Service $test_FMRI did not go online"
121 exit $STF_FAIL
122 fi
123
124 print -- "--INFO: Checking start methods working directory"
125 line=`grep_logline_entry $test_service $test_instance start projectid`
126 if [ $? -ne 0 ]; then
127 print -- "--DIAG: Could not find projectid line from "
128 print -- " start method"
129 exit $STF_FAIL
130 fi
131 if [ "${line}" != "$context_projid" ]; then
132 print -- "--DIAG: Did not have project id $context_projid."
133 print -- " instead it was: '${line}'"
134 exit $STF_FAIL
135 fi
136
137 print -- "--INFO: Cleaning up service"
138 cleanup
139
140 exit $STF_PASS