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_029
32 # DESCRIPTION:
33 # If a service, service_A, has a dependency on another service,
34 # service_B, and service_B has a dependency on service_A then
35 # service_B will be transitioned to maintenance, while service_A
36 # stays in the offline state.
37 # (single link circular 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 common_cleanup
50 rm -f $service_state1 $service_state2
51 }
52
53 trap cleanup 0 1 2 15
54
55 readonly ME=$(whence -p ${0})
56 readonly MYLOC=$(dirname ${ME})
57
58 DATA=$MYLOC
59
60 readonly registration_template=$DATA/service_029.xml
61
62 extract_assertion_info $ME
63
64 # make sure that the svc.startd is running
65 verify_daemon
66 if [ $? -ne 0 ]; then
67 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
68 print -- " continue"
69 exit $STF_UNRESOLVED
70 fi
71
72 # Make sure the environment is clean - the test service isn't running
73 print -- "--INFO: Cleanup any old $test_FMRI1, $test_FMRI2 state"
74 service_cleanup $test_service
75 if [ $? -ne 0 ]; then
76 print -- "--DIAG: $assertion: cleanup of a previous instance failed"
77 exit $STF_UNRESOLVED
78 fi
79
80 print -- "--INFO: generating manifest for importation into repository"
81 manifest_generate $registration_template \
82 TEST_SERVICE=$test_service \
83 TEST_INSTANCE1=$test_instance1 \
84 TEST_INSTANCE2=$test_instance2 \
85 SERVICE_APP=$service_app \
86 LOGFILE=$service_log \
87 STATEFILE1=$service_state1 \
88 STATEFILE2=$service_state2 \
89 > $registration_file
90
91 print -- "--INFO: Importing service into repository"
92 manifest_purgemd5 $registration_file
93 svccfg -v import $registration_file >$svccfg_errfile 2>&1
94
95 if [ $? -ne 0 ]; then
96 print -- "--DIAG: $assertion: Unable to import the services $test_FMRI1"
97 print -- " and $test_FMRI2 error messages from svccfg: "
98 print -- " \"$(cat $svccfg_errfile)\""
99 exit $STF_UNRESOLVED
100 fi
101 service_setup=1
102
103 print -- "--INFO: Wait for one of $test_FMRI1, $test_FMRI2 to go to maintenance"
104 service_wait_state $test_FMRI1 maintenance&
105 typeset pid1=$!
106 service_wait_state $test_FMRI2 maintenance&
107 typeset pid2=$!
108 wait $pid1
109 typeset status1=$?
110 wait $pid2
111 typeset status2=$?
112
113 if [ $status1 -ne 0 -a $status2 -ne 0 ]; then
114 print -- "--DIAG: None of $test_service's instances went to maintenance"
115 print -- " state $test_FMRI1 = '$(svcs -H -o STATE $test_FMRI1)'"
116 print -- " state $test_FMRI2 = '$(svcs -H -o STATE $test_FMRI2)'"
117 exit $STF_FAIL
118 fi
119
120 if [ $status1 -eq 0 ]; then
121 offline=$test_FMRI2
122 maintenance=$test_FMRI1
123 else
124 offline=$test_FMRI1
125 maintenance=$TEST_FMRI2
126 fi
127
128 print -- "--INFO: Verifying that $offline is in the offline state"
129 service_wait_state $offline offline
130 if [ $? -ne 0 ]; then
131 print -- "--DIAG: $assertion: Service $offline did not go to the"
132 print -- " offline state. It is in the " \
133 "\"$(svcs -H -o STATE $offline)\" state."
134 exit $STF_FAIL
135 fi
136
137 print -- "--INFO: Cleaning up service"
138 cleanup
139
140 exit $STF_PASS