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 ###############################################################################
  30 # start __stf_assertion__
  31 #
  32 # ASSERTION: svccfg_delpg_006
  33 #
  34 # DESCRIPTION:
  35 #       The 'delpg' subcommand must be called when the current entity
  36 #       is a service or instance.  If the current entity is scope than
  37 #       a diagnostic message is sent to stderr and an exit status
  38 #       of 1 is returned.
  39 #
  40 # end __stf_assertion__
  41 ###############################################################################
  42 
  43 
  44 # First STF library
  45 . ${STF_TOOLS}/include/stf.kshlib
  46 
  47 # Load GL library
  48 . ${STF_SUITE}/include/gltest.kshlib
  49 
  50 
  51 readonly ME=$(whence -p ${0})
  52 readonly MYLOC=$(dirname ${ME})
  53 
  54 # Initialize test result 
  55 typeset -i RESULT=$STF_PASS
  56 
  57 
  58 function cleanup {
  59         
  60         rm -f $OUTFILE $ERRFILE 
  61 
  62         exit $RESULT
  63 }
  64 
  65 trap cleanup 0 1 2 15
  66 
  67 # make sure that the environment is sane - svc.configd is up and running
  68 check_gl_env
  69 [[ $? -ne 0 ]] && {
  70         echo "--DIAG: 
  71         Invalid test environment - svc.configd not available"
  72 
  73         RESULT=$STF_UNRESOLVED 
  74         exit $RESULT
  75 }
  76 
  77 # extract and print assertion information from this source script.
  78 extract_assertion_info $ME
  79 
  80 assertion=svccfg_delpg_006
  81 
  82 
  83 
  84 svccfg delpg foo > $OUTFILE 2>$ERRFILE
  85 ret=$?
  86 # Verify that the return value is as expected - non-fatal error
  87 [[ $ret -ne 1 ]] &&  {
  88         echo "--DIAG: [${assertion}]
  89         svccfg delpg expected to return 1, got $ret"
  90 
  91         RESULT=$STF_FAIL
  92 }
  93 
  94 # Verify that nothing in stdout - non-fatal error
  95 [[ -s $OUTFILE ]] &&  {
  96         echo "--DIAG: [${assertion}]
  97         stdout not expected, but got $(cat $OUTFILE)"
  98 
  99         RESULT=$STF_FAIL
 100 }
 101 
 102 
 103 # Verify that message in stderr - non-fatal error
 104 if ! egrep -s "$NOT_SELECTED_ERRMSG" $ERRFILE
 105 then
 106         echo "--DIAG: [${assertion}]
 107         Expected error message \"$NOT_SELECTED_ERRMSG\"
 108         but got \"$(cat $ERRFILE)\""
 109 
 110         RESULT=$STF_FAIL
 111 fi
 112 
 113 rm -f $ERRFILE $OUTFILE
 114 
 115 print_result $RESULT
 116 
 117 exit $RESULT