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: svcadm_refresh_005
  32 #
  33 # DESCRIPTION:
  34 #       svcadm refresh <invalid-fmri> should fail with exit 1
  35 #       svcadm refresh <invalid name> should fail with exit 1
  36 #       svcadm -v refresh <invalid-fmri> should fail with exit 1
  37 #       svcadm -v refresh <invalid-name> should fail with exit 1
  38 # STRATEGY:
  39 #       - Call svcadm refresh <invalid-fmri> and make sure it fails with
  40 #               exit 1.
  41 #       - Call svcadm -v refresh <invalid-fmri> and make sure should fail 
  42 #               with exit 1.
  43 #       - call svcadm [-v] refresh <invalid-name> and make sure it fails
  44 #               with exit 1.
  45 #
  46 # COMMANDS: svcadm(1)
  47 #
  48 # end __stf_assertion__
  49 ################################################################################
  50 
  51 # First load up definitions of STF result variables like STF_PASS etc.
  52 . ${STF_TOOLS}/include/stf.kshlib
  53 
  54 # Load up definitions of shell functionality common to all smf sub-suites.
  55 . ${STF_SUITE}/include/gltest.kshlib
  56 
  57 # Define Variables
  58 readonly assertion=svcadm_refresh_005
  59 readonly invalid_fmri="foo$$"
  60 readonly invalid_name=100
  61 readonly ME=$(whence -p ${0})
  62 readonly MYLOC=$(dirname ${ME})
  63 
  64 # Extract and print the assertion from this source script.
  65 extract_assertion_info $ME
  66 
  67 # Initialize test result to pass.
  68 typeset -i RESULT=${STF_UNRESOLVED}
  69 
  70 # Exit code for individual commands.
  71 typeset -i tmp_rc=0
  72 
  73 # Make sure we run as root
  74 if ! /usr/bin/id | grep "uid=0(root)" > /dev/null 2>&1
  75 then
  76         echo "--DIAG: [$assertion]
  77         This test must be run from root."
  78         print_result $RESULT
  79         exit $RESULT
  80 fi
  81 
  82 
  83 # Execute environmental sanity checks.
  84 check_gl_env
  85 tmp_rc=$?
  86 if [[ $tmp_rc -ne 0 ]]
  87 then
  88         echo "--DIAG: [$assertion]
  89         Invalid smf environment, quitting."
  90         print_result $RESULT
  91         exit $RESULT
  92 fi
  93 
  94 echo "--INFO: [${assertion}]
  95         Call svcadm refresh $invalid_fmri"
  96 
  97 svcadm refresh $invalid_fmri >/dev/null 2>&1
  98 ret=$?
  99 if [ $ret -ne 1 ]; then
 100         RESULT=$(update_result $STF_FAIL $RESULT)
 101         echo "--DIAG: [$assertion]
 102         EXPECTED: svcadm refresh $invalid_fmri should exit 1
 103         OBSERVED: svcadm refresh $invalid_fmri exits with status $ret"
 104         print_result $RESULT
 105         exit $RESULT
 106 fi
 107 
 108 echo "--INFO: [${assertion}]
 109         Call svcadm -v refresh $invalid_fmri"
 110 
 111 svcadm -v refresh $invalid_fmri >/dev/null 2>&1
 112 ret=$?
 113 if [ $ret -ne 1 ]; then
 114         RESULT=$(update_result $STF_FAIL $RESULT)
 115         echo "--DIAG: [$assertion]
 116         EXPECTED: svcadm -v refresh $invalid_fmri should exit 1
 117         OBSERVED: svcadm -v refresh $invalid_fmri exits with status $ret"
 118         print_result $RESULT
 119         exit $RESULT
 120 fi
 121 
 122 echo "--INFO: [${assertion}]
 123         Call svcadm -v refresh $invalid_name"
 124 
 125 svcadm -v refresh $invalid_name >/dev/null 2>&1
 126 ret=$?
 127 if [ $ret -ne 1 ]; then
 128         RESULT=$(update_result $STF_FAIL $RESULT)
 129         echo "--DIAG: [$assertion]
 130         EXPECTED: svcadm -v refresh $invalid_name should exit 1
 131         OBSERVED: svcadm -v refresh $invalid_name exits with status $ret"
 132         print_result $RESULT
 133         exit $RESULT
 134 fi
 135 
 136 echo "--INFO: [${assertion}]
 137         Call svcadm refresh $invalid_name"
 138 
 139 svcadm refresh $invalid_name >/dev/null 2>&1
 140 ret=$?
 141 if [ $ret -ne 1 ]; then
 142         RESULT=$(update_result $STF_FAIL $RESULT)
 143         echo "--DIAG: [$assertion]
 144         EXPECTED: svcadm refresh $invalid_name should exit 1
 145         OBSERVED: svcadm refresh $invalid_name exits with status $ret"
 146         print_result $RESULT
 147         exit $RESULT
 148 fi
 149 
 150 RESULT=$STF_PASS
 151 print_result $RESULT
 152 exit $RESULT
 153 
 154 #
 155 ### END
 156 #