Blame IbaTools/FastFabric/switch_configure.exp

Packit Service 209154
#!/usr/bin/expect -f
Packit Service 3470d1
# BEGIN_ICS_COPYRIGHT8 ****************************************
Packit Service 3470d1
# 
Packit Service 3470d1
# Copyright (c) 2015, Intel Corporation
Packit Service 3470d1
# 
Packit Service 3470d1
# Redistribution and use in source and binary forms, with or without
Packit Service 3470d1
# modification, are permitted provided that the following conditions are met:
Packit Service 3470d1
# 
Packit Service 3470d1
#     * Redistributions of source code must retain the above copyright notice,
Packit Service 3470d1
#       this list of conditions and the following disclaimer.
Packit Service 3470d1
#     * Redistributions in binary form must reproduce the above copyright
Packit Service 3470d1
#       notice, this list of conditions and the following disclaimer in the
Packit Service 3470d1
#       documentation and/or other materials provided with the distribution.
Packit Service 3470d1
#     * Neither the name of Intel Corporation nor the names of its contributors
Packit Service 3470d1
#       may be used to endorse or promote products derived from this software
Packit Service 3470d1
#       without specific prior written permission.
Packit Service 3470d1
# 
Packit Service 3470d1
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit Service 3470d1
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit Service 3470d1
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Packit Service 3470d1
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
Packit Service 3470d1
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit Service 3470d1
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Packit Service 3470d1
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Packit Service 3470d1
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Packit Service 3470d1
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit Service 3470d1
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit Service 3470d1
# 
Packit Service 3470d1
# END_ICS_COPYRIGHT8   ****************************************
Packit Service 3470d1
Packit Service 3470d1
# [ICS VERSION STRING: unknown]
Packit Service 3470d1
Packit Service 3470d1
#=============================================================================#
Packit Service 3470d1
# Test Suite Description:
Packit Service 3470d1
#-----------------------------------------------------------------------------#
Packit Service 3470d1
## configure
Packit Service 3470d1
## -------
Packit Service 3470d1
## configure all switches
Packit Service 3470d1
#=============================================================================#
Packit Service 3470d1
Packit Service 3470d1
# manditory setup
Packit Service 3470d1
log_user 0;	# disable detailed logging to stdout
Packit Service 3470d1
Packit Service 3470d1
# uncomment the following to debug the test
Packit Service 3470d1
#strace 20
Packit Service 3470d1
#log_user 1
Packit Service 3470d1
#exp_internal 1
Packit Service 3470d1
#cmd_trace on
Packit Service 3470d1
#strace 4
Packit Service 3470d1
Packit Service 3470d1
set install_exit_code 0
Packit Service 3470d1
Packit Service 3470d1
proc suite_setup {} {
Packit Service 3470d1
	# example of conditional setup
Packit Service 3470d1
	#test_execute {load populate} {
Packit Service 3470d1
		#do some installation or configuration stuff
Packit Service 3470d1
	#}
Packit Service 3470d1
}
Packit Service 3470d1
Packit Service 3470d1
proc case_setup {} {
Packit Service 3470d1
# setup to do at start of each test case
Packit Service 3470d1
# Usage:
Packit Service 3470d1
#	pass as argument to start_suite
Packit Service 3470d1
# Arguments:
Packit Service 3470d1
#	None
Packit Service 3470d1
# This procedure will be run at the start of every test case
Packit Service 3470d1
# It provides an opportunity for uniform cleanup/setup for each test case
Packit Service 3470d1
Packit Service 3470d1
}
Packit Service 3470d1
Packit Service 3470d1
proc case_cleanup { failed } {
Packit Service 3470d1
# cleanup to do after each test case
Packit Service 3470d1
# Usage:
Packit Service 3470d1
#	pass as argument to start_suite
Packit Service 3470d1
# Arguments:
Packit Service 3470d1
#	failed - set to 1 if test case failed in which case additional
Packit Service 3470d1
#		information/files may be desired in test_tmp
Packit Service 3470d1
#		set to 0 if test case passed
Packit Service 3470d1
# This procedure will be run at the end of every test case
Packit Service 3470d1
# It provides an opportunity for uniform cleanup after each test case
Packit Service 3470d1
	global env
Packit Service 3470d1
Packit Service 3470d1
	test_execute {} {
Packit Service 3470d1
		if { $failed } {
Packit Service 3470d1
			global opaswitch
Packit Service 3470d1
			# could put cleanup here
Packit Service 3470d1
		}
Packit Service 3470d1
	}
Packit Service 3470d1
}
Packit Service 3470d1
Packit Service 3470d1
array set sw_config_linkwidths {
Packit Service 3470d1
1 1X
Packit Service 3470d1
2 2X
Packit Service 3470d1
3 1X/2X
Packit Service 3470d1
4 3X
Packit Service 3470d1
5 1X/3X
Packit Service 3470d1
6 2X/3X
Packit Service 3470d1
7 1X/2X/3X
Packit Service 3470d1
8 4X
Packit Service 3470d1
9 1X/4X
Packit Service 3470d1
10 2X/4X
Packit Service 3470d1
11 1X/2X/4X
Packit Service 3470d1
12 3X/4X
Packit Service 3470d1
13 1X/3X/4X
Packit Service 3470d1
14 2X/3X/4X
Packit Service 3470d1
15 1x/2X/3X/4X
Packit Service 3470d1
0 "no change"
Packit Service 3470d1
}
Packit Service 3470d1
Packit Service 3470d1
array set sw_config_nodedesc {
Packit Service 3470d1
0 "not being set"
Packit Service 3470d1
1 "being set as per opaswitches file"
Packit Service 3470d1
}
Packit Service 3470d1
Packit Service 3470d1
array set sw_config_fmenabled {
Packit Service 3470d1
0 "disabled"
Packit Service 3470d1
1 "enabled"
Packit Service 3470d1
-1 "no change"
Packit Service 3470d1
}
Packit Service 3470d1
Packit Service 3470d1
array set sw_config_linkcrcmode {
Packit Service 3470d1
0 "16b"
Packit Service 3470d1
1 "14b/16b"
Packit Service 3470d1
2 "48b/16b"
Packit Service 3470d1
3 "48b/14b/16b"
Packit Service 3470d1
4 "per lane/16b"
Packit Service 3470d1
5 "per lane/14b/16b"
Packit Service 3470d1
6 "per lane/48b/16b"
Packit Service 3470d1
7 "per lane/48b/14b/16b"
Packit Service 3470d1
-1 "no change"
Packit Service 3470d1
}
Packit Service 3470d1
Packit Service 3470d1
proc sw_get_array_entry { arrayname key } {
Packit Service 3470d1
Packit Service 3470d1
variable $arrayname
Packit Service 3470d1
Packit Service 3470d1
upvar #0 $arrayname myarray
Packit Service 3470d1
Packit Service 3470d1
if {![info exists myarray($key)]} {
Packit Service 3470d1
	return "Invalid Input: $key"
Packit Service 3470d1
} else {
Packit Service 3470d1
	return $myarray($key)
Packit Service 3470d1
}
Packit Service 3470d1
Packit Service 3470d1
}
Packit Service 3470d1
Packit Service 3470d1
test_suite "configure" "configure" "configure all switches:
Packit Service 3470d1
LINKWIDTH: [sw_get_array_entry sw_config_linkwidths $env(LINKWIDTH_SETTING)]
Packit Service 3470d1
NODEDESC:  [sw_get_array_entry sw_config_nodedesc $env(NODEDESC_SETTING)]
Packit Service 3470d1
FMENABLED: [sw_get_array_entry sw_config_fmenabled $env(FMENABLED_SETTING)]
Packit Service 3470d1
LINKCRCMODE:	[sw_get_array_entry sw_config_linkcrcmode $env(LINKCRCMODE_SETTING)]
Packit Service 3470d1
Packit Service 3470d1
File: /usr/lib/opa/tools/switch_configure.exp" suite_setup noop {
Packit Service 3470d1
	global opaswitch
