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_018
  32 # DESCRIPTION:
  33 #  svc.startd will start a method from the directory specified in
  34 #  the working_directory attribute of the method_context.
  35 #
  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/svc.startd/include/svc.startd_common.kshlib
  43 
  44 typeset service_setup=0
  45 function cleanup {
  46         common_cleanup
  47         [ -n "$TESTDIR" ] && rm -rf $TESTDIR
  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 readonly registration_template=$DATA/service_018.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 if [ $? -ne 0 ]; then
  73         print -- "--DIAG: $assertion: cleanup of a previous instance failed"
  74         exit $STF_UNRESOLVED
  75 fi
  76 
  77 print -- "--INFO: create world read/writeable log file for the service"
  78 rm -f $service_log
  79 touch $service_log
  80 if [ $? -ne 0 ]; then
  81         print -- "--DIAG: $assertion: could not create log file"
  82         exit $STF_UNRESOLVED
  83 fi
  84 chmod a+rw $service_log
  85 if [ $? -ne 0 ]; then
  86         print -- "--DIAG: $assertion: could not make log file world writeable"
  87         exit $STF_UNRESOLVED
  88 fi
  89 
  90 TESTDIR="$RUNDIR/test_dir"
  91 if [ ! -d "$TESTDIR" ]; then
  92         mkdir -p "$TESTDIR"
  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         STARTINGDIR="$TESTDIR" \
 102         STATEFILE=$service_state > $registration_file
 103 manifest_zone_clean $registration_file
 104 
 105 print -- "--INFO: Importing service into repository"
 106 manifest_purgemd5 $registration_file
 107 svccfg -v import $registration_file >$svccfg_errfile 2>&1
 108 
 109 if [ $? -ne 0 ]; then
 110         print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
 111         print -- "  error messages from svccfg: \"$(cat $svccfg_errfile)\""
 112         exit $STF_UNRESOLVED
 113 fi
 114 service_setup=1
 115 
 116 print -- "--INFO: Wait for $test_FMRI to come online"
 117 service_wait_state $test_FMRI online
 118 if [ $? -ne 0 ]; then
 119         print -- "--DIAG: $assertion: Service $test_FMRI did not go online"
 120         exit $STF_FAIL
 121 fi
 122 
 123 print -- "--INFO: Checking start methods working directory"
 124 line=`grep_logline_entry $test_service $test_instance start mycwd`
 125 if [ $? -ne 0 ]; then
 126         print -- "--DIAG: Could not find mycwd line from "
 127         print -- " start method '${line}'"
 128         exit $STF_FAIL
 129 fi
 130 if [ "${line}" != "$TESTDIR" ]; then
 131         print -- "--DIAG: Did not have workign directory $TESTDIR."
 132         print -- "  instead it was: '${line}'"
 133         exit $STF_FAIL
 134 fi
 135 
 136 print -- "--INFO: Cleaning up service"
 137 cleanup
 138 
 139 exit $STF_PASS