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: context_023
  32 # DESCRIPTION:
  33 #  :default can be used as a token to indicate the use of the resource
  34 #  pool specified in the project(4) entry for the project specified in
  35 #  the "project" attribute of the method_context.
  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/svc.startd/include/svc.startd_common.kshlib
  44 
  45 zone=`/bin/zonename`
  46 if [ "$zone" != "global" ]
  47 then
  48         exit $STF_UNSUPPORTED
  49 fi
  50 
  51 typeset service_setup=0
  52 function cleanup {
  53         common_cleanup
  54 }
  55 
  56 trap cleanup 0 1 2 15
  57 
  58 readonly ME=$(whence -p ${0})
  59 readonly MYLOC=$(dirname ${ME})
  60 
  61 DATA=$MYLOC
  62 
  63 readonly registration_template=$DATA/service_023.xml
  64 
  65 extract_assertion_info $ME
  66 
  67 # make sure that the svc.startd is running
  68 verify_daemon
  69 if [ $? -ne 0 ]; then
  70         print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
  71         print -- "  continue"
  72         exit $STF_UNRESOLVED
  73 fi
  74 
  75 # Make sure the environment is clean - the test service isn't running
  76 print -- "--INFO: Cleanup any old $test_FMRI state"
  77 service_cleanup $test_service
  78 if [ $? -ne 0 ]; then
  79         print -- "--DIAG: $assertion: cleanup of a previous instance failed"
  80         exit $STF_UNRESOLVED
  81 fi
  82 
  83 print -- "--INFO: create world read/writeable log file for the service"
  84 rm -f $service_log
  85 touch $service_log
  86 if [ $? -ne 0 ]; then
  87         print -- "--DIAG: $assertion: could not create log file"
  88         exit $STF_UNRESOLVED
  89 fi
  90 chmod a+rw $service_log
  91 if [ $? -ne 0 ]; then
  92         print -- "--DIAG: $assertion: could not make log file world writeable"
  93         exit $STF_UNRESOLVED
  94 fi
  95 chmod a+rwx $RUNDIR
  96 if [ $? -ne 0 ]; then
  97         print -- "--DIAG: $assertion: could not make $RUNDIR world rwx"
  98         exit $STF_UNRESOLVED
  99 fi
 100 
 101 print -- "--INFO: generating manifest for importation into repository"
 102 manifest_generate $registration_template \
 103         TEST_SERVICE=$test_service \
 104         TEST_INSTANCE=$test_instance \
 105         SERVICE_APP=$service_app \
 106         LOGFILE=$service_log \
 107         TEST_USER=$ctx_user \
 108         TEST_GROUP=$ctx_group \
 109         TEST_PROJECT=$ctx_project \
 110         STATEFILE=$service_state > $registration_file
 111 manifest_zone_clean $registration_file
 112 
 113 print -- "--INFO: Importing service into repository"
 114 manifest_purgemd5 $registration_file
 115 svccfg -v import $registration_file >$svccfg_errfile 2>&1
 116 
 117 if [ $? -ne 0 ]; then
 118         print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
 119         print -- "  error messages from svccfg: \"$(cat $svccfg_errfile)\""
 120         exit $STF_UNRESOLVED
 121 fi
 122 service_setup=1
 123 
 124 print -- "--INFO: Wait for $test_FMRI to come online"
 125 service_wait_state $test_FMRI online
 126 if [ $? -ne 0 ]; then
 127         print -- "--DIAG: $assertion: Service $test_FMRI did not go online"
 128         exit $STF_FAIL
 129 fi
 130 
 131 print -- "--INFO: Checking start methods resource pool name"
 132 line=`grep_logline_entry $test_service $test_instance start poolinfo`
 133 if [ $? -ne 0 ]; then
 134         print -- "--DIAG: Could not find resource pool line from"
 135         print -- " start method"
 136         exit $STF_FAIL
 137 fi
 138 if [ "${line}" != "$ctx_default_resourcepool" ]; then
 139         print -- "--DIAG: Did not have $ctx_default_resourcepool as pool."
 140         print -- "  instead it was: '${line}'"
 141         exit $STF_FAIL
 142 fi
 143 
 144 print -- "--INFO: Cleaning up service"
 145 cleanup
 146 
 147 exit $STF_PASS