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