1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849
|
#!/bin/sh
# the next line restarts using tclsh \
exec ibmssh "$0" "$@"
#--
# Copyright (c) 2004-2010 Mellanox Technologies LTD. All rights reserved.
#
# This software is available to you under a choice of one of two
# licenses. You may choose to be licensed under the terms of the GNU
# General Public License (GPL) Version 2, available from the file
# COPYING in the main directory of this source tree, or the
# OpenIB.org BSD license below:
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# - Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# - Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#--
#############################################################################
# Id ..........$Id$
# Revision.....$Revision: 1.11 $
# Date.........$Date: 2005/07/05 07:07:37 $
# Author.......$Author: eitan $
#EOH#########################################################################
set ToolUsage {[-h] [-o osm-path][-f flow-file][-c checker-file] -t topology [-n osm-node-name][-p osm-port-num][-s seed][-V verbosity-list]}
set ToolUsage "Usage: $argv0 $ToolUsage"
set version "1.0"
proc Usage {} {
global ToolUsage
puts "$ToolUsage"
}
##############################################################################
proc Help {} {
global ToolUsage
global version
puts "
Tests over the Simulator
--------------------------
$ToolUsage
The test flow starts the simulator and runs the the given test flow
on top of it. Then it runs the test flow. The default test flow starts
OpenSM and wait for Subnet-Up event. User given flow can make use of the
provided facilities for starting OpenSM and tracking it events.
Command Line Arguments (required):
-t topology = a topology file describing the fabric.
Command Line Options:
-f flow-file = a tcl file sourced by the sim after the fabric is setup.
See following discussion about the provided API and global variables
that are available for the flow.
-c checker-file = a tcl file defining when osm completed and what
checks are requierd to validate it's outputs. The procedure named
'checker' is invoked by the test flow to start the checking flow.
(the default flow waits for OpenSM to complete setup the fabric and
run ibdmchk).
-o osm-path = Full path to OpenSM (/usr/mellanox/osm-sim/bin/opensm).
-n osm-node = Topology file node name the SM runs on (default H-1/U1).
-p port-num = Port number the SM attaches to (default 1).
-s seed = random seed to be used.
-V verbosity-list = module verbosity list. The first should be the global
verbosity. See IBMgtSim for full list of modules.
Examples:
-V 0xffff = Full verbosity on all modules
-V '\"0x3 server 0x6f2 sma 0xffff\"' = Only fatal and error
for all modules full verbosity for the SMA module and default
verbosity for the Server module.
-h - help.
Provided and Required Flow file API:
------------------------------------
Several utilities are provided by this main test running utility:
1. startOsmLogAnalyzer <osmLogFileName>
starts a tracker and analyzer of the OpenSM log file provided.
The tracker will invoke callbacks registered in the global variable:
osmLogCallbacks(<osmLogFileName>)
2. waitForOsmEvent <eventsVarName> <lastEventLogLenVarName> <osmLogFileName>
This is a
$version
"
}
##############################################################################
#
# OpenSM log file analyzer
#
# Continuously monitor the OpenSM log file and generate a log of all the
# events reported in the log file.
#
# On any event - it scans through the list of callbacks to be invoked
# and calls them acordingly. The list of callabcks is in osmLogCallbacks(logFile)
#
# The log of all events is accumulated in the global list:
# osmEventLog(logFile)
#
# The format of the event log list entry is:
# <eventType> <time> <full line>
#
# <eventType> = SubnetUp, Standby, ERR, ErrorsInInitialization, ReportNoice, ....
# <time> = the local time in tracker.
# <full line> = the complete log file line.
#
proc startOsmLogAnalyzer {logFileName} {
global osmEventLog osmTrackerPipes osmSubProcessIds
# clear the log
set osmEventLog($logFileName) {}
# Open Up the OpenSM Log file
set logFile [open "| tail -F $logFileName" r+]
lappend osmTrackerPipes $logFile
lappend osmSubProcessIds [pid $logFile]
fconfigure $logFile -buffering none -blocking 0
fileevent $logFile readable [list osmLogAnalyzerEvent $logFile $logFileName]
}
proc osmLogAnalyzerEvent {logFile logFileName} {
global osmEventLog osmLogCallbacks
if {[eof $logFile]} {
puts "-I- EOF on OpenSM Pipe"
fileevent $logFile readable {}
close $logFile
return
}
# actually read and analyze
while {[gets $logFile sLine] >= 0} {
set event ""
if {[regexp -- {-[>] SUBNET UP} $sLine]} {
set event SubnetUp
set data {}
} elseif {[regexp { ERR } $sLine]} {
set event ERR
set data $sLine
} elseif {[regexp {STANDBY} $sLine]} {
set event STANDBY
set data {}
}
if {$event != ""} {
puts "-I- OpenSM Event:$event $data"
lappend osmEventLog($logFileName) [list $event [clock seconds] $sLine]
if {[info exists osmLogCallbacks($logFileName)]} {
foreach cb $osmLogCallbacks($logFileName) {
if {[catch {eval "$cb"} e]} {
puts $errorInfo
}
}
}
}
}
}
proc waitForOsmEvent {eventsVarName lastEventLogLenVarName logFile} {
global osmEventLog osmLogCallbacks
upvar #0 $lastEventLogLenVarName lastEventLogLen
upvar #0 $eventsVarName events
if {[llength $osmEventLog($logFile)] > $lastEventLogLen} {
set prevLen $lastEventLogLen
set lastEventLogLen [llength $osmEventLog($logFile)]
puts "-I- New [expr $lastEventLogLen - $prevLen] events of $logFile"
set events [lrange $osmEventLog($logFile) $prevLen end]
return
}
puts "-I- No new event or $logFile"
set events {}
return
}
# wait for the SM with the given log to be either dead or in subnet up
proc osmWaitForUpOrDead {osmLog {ignorePrev 0}} {
global osmUpOrDeadEvents osmUpOrDeadLogLen
global osmLogCallbacks
# wait for OpenSM to complete setting up the fabric
if {![info exists osmUpOrDeadLogLen] || $ignorePrev} {
set osmUpOrDeadLogLen 0
set osmUpOrDeadEvents {}
}
set osmLogCallbacks($osmLog) \
"{waitForOsmEvent osmUpOrDeadEvents osmUpOrDeadLogLen $osmLog}"
puts "-I- Waiting for OpenSM subnet up ..."
set done 0
while {$done == 0} {
foreach event $osmUpOrDeadEvents {
if {[lindex $event 0] == "exit"} {
set exitCode 1
set done 1
} elseif {[lindex $event 0] == "SubnetUp"} {
set done 1
set exitCode 0
}
}
set osmUpOrDeadEvents {}
if {$done != 0} {return $exitCode}
vwait osmUpOrDeadEvents
}
return $exitCode
}
# wait for the SM with the given log to be either dead or in subnet up
# also support
proc osmWaitForUpOrDeadWithTimeout {osmLog timeout_ms {ignorePrev 0}} {
global osmUpOrDeadEvents osmUpOrDeadLogLen
global osmLogCallbacks
# wait for OpenSM to complete setting up the fabric
if {![info exists osmUpOrDeadLogLen] || $ignorePrev} {
set osmUpOrDeadLogLen 0
set osmUpOrDeadEvents {}
}
set osmLogCallbacks($osmLog) \
"{waitForOsmEvent osmUpOrDeadEvents osmUpOrDeadLogLen $osmLog}"
after $timeout_ms [list set osmUpOrDeadEvents {timeout 0 {}}]
puts "-I- Waiting for OpenSM subnet up ..."
set done 0
while {$done == 0} {
vwait osmUpOrDeadEvents
foreach event $osmUpOrDeadEvents {
if {[lindex $event 0] == "exit"} {
puts "-E- OpenSM exit event"
set exitCode 1
set done 1
} elseif {[lindex $event 0] == "timeout"} {
puts "-E- Exiting on timeout after $timeout_ms msec"
set exitCode 1
set done 1
} elseif {[lindex $event 0] == "SubnetUp"} {
set done 1
set exitCode 0
}
}
}
return $exitCode
}
proc osmTrackProcess {osmPId logFile} {
global osmEventLog osmLogCallbacks
# wait for OpenSM to exit
set isAlive 0
catch {set isAlive [exec ps -p $osmPId | wc -l]}
if {$isAlive < 2} {
puts "-I- OpenSM with log:$logFile died"
lappend osmEventLog($logFile) [list exit [clock seconds] none]
if {[info exists osmLogCallbacks($logFile)]} {
foreach cb $osmLogCallbacks($logFile) {
eval $cb
}
}
} else {
after 1200 [list osmTrackProcess $osmPId $logFile]
}
}
##############################################################################
#
# Start up the test applications
# This is the default flow that will start OpenSM only in 0x43 verbosity
# Return a list of process ids it started (to be killed on exit)
#
proc runner {simDir osmPath osmPortGuid} {
set osmStdOutLog [file join $simDir osm.stdout.log]
set osmLog [file join $simDir osm.log]
puts "-I- Starting: $osmPath -D 0x43 -g $osmPortGuid ..."
set osmPId [exec $osmPath -D 0x43 -f $osmLog -g $osmPortGuid > $osmStdOutLog &]
# start a tracker on the log file and process:
startOsmLogAnalyzer $osmLog
after 1000 [list osmTrackProcess $osmPId $osmLog]
return $osmPId
}
##############################################################################
#
# Check for the test results
# Return the exit code
proc checker {simDir osmPath osmPortGuid} {
set ibdmchkLog [file join $simDir ibdmchk.log]
set osmLog [file join $simDir osm.log]
set exitCode [osmWaitForUpOrDead $osmLog]
set subnetFile [file join $simDir subnet.lst]
set fdbsFile [file join $simDir osm.fdbs]
set mcfdbsFile [file join $simDir osm.mcfdbs]
set cmd "ibdmchk -s $subnetFile -f $fdbsFile -m $mcfdbsFile"
if {$exitCode == 0} {
if {[catch {set res [eval "exec $cmd > $ibdmchkLog"]} e]} {
puts $e
set exitCode 1
} else {
puts "-I- ibdmchk completed successfully"
set exitCode 0
}
}
return $exitCode
}
##############################################################################
#
# Exit the test flow killing OpenSM and the Simulator
#
proc exitTestFlow {pidList simPipeId exitCode} {
global simDir tmpDir
global simCtrlSock osmTrackerPipes
puts "-I- Closing SIM ... "
catch {
puts $simCtrlSock "puts {exiting from remote}"
puts $simCtrlSock "exit"
}
puts "-I- Closing Sub Processes ... "
foreach pId $pidList {
catch {exec kill -9 $pId}
}
catch {
set subProcesses [exec ps --ppid [pid] -o pid]
foreach p $subProcesses {
catch {exec kill $p}
}
}
after 5000
puts "-I- Closing Pipes ..."
foreach logPipe [array names osmTrackerPipes] {
catch {fileevent $logPipe readable {}; close $logPipe}
}
puts "-I- Status = $exitCode"
if {$exitCode == 0} {
exec rm -rf $simDir
} else {
puts "-I- Simulation dir left intact:$simDir"
}
exit $exitCode
}
##############################################################################
#
# Wait for the simulator to report it is ready to serve
#
proc waitForSimReady {pipeId} {
while {[gets $pipeId sLine] >= 0} {
if {$sLine == "-I- Ready to serve"} {
puts "-I- Simulator Ready"
return 1
}
}
error "Simulator died"
}
##############################################################################
#
# Connect to the simulator control server
#
# define the global simCtrlSock
proc connToSimControlServer {simDir} {
global simCtrlSock
set simCtrlFile [file join $simDir ibmgtsim.ctrl.server]
if {![file readable $simCtrlFile]} {
error "-E- No control server file found"
}
set f [open $simCtrlFile r]
gets $f sLine
if {[llength $sLine] != 2} {
error "-E- Bad format for $simCtrlFile got:$sLine"
}
close $f
set srvHost [lindex $sLine 0]
set srvPort [lindex $sLine 1]
puts "-I- Connecting to the simulator control server:$srvHost port:$srvPort "
set simCtrlSock [socket $srvHost $srvPort]
puts "-I- Connected to the simulator control server"
fconfigure $simCtrlSock -buffering line -blocking 1
return $simCtrlSock
}
##############################################################################
#
# Obtain the first node info
#
proc getSMNodeInfo {simDir nodeName} {
global getSMNodeInfo_DB
if {![info exists getSMNodeInfo_DB]} {
# open up the ibmgtsim.guids.txt
set f [open [file join $simDir ibmgtsim.guids.txt]]
set lineNum 0
set autoLid 0
while {[gets $f sLine] >= 0 } {
incr lineNum
if {[regexp {^NODE\s+(\S+)/U([0-9]+)\s+(\S+)} $sLine d1 n ca ng]} {
set getSMNodeInfo_DB($n/U$ca) [list $ca $ng]
} elseif {[regexp {^PORT\s+(\S+)/P([0-9]+)\s+(\S+)} $sLine d1 n p pg]} {
set getSMNodeInfo_DB($n/P$p) [list $pg [incr autoLid]]
}
}
close $f
puts "-I- Defined [llength [array names getSMNodeInfo_DB]] guids"
}
# first look for the node name:
if {![info exists getSMNodeInfo_DB($nodeName)]} {
error "Fail to find any info about node:$nodeName"
}
# return the node guid
set res {}
lappend res $getSMNodeInfo_DB($nodeName)
# followed by each port guid and lid:
foreach portName [lsort [array names getSMNodeInfo_DB $nodeName/P*]] {
lappend res $getSMNodeInfo_DB($portName)
}
if {[regexp {(.*)/U1} $nodeName d1 nodeNameNoU]} {
foreach portName [lsort [array names getSMNodeInfo_DB $nodeNameNoU/P*]] {
lappend res $getSMNodeInfo_DB($portName)
}
}
return $res
}
##############################################################################
#
# Get a TS port guid string of the format 0000:ffff:1111:2222
#
proc getPortGuidStr {guid} {
set guidRex \
"0x(\[0-9a-fA-F\]{4})(\[0-9a-fA-F\]{4})(\[0-9a-fA-F\]{4})(\[0-9a-fA-F\]{4})"
if {![regexp $guidRex $guid d1 n1 n2 n3 n4]} {
error "Bad guid format:$guid"
}
return "$n1:$n2:$n3:$n4"
}
##############################################################################
#
# Make a proc file system for the given node. Return the port GUID
#
proc makeProcFSForNode {simDir nodeName {portNum 0} {portLid 0}} {
set thePortGuid 0
set nodeData [getSMNodeInfo $simDir $nodeName]
puts "-I- Node $nodeName data: $nodeData"
foreach {ca ng} [lindex $nodeData 0] {break}
set nodeGuidStr [getPortGuidStr $ng]
# we use the index into the nodeData...
if {$portNum == 0} {
set portNum 1
}
# number of ports
set numPorts [expr [llength $nodeData] -1]
# Create the node dir
file mkdir [file join $simDir $nodeName ca$ca]
# Node Info
set of [open [file join $simDir $nodeName ca$ca info] w]
puts $of "name: InfiniHost0
provider: tavor
node GUID: $nodeGuidStr
ports: $numPorts
vendor ID: 0x2c9
device ID: 0x5a44
HW revision: 0xa1
FW revision: 0x300020002
"
close $of
# do the ports: (node data has node guid and ports)
for {set portIdx 1} {$portIdx <= $numPorts} {incr portIdx} {
set portData [lindex $nodeData $portIdx]
set pg [lindex $portData 0]
# the port guid we need should look like 0000:0000:0000:0000
set portGuidStr [getPortGuidStr $pg]
set lid [lindex $portData 1]
# use the given lid for the port
if {$portNum == $portIdx} {
set thePortGuid $pg
if {$portLid != 0} {
set lid $portLid
}
}
# Port1
file mkdir [file join $simDir $nodeName ca$ca port$portIdx]
# port info
set of [open [file join $simDir $nodeName ca$ca port$portIdx info] w]
puts $of "state: INIT
LID: [format 0x%04x $lid]
LMC: 0x0000
SM LID: 0x0001
SM SL: 0x0000
Capabilities: IsTrapSupported
IsAutomaticMigrationSupported
IsSLMappingSupported
IsLEDInfoSupported
IsSystemImageGUIDSupported
IsVendorClassSupported
IsCapabilityMaskNoticeSupported
"
close $of
set of [open [file join $simDir $nodeName ca$ca port$portIdx pkey_table] w]
puts $of {[ 0] ffff}
close $of
set of [open [file join $simDir $nodeName ca$ca port$portIdx gid_table] w]
puts $of "\[ 0\] fe80:0000:0000:0000:$portGuidStr"
close $of
}
return $thePortGuid
}
##############################################################################
#
# Get LD_PRELOAD to overcome /lib/tls issues
#
proc getLibAltPath {libName} {
if {[file isdirectory /lib64]} {
set res [lindex [glob /lib64/$libName*] 0]
} else {
set res [lindex [glob /lib/$libName*] 0]
}
return $res
}
# Return either an empty string or the LD_PRELOAD to perform
proc getLdPreloadCmd {} {
set res ""
if {[file isdirectory /lib/tls] ||[file isdirectory /lib64/tls]} {
append res "[getLibAltPath libpthread.so]:"
append res "[getLibAltPath libc.so]:"
append res "[getLibAltPath libm.so]:"
append res "[getLibAltPath librt.so]"
puts "-I- Required Preload: $res"
}
return $res
}
# return the absolute file name for the given file or error and exit if the
# file does not exists or is not readable
proc getAbsoluteFileName {fileName} {
if {![file exists $fileName]} {
puts "-E- Given file:$fileName does not exist"
exit 1
}
if {![file readable $fileName]} {
puts "-E- Given file:$fileName is not readable"
exit 1
}
return [file normalize $fileName]
}
##############################################################################
#
# Get Opt
#
set optind 0
proc getopt { argslist optstring optret argret } {
global optind optindc
upvar $optret retvar
upvar $argret optarg
# default settings for a normal return
set optarg ""
set retvar ""
set retval 0
# check if we are in a single char mode or support long
# option string
if {[string match "* *" $optstring]} {
set longOptMode 1
} else {
set longOptMode 0
}
# check if we're past the end of the args list
if { $optind < [ llength $argslist ] } then {
# if we got -- or an option that doesn't begin with -, return (skipping
# the --). otherwise process the option arg.
switch -glob -- [ set arg [ lindex $argslist $optind ]] {
"--" {
incr optind
}
"-*" {
# opt needs to return the name of the option
regexp -- {-([^:]+):?} $arg d1 opt
incr optind
if {$longOptMode} {
# options are defined as words optionaly containing ":"
if { [ lsearch -regexp $optstring "^$opt:?\$" ] >= 0 } then {
set retvar $opt
set retval 1
if { [ lsearch -regexp $optstring "^$opt:\$" ] >= 0 } then {
if { $optind < [ llength $argslist ] } then {
set optarg [lindex $argslist $optind]
incr optind
} else {
set optarg "Option requires an argument -- $opt"
set retvar $optarg
set retval -1
}
}
} else {
set optarg "Illegal option -- $opt"
set retvar $optarg
set retval -1
}
} else {
# traditional single char options
if { [ string match "*$opt*" $optstring ] } then {
set retvar $opt
set retval 1
if { [ string match "*$opt:*" $optstring ] } then {
if { $optind < [ llength $argslist ] } then {
set optarg [lindex $argslist $optind]
incr optind
} else {
set optarg "Option requires an argument -- $opt"
set retvar $optarg
set retval -1
}
}
} else {
set optarg "Illegal option -- $opt"
set retvar $optarg
set retval -1
}
}
}
}
}
return $retval
}
##############################################################################
#
# MAIN FLOW:
#
set pid [pid]
set simulationFlowFile ""
set checkerFlowFile ""
set topologyFile ""
set osmPath /usr/mellanox/osm-sim/bin/opensm
# default verbosity show: time, context, fatal and error
set moduleVerbosityList 0xA3
set osmPortNum 1
set osmNodeName "H-1/U1"
set osmSubProcessIds {}
set randomSeed [expr int(rand() * 100000)]
while { [ set err [ getopt $argv "hvV:o:f:c:t:n:p:s:" opt arg ]] } {
if { $err < 0 } then {
Usage
exit 2
} else {
switch -exact $opt {
h {Help; exit 0}
v {puts "";puts $version; puts ""; exit 0}
o {set osmPath $arg}
f {set simulationFlowFile [getAbsoluteFileName $arg]}
c {set checkerFlowFile [getAbsoluteFileName $arg]}
n {set osmNodeName $arg}
p {set osmPortNum $arg}
t {set topologyFile [getAbsoluteFileName $arg]}
s {set randomSeed $arg}
V {set moduleVerbosityList $arg }
default {
puts "-E- Unsupported option:$opt"
puts $ToolUsage
exit 1
}
}
}
}
# make sure we got a topology:
if {$topologyFile == ""} {
puts "-E- Missing mandatory flag -t. Topology file was not defined."
Usage
exit
}
# handle extra args
set left_args [ lrange $argv $optind end ]
if {[llength $left_args]} {
puts "-E- illegal parameter(s) used : $left_args"
Usage
exit 1
}
puts "-I- Using random seed:$randomSeed"
rmSeed $randomSeed
# track opened pipes
set osmTrackerPipes {}
# define tmp directory to use:
set tmpDir /var/cache/ibutils
# Define the temporary directory:
set simDir [file join $tmpDir ibmgtsim.$pid]
puts "-I- Simulation directory is: $simDir"
set env(IBMGTSIM_DIR) $simDir/
set env(OSM_CACHE_DIR) $simDir/
set env(OSM_TMP_DIR) $simDir/
file mkdir $simDir
cd $simDir
# We also want to verify the correct osmvendor is selected
set env(LD_LIBRARY_PATH) \
"[file join [file dirname [file dirname $osmPath]] lib]"
# if provided a flow file use it
if {$checkerFlowFile != ""} {
source $checkerFlowFile
}
set simLog [file join $simDir sim.log]
set simStdOutLog [file join $simDir sim.stdout.log]
if {[catch {
# Start the Simulator
if {$simulationFlowFile != ""} {
set cmd "IBMgtSim -s $randomSeed -V $moduleVerbosityList -t $topologyFile -f $simulationFlowFile -l $simLog"
} else {
set cmd "IBMgtSim -s $randomSeed -V $moduleVerbosityList -t $topologyFile -l $simLog"
}
puts "-I- Calling $cmd"
eval "exec $cmd > $simStdOutLog &"
set sim [open "|tail -F $simStdOutLog" r+]
lappend osmSubProcessIds [pid $sim]
# wait for the simulator to report it is ready to serve
waitForSimReady $sim
# connect to the server
connToSimControlServer $simDir
fconfigure $sim -buffering line -blocking 0
# make the node files for the OpenSM Node:
set osmPortGuid [makeProcFSForNode $simDir $osmNodeName $osmPortNum 1]
# set the node name for OpenSM
set env(IBMGTSIM_NODE) $osmNodeName
# start OpenSM
set osmPid [runner $simDir $osmPath $osmPortGuid]
lappend osmSubProcessIds $osmPid
# run the checker
set exitCode [checker $simDir $osmPath $osmPortGuid]
# exit everything
exitTestFlow $osmSubProcessIds $sim $exitCode
} e]} {
puts "$e"
if {[info exists sim]} {
close $sim
}
puts "-E- $errorInfo"
exitTestFlow $osmSubProcessIds $sim 2
exit 1
}
|