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_delpg_002
  32 #
  33 # DESCRIPTION:
  34 #       If the property group specified in 'delpg name' does not exist
  35 #       in the currently selected entity then a diagnostic message is
  36 #       sent to stderr and an exit status of 1 is returned.
  37 #
  38 #
  39 # end __stf_assertion__
  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         # Note that $TEST_SERVICE may or may not exist so don't check
  59         # results.  Just make sure the service is gone.
  60         service_delete $TEST_SERVICE > /dev/null 2>&1
  61 
  62         service_exists ${TEST_SERVICE}
  63         [[ $? -eq 0 ]] && {
  64                 echo "--DIAG: [${assertion}, cleanup]
  65                 service ${TEST_SERVICE} should not exist in 
  66                 repository after being deleted, but does"
  67 
  68                 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
  69         }
  70 
  71         rm -f $OUTFILE $ERRFILE $CMDFILE
  72 
  73         exit $RESULT
  74 }
  75 
  76 trap cleanup 0 1 2 15
  77 
  78 # make sure that the environment is sane - svc.configd is up and running
  79 check_gl_env
  80 [[ $? -ne 0 ]] && {
  81         echo "--DIAG: 
  82         Invalid test environment -svc.configd not available"
  83 
  84         RESULT=$STF_UNRESOLVED
  85         exit $RESULT
  86 }
  87 
  88 # extract and print assertion information from this source script.
  89 extract_assertion_info $ME
  90 
  91 assertion=svccfg_delpg_002
  92 
  93 typeset -i RESULT=$STF_PASS
  94 
  95 # Before starting make sure that the test service doesn't already exist.
  96 # If it does then consider it a fatal error.
  97 service_exists $TEST_SERVICE
  98 [[ $? -eq 0 ]] && {
  99         echo "--DIAG: [${assertion}]
 100         service $TEST_SERVICE should not exist in repository but does"
 101 
 102         RESULT=$(update_result $STF_UNRESOLVED $RESULT)
 103         exit $RESULT
 104 }
 105 
 106 
 107 #
 108 # Add the service.  If this fails consider it a fatal error
 109 #
 110 svccfg add $TEST_SERVICE > $OUTFILE 2>$ERRFILE
 111 ret=$?
 112 [[ $ret -ne 0 ]] && {
 113         echo "--DIAG: [${assertion}]
 114         error adding service $TEST_SERVICE needed for test
 115         error output is $(cat $ERRFILE)"
 116 
 117         RESULT=$(update_result $STF_UNRESOLVED $RESULT)
 118         exit $RESULT
 119 }
 120 
 121 # Make sure the service is there
 122 service_exists $TEST_SERVICE
 123 [[ $? -ne 0 ]] && {
 124         echo "--DIAG: [${assertion}]
 125         service $TEST_SERVICE should exist in
 126         repository after being added, but does not"
 127 
 128         RESULT=$(update_result $STF_UNRESOLVED $RESULT)
 129         exit $RESULT
 130 }
 131 
 132 
 133 #
 134 # Delete property group that is not defined
 135 #
 136 cat <<EOF>$CMDFILE
 137 select ${TEST_SERVICE}
 138 delpg foo
 139 EOF
 140 
 141 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
 142 ret=$?
 143 
 144 # Verify that the return value is as expected - non-fatal error
 145 [[ $ret -ne 1 ]] &&  {
 146         echo "--DIAG: [${assertion}]
 147         svccfg expected to return 1, got $ret"
 148 
 149         RESULT=$STF_FAIL
 150 }
 151 
 152 # Verify that nothing in stdout - non-fatal error
 153 [[ -s $OUTFILE ]] &&  {
 154         echo "--DIAG: [${assertion}]
 155         stdout not expected, but got $(cat $OUTFILE)"
 156 
 157         RESULT=$STF_FAIL
 158 }
 159 
 160 # Verify that message in stderr - non-fatal error
 161 if ! egrep -s "$NO_PROPGRP_ERRMSG" $ERRFILE
 162 then
 163         echo "--DIAG: [${assertion}]
 164         Expected error message \"$NO_PROPGRP_ERRMSG\"
 165         but got \"$(cat $ERRFILE)\""
 166 
 167         RESULT=$STF_FAIL
 168 fi
 169 
 170 exit $RESULT