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_setprop_011
  32 #
  33 # DESCRIPTION:
  34 #       If 'setprop pg/name = [type:] *' subcommand specifies
  35 #       a property that already exists and the type disagrees 
  36 #       with the existing type on the property, the request 
  37 #       will return a diagnostic message and a return value of 1.
  38 #
  39 # STRATEGY:
  40 #       The test is performed through an expect script which is
  41 #       called from this script.
  42 #
  43 # end __stf_assertion__
  44 ###############################################################################
  45 
  46 # First STF library
  47 . ${STF_TOOLS}/include/stf.kshlib
  48 
  49 # Load GL library
  50 . ${STF_SUITE}/include/gltest.kshlib
  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 
  59 function cleanup {
  60         
  61         # Note that $TEST_SERVICE may or may not exist so don't check
  62         # results.  Just make sure the service is gone.
  63         service_delete $TEST_SERVICE 
  64 
  65         service_exists ${TEST_SERVICE}
  66         [[ $? -eq 0 ]] && {
  67                 echo "--DIAG: [${assertion}, cleanup]
  68                 service ${TEST_SERVICE} should not exist in 
  69                 repository after being deleted, but does"
  70 
  71                 RESULT=$(update_result $STF_UNRESOLVED $RESULT)
  72         }
  73 
  74         rm -f $OUTFILE $ERRFILE $CMDFILE
  75 
  76         exit $RESULT
  77 }
  78 
  79 trap cleanup 0 1 2 15
  80 
  81 # make sure that the environment is sane - svc.configd is up and running
  82 check_gl_env
  83 [[ $? -ne 0 ]] && {
  84         echo "--DIAG: 
  85         Invalid test environment - svc.configd is not available"
  86 
  87         RESULT=$STF_UNRESOLVED 
  88         exit $RESULT
  89 }
  90 
  91 # extract and print assertion information from this source script.
  92 extract_assertion_info $ME
  93 
  94 assertion=svccfg_setprop_011
  95 
  96 
  97 # Before starting make sure that the test service doesn't already exist.
  98 # If it does then consider it a fatal error.
  99 service_exists $TEST_SERVICE
 100 [[ $? -eq 0 ]] && {
 101         echo "--DIAG: [${assertion}]
 102         service $TEST_SERVICE should not exist in 
 103         repository but does"
 104 
 105         RESULT=$(update_result $STF_UNRESOLVED $RESULT)
 106         exit $RESULT
 107 }
 108 
 109 
 110 #
 111 # Add the service.  If this fails consider it a fatal error
 112 #
 113 
 114 svccfg add $TEST_SERVICE > $OUTFILE 2>$ERRFILE
 115 ret=$?
 116 [[ $ret -ne 0 ]] && {
 117         echo "--DIAG: [${assertion}]
 118         error adding service $TEST_SERVICE needed for test"
 119 
 120         RESULT=$(update_result $STF_UNRESOLVED $RESULT)
 121         exit $RESULT
 122 }
 123 
 124 
 125 echo "--INFO: [${assertion}] 
 126         Running error tests on service entities"
 127 
 128 # Run the error test on service entities
 129 
 130 $MYLOC/setprop_011 $TEST_SERVICE
 131 ret=$?
 132 [[ $ret -ne 0 ]] && TEST_RESULT=$STF_FAIL
 133 
 134 
 135 cat <<EOF>$CMDFILE
 136 select ${TEST_SERVICE}
 137 add ${TEST_INSTANCE}
 138 EOF
 139 
 140 svccfg -f $CMDFILE > $OUTFILE 2>$ERRFILE
 141 ret=$?
 142 
 143 # Verify that the return value is as expected - non-fatal error
 144 [[ $ret -ne 0 ]] &&  {
 145         echo "--DIAG: [${assertion}]
 146         svccfg add expected to return 0, got $ret"
 147 
 148         RESULT=$(update_result $STF_UNRESOLVED $RESULT)
 149         exit $RESULT
 150 }
 151 
 152 
 153 # Run the error test on instance entities
 154 
 155 echo "--INFO: [${assertion}] 
 156         Running error tests on instance entities"
 157 
 158 $MYLOC/test_011 $TEST_SERVICE $TEST_INSTANCE
 159 ret=$?
 160 [[ $ret -ne 0 ]] && TEST_RESULT=$STF_FAIL
 161 
 162 RESULT=$(update_result $TEST_RESULT $RESULT)
 163 
 164 # Test done
 165 
 166 exit $RESULT