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 2009 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 # ident "@(#)tp_usage_003.ksh   1.4     09/08/01 SMI"
  27 #
  28 
  29 #
  30 # sharemgr usage test case
  31 #
  32 
  33 #__stc_assertion_start
  34 #
  35 #ID: usage003
  36 #
  37 #DESCRIPTION:
  38 #
  39 #       Check individual usage doesn't present incorrect data when no
  40 #       option is given.
  41 #
  42 #STRATEGY:
  43 #
  44 #       Setup:
  45 #               - dump the sharemgr usage for each documented sub-command
  46 #       Test:
  47 #               - Check the sub-command is listed correctly.
  48 #       Cleanup:
  49 #               - N/A
  50 #
  51 #       STRATEGY_NOTES:
  52 #               - only checking subcommands that require options
  53 #
  54 #KEYWORDS:
  55 #
  56 #       usage
  57 #
  58 #TESTABILITY: explicit
  59 #
  60 #AUTHOR: sean.wilcox@sun.com
  61 #
  62 #REVIEWERS: TBD
  63 #
  64 #TEST_AUTOMATION_LEVEL: automated
  65 #
  66 #CODING_STATUS: COMPLETE
  67 #
  68 #__stc_assertion_end
  69 function usage003 {
  70         tet_result PASS
  71         tc_id="usage003"
  72         tc_desc="Check the usage output of sharemgr sub-commands"
  73         usage_log="$SHR_TMPDIR/share_usage.log"
  74         usage_list="add-share create delete disable enable"
  75         usage_list="$usage_list move-share remove-share set"
  76         usage_list="$usage_list set-share unset unshare"
  77         badopt="-xyz"
  78 
  79         cmd_list=""
  80         unset GROUPS
  81         print_test_case $tc_id - $tc_desc
  82 
  83         for usage_item in $usage_list
  84         do
  85                 result=0
  86                 $SHAREMGR $usage_item 2>&1 | grep usage > $usage_log 2>&1
  87                 append_cmd "$SHAREMGR $usage_item"
  88                 if [ "$report_only" ]
  89                 then
  90                         continue
  91                 fi
  92                 shown_item=`awk ' {
  93                         if ( $2 == item ) { print $2 }
  94                     } ' item=$usage_item $usage_log`
  95                 if [ "$shown_item" != "$usage_item" ]
  96                 then
  97                         result=1
  98                 fi
  99                 if [ $result -ne 0 ]
 100                 then
 101                         tet_infoline "$usage_item not shown correctly in usage"
 102                         infofile "" $usage_log
 103                         tet_result FAIL
 104                 else
 105                         if [ "$verbose" ]
 106                         then
 107                                 tet_infoline "-----------------------------"
 108                                 tet_infoline "PASS : $usage_item"
 109                                 tet_infoline "$SHAREMGR $usage_item $badopt"
 110                                 tet_infoline `$SHAREMGR $usage_item $badopt`
 111                                 tet_infoline "-----------------------------"
 112                         fi
 113                 fi
 114         done
 115 
 116         #
 117         # cleanup
 118         #
 119         rm -f $usage_log
 120         report_cmds $tc_id POS
 121 }