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_001
  32 #
  33 # DESCRIPTION:
  34 #       The 'delprop pg/name' subcommand deletes the property, 
  35 #       'name',  of the property group 'pg' of the currently 
  36 #       selected entity.
  37 #
  38 #
  39 # end __stf_assertion__
  40 ###############################################################################
  41 
  42 
  43 # First STF library
  44 . ${STF_TOOLS}/include/stf.kshlib
  45 
  46 # Load GL library
  47 . ${STF_SUITE}/include/gltest.kshlib
  48 
  49 # Assertion ID
  50 readonly assertion=svccfg_delprop_001
  51 
  52 readonly ME=$(whence -p ${0})
  53 readonly MYLOC=$(dirname ${ME})
  54 
  55 # Initialize test result 
  56 typeset -i RESULT=$STF_PASS
  57 
  58 function cleanup {
  59 
  60         # Note that $TEST_SERVICE may or may not exist so don't check
  61         # results.  Just make sure the service is gone.
  62         service_delete $TEST_SERVICE > /dev/null 2>&1
  63 
  64         service_exists ${TEST_SERVICE}
  65         [[ $? -eq 0 ]] && {
  66                 echo "--DIAG: [${assertion}, cleanup]
  67                 service ${TEST_SERVICE} should not exist in
  68                 repository after being deleted, but does"
  69 
  70                 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
  71         }
  72 
  73         rm -f $OUTFILE $ERRFILE $CMDFILE
  74         exit $RESULT 
  75 } 
  76 
  77 trap cleanup 0 1 2 15
  78 
  79 # make sure that the environment is sane - svc.configd is up and running
  80 check_gl_env
  81 [[ $? -ne 0 ]] && {
  82         echo "--DIAG:
  83         Invalid test environment - svc.configd not available"
  84 
  85         RESULT=$STF_UNRESOLVED 
  86         exit $RESULT
  87 }
  88 
  89 # extract and print assertion information from this source script.
  90 extract_assertion_info $ME
  91 
  92 
  93 cat << EOF > $CMDFILE
  94 add $TEST_SERVICE
  95 select $TEST_SERVICE
  96 addpg $TEST_PROPERTY framework
  97 setprop $TEST_PROPERTY/foo_nodelete = astring: "bar"
  98 setprop $TEST_PROPERTY/foo_delete = astring: "bar"
  99 EOF
 100 
 101 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
 102 ret=$?
 103 [[ $ret -ne 0 ]] && {
 104         echo "--DIAG: [${assertion}, setup]
 105         svccfg expected to return 0, got $ret
 106         error output is $(cat $ERRFILE)"
 107 
 108         RESULT=$(update_result $STF_UNRESOLVED $RESULT)
 109         exit $RESULT
 110 }
 111 
 112 
 113 # Call delprop with extra options
 114 
 115 cat << EOF > $CMDFILE
 116 select $TEST_SERVICE
 117 delprop $TEST_PROPERTY/foo_delete
 118 EOF
 119 
 120 
 121 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
 122 ret=$?
 123 
 124 # Verify that the return value is as expected
 125 [[ $ret -ne 0 ]] &&  {
 126         echo "--DIAG: [${assertion}]
 127         svccfg expected to return 0, got $ret"
 128 
 129         RESULT=$STF_FAIL
 130 }
 131 
 132 # Verify that nothing in stdout
 133 [[ -s $OUTFILE ]] &&  {
 134         echo "--DIAG: [${assertion}]
 135         did not expect stdout, but got:
 136         $(cat $OUTFILE)"
 137 
 138         RESULT=$STF_FAIL
 139 }
 140 
 141 
 142 # Verify that nothing in stdout
 143 [[ -s $ERRFILE ]] &&  {
 144         echo "--DIAG: [${assertion}]
 145         did not expect stderr, but got:
 146         $(cat $ERRFILE)"
 147 
 148         RESULT=$STF_FAIL
 149 }
 150 
 151 svcprop -p $TEST_PROPERTY $TEST_SERVICE > $OUTFILE 2>$ERRFILE
 152 ret=$?
 153 
 154 # Verify that the return value is as expected
 155 [[ $ret -ne 0 ]] &&  {
 156         echo "--DIAG: [${assertion}]
 157         svcprop returned $ret, not 0 as expected
 158         error output is $(cat $ERRFILE)"
 159 
 160         RESULT=$STF_FAIL
 161 }
 162 
 163 # Verify that the other property is still in the repository
 164 if ! egrep -s "foo_nodelete" $OUTFILE
 165 then
 166         echo "--DIAG: [${assertion}]
 167         property foo_nodelete should be in the repository, but is not."
 168 
 169         RESULT=$STF_FAIL
 170 fi
 171 
 172 # Verify that the deleted property is not in the repository
 173 if  egrep -s "foo_delete" $OUTFILE
 174 then
 175         echo "--DIAG: [${assertion}]
 176         property foo_delete should not be in the repository, but is."
 177 
 178         RESULT=$STF_FAIL
 179 fi
 180 
 181 exit $RESULT