Packit Service 3470d1
Packit Service 3470d1
	# Global Initializations for Test Suite:
Packit Service 3470d1
	# --------------------------------------
Packit Service 3470d1
Packit Service 3470d1
	# ADD ANY GLOBAL INITIALIZATION HERE, SUCH AS:
Packit Service 3470d1
	# set env(MY_ENV_VAR) value
Packit Service 3470d1
	# also validate the environment
Packit Service 3470d1
	# if the environment is bad call fail_suite "information" abort_now
Packit Service 3470d1
	# abort_now should be 0 if it is safe to proceed and simply ignore all
Packit Service 3470d1
	# test_case calls.  it should be 1 if that is not possible.
Packit Service 3470d1
Packit Service 3470d1
	# Procedures used to support Test Suite:
Packit Service 3470d1
	# --------------------------------------
Packit Service 3470d1
Packit Service 3470d1
	# The actual test cases:
Packit Service 3470d1
	# ----------------------
Packit Service 3470d1
Packit Service 3470d1
	parallel opaswitch $env(CFG_OPASWITCHES) {
Packit Service 3470d1
		set opaswitch [ trim_opaswitch_distance "$opaswitch"]
Packit Service 3470d1
		local_sh
Packit Service 3470d1
		test_case_ext_mgmt_sw_config $opaswitch
Packit Service 3470d1
	}
Packit Service 3470d1
}