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_041
  32 # DESCRIPTION:
  33 #  If adding a dependent service to an existing service creates
  34 #  a circular dependency then that service will go into the
  35 #  maintenance state. All the other services will enter the offline
  36 #  state.
  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         rm -f $svccfg_errfile
  49         common_cleanup
  50         rm -f $service_state1 $service_state2 $service_state3
  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_041.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         TEST_INSTANCE3=$test_instance3 \
  86         SERVICE_APP=$service_app \
  87         LOGFILE=$service_log \
  88         STATEFILE1=$service_state1 \
  89         STATEFILE2=$service_state2 \
  90         STATEFILE3=$service_state3 \
  91         > $registration_file
  92 
  93 print -- "--INFO: Importing service into repository"
  94 manifest_purgemd5 $registration_file
  95 svccfg -v import $registration_file >$svccfg_errfile 2>&1
  96 
  97 if [ $? -ne 0 ]; then
  98         print -- "--DIAG: $assertion: Unable to import the services $test_FMRI1"
  99         print -- "  and $test_FMRI2 error messages from svccfg: "
 100         print -- "  \"$(cat $svccfg_errfile)\""
 101         exit $STF_UNRESOLVED
 102 fi
 103 service_setup=1
 104 
 105 print -- "--INFO: Waiting for $test_FMRI3 to go to online"
 106 service_wait_state $test_FMRI3 online
 107 if [ $? -ne 0 ]; then
 108         print -- "--DIAG: $assertion: Service $test_FMRI3 did not go online"
 109         exit $STF_FAIL
 110 fi
 111 
 112 print -- "--INFO: Add dependency from $test_FMRI1 -> $test_FMRI3"
 113 service_dependency_add $test_FMRI1 adepc require_all refresh svc:/$test_FMRI3
 114 
 115 print -- "--INFO: Refresh $test_FMRI1"
 116 svcadm refresh $test_FMRI1
 117 if [ $? -ne 0 ]; then
 118         print -- "--DIAG: $assertion: Service $test_FMRI1 didn't refresh"
 119         exit $STF_FAIL
 120 fi
 121 
 122 print -- "--INFO: Verify service $test_FMRI1 is in maintenance"
 123 service_wait_state $test_FMRI1 maintenance
 124 if [ $? -ne 0 ]; then
 125         print -- "--DIAG: $assertion: Service $test_FMRI3 is not in maintenance"
 126         print -- "  it is in '$(svcs -H -o STATE $test_FMRI3)' instead."
 127         exit $STF_FAIL
 128 fi
 129 
 130 print -- "--INFO: Verify that $test_FMRI2 is in offline state"
 131 service_wait_state $test_FMRI2 offline
 132 if [ $? -ne 0 ]; then
 133         print -- "--DIAG: $assertion: Service $test_FMRI2 is not offline"
 134         print -- "  it is in '$(svcs -H -o STATE $test_FMRI2)' instead."
 135         exit $STF_FAIL
 136 fi
 137 
 138 print -- "--INFO: Verify that $test_FMRI3 is in offline state"
 139 service_wait_state $test_FMRI3 offline
 140 if [ $? -ne 0 ]; then
 141         print -- "--DIAG: $assertion: Service $test_FMRI3 is not offline"
 142         print -- "  it is in '$(svcs -H -o STATE $test_FMRI3)' instead."
 143         exit $STF_FAIL
 144 fi
 145 
 146 print -- "--INFO: Cleaning up service"
 147 cleanup
 148 
 149 exit $STF_PASS