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
27 #
28 ###############################################################
29 #
30 # This routine tests both -i and -t options for hba-port
31 # and compares the output with hba-port -it and plain hba-port.
32 #
33 ###############################################################
34 #
35 # __stc_assertion_start
36 #
37 #
38 # ID: fcinfo_comstar_002
39 #
40 # DESCRIPTION:
41 # It checks the output of hba-port commands uisng
42 # following commands.
43 # - fcinfo hba-port
44 # - fcinfo hba-port -it
45 # - fcinfo hba-port -i
46 # - fcinfo hba-port -t
47 #
48 # STRATEGY:
49 #
50 # Setup:
51 # Both target mode hba port and initiator mode hba prot
52 # should exist to properly run the test.
53 # Test:
54 # Verify the return code of each command listed above and
55 # compare the output
56 # 'fcinfo hba-port' vs 'fcinfo hba-port -it'
57 # combinatioin of -i and -t output vs 'fcinfo hba-port -it'
58 # Cleanup:
59 # None
60 #
61 # STRATEGY_NOTES:
62 # the initiator mode hba port is not required to have
63 # remote-ports connected.
64 #
65 # KEYWORDS:
66 # fcinfo hba-port
67 #
68 #
69 # TESTABILITY: explicit
70 #
71 # AUTHOR: hyon.kim@sun.com
72 #
73 # REVIEWERS: <e-mail, e-mail>
74 #
75 #
76 # ASSERTION_SOURCE:
77 #
78 # // Optional field - a pointer to the document source of the assertion
79 #
80 #
81 # TEST_AUTOMATION_LEVEL: automated
82 #
83 # CODING_STATUS: IN_PROGRESS
84 #
85 # __stc_assertion_end
86 #
87 ##############################################################################
88 function fcinfo_hbaport_cmds
89 {
90 typeset return_code=0
91 typeset re_code=0
92
93 ###########################################################
94 # test hba-port -it option
95 ###########################################################
96 CMD="fcinfo hba-port -it"
97 cti_execute_cmd "$CMD"
98 re_code=$?
99 ((return_code+=$re_code))
100 cti_report "$CMD returns: $re_code"
101
102 ###########################################################
103 # test hba-port -i option
104 ###########################################################
105 # test hba-port -i option
106 CMD="fcinfo hba-port -i"
107 cti_execute_cmd "$CMD"
108 re_code=$?
109 ((return_code+=$re_code))
110 cti_report "$CMD returns: $re_code"
111
112 ###########################################################
113 # test hba-port -t option
114 ###########################################################
115 CMD="fcinfo hba-port -t"
116 cti_execute_cmd "$CMD"
117 re_code=$?
118 ((return_code+=$re_code))
119 cti_report "$CMD returns: $re_code"
120
121
122 if [ $return_code -ne 0 ];then
123 cti_report "Individual hba-port -it, -i, -t commands failed."
124 else
125 # obtain an unique list of target mode WWNs for each of the HBA types
126 cti_execute_cmd "fcinfo hba-port -it | grep Port" \
127 > ${LOGDIR}/wwn-it.out
128
129 # obtain an unique list of target mode WWNs for each of the HBA types
130 cti_execute_cmd "fcinfo hba-port | grep Port" \
131 > ${LOGDIR}/wwn-plain.out
132
133 ##########################################################
134 # compare plain hba-port output with 'hba-port -it' output
135 ##########################################################
136 diff ${LOGDIR}/wwn-it.out ${LOGDIR}/wwn-plain.out >> ${LOGFILE} 2>&1
137 re_code=$?
138 cti_report "diff between plain hba-port and hba-port -it returns: "\
139 "$re_code"
140 ((return_code+=$re_code))
141
142 #obtain typical target mode HBA to run test
143 cti_execute_cmd "fcinfo hba-port -t | grep Port" > ${LOGDIR}/tgt.out
144 cti_execute_cmd "fcinfo hba-port -i | grep Port" > ${LOGDIR}/init.out
145 cat ${LOGDIR}/init.out > ${LOGDIR}/wwn-merge.out
146 cat ${LOGDIR}/tgt.out >> ${LOGDIR}/wwn-merge.out
147
148 ##########################################################
149 # compare 'hba-port -it' output with merged output.
150 ##########################################################
151 diff ${LOGDIR}/wwn-it.out ${LOGDIR}/wwn-merge.out >> ${LOGFILE} 2>&1
152 re_code=$?
153 cti_report "diff between hba-port -it and "\
154 "merge of hba-port -i and -t returns $re_code"
155 ((return_code+=$re_code))
156 fi
157
158 return $return_code
159 }
160
161 ##########################################################
162 # tp_fcinfo_002 calls fcinfo_hbaport_cmds().
163 ##########################################################
164 function tp_fcinfo_002
165 {
166 typeset TEST_NAME="options -i and -t for fcinfo command"
167 cti_assert fcinfo_comstar_002 "Testing $TEST_NAME "
168 typeset return_code=0
169 typeset re_code=0
170
171 ###########################################################
172 # test hba-port -it option
173 ###########################################################
174 CMD="fcinfo hba-port -it"
175 cti_execute_cmd "$CMD"
176 re_code=$?
177 ((return_code+=$re_code))
178 cti_report "$CMD returns: $re_code"
179
180 ###########################################################
181 # test hba-port -i option
182 ###########################################################
183 # test hba-port -i option
184 CMD="fcinfo hba-port -i"
185 cti_execute_cmd "$CMD"
186 re_code=$?
187 ((return_code+=$re_code))
188 cti_report "$CMD returns: $re_code"
189
190 ###########################################################
191 # test hba-port -t option
192 ###########################################################
193 CMD="fcinfo hba-port -t"
194 cti_execute_cmd "$CMD"
195 re_code=$?
196 ((return_code+=$re_code))
197 cti_report "$CMD returns: $re_code"
198
199
200 if [ $return_code -ne 0 ];then
201 cti_report "Individual hba-port -it, -i, -t commands failed."
202 else
203 # obtain an unique list of target mode WWNs for each of the HBA types
204 CMD="fcinfo hba-port -it | grep 'Port WWN' > ${LOGDIR}/wwn-it.out"
205 cti_execute_cmd $CMD
206 cti_reportfile "${LOGDIR}/wwn-it.out"
207
208 # obtain an unique list of target mode WWNs for each of the HBA types
209 CMD="fcinfo hba-port | grep 'Port WWN' > ${LOGDIR}/wwn-plain.out"
210 cti_execute_cmd $CMD
211
212 ##########################################################
213 # compare plain hba-port output with 'hba-port -it' output
214 ##########################################################
215 CMD="diff ${LOGDIR}/wwn-it.out ${LOGDIR}/wwn-plain.out"
216 cti_execute_cmd $CMD
217 re_code=$?
218 cti_report "diff between plain hba-port and hba-port -it returns: "\
219 "$re_code"
220 ((return_code+=$re_code))
221
222 #obtain typical target mode HBA to run test
223 CMD="fcinfo hba-port -t | grep 'Port WWN' > ${LOGDIR}/tgtmode.out"
224 cti_execute_cmd $CMD
225 CMD="fcinfo hba-port -i | grep 'Port WWN' > ${LOGDIR}/initmode.out"
226 cti_execute_cmd $CMD
227 cti_execute_cmd "cat ${LOGDIR}/initmode.out > ${LOGDIR}/wwn-merge.out"
228 cti_execute_cmd "cat ${LOGDIR}/tgtmode.out >> ${LOGDIR}/wwn-merge.out"
229 cti_reportfile "${LOGDIR}/wwn-merge.out"
230
231 ##########################################################
232 # compare 'hba-port -it' output with merged output.
233 ##########################################################
234 cti_execute_cmd "diff ${LOGDIR}/wwn-it.out ${LOGDIR}/wwn-merge.out"
235 re_code=$?
236 cti_report "diff between hba-port -it and "\
237 "merge of hba-port -i and -t returns $re_code"
238 ((return_code+=$re_code))
239 fi
240
241 if [[ $return_code != 0 ]]
242 then
243 cti_report "Test Purpose 2: $TEST_NAME failed with return"\
244 "code $return_code"
245 cti_fail "Test Purpose 2: $TEST_NAME failed"
246 else
247 cti_report "$TEST_NAME output: "
248 cti_pass "Test Purpose 2: $TEST_NAME passed"
249 fi
250 }