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 # tests run by this program are:
30 #
31 # This routine tests help functions and target mode supported
32 # subocmmands and options
33 #
34 ###############################################################
35 # __stc_assertion_start
36 #
37 # ID: fcinfo_comstar_001
38 #
39 # DESCRIPTION:
40 # Runs supported fcinfo subcommand/options to comstar hba port.
41 # - fcinfo hba-port -t
42 # - fcinfo hba-port -tl
43 # - fcinfo hba-port <target mode hba-port wwn>
44 # - fcinfo hba-port -l <target mode hba-port wwn>
45 # - fcinfo remote-port -p <hba-port wwn>
46 # - fcinfo remote-port -pl <hba-port wwn>
47 # - fcinfo remote-port -pl <hba-port wwn> <remote-port wwn>
48 # - fcinfo remote-port -pl <hba-port wwn> <remote-port wwn1>
49 # <remote-port wwn2>
50 #
51 # STRATEGY:
52 #
53 # Setup:
54 # Target mode hba port should exists on the hosts that the test
55 # runs.
56 # Test:
57 # Verify the return code of each command listed below.
58 # Cleanup:
59 # None
60 #
61 # STRATEGY_NOTES:
62 # remote initiators should be connected to properly drive
63 # the remote-port test.
64 #
65 # KEYWORDS:
66 # fcinfo hba-port remote-port
67 #
68 # TESTABILITY: explicit
69 #
70 # AUTHOR: hyon.kim@sun.com
71 #
72 # REVIEWERS: <e-mail, e-mail>
73 #
74 #
75 # ASSERTION_SOURCE:
76 #
77 # // Optional field - a pointer to the document source of the assertion
78 #
79 #
80 # TEST_AUTOMATION_LEVEL: automated
81 #
82 # CODING_STATUS: IN_PROGRESS
83 #
84 # __stc_assertion_end
85 #########################################################
86 # test purpose 001
87 #########################################################
88 function tp_fcinfo_001
89 {
90 typeset TEST_NAME="all supported subcommands/options for comstar ports"
91 cti_assert fcinfo_comstar_001 "Testing $TEST_NAME "
92 typeset MAX_DEVICES=3
93 typeset return_code=0
94 typeset re_code=0
95
96 #########################################################
97 # if no target mode port found, stop and return and error
98 #########################################################
99 CMD="fcinfo hba-port -t"
100 cti_execute_cmd "$CMD"
101 if [ $? -ne 0 ];then return 1;fi
102
103 #########################################################
104 # if construct the list of target mode ports.
105 #########################################################
106 # obtain an unique list of target mode WWNs for each of the HBA types
107 CMD="fcinfo hba-port -t | grep 'Port WWN' > ${LOGDIR}/tgtmode-wwn.out"
108 cti_execute_cmd $CMD
109 cti_reportfile "${LOGDIR}/tgtmode-wwn.out"
110
111 #obtain typical target mode HBA to run test
112 CMD="fcinfo hba-port -t | grep Manufacturer > ${LOGDIR}/tgtmode-hbatype.out"
113 cti_execute_cmd $CMD
114 cti_reportfile "${LOGDIR}/tgtmode-hbatype.out"
115
116 CMD="paste ${LOGDIR}/tgtmode-hbatype.out ${LOGDIR}/tgtmode-wwn.out"
117 CMD="$CMD > ${LOGDIR}/tgtmode-wwn-hba-list.out"
118 cti_execute_cmd $CMD
119 cti_reportfile "${LOGDIR}/tgtmode-wwn-hba-list.out"
120
121 cti_execute_cmd "cat ${LOGDIR}/tgtmode-wwn-hba-list.out |"\
122 "grep QLogic > ${LOGDIR}/tgtmode-unique.list"
123 cti_execute_cmd "cat ${LOGDIR}/tgtmode-wwn-hba-list.out |"\
124 "grep JNI >> ${LOGDIR}/tgtmode-unique.list"
125 cti_execute_cmd "cat ${LOGDIR}/tgtmode-wwn-hba-list.out |"\
126 "grep Emulex >> ${LOGDIR}/tgtmode-unique.list"
127 cti_execute_cmd "cat ${LOGDIR}/tgtmode-wwn-hba-list.out |"\
128 "grep Sun >> ${LOGDIR}/tgtmode-unique.list"
129 cti_reportfile "${LOGDIR}/tgtmode-unique.list"
130
131 CMD="cut -f 3 -d: ${LOGDIR}/tgtmode-unique.list >"
132 CMD="$CMD ${LOGDIR}/uniquetgtmodeHBAWWNList"
133 cti_execute_cmd $CMD
134 cti_reportfile "${LOGDIR}/uniquetgtmodeHBAWWNList"
135
136 #Go through each target mode port and run hba-port/remote-port command.
137 UNIQHBAWWNLIST=`eval "cat ${LOGDIR}/uniquetgtmodeHBAWWNList"`
138 for hbaPWWN in $UNIQHBAWWNLIST;
139 do
140 cti_report "Working on Targt mode HBAPort: $hbaPWWN"
141
142 # run hba-port with a specific hba port wwn.
143 CMD="fcinfo hba-port $hbaPWWN"
144 cti_execute_cmd "$CMD"
145 re_code=$?
146 ((return_code+=$re_code))
147 cti_report "$CMD returns: $re_code"
148
149 # run hba-port -l with a specific hba port wwn.
150 CMD="fcinfo hba-port -l $hbaPWWN"
151 cti_execute_cmd "$CMD"
152 re_code=$?
153 ((return_code+=$re_code))
154 cti_report "$CMD returns: $re_code"
155
156 # run remote-port -p with a specific hba port wwn.
157 CMD="fcinfo remote-port -p $hbaPWWN"
158 cti_execute_cmd "$CMD"
159 re_code=$?
160 ((return_code+=$re_code))
161 cti_report "$CMD returns: $re_code"
162
163 # run remote-port -lp with a specific hba port wwn.
164 CMD="fcinfo remote-port -lp $hbaPWWN"
165 cti_execute_cmd "$CMD"
166 re_code=$?
167 ((return_code+=$re_code))
168 cti_report "$CMD returns: $re_code"
169
170 #########################################################
171 # Go through each remote port run -lp
172 #########################################################
173 for rmtport1 in `eval "fcinfo remote-port -p $hbaPWWN" \
174 | grep 'Remote Port WWN' | awk ' { print $4 }'`;
175 do
176
177 # run remote-port -lp with a specific hba port wwn and remote port
178 # wwn.
179 CMD="fcinfo remote-port -lp $hbaPWWN $rmtport1"
180 cti_execute_cmd "$CMD"
181 re_code=$?
182 ((return_code+=$re_code))
183 cti_report "$CMD returns: $re_code"
184 device_count=0
185 for rmtport2 in `eval "fcinfo remote-port -p $hbaPWWN" \
186 | grep 'Remote Port WWN' | awk ' { print $4}'`;
187 do
188 # run remote-port -lp with a specific hba port wwn and remote
189 # port wwns.
190 CMD="fcinfo remote-port -lp $hbaPWWN $rmtport1 $rmtport2"
191 cti_execute_cmd "$CMD"
192 re_code=$?
193 ((return_code+=$re_code))
194 cti_report "$CMD returns: $re_code"
195 if [[ $device_count -le $MAX_DEVICES ]]; then
196 device_count=`expr $device_count + 1`
197 else
198 break
199 fi
200 done
201 done
202 done
203
204 #########################################################
205 # Testing -lt option without wwn operand.
206 #########################################################
207 cti_report "Testing -lt option without wwn operand"
208 CMD="fcinfo hba-port -lt"
209 cti_execute_cmd "$CMD"
210 re_code=$?
211 ((return_code+=$re_code))
212 cti_report "$CMD returns: $re_code"
213
214 if [[ $return_code != 0 ]]
215 then
216 cti_report "Test Purpose 1: $TEST_NAME failed with return"\
217 "code $return_code"
218 cti_fail "Test Purpose 1: $TEST_NAME failed"
219 else
220 cti_report "$TEST_NAME output: "
221 cti_pass "Test Purpose 1: $TEST_NAME passed"
222 fi
223 }