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_036
  32 # DESCRIPTION:
  33 #  A method containing the shorthand ':kill' will send a signal to all
  34 #  the processes executing in the service upon the execution of the
  35 #  method. The service has a single process.
  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         [[ "$pps" = "disabled" ]] && coreadm -d proc-setid 2>/dev/null
  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_036.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 # Make sure the environment is clean - the test service isn't running
  71 print -- "--INFO: Cleanup any old $test_FMRI state"
  72 service_cleanup $test_service
  73 rm -f $service_state
  74 if [ $? -ne 0 ]; then
  75         print -- "--DIAG: $assertion: unable to clean up any pre-existing state"
  76         exit $STF_UNRESOLVED
  77 fi
  78 
  79 pps=$(env LC_ALL=C coreadm | grep 'per-process setid' | awk '{print $NF }')
  80 
  81 if [ -z "$pps" ]; then
  82         print -- "--DIAG: could not get state from coreadm"
  83         exit $STF_UNRESOLVED
  84 fi
  85 
  86 if [ "$pps" = "disabled" ]; then
  87         print -- "--INFO: Enabling per-process setid coredumps"
  88         coreadm -e proc-setid
  89         if [ $? -ne 0 ]; then
  90                 print -- "--DIAG: Could not enable per-process setid coredumps"
  91                 exit $STF_UNRESOLVED
  92         fi
  93 fi
  94 
  95 print -- "--INFO: generating manifest for importation into repository"
  96 manifest_generate $registration_template \
  97         TEST_SERVICE=$test_service \
  98         TEST_INSTANCE=$test_instance \
  99         SERVICE_APP=$service_app \
 100         LOGFILE=$service_log \
 101         STATEFILE=$service_state \
 102         > $registration_file
 103 
 104 print -- "--INFO: Importing service into repository"
 105 manifest_purgemd5 $registration_file
 106 svccfg -v import $registration_file >$svccfg_errfile 2>&1
 107 if [ $? -ne 0 ]; then
 108         print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
 109         print -- "  error messages from svccfg: \"$(cat $svccfg_errfile)\""
 110         exit $STF_UNRESOLVED
 111 fi
 112 service_setup=1
 113 
 114 print -- "--INFO: enabling $test_FMRI"
 115 svcadm enable $test_FMRI
 116 if [ $? -ne 0 ]; then
 117         print -- "--DIAG: $assertion: enable command of $test_FMRI failed"
 118         exit $STF_FAIL
 119 fi
 120 
 121 print -- "--INFO: waiting for execution of start method"
 122 service_wait_method $test_FMRI start
 123 if [ $? -ne 0 ]; then
 124         print -- "--DIAG: $assertion: Service $test_FMRI didn't issue start"
 125         exit $STF_UNRESOLVED
 126 fi
 127 
 128 print -- "--INFO: setting core file generation for children"
 129 PIDS=`service_getpids -s $test_service -i $test_instance -f $service_state`
 130 coreadm -p "$RUNDIR/core.%p" $PIDS
 131 if [ $? -ne 0 ]; then
 132         print -- "--DIAG: $assertion: could not set core file generation"
 133         exit $STF_UNRESOLVED
 134 fi
 135 
 136 print -- "--INFO: disabling service"
 137 svcadm disable $test_FMRI
 138 if [ $? -ne 0 ]; then
 139         print -- "--DIAG: $assertion: could not disable service"
 140         exit $STF_UNRESOLVED
 141 fi
 142 
 143 print -- "--INFO: waiting for a core file to be generated"
 144 file_wait_exist $RUNDIR/core.$PIDS
 145 if [ $? -ne 0 ]; then
 146         print -- "--DIAG: $assertion: core file not generated"
 147         exit $STF_FAIL
 148 fi
 149 rm -f $RUNDIR/core.$PIDS
 150 
 151 print -- "--INFO: Cleaning up service"
 152 cleanup
 153 
 154 exit $STF_PASS