~ubuntu-branches/ubuntu/raring/ibutils/raring-proposed

« back to all changes in this revision

Viewing changes to ibis/tests/ibpm_test.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Benoit Mortier
  • Date: 2010-01-11 22:22:00 UTC
  • Revision ID: james.westby@ubuntu.com-20100111222200-53kum2et5nh13rv3
Tags: upstream-1.2-OFED-1.4.2
ImportĀ upstreamĀ versionĀ 1.2-OFED-1.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# the next line restarts using tclsh \
 
3
   exec tclsh8.3 "$0" "$@"
 
4
 
 
5
set Usage "Usage: $argv0 portNum <rem_lid> <rem_port> <bad_lid> <bad_port>"
 
6
 
 
7
set Help "
 
8
 
 
9
IBPM API Test
 
10
 
 
11
SYNOPSYS:
 
12
 $Usage
 
13
 
 
14
DESCRIPTION:
 
15
 This simple test works at the PM lowest level interface.
 
16
 It perfoems the following checks.
 
17
 
 
18
API pmMultiMaxGet :
 
19
max_get_1 - simply invoke and verify we get 64
 
20
 
 
21
API pmGetPortCounters :
 
22
get_cnt_1 - Use a good lid and port pair - check we did obtain some values
 
23
get_cnt_2 - Use a bad  lid and port pair - check we fail
 
24
 
 
25
API pmGetPortCountersMulti :
 
26
get_multi1 - Use local and remote ports - check we did obtain some data.
 
27
get_multi2 - Use local, remote and bad ports - check we did obtain some data.
 
28
 
 
29
API pmClrAllCounters :
 
30
clr1 - Clear local port - make sure we got 0...
 
31
clr2 - Clear remote port - make sure we got 0...
 
32
clr3 - Clear bad port - make sure we got an error
 
33
 
 
34
API pmClrAllCountersMulti :
 
35
clr_multi1 - Clear local and remote ports - make sure we got 0...
 
36
clr_multi2 - Clear local, remote and bad port - make sure we got 0s abnd err
 
37
 
 
38
FLOWS:
 
39
flow1 - get ports on local and remote. See number of packets advanced on local
 
40
TODO: flow2 - Validate each counter by using CR-Space access.
 
41
 
 
42
"
 
43
########################################################################
 
44
 
 
45
# provide a verbose evaluation method:
 
46
proc ex {expr} {
 
47
   global verbose
 
48
 
 
49
   if {$verbose} {puts "EX: $expr"}
 
50
   if {[catch {eval "set res \[$expr\]"} e]} {
 
51
      if {$verbose} {puts "EX: ERR: $e"}
 
52
      return $e
 
53
   } else {
 
54
      if {$verbose} {puts "EX: => $res"}
 
55
   }
 
56
   return $res
 
57
}
 
58
 
 
59
# Make sure we got some reasonable counter values.
 
60
proc ibpm_validate_counters {counters} {
 
61
   return [regexp {port_select.*counter_select.*symbol_error_counter.*port_rcv_pkts} $counters]
 
62
}
 
63
 
 
64
# Make sure counters were cleared. return 1 if all zeros.
 
65
proc ibpm_validate_counters_cleared {counters} {
 
66
   if {[regexp {counter_select.*\s+.([a-z][a-z_15]+\s+[1-9][0-9]+)} $counters d1 viol]} {
 
67
      puts "-E- found non zero counters: $viol"
 
68
      return 0
 
69
   }
 
70
   return 1
 
71
}
 
72
 
 
73
# given a key and a list of ley/value pairs get the pair
 
74
proc assoc {key key_list} {
 
75
        foreach kv $key_list {
 
76
                if {[lindex $kv 0] == $key} {return [lrange $kv 1 end]}
 
77
        }
 
78
        return ""
 
79
}
 
80
 
 
81
########################################################################
 
82
 
 
83
#
 
84
# PARSE COMMAND LINE
 
85
#
 
86
if {[llength $argv] && [lindex $argv 0] == "-v"} {
 
87
   set argv [lrange $argv 1 end]
 
88
   set verbose 1
 
89
} else {
 
90
   set verbose 0
 
91
}
 
92
 
 
93
if {[llength $argv] != 5} {
 
94
   puts $Usage
 
95
   exit
 
96
}
 
97
 
 
98
set doBadCases 1
 
99
set numLoops 10
 
100
 
 
101
set locPort [lindex $argv 0]
 
102
set remLid  [lindex $argv 1]
 
103
set remPort [lindex $argv 2]
 
104
set badLid  [lindex $argv 3]
 
105
set badPort [lindex $argv 4]
 
106
 
 
107
#
 
108
# Set ibis port:
 
109
#
 
110
package require ibis
 
111
ibis_set_verbosity 0xff
 
112
set availPorts [ibis_get_local_ports_info]
 
113
 
 
114
# make sure we can bind to the requested port
 
