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