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_027
  32 # DESCRIPTION:
  33 #  Service with a single process.
  34 #  If a service instance in the online state dies due to a hwerr
  35 #  then the svc.startd should attempt to restart the service.
  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/include/svc.startd_fileops.kshlib
  43 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
  44 
  45 typeset service_setup=0
  46 function cleanup {
  47         common_cleanup
  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 registration_template=$DATA/service_027.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 # feature testing
  70 features=`feature_test MTST`
  71 if [ $? -ne 0 ]; then
  72         print -- "--DIAG: $assertion: $features missing from startd"
  73         exit $STF_UNTESTED
  74 fi
  75 
  76 # Make sure the environment is clean - the test service isn't running
  77 print -- "--INFO: Cleanup any old $test_FMRI state"
  78 service_cleanup $test_service
  79 rm -f $service_state
  80 if [ $? -ne 0 ]; then
  81         print -- "--DIAG: $assertion: unable to clean up any pre-existing state"
  82         exit $STF_UNRESOLVED
  83 fi
  84 
  85 print -- "--INFO: generating manifest for importation into repository"
  86 manifest_generate $registration_template \
  87         TEST_SERVICE=$test_service \
  88         TEST_INSTANCE=$test_instance \
  89         SERVICE_APP=$service_app \
  90         LOGFILE=$service_log \
  91         STATEFILE=$service_state \
  92         > $registration_file
  93 
  94 print -- "--INFO: Importing service into repository"
  95 manifest_purgemd5 $registration_file
  96 svccfg -v import $registration_file >$svccfg_errfile 2>&1
  97 if [ $? -ne 0 ]; then
  98         print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
  99         print -- "  error messages from svccfg: \"$(cat $svccfg_errfile)\""
 100         exit $STF_UNRESOLVED
 101 fi
 102 service_setup=1
 103 
 104 print -- "--INFO: enabling $test_FMRI"
 105 svcadm enable $test_FMRI
 106 if [ $? -ne 0 ]; then
 107         print -- "--DIAG: $assertion: enable command of $test_FMRI failed"
 108         exit $STF_FAIL
 109 fi
 110 
 111 print -- "--INFO: waiting for execution of start method"
 112 service_wait_method $test_FMRI start
 113 if [ $? -ne 0 ]; then
 114         print -- "--DIAG: $assertion: Service $test_FMRI didn't issue start"
 115         exit $STF_UNRESOLVED
 116 fi
 117 
 118 print -- "--INFO: Validating service reaches online mode"
 119 service_wait_state $test_FMRI online
 120 if [ $? -ne 0 ]; then
 121         print -- "--DIAG: $assertion: Service $test_FMRI didn't"
 122         print -- "  transition to online mode"
 123         exit $STF_FAIL
 124 fi
 125 
 126 PIDS=`service_getpids -s $test_service -i $test_instance -f $service_state`
 127 print -- "--INFO: child pids are: $PIDS"
 128 
 129 $service_app -s $test_service -i $test_instance -l $service_log -m "trigger" \
 130         -r "lockdown 0"
 131 
 132 service_wait_method $test_FMRI memcntl 5
 133 if [ $? -ne 0 ]; then
 134         print "--DIAG: could not mlock memory space of service"
 135         exit $STF_UNRESOLVED
 136 fi
 137 
 138 print -- "--INFO: issue a hardware error to the service pid"
 139 $service_app -s $test_service -i $test_instance -l $service_log -m "trigger" \
 140         -r "forkexec 0 mtst udue"
 141 
 142 print -- "--INFO: Waiting for service's start method"
 143 service_wait_method $test_FMRI start
 144 if [ $? -ne 0 ]; then
 145         print -- "--DIAG: $assertion: didn't issue start method"
 146         exit $STF_FAIL
 147 fi
 148 
 149 print -- "--INFO: Waiting for service to reach online state"
 150 service_wait_state $test_FMRI online
 151 if [ $? -ne 0 ]; then
 152         print -- "--DIAG: $assertion: service $test_FMRI didn't"
 153         print -- "  come online"
 154         exit $STF_FAIL
 155 fi
 156 
 157 print -- "--INFO: Cleaning up service"
 158 cleanup
 159 
 160 exit $STF_PASS