115
if {[llength $availPorts] < $locPort} {
 
116
   puts "-E- Not enough local ports: [llength $availPorts] (required $locPort)"
 
117
   exit
 
118
}
 
119
 
 
120
set portInfo [lindex $availPorts [expr $locPort - 1]]
 
121
# make sure it is active...
 
122
if {[lindex $portInfo 2] != "ACTIVE"} {
 
123
   puts "-E- Requested port: $locPort status is:$portInfo"
 
124
   exit
 
125
}
 
126
 
 
127
set locLid [expr [lindex $portInfo 1]]
 
128
 
 
129
# bind to the port
 
130
ibis_set_port [lindex $portInfo 0]
 
131
 
 
132
package require ibpm
 
133
 
 
134
#
 
135
# Start API testing
 
136
#
 
137
set anyError 0
 
138
 
 
139
for {set i 0} {$i < $numLoops} {incr i} {
 
140
   # API pmMultiMaxGet :
 
141
   # max_get_1 - simply invoke and verify we get 64
 
142
   if {[ex pmMultiMaxGet] != 64} {
 
143
      puts "-E- pmMultiMaxGet did not return 64"
 
144
      incr anyError
 
145
   }
 
146
 
 
147
   #
 
148
   # API pmGetPortCounters :
 
149
   # get_cnt_1 - Use a good lid and port pair - check we did obtain some values
 
150
   set cnts [ex "pmGetPortCounters $locLid $locPort"]
 
151
   if {![ibpm_validate_counters $cnts]} {
 
152
      puts "-E- Failed to validate counters."
 
153
      incr anyError
 
154
   }
 
155
 
 
156
   if {$doBadCases} {
 
157
      # get_cnt_2 - Use a bad  lid and port pair - check we fail
 
158
      set cnts [ex "pmGetPortCounters $badLid $badPort"]
 
159
      if {[ibpm_validate_counters $cnts]} {
 
160
         puts "-E- Failed to invalidate counters error."
 
161
         incr anyError
 
162
      }
 
163
   }
 
164
 
 
165
   #
 
166
   # API pmGetPortCountersMulti :
 
167
   # get_multi1 - Use local and remote ports - check we did obtain some data.
 
168
   set cnts [ex "pmGetPortCountersMulti 2 {$locLid $remLid} {$locPort $remPort}"]
 
169
   if {![ibpm_validate_counters [lindex $cnts 0]]} {
 
170
      puts "-E- Failed to validate counters:[lindex $cnts 0] "
 
171
      incr anyError
 
172
   }
 
173
   if {![ibpm_validate_counters [lindex $cnts 1]]} {
 
174
      puts "-E- Failed to validate counters:[lindex $cnts 1] "
 
175
      incr anyError
 
176
   }
 
177
 
 
178
   # get_multi2 - Use local, remote and bad ports - check we obtain some data.
 
179
   # Last is bad
 
180
   set cnts [ex "pmGetPortCountersMulti 3 {$locLid $remLid $badLid} {$locPort $remPort $badPort}"]
 
181
   if {![ibpm_validate_counters [lindex $cnts 0]]} {
 
182
      puts "-E- Failed to validate counters:[lindex $cnts 0] "
 
183
      incr anyError
 
184
   }
 
185
   if {![ibpm_validate_counters [lindex $cnts 1]]} {
 
186
      puts "-E- Failed to validate counters:[lindex $cnts 1] "
 
187
      incr anyError
 
188
   }
 
189
   if {[ibpm_validate_counters [lindex $cnts 2]]} {
 
190
      puts "-E- Failed to invalidate bad counters:[lindex $cnts 2] "
 
191
      incr anyError
 
192
   }
 
193
   # Middle BAD
 
194
   set cnts [ex "pmGetPortCountersMulti 3 {$locLid $badLid $remLid} {$locPort $badPort $remPort}"]
 
195
   if {![ibpm_validate_counters [lindex $cnts 0]]} {
 
196
      puts "-E- Failed to validate counters:[lindex $cnts 0] "
 
197
      incr anyError
 
198
   }
 
199
   if {![ibpm_validate_counters [lindex $cnts 2]]} {
 
200
      puts "-E- Failed to validate counters:[lindex $cnts 2] "
 
201
      incr anyError
 
202
   }
 
203
   if {[ibpm_validate_counters [lindex $cnts 1]]} {
 
204
      puts "-E- Failed to invalidate bad counters:[lindex $cnts 1] "
 
205
      incr anyError
 
206
   }
 
207
   # End BAD:
 
208
   set cnts [ex "pmGetPortCountersMulti 3 {$badLid $locLid $remLid} {$badPort $locPort $remPort}"]
 
209
   if {![ibpm_validate_counters [lindex $cnts 1]]} {
 
210
      puts "-E- Failed to validate counters:[lindex $cnts 1] "
 
211
      incr anyError
 
212
   }
 
213
   if {![ibpm_validate_counters [lindex $cnts 2]]} {
 
214
      puts "-E- Failed to validate counters:[lindex $cnts 2] "
 
215
      incr anyError
 
216
   }
 
217
   if {[ibpm_validate_counters [lindex $cnts 0]]} {
 
218
      puts "-E- Failed to invalidate bad counters:[lindex $cnts 0] "
 
219
      incr anyError
 
220
   }
 
221
 
 
222
   #
 
223
   # API pmClrAllCounters :
 
224
   # clr1 - Clear local port - make sure we got 0...
 
225
   set err [ex "pmClrAllCounters $locLid $locPort"]
 
226
   if {$err} {
 
227
      puts "-E- Failed to clear counters on lid:$locLid port:$locPort  "
 
228
      incr anyError
 
229
   }
 
230
   set cnts [ex "pmGetPortCounters $locLid $locPort"]
 
231
   if {![ibpm_validate_counters_cleared [lindex $cnts 0]]} {
 
232
      puts "-E- Some counters not cleared on lid:$locLid port:$locPort => [lindex $cnts 0]"
 
233
      incr anyError
 
234
   }
 
235
   # clr2 - Clear remote port - make sure we got 0...
 
236
   set err [ex "pmClrAllCounters $remLid $remPort"]
 
237
   if {$err} {
 
238
      puts "-E- Failed to clear counters on lid:$remLid port:$remPort  "
 
239
      incr anyError
 
240
   }
 
241
   set cnts [ex "pmGetPortCounters $remLid $remPort"]
 
242
   if {![ibpm_validate_counters_cleared [lindex $cnts 0]]} {
 
243
      puts "-E- Some counters not cleared on lid:$remLid port:$remPort => [lindex $cnts 0]"
 
244
      incr anyError
 
245
   }
 
246
 
 
247
   # clr3 - Clear bad port - make sure we got an error
 
248
   set err [ex "pmClrAllCounters $badLid $badPort"]
 
249
   if {$err == 0} {
 
250
      puts "-E- Failed to catch bad clear counters on lid:$badLid port:$badPort  "
 
251
      incr anyError
 
252
   }
 
253
 
 
254
   #
 
255
   # API pmClrAllCountersMulti :
 
256
   # clr_multi1 - Clear local and remote ports - make sure we got 0...
 
257
   set err \
 
258
      [ex "pmClrAllCountersMulti 2 {$locLid $remLid} {$locPort $remPort}"]
 
259
   if {$err != 0} {
 
260
      puts "-E- Failed to clear counters on lid:$locLid port:$locPort => $err "
 
261
      incr anyError
 
262
   }
 
263
   set multiCnts \
 
264
      [ex "pmGetPortCountersMulti 2 {$locLid $remLid} {$locPort $remPort}"]
 
265
   foreach cnt $multiCnts {
 
266
      if {![ibpm_validate_counters_cleared $cnts]} {
 
267
         puts "-E- Some counters not cleared on lid:$remLid port:$remPort => $cnts"
 
268
         incr anyError
 
269
      }
 
270
   }
 
271
 
 
272
   # clr_multi2 - Clear local, remote and bad - make sure we got 0s abnd err
 
273
   #
 
274
   set err \
 
275
      [ex "pmClrAllCountersMulti 2 {$locLid $remLid $badLid} {$locPort $remPort $badPort}"]
 
276
   if {$err != 0} {
 
277
      puts "-E- Failed to clear counters on lid:$locLid port:$locPort => $err "
 
278
      incr anyError
 
279
   }
 
280
   set multiCnts \
 
281
      [ex "pmGetPortCountersMulti 2 {$locLid $remLid} {$locPort $remPort}"]
 
282
   foreach cnt $multiCnts {
 
283
      if {![ibpm_validate_counters_cleared $cnts]} {
 
284
         puts "-E- Some counters not cleared on lid:$remLid port:$remPort => $cnts"
 
285
         incr anyError
 
286
      }
 
287
   }
 
288
 
 
289
   # FLOWS:
 
290
   # flow1 - get ports on local and remote. See number packets advanced...
 
291
   set cnts \
 
292
      [ex "pmGetPortCountersMulti 2 {$locLid $remLid} {$locPort $remPort}"]
 
293
   set xmitPkts1 [assoc port_xmit_pkts [lindex $cnts 0]]
 
294
   set cnts \
 
295
      [ex "pmGetPortCountersMulti 2 {$locLid $remLid} {$locPort $remPort}"]
 
296
   set xmitPkts2 [assoc port_xmit_pkts [lindex $cnts 0]]
 
297
   if {$xmitPkts1 >= $xmitPkts2} {
 
298
      puts "-E- Expected number of local port packets to grow. But xmitPkts1:$xmitPkts1 >= xmitPkts2:$xmitPkts2"
 
299
      incr anyError
 
300
   }
 
301
 
 
302
   # flow2 - Validate each counter by using CR-Space access.
 
303
}
 
304
 
 
305
if {$anyError} {
 
306
   puts "-E- TEST FAILED (with $anyError errors)"
 
307
}
 
308
exit $anyError