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