Codebase list ibutils / 46667d42-6d28-4f6f-9da8-c4c4650ae96c/main ibmgtsim / tests / ibdiagnet.check.tcl
46667d42-6d28-4f6f-9da8-c4c4650ae96c/main

Tree @46667d42-6d28-4f6f-9da8-c4c4650ae96c/main (Download .tar.gz)

ibdiagnet.check.tcl @46667d42-6d28-4f6f-9da8-c4c4650ae96c/mainraw · history · blame

#--
# 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.
#--

# This is the checker for that setup a network with OpenSM and then calls
# the ibdiag on the full fabric
# Intended to run with a set of sim flows - each causing some other errors

##############################################################################
#
# 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 -V -s 0 -g $osmPortGuid ..."
   set osmPid [exec $osmPath -d2 -V -s 0 -f $osmLog -g $osmPortGuid > $osmStdOutLog &]

   # start a tracker on the log file and process:
   startOsmLogAnalyzer $osmLog

   return $osmPid
}

##############################################################################
#
# Check for the test results: make sure we got a "SUBNET UP"
# Return the exit code
proc checker {simDir osmPath osmPortGuid} {
   global env simCtrlSock topologyFile
   set osmLog [file join $simDir osm.log]

   puts "-I- Waiting max time of 100sec...."

   if {[osmWaitForUpOrDeadWithTimeout $osmLog 1000000]} {
      return 1
   }

   # Invoke a simulation flow specific checker:
   puts $simCtrlSock "postSmSettings \$fabric"
   puts "SIM: [gets $simCtrlSock]"

   set ibdiagnetLog [file join $simDir ibdiagnet.stdout.log]
   set cmd "ibdiagnet -v -r -o $simDir -t $topologyFile"

   puts "-I- Invoking $cmd "
   if {[catch {set res [eval "exec $cmd > $ibdiagnetLog"]} e]} {
      puts "-E- ibdiagnet failed with error:$e"
      return 1
   }

   # Invoke a simulation flow specific checker:
   puts $simCtrlSock "verifyDiagRes \$fabric $ibdiagnetLog"
   set res [gets $simCtrlSock]
   puts "SIM: $res"
   if {$res == 0} {return 0}

   # make sure directory is not remoevd
   return 1
}