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_enable_011
  33 #
  34 # DESCRIPTION:
  35 #       svcadm enable <without any arguments> should fail with exit 2.
  36 #       svcadm -v enable <without any arguments> should fail with exit 2.
  37 # STRATEGY:
  38 #
  39 # COMMANDS: svcadm(1)
  40 #
  41 # end __stf_assertion__
  42 ################################################################################
  43 
  44 # First load up definitions of STF result variables like STF_PASS etc.
  45 . ${STF_TOOLS}/include/stf.kshlib
  46 
  47 # Load up definitions of shell functionality common to all smf sub-suites.
  48 . ${STF_SUITE}/include/gltest.kshlib
  49 
  50 # Define Variables
  51 readonly assertion=svcadm_enable_011
  52 readonly ME=$(whence -p ${0})
  53 readonly MYLOC=$(dirname ${ME})
  54 
  55 # gltest.kshlib functions to extract and print assertion information
  56 # from this source script.
  57 extract_assertion_info $ME
  58 
  59 # Initialize test result to pass.
  60 typeset -i RESULT=${STF_UNRESOLVED}
  61 
  62 # Exit code for individual commands.
  63 typeset -i tmp_rc=0
  64 
  65 # Make sure we run as root
  66 if ! /usr/bin/id | grep "uid=0(root)" > /dev/null 2>&1
  67 then
  68         echo "--DIAG: [$assertion]
  69         This test must be run from root."
  70         print_result $RESULT
  71         exit $RESULT
  72 fi
  73 
  74 
  75 # Execute environmental sanity checks.
  76 check_gl_env
  77 tmp_rc=$?
  78 if [[ $tmp_rc -ne 0 ]]
  79 then
  80     echo "--DIAG: [$assertion]
  81         Invalid smf environment, quitting."
  82     print_result $RESULT
  83     exit $RESULT
  84 fi
  85 
  86 echo "--INFO: [${assertion}]
  87         Call svcadm enable <no arguments>"
  88 
  89 svcadm enable >/dev/null 2>&1
  90 ret=$?
  91 if [ $ret -ne 2 ]; then
  92     RESULT=$(update_result $STF_FAIL $RESULT)
  93     echo "--DIAG: [$assertion]
  94         EXPECTED: svcadm enable <no arguments> should exit 2
  95         ACTUAL: svcadm enable <no arguments> exited with $ret"
  96     print_result $RESULT
  97     exit $RESULT
  98 fi
  99 
 100 echo "--INFO: [${assertion}]
 101         Call svcadm -v enable <no arguments>"
 102 
 103 svcadm -v enable >/dev/null 2>&1
 104 ret=$?
 105 if [ $ret -ne 2 ]; then
 106     RESULT=$(update_result $STF_FAIL $RESULT)
 107     echo "--DIAG: [$assertion]
 108         EXPECTED: svcadm -v enable <no arguments> should exit 2
 109         ACTUAL: svcadm -v enable <no arguments> exited with $ret"
 110     print_result $RESULT
 111     exit $RESULT
 112 fi
 113 
 114 RESULT=$STF_PAS
 115 print_result $RESULT
 116 exit $RESULT