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_051
32 # DESCRIPTION:
33 # A service with a single dependency in a "require_all" 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 # This is a separate service dependency
38 #
39 # end __stf_assertion__
40 #
41
42 . ${STF_TOOLS}/include/stf.kshlib
43 . ${STF_SUITE}/include/gltest.kshlib
44 . ${STF_SUITE}/include/svc.startd_config.kshlib
45 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
46
47 typeset service_setup=0
48 function cleanup {
49 again=$service_setup
50 test_service=$test_service1
51 common_cleanup
52 service_setup=$again
53 test_service=$test_service2
54 common_cleanup
55 rm -f $service_state1 $service_state2
56 }
57
58 trap cleanup 0 1 2 15
59
60 readonly ME=$(whence -p ${0})
61 readonly MYLOC=$(dirname ${ME})
62
63 DATA=$MYLOC
64
65 readonly registration_template=$DATA/service_051.xml
66
67 extract_assertion_info $ME
68
69 # make sure that the svc.startd is running
70 verify_daemon
71 if [ $? -ne 0 ]; then
72 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
73 print -- " continue"
74 exit $STF_UNRESOLVED
75 fi
76
77 # Make sure the environment is clean - the test service isn't running
78 print -- "--INFO: Cleanup any old $test_service1, $test_service2 state"
79 service_cleanup $test_service1
80 if [ $? -ne 0 ]; then
81 print -- "--DIAG: $assertion: cleanup of $test_service1 instance failed"
82 exit $STF_UNRESOLVED
83 fi
84 service_cleanup $test_service2
85 if [ $? -ne 0 ]; then
86 print -- "--DIAG: $assertion: cleanup of $test_service2 instance failed"
87 exit $STF_UNRESOLVED
88 fi
89
90 print -- "--INFO: generating manifest for importation into repository"
91 manifest_generate $registration_template \
92 TEST_SERVICE1=$test_service1 \
93 TEST_SERVICE2=$test_service2 \
94 TEST_INSTANCE1=$test_instance1 \
95 TEST_INSTANCE2=$test_instance2 \
96 SERVICE_APP=$service_app \
97 LOGFILE=$service_log \
98 STATEFILE1=$service_state1 \
99 STATEFILE2=$service_state2 > $registration_file
100
101 print -- "--INFO: Importing service into repository"
102 manifest_purgemd5 $registration_file
103 svccfg -v import $registration_file >$svccfg_errfile 2>&1
104
105 if [ $? -ne 0 ]; then
106 print -- "--DIAG: $assertion: Unable to import the services $test_FMRI1"
107 print -- " and $test_FMRI2 error messages from svccfg: "
108 print -- " \"$(cat $svccfg_errfile)\""
109 exit $STF_UNRESOLVED
110 fi
111 service_setup=1
112
113 print -- "--INFO: Wait for $test_FMRI2 to come online - it should not"
114 service_wait_state $test_FMRI2 online
115 if [ $? -eq 0 ]; then
116 print -- "--DIAG: $assertion: Service $test_FMRI2 came online"
117 exit $STF_FAIL
118 fi
119
120 print -- "--INFO: Enabling service $test_FMRI1"
121 svcadm enable $test_FMRI1
122 if [ $? -ne 0 ]; then
123 print -- "--DIAG: $assertion: Service $test_FMRI1 did not enable"
124 exit $STF_FAIL
125 fi
126
127 print -- "--INFO: Waiting for $test_FMRI1 to come online"
128 service_wait_state $test_FMRI1 online
129 if [ $? -ne 0 ]; then
130 print -- "--DIAG: $assertion: Service $test_FMRI1 did not come online"
131 exit $STF_FAIL
132 fi
133
134 print -- "--INFO: Waiting for $test_FMRI2 to come online"
135 service_wait_state $test_FMRI2 online
136 if [ $? -ne 0 ]; then
137 print -- "--DIAG: $assertion: Service $test_FMRI2 did not come online"
138 exit $STF_FAIL
139 fi
140
141 print -- "--INFO: Cleaning up service"
142 cleanup
143
144 exit $STF_PASS