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_033
  32 # DESCRIPTION:
  33 #  If the service stop method does not exist then the svc.startd 
  34 #  shall transition the service into maintenance state.
  35 # end __stf_assertion__
  36 #
  37 
  38 . ${STF_TOOLS}/include/stf.kshlib
  39 . ${STF_SUITE}/include/gltest.kshlib
  40 . ${STF_SUITE}/include/svc.startd_config.kshlib
  41 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
  42 
  43 typeset service_setup=0
  44 function cleanup {
  45         [[ $service_setup -ne 0 ]] && $service_app -s $test_service \
  46                         -i $test_instance -m force_stop
  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_033.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_FMRI state"
  71 service_cleanup $test_service
  72 rm -f $service_state
  73 if [ $? -ne 0 ]; then
  74         print -- "--DIAG: $assertion: unable to clean up any pre-existing state"
  75         exit $STF_UNRESOLVED
  76 fi
  77 
  78 print -- "--INFO: generating manifest for importation into repository"
  79 manifest_generate $registration_template \
  80         TEST_SERVICE=$test_service \
  81         TEST_INSTANCE=$test_instance \
  82         SERVICE_APP=$service_app \
  83         LOGFILE=$service_log \
  84         STATEFILE=$service_state \
  85         > $registration_file
  86 
  87 print -- "--INFO: Importing service into repository"
  88 manifest_purgemd5 $registration_file
  89 svccfg -v import $registration_file >$svccfg_errfile 2>&1
  90 if [ $? -ne 0 ]; then
  91         print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
  92         print -- "  error messages from svccfg: \"$(cat $svccfg_errfile)\""
  93         exit $STF_UNRESOLVED
  94 fi
  95 service_setup=1
  96 
  97 print -- "--INFO: Wait for $test_FMRI to come online"
  98 service_wait_state $test_FMRI online
  99 if [ $? -ne 0 ]; then
 100         print -- "--DIAG: $assertion: Service $test_FMRI didn't go online"
 101         exit $STF_FAIL
 102 fi
 103 
 104 print -- "--INFO: disabling service"
 105 svcadm disable $test_FMRI
 106 if [ $? -ne 0 ]; then
 107         print -- "--DIAG: $assertion: disable command for Service "
 108         print -- "  $test_FMRI didn't succeed"
 109         exit $STF_UNRESOLVED
 110 fi
 111 
 112 print -- "--INFO: Validating service is in maintenance mode"
 113 service_wait_state $test_FMRI maintenance
 114 if [ $? -ne 0 ]; then
 115         print -- "--DIAG: $assertion: Service $test_FMRI did not "
 116         print -- "  transition to maintenance mode"
 117         exit $STF_FAIL
 118 fi
 119 
 120 print -- "--INFO: Cleaning up service"
 121 cleanup
 122 
 123 exit $STF_PASS