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: methods_028
  32 # DESCRIPTION:
  33 #  If a service instance in the online state dies due to a hwerr
  34 #  then the svc.startd should attempt to restart the service.
  35 #  The service possesses more than one sub-process.
  36 #
  37 # end __stf_assertion__
  38 #
  39 
  40 . ${STF_TOOLS}/include/stf.kshlib
  41 . ${STF_SUITE}/include/gltest.kshlib
  42 . ${STF_SUITE}/include/svc.startd_config.kshlib
  43 . ${STF_SUITE}/tests/include/svc.startd_fileops.kshlib
  44 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
  45 
  46 typeset service_setup=0
  47 function cleanup {
  48         common_cleanup
  49 }
  50 
  51 trap cleanup 0 1 2 15
  52 
  53 readonly ME=$(whence -p ${0})
  54 readonly MYLOC=$(dirname ${ME})
  55 
  56 DATA=$MYLOC
  57 
  58 registration_template=$DATA/service_028.xml
  59 
  60 extract_assertion_info $ME
  61 
  62 # make sure that the svc.startd is running
  63 verify_daemon
  64 if [ $? -ne 0 ]; then
  65         print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
  66         print -- "  continue"
  67         exit $STF_UNRESOLVED
  68 fi
  69 
  70 # feature testing
  71 features=`feature_test MTST`
  72 if [ $? -ne 0 ]; then
  73         print -- "--DIAG: $assertion: $features missing from startd"
  74         exit $STF_UNTESTED
  75 fi
  76 
  77 # Make sure the environment is clean - the test service isn't running
  78 print -- "--INFO: Cleanup any old $test_FMRI state"
  79 service_cleanup $test_service
  80 rm -f $service_state
  81 if [ $? -ne 0 ]; then
  82         print -- "--DIAG: $assertion: unable to clean up any pre-existing state"
  83         exit $STF_UNRESOLVED
  84 fi
  85 
  86 print -- "--INFO: generating manifest for importation into repository"
  87 manifest_generate $registration_template \
  88         TEST_SERVICE=$test_service \
  89         TEST_INSTANCE=$test_instance \
  90         SERVICE_APP=$service_app \
  91         LOGFILE=$service_log \
  92         STATEFILE=$service_state \
  93         > $registration_file
  94 
  95 print -- "--INFO: Importing service into repository"
  96 manifest_purgemd5 $registration_file
  97 svccfg -v import $registration_file >$svccfg_errfile 2>&1
  98 if [ $? -ne 0 ]; then
  99         print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
 100         print -- "  error messages from svccfg: \"$(cat $svccfg_errfile)\""
 101         exit $STF_UNRESOLVED
 102 fi
 103 service_setup=1
 104 
 105 print -- "--INFO: enabling $test_FMRI"
 106 svcadm enable $test_FMRI
 107 if [ $? -ne 0 ]; then
 108         print -- "--DIAG: $assertion: enable command of $test_FMRI failed"
 109         exit $STF_FAIL
 110 fi
 111 
 112 print -- "--INFO: waiting for execution of start method"
 113 service_wait_method $test_FMRI start
 114 if [ $? -ne 0 ]; then
 115         print -- "--DIAG: $assertion: Service $test_FMRI didn't issue start"
 116         exit $STF_UNRESOLVED
 117 fi
 118 
 119 print -- "--INFO: Validating service reaches online mode"
 120 service_wait_state $test_FMRI online
 121 if [ $? -ne 0 ]; then
 122         print -- "--DIAG: $assertion: Service $test_FMRI didn't"
 123         print -- "  transition to online mode"
 124         exit $STF_FAIL
 125 fi
 126 
 127 print -- "--INFO: get the services to generate core files into log dir"
 128 PIDS=`service_getpids -s $test_service -i $test_instance -f $service_state`
 129 print -- "--INFO: child pids are: $PIDS"
 130 
 131 echo $PIDS | read pid1 pid2
 132 
 133 # pad run log
 134 $service_app -s $test_service -i $test_instance -l $service_log -m "blank"
 135 
 136 print -- "--INFO: cause one of the service processes to issue an hwerr"
 137 $service_app -s $test_service -i $test_instance -l $service_log -m "trigger" \
 138         -r "forkexec 1 mtst udue"
 139 
 140 print -- "--INFO: Waiting for service's start method"
 141 service_wait_method $test_FMRI start
 142 if [ $? -ne 0 ]; then
 143         print -- "--DIAG: $assertion: didn't issue start method"
 144         exit $STF_FAIL
 145 fi
 146 
 147 print -- "--INFO: verify that process $pid1 is no longer executing"
 148 kill -0 $pid1
 149 if [ $? -eq 0 ]; then
 150         print -- "--DIAG: service $pid1 is still executing"
 151         exit $STF_FAIL
 152 fi
 153 
 154 print -- "--INFO: Waiting for service to reach online state"
 155 service_wait_state $test_FMRI online
 156 if [ $? -ne 0 ]; then
 157         print -- "--DIAG: $assertion: service $test_FMRI didn't"
 158         print -- "  come online"
 159         exit $STF_FAIL
 160 fi
 161 
 162 print -- "--INFO: Cleaning up service"
 163 cleanup
 164 
 165 exit $STF_PASS