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 # 
  25 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  26 # Use is subject to license terms.
  27 #
  28 
  29 ###############################################################################
  30 # start __stf_assertion__
  31 #
  32 # ASSERTION: svcadm_delegate_003
  33 #
  34 # DESCRIPTION:
  35 #       svcadm  delegate <without any arguments> should fail with exit 2.
  36 #       svcadm delegate <only one valid argument> should fail with exit 2.
  37 #       svcadm delegate <only one invalid argument> should fail with exit 2.
  38 #       svcadm delegate <only one invalid name> should fail with exit 2.
  39 #       svcadm -v  delegate <without any arguments> should fail with exit 2.
  40 #       svcadm -v delegate <only one valid argument> should fail with exit 2.
  41 #       svcadm -v delegate <only one invalid argument> should fail with exit 2.
  42 #       svcadm -v delegate <only one invalid name> should fail with exit 2.
  43 # STRATEGY:
  44 #
  45 # COMMANDS: svcadm(1)
  46 #
  47 # end __stf_assertion__
  48 ################################################################################
  49 
  50 # First load up definitions of STF result variables like STF_PASS etc.
  51 . ${STF_TOOLS}/include/stf.kshlib
  52 
  53 # Load up definitions of shell functionality common to all smf sub-suites.
  54 . ${STF_SUITE}/include/gltest.kshlib
  55 
  56 # Define Variables
  57 readonly assertion=svcadm_delegate_003
  58 readonly ME=$(whence -p ${0})
  59 readonly MYLOC=$(dirname ${ME})
  60 readonly validarg="svc:/system/svc/restarter:default"
  61 readonly invalidarg="foo$$"
  62 readonly invalidname="100"
  63 
  64 # gltest.kshlib functions to extract and print assertion information
  65 # from this source script.
  66 extract_assertion_info $ME
  67 
  68 # Initialize test result to pass.
  69 typeset -i RESULT=${STF_PASS}
  70 
  71 # Exit code for individual commands.
  72 typeset -i tmp_rc=0
  73 
  74 # Make sure we run as root
  75 if ! /usr/bin/id | grep "uid=0(root)" > /dev/null 2>&1
  76 then
  77         RESULT=$(update_result $STF_UNRESOLVED $RESULT)
  78         echo "--DIAG: [$assertion]
  79         This test must be run from root."
  80         print_result $RESULT
  81         exit $RESULT
  82 fi
  83 
  84 
  85 # Execute environmental sanity checks.
  86 check_gl_env
  87 tmp_rc=$?
  88 if [[ $tmp_rc -ne 0 ]]
  89 then
  90     RESULT=$(update_result $STF_UNRESOLVED $RESULT)
  91     echo "--DIAG: [$assertion]
  92         Invalid smf environment, quitting."
  93     print_result $RESULT
  94     exit $RESULT
  95 fi
  96 
  97 echo "--INFO: [${assertion}]
  98         Call svcadm delegate <no arguments>"
  99 svcadm delegate >/dev/null 2>&1
 100 ret=$?
 101 if [ $ret -ne 2 ]; then
 102     RESULT=$(update_result $STF_FAIL $RESULT)
 103     echo "--DIAG: [$assertion]
 104         EXPECTED: svcadm  delegate <no arguments> should exit 2
 105         ACTUAL: svcadm  delegate <no arguments> exited with $ret"
 106     print_result $RESULT
 107     exit $RESULT
 108 fi
 109 
 110 echo "--INFO: [${assertion}]
 111         Call svcadm delegate <one valid argument>"
 112 svcadm delegate $validarg >/dev/null 2>&1
 113 ret=$?
 114 if [ $ret -ne 2 ]; then
 115     RESULT=$(update_result $STF_FAIL $RESULT)
 116     echo "--DIAG: [$assertion]
 117         EXPECTED: svcadm  delegate $validarg should exit 2
 118         ACTUAL: svcadm  delegate $validarg exited with $ret"
 119     print_result $RESULT
 120     exit $RESULT
 121 fi
 122 
 123 echo "--INFO: [${assertion}]
 124         Call svcadm delegate <one invalid argument>"
 125 svcadm delegate $invalidarg >/dev/null 2>&1
 126 ret=$?
 127 if [ $ret -ne 2 ]; then
 128     RESULT=$(update_result $STF_FAIL $RESULT)
 129     echo "--DIAG: [$assertion]
 130         EXPECTED: svcadm  delegate $invalidarg should exit 2
 131         ACTUAL: svcadm  delegate $invalidarg exited with $ret"
 132     print_result $RESULT
 133     exit $RESULT
 134 fi
 135 
 136 echo "--INFO: [${assertion}]
 137         Call svcadm delegate <one invalid name>"
 138 svcadm delegate $invalidname >/dev/null 2>&1
 139 ret=$?
 140 if [ $ret -ne 2 ]; then
 141     RESULT=$(update_result $STF_FAIL $RESULT)
 142     echo "--DIAG: [$assertion]
 143         EXPECTED: svcadm  delegate $invalidname should exit 2
 144         ACTUAL: svcadm  delegate $invalidname exited with $ret"
 145     print_result $RESULT
 146     exit $RESULT
 147 fi
 148 
 149 echo "--INFO: [${assertion}]
 150         Call svcadm -v delegate <one invalid arg>"
 151 svcadm -v delegate $invalidarg >/dev/null 2>&1
 152 ret=$?
 153 if [ $ret -ne 2 ]; then
 154     RESULT=$(update_result $STF_FAIL $RESULT)
 155     echo "--DIAG: [$assertion]
 156         EXPECTED: svcadm -v delegate $invalidarg should exit 2
 157         ACTUAL: svcadm -v delegate $invalidarg exited with $ret"
 158     print_result $RESULT
 159     exit $RESULT
 160 fi
 161 
 162 echo "--INFO: [${assertion}]
 163         Call svcadm -v delegate <invalid arg>"
 164 svcadm -v delegate $validarg >/dev/null 2>&1
 165 ret=$?
 166 if [ $ret -ne 2 ]; then
 167     RESULT=$(update_result $STF_FAIL $RESULT)
 168     echo "--DIAG: [$assertion]
 169         EXPECTED: svcadm -v delegate $validarg should exit 2
 170         ACTUAL: svcadm -v delegate $validarg exited with $ret"
 171     print_result $RESULT
 172     exit $RESULT
 173 fi
 174 
 175 echo "--INFO: [${assertion}]
 176         Call svcadm -v delegate <invalid name>"
 177 svcadm -v delegate $invalidname >/dev/null 2>&1
 178 ret=$?
 179 if [ $ret -ne 2 ]; then
 180     RESULT=$(update_result $STF_FAIL $RESULT)
 181     echo "--DIAG: [$assertion]
 182         EXPECTED: svcadm -v delegate $invalidname should exit 2
 183         ACTUAL: svcadm -v delegate $invalidname exited with $ret"
 184     print_result $RESULT
 185     exit $RESULT
 186 fi
 187 
 188 echo "--INFO: [${assertion}]
 189         Call svcadm -v delegate <no arguments>"
 190 svcadm -v delegate >/dev/null 2>&1
 191 ret=$?
 192 if [ $ret -ne 2 ]; then
 193     RESULT=$(update_result $STF_FAIL $RESULT)
 194     echo "--DIAG: [$assertion]
 195         EXPECTED: svcadm -v delegate should exit 2
 196         ACTUAL: svcadm -v delegate exited with $ret"
 197     print_result $RESULT
 198     exit $RESULT
 199 fi
 200 
 201 print_result $RESULT
 202 exit $RESULT