Blame IbaTools/FastFabric/switch_getconfig.exp

Packit 857059
Packit 857059
# BEGIN_ICS_COPYRIGHT8 ****************************************
Packit 857059
# 
Packit 857059
# Copyright (c) 2015-2017, Intel Corporation
Packit 857059
# 
Packit 857059
# Redistribution and use in source and binary forms, with or without
Packit 857059
# modification, are permitted provided that the following conditions are met:
Packit 857059
# 
Packit 857059
#     * Redistributions of source code must retain the above copyright notice,
Packit 857059
#       this list of conditions and the following disclaimer.
Packit 857059
#     * Redistributions in binary form must reproduce the above copyright
Packit 857059
#       notice, this list of conditions and the following disclaimer in the
Packit 857059
#       documentation and/or other materials provided with the distribution.
Packit 857059
#     * Neither the name of Intel Corporation nor the names of its contributors
Packit 857059
#       may be used to endorse or promote products derived from this software
Packit 857059
#       without specific prior written permission.
Packit 857059
# 
Packit 857059
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit 857059
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 857059
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Packit 857059
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
Packit 857059
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 857059
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Packit 857059
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Packit 857059
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Packit 857059
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 857059
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 857059
# 
Packit 857059
# END_ICS_COPYRIGHT8   ****************************************
Packit 857059
Packit 857059
# [ICS VERSION STRING: unknown]
Packit 857059
Packit 857059
#=============================================================================#
Packit 857059
# Test Suite Description:
Packit 857059
#-----------------------------------------------------------------------------#
Packit 857059
## switch getportconfig
Packit 857059
## -------
Packit 857059
## report of port configurations of all unmanaged switch nodes
Packit 857059
#=============================================================================#
Packit 857059
Packit 857059
# manditory setup
Packit 857059
log_user 0;	# disable detailed logging to stdout
Packit 857059
Packit 857059
# uncomment the following to debug the test
Packit 857059
#strace 20
Packit 857059
#log_user 1
Packit 857059
#exp_internal 1
Packit 857059
#cmd_trace on
Packit 857059
#strace 4
Packit 857059
Packit 857059
set install_exit_code 0
Packit 857059
Packit 857059
proc suite_setup {} {
Packit 857059
	# example of conditional setup
Packit 857059
	#test_execute {load populate} {
Packit 857059
		#do some installation or configuration stuff
Packit 857059
	#}
Packit 857059
}
Packit 857059
Packit 857059
proc case_setup {} {
Packit 857059
# setup to do at start of each test case
Packit 857059
# Usage:
Packit 857059
#	pass as argument to start_suite
Packit 857059
# Arguments:
Packit 857059
#	None
Packit 857059
# This procedure will be run at the start of every test case
Packit 857059
# It provides an opportunity for uniform cleanup/setup for each test case
Packit 857059
Packit 857059
}
Packit 857059
Packit 857059
proc case_cleanup { failed } {
Packit 857059
# cleanup to do after each test case
Packit 857059
# Usage:
Packit 857059
#	pass as argument to start_suite
Packit 857059
# Arguments:
Packit 857059
#	failed - set to 1 if test case failed in which case additional
Packit 857059
#		information/files may be desired in test_tmp
Packit 857059
#		set to 0 if test case passed
Packit 857059
# This procedure will be run at the end of every test case
Packit 857059
# It provides an opportunity for uniform cleanup after each test case
Packit 857059
	global env
Packit 857059
Packit 857059
	test_execute {} {
Packit 857059
		if { $failed } {
Packit 857059
			global opaswitch
Packit 857059
			# could put cleanup here
Packit 857059
		}
Packit 857059
	}
Packit 857059
}
Packit 857059
Packit 857059
test_suite "switchgetportconfig" "report switch getconfig" "report port configurations of all externally managed switch nodes
Packit 857059
File: /usr/lib/opa/tools/switch_getconfig.exp" suite_setup noop {
Packit 857059
	global opaswitch
Packit 857059
Packit 857059
	# Global Initializations for Test Suite:
Packit 857059
	# --------------------------------------
Packit 857059
Packit 857059
	# ADD ANY GLOBAL INITIALIZATION HERE, SUCH AS:
Packit 857059
	# set env(MY_ENV_VAR) value
Packit 857059
	# also validate the environment
Packit 857059
	# if the environment is bad call fail_suite "information" abort_now
Packit 857059
	# abort_now should be 0 if it is safe to proceed and simply ignore all
Packit 857059
	# test_case calls.  it should be 1 if that is not possible.
Packit 857059
Packit 857059
	# Procedures used to support Test Suite:
Packit 857059
	# --------------------------------------
Packit 857059
Packit 857059
	# The actual test cases:
Packit 857059
	# ----------------------
Packit 857059
Packit 857059
	# we will get config information to this temp file
Packit 857059
	set mypid [pid]
Packit 857059
	set fname [ exec mktemp --tmpdir "sw_getconfig_XXXX" ]
Packit 857059
	set fd [ open "$fname" {CREAT WRONLY APPEND TRUNC} ]
Packit 857059
Packit 857059
	parallel opaswitch $env(CFG_OPASWITCHES) {
Packit 857059
		fconfigure $fd -buffering line
Packit 857059
		set opaswitch [ trim_opaswitch_distance "$opaswitch"]
Packit 857059
		test_case_i2c_extmgd_switchgetportconfig "$opaswitch" "$fd"
Packit 857059
	}
Packit 857059
Packit 857059
	# omit some lines, and provide a summary of how many switches have each
Packit 857059
	# type of config
Packit 857059
	catch { close $fd }
Packit 857059
	catch {
Packit 857059
		set summary [exec cat $fname | egrep -v {^[[:space:]]*$|Node Description} | /usr/lib/opa/tools/show_counts 2>@1 ]
Packit 857059
		show_message "Summary:\ncount - configuration\n$summary"
Packit 857059
	}
Packit 857059
	catch { exec rm -f $fname }
Packit 857059
}