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: depends_005
32 # DESCRIPTION:
33 # A service with a single dependency in a "require_any" grouping
34 # property is specified. The dependency is satisfied.
35 # svc.startd will transition the service into the online state.
36 # Services: a, b; b depends on a
37 #
38 # end __stf_assertion__
39 #
40
41 . ${STF_TOOLS}/include/stf.kshlib
42 . ${STF_SUITE}/include/gltest.kshlib
43 . ${STF_SUITE}/include/svc.startd_config.kshlib
44 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
45
46 typeset service_setup=0
47 function cleanup {
48 common_cleanup
49 rm -f $service_state1 $service_state2
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 readonly registration_template=$DATA/service_005.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_FMRI1, $test_FMRI2 state"
73 service_cleanup $test_service
74 if [ $? -ne 0 ]; then
75 print -- "--DIAG: $assertion: cleanup of a previous instance failed"
76 exit $STF_UNRESOLVED
77 fi
78
79 print -- "--INFO: generating manifest for importation into repository"
80 manifest_generate $registration_template \
81 TEST_SERVICE=$test_service \
82 TEST_INSTANCE1=$test_instance1 \
83 TEST_INSTANCE2=$test_instance2 \
84 SERVICE_APP=$service_app \
85 LOGFILE=$service_log \
86 STATEFILE1=$service_state1 \
87 STATEFILE2=$service_state2 > $registration_file
88
89 print -- "--INFO: Importing service into repository"
90 manifest_purgemd5 $registration_file
91 svccfg -v import $registration_file >$svccfg_errfile 2>&1
92
93 if [ $? -ne 0 ]; then
94 print -- "--DIAG: $assertion: Unable to import the services $test_FMRI1"
95 print -- " and $test_FMRI2 error messages from svccfg: "
96 print -- " \"$(cat $svccfg_errfile)\""
97 exit $STF_UNRESOLVED
98 fi
99 service_setup=1
100
101 print -- "--INFO: Wait for $test_FMRI2 to come online - it should not"
102 service_wait_state $test_FMRI2 online
103 if [ $? -eq 0 ]; then
104 print -- "--DIAG: $assertion: Service $test_FMRI2 came online"
105 exit $STF_FAIL
106 fi
107
108 print -- "--INFO: Enabling service $test_FMRI1"
109 svcadm enable $test_FMRI1
110 if [ $? -ne 0 ]; then
111 print -- "--DIAG: $assertion: Service $test_FMRI1 did not enable"
112 exit $STF_FAIL
113 fi
114
115 print -- "--INFO: Checking if svc.startd is still executing"
116 pgrep -z $(zonename) svc.startd >/dev/null
117 if [ $? -ne 0 ]; then
118 print -- "--DIAG: $assertion: svc.startd is not executing (!)"
119 exit $STF_UNRESOLVED
120 fi
121
122 print -- "--INFO: Waiting for $test_FMRI1 to come online"
123 service_wait_state $test_FMRI1 online
124 if [ $? -ne 0 ]; then
125 print -- "--DIAG: $assertion: Service $test_FMRI1 did not come online"
126 exit $STF_FAIL
127 fi
128
129 print -- "--INFO: Waiting for $test_FMRI2 to come online"
130 service_wait_state $test_FMRI2 online
131 if [ $? -ne 0 ]; then
132 print -- "--DIAG: $assertion: Service $test_FMRI2 did not come online"
133 exit $STF_FAIL
134 fi
135
136 print -- "--INFO: Cleaning up service"
137 cleanup
138
139 exit $STF_PASS