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_016
  32 # DESCRIPTION:
  33 #  Attempting to start a service with an invalid profile set in the
  34 #  method_profile attribute will result in an error.  svc.startd
  35 #  will re-attempt to start the service until the error threshold
  36 #  is reached and, at that point, the service will be placed into
  37 #  maintenance state.
  38 #
  39 # end __stf_assertion__
  40 #
  41 
  42 . ${STF_TOOLS}/include/stf.kshlib
  43 . ${STF_SUITE}/include/gltest.kshlib
  44 . ${STF_SUITE}/include/svc.startd_config.kshlib
  45 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
  46 
  47 typeset service_setup=0
  48 function cleanup {
  49         common_cleanup
  50 }
  51 
  52 trap cleanup 0 1 2 15
  53 
  54 readonly ME=$(whence -p ${0})
  55 readonly MYLOC=$(dirname ${ME})
  56 
  57 DATA=$MYLOC
  58 
  59 readonly registration_template=$DATA/service_016.xml
  60 
  61 extract_assertion_info $ME
  62 
  63 # make sure that the svc.startd is running
  64 verify_daemon
  65 if [ $? -ne 0 ]; then
  66         print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
  67         print -- "  continue"
  68         exit $STF_UNRESOLVED
  69 fi
  70 
  71 # Make sure the environment is clean - the test service isn't running
  72 print -- "--INFO: Cleanup any old $test_FMRI state"
  73 service_cleanup $test_service
  74 if [ $? -ne 0 ]; then
  75         print -- "--DIAG: $assertion: cleanup of a previous instance failed"
  76         exit $STF_UNRESOLVED
  77 fi
  78 
  79 print -- "--INFO: create world read/writeable log file for the service"
  80 rm -f $service_log
  81 touch $service_log
  82 if [ $? -ne 0 ]; then
  83         print -- "--DIAG: $assertion: could not create log file"
  84         exit $STF_UNRESOLVED
  85 fi
  86 chmod a+rw $service_log
  87 if [ $? -ne 0 ]; then
  88         print -- "--DIAG: $assertion: could not make log file world writeable"
  89         exit $STF_UNRESOLVED
  90 fi
  91 chmod a+rwx $RUNDIR
  92 if [ $? -ne 0 ]; then
  93         print -- "--DIAG: $assertion: could not make $RUNDIR world rwx"
  94         exit $STF_UNRESOLVED
  95 fi
  96 
  97 print -- "--INFO: initializing service_statefile"
  98 $service_app -s $test_service -i $test_instance -f $service_state -m init
  99 if [ ! -f $service_state ]; then
 100         print -- "--DIAG: Could not create service state"
 101         exit $STF_UNRESOLVED
 102 fi
 103 chmod a+rw $service_state
 104 
 105 print -- "--INFO: generating manifest for importation into repository"
 106 manifest_generate $registration_template \
 107         TEST_SERVICE=$test_service \
 108         TEST_INSTANCE=$test_instance \
 109         SERVICE_APP=$service_app \
 110         LOGFILE=$service_log \
 111         TEST_PROFILENAME="This Profile Certainly Does Not Exist Here" \
 112         STATEFILE=$service_state > $registration_file
 113 
 114 print -- "--INFO: Importing service into repository"
 115 manifest_purgemd5 $registration_file
 116 svccfg -v import $registration_file >$svccfg_errfile 2>&1
 117 
 118 if [ $? -ne 0 ]; then
 119         print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
 120         print -- "  error messages from svccfg: \"$(cat $svccfg_errfile)\""
 121         exit $STF_UNRESOLVED
 122 fi
 123 service_setup=1
 124 
 125 print -- "--INFO: Wait for $test_FMRI to enter maintenance"
 126 service_wait_state $test_FMRI maintenance
 127 if [ $? -ne 0 ]; then
 128         print -- "--DIAG: $assertion: Service $test_FMRI did not go to"
 129         print -- "  maintenance. It was in '$(svcs -H -o STATE $test_FMRI)'."
 130         exit $STF_FAIL
 131 fi
 132 
 133 print -- "--INFO: Cleaning up service"
 134 cleanup
 135 
 136 exit $STF_PASS