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_002.ksh 1.4 09/08/01 SMI"
27 #
28
29 #
30 # sharemgr usage test case
31 #
32
33 #__stc_assertion_start
34 #
35 #ID: usage002
36 #
37 #DESCRIPTION:
38 #
39 # Check individual usage doesn't present incorrect data when a
40 # bad 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 # - Check all the documented options are listed.
49 # Cleanup:
50 # - N/A
51 #
52 # STRATEGY_NOTES:
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 usage002 {
70 tet_result PASS
71 tc_id="usage002"
72 tc_desc="Check the usage output of sharemgr sub-commands with bad option"
73 usage_log="$SHR_TMPDIR/share_usage.log"
74 usage_list="add-share create delete disable enable list"
75 usage_list="$usage_list move-share remove-share set"
76 usage_list="$usage_list set-share show 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 $badopt 2>&1 | grep usage > $usage_log 2>&1
87 append_cmd "$SHAREMGR $usage_item $badopt"
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 "shown_item = $shown_item"
102 tet_infoline "$usage_item not shown correctly in usage"
103 infofile "" $usage_log
104 tet_result FAIL
105 else
106 if [ "$verbose" ]
107 then
108 tet_infoline "-----------------------------"
109 tet_infoline "PASS : $usage_item"
110 tet_infoline "$SHAREMGR $usage_item $badopt"
111 tet_infoline `$SHAREMGR $usage_item $badopt`
112 tet_infoline "-----------------------------"
113 fi
114 fi
115 done
116
117 #
118 # cleanup
119 #
120 rm -f $usage_log
121 report_cmds $tc_id POS
122 }