1 #
   2 # CDDL HEADER START
   3 #
   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the "License").
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 # ident "@(#)tp_zones_named_001.ksh     1.2     08/12/19 SMI"
  27 #
  28 
  29 LOGFILE=${LOGDIR}/mkdir.out
  30 . ${TET_SUITE_ROOT}/lofi-tests/lib/fs_common
  31 
  32 #
  33 # start __stc_assertion__
  34 #
  35 # ASSERTION: zones_named_001
  36 #
  37 # DESCRIPTION:
  38 #       In a non-global zone, the lofiadm command should fail.
  39 #
  40 # STRATEGY:
  41 #       - Make sure we're operating in a named zone.
  42 #       - Execute the lofiadm command with no arguments.  The command is
  43 #         expected to fail.
  44 #
  45 # end __stc_assertion__
  46 #
  47 function tp_zones_named_001 {
  48         typeset cmd
  49         typeset status=0
  50 
  51         typeset -r ASSERTION="zones_named_001"
  52         typeset -r TP_NAME=tp_${ASSERTION}
  53         typeset -r ME=$(whence -p ${0})
  54         extract_assertion_info $(dirname $ME)/$TP_NAME
  55 
  56         # Initialization
  57         cti_pass
  58         cti_assert $ASSERTION "lofiadm command should fail in non-global zone"
  59 
  60         # Make sure we're in a non-global zone
  61         global_zone_check
  62         if (( $? == 0 )); then
  63                 cti_untested "Cannot execute this test in the global zone"
  64                 return
  65         fi
  66 
  67         # Execute the lofiadm command
  68         cmd="lofiadm"
  69         record_cmd_execution "$cmd"
  70         cti_execute "PASS" "$cmd"
  71 
  72         if (( $? == 0 )); then
  73                 cti_fail "'lofiadm' command succeeded when it was expected" \
  74                     "to fail"
  75                 status=1
  76         else
  77                 cti_pass "'lofiadm' command failed when executed in" \
  78                     "non-global zone, as expected"
  79         fi
  80 
  81         if [[ -n "$VERBOSE" ]] || (( $status != 0 )); then
  82                 display_execution_record
  83         else
  84                 delete_execution_record
  85         fi
  86 }