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