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_040
  32 # DESCRIPTION:
  33 #  A service that possesses a "failing, but not unrecoverable" enable
  34 #  method will upon the issuing of 'svcadm enable' result in the enable
  35 #  method being executed until the error threshold is reached and the
  36 #  service not leaving the disabled state.
  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/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_040.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. "
  65         print -- "  Cannot continue"
  66         exit $STF_UNRESOLVED
  67 fi
  68 
  69 # feature testing
  70 features=`feature_test METH_ENABLE`
  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 if [ $? -ne 0 ]; then
  80         print -- "--DIAG: $assertion: cleanup of previous service state failed"
  81         exit $STF_UNRESOLVED
  82 fi
  83 
  84 print -- "--INFO: generating manifest for importation into repository"
  85 manifest_generate $registration_template \
  86         TEST_SERVICE=$test_service \
  87         TEST_INSTANCE=$test_instance \
  88         SERVICE_APP=$service_app \
  89         LOGFILE=$service_log \
  90         STATEFILE=$service_state \
  91         ENABLE_RESULT="returncode $SVC_METHOD_OTHEREXIT" \
  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: Wait for $test_FMRI to come online ... it should not!"
 105 service_wait_state $test_FMRI online
 106 if [ $? -eq 0 ]; then
 107         print -- "--DIAG: $assertion: Service $test_FMRI went online"
 108         exit $STF_FAIL
 109 fi
 110 
 111 print -- "--INFO: Enabling service"
 112 svcadm enable $test_FMRI
 113 if [ $? -ne 0 ]; then
 114         print -- "--DIAG: $assertion: Service $test_FMRI didn't try to enable"
 115         exit $STF_UNRESOLVED
 116 fi
 117 
 118 print -- "--INFO: Waiting for invocation of enable method"
 119 service_wait_method $test_FMRI enable
 120 if [ $? -ne 0 ]; then
 121         print -- "--DIAG: $assertion: $test_FMRI didn't execute enable method"
 122         exit $STF_FAIL
 123 fi
 124 
 125 print -- "--INFO: Waiting for transition of $test_FMRI back to disabled"
 126 service_wait_state $test_FMRI disabled
 127 if [ $? -ne 0 ]; then
 128         print -- "--DIAG: $assertion: Service $test_FMRI didn't goto disabled"
 129         exit $STF_FAIL
 130 fi
 131 
 132 print -- "--INFO: Validating last invoked method was enable"
 133 lastcalled=`service_lastcall -f $service_state -s $test_service \
 134         -i $test_instance`
 135 if [ "$lastcalled" != "enable" ]; then
 136         print -- "--DIAG: $assertion: Service $test_FMRI didn't call "
 137         print -- "  enable method last called method was '$lastcalled' method"
 138         exit $STF_FAIL
 139 fi
 140 
 141 print -- "--INFO: Cleaning up service"
 142 cleanup
 143 
 144 exit $STF_PASS