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_delprop_002
  32 #
  33 # DESCRIPTION:
  34 #       The 'delprop pg' subcommand deletes the property group 
  35 #       'pg' of the currently selected entity.
  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 # Assertion ID
  49 readonly assertion=svccfg_delprop_002
  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 function cleanup {
  58 
  59         # Note that $TEST_SERVICE may or may not exist so don't check
  60         # results.  Just make sure the service is gone.
  61         service_delete $TEST_SERVICE > /dev/null 2>&1
  62 
  63         service_exists ${TEST_SERVICE}
  64         [[ $? -eq 0 ]] && {
  65                 echo "--DIAG: [${assertion}, cleanup]
  66                 service ${TEST_SERVICE} should not exist in
  67                 repository after being deleted, but does"
  68 
  69                 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
  70         }
  71 
  72         rm -f $OUTFILE $ERRFILE $CMDFILE
  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 
  92 cat << EOF > $CMDFILE
  93 add $TEST_SERVICE
  94 select $TEST_SERVICE
  95 addpg $TEST_PROPERTY framework
  96 setprop $TEST_PROPERTY/foo = astring: "bar"
  97 EOF
  98 
  99 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
 100 ret=$?
 101 [[ $ret -ne 0 ]] && {
 102         echo "--DIAG: [${assertion}, setup]
 103         svccfg expected to return 0, got $ret
 104         error output is $(cat $ERRFILE)"
 105 
 106         RESULT=$(update_result $STF_UNRESOLVED $RESULT)
 107         exit $RESULT
 108 }
 109 
 110 
 111 # Call delprop with extra options
 112 
 113 cat << EOF > $CMDFILE
 114 select $TEST_SERVICE
 115 delprop $TEST_PROPERTY
 116 EOF
 117 
 118 
 119 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
 120 ret=$?
 121 
 122 # Verify that the return value is as expected
 123 [[ $ret -ne 0 ]] &&  {
 124         echo "--DIAG: [${assertion}]
 125         svccfg expected to return 0, got $ret"
 126 
 127         RESULT=$STF_FAIL
 128 }
 129 
 130 # Verify that nothing in stdout
 131 [[ -s $OUTFILE ]] &&  {
 132         echo "--DIAG: [${assertion}]
 133         did not expect stdout, but got:
 134         $(cat $OUTFILE)"
 135 
 136         RESULT=$STF_FAIL
 137 }
 138 
 139 
 140 # Verify that nothing in stdout
 141 [[ -s $ERRFILE ]] &&  {
 142         echo "--DIAG: [${assertion}]
 143         did not expect stderr, but got:
 144         $(cat $ERRFILE)"
 145 
 146         RESULT=$STF_FAIL
 147 }
 148 
 149 # Verify that the property is still in the repository
 150 svcprop -p $TEST_PROPERTY $TEST_SERVICE > $OUTFILE 2>$ERRFILE
 151 ret=$?
 152 
 153 # Verify that the return value is as expected
 154 [[ $ret -ne 1 ]] &&  {
 155         echo "--DIAG: [${assertion}]
 156         svcprop returned $ret, not 1 as expected"
 157 
 158         RESULT=$STF_FAIL
 159 }
 160 
 161 # Verify that nothing in stdout
 162 [[ -s $OUTFILE ]] &&  {
 163         echo "--DIAG: [${assertion}]
 164         did not expect stdout, but got:
 165         $(cat $OUTFILE)"
 166 
 167         RESULT=$STF_FAIL
 168 }
 169 
 170 
 171 # Verify that message in stderr - non-fatal error
 172 if ! egrep -s "$NOT_FOUND_PROPGRP_ERRMSG" $ERRFILE
 173 then
 174         echo "--DIAG: [${assertion}]
 175         Expected error message \"$NOT_FOUND_PROPGRP_ERRMSG\"
 176         but got \"$(cat $ERRFILE)\""
 177 
 178         RESULT=$STF_FAIL
 179 fi
 180 
 181 
 182 rm -f $OUTFILE $ERRFILE $CMDFILE
 183 
 184 exit $RESULT