Blame TestTools/network.exp

Packit 857059
# BEGIN_ICS_COPYRIGHT8 ****************************************
Packit 857059
# 
Packit 857059
# Copyright (c) 2015, 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
# This is an expect (tcl) library of procedures to aid network testing
Packit 857059
# These functions provide support for pre-built test cases which can be
Packit 857059
# provided arguments to indicate the network to be tested
Packit 857059
Packit 857059
## tcl procedures to support testing:
Packit 857059
## =============================================
Packit 857059
Packit 857059
proc test_case_ping1 { host desthosts ulp suffix mtu { punchlist 0 } } {
Packit 857059
##
Packit 857059
## test_case_ping1
Packit 857059
## -------------------
Packit 857059
## execute a test case to perform basic 1 packet pings
Packit 857059
## from host to each of desthosts
Packit 857059
##
Packit 857059
## Usage:
Packit 857059
##	test_cases_ping1 host desthosts ulp suffix mtu [punchlist]
Packit 857059
## Arguments:
Packit 857059
##	host - host to initiate ping from
Packit 857059
##	desthosts - list of hosts to send to
Packit 857059
##	ulp - protocol being used
Packit 857059
##	suffix - hostname suffix for network ($env(CFG_IPOIB_SUFFIX),
Packit 857059
##			or $env(CFG_INIC_SUFFIX) or "")
Packit 857059
##			Only used for integration tests, when used by FastFabric, set to ""
Packit 857059
##	mtu - MTU for network
Packit 857059
##  punchlist - should punchlist be updated on failure (default=0=no)
Packit 857059
## Returns:
Packit 857059
##	nothing
Packit 857059
## Additional Information:
Packit 857059
##	must be used within a test_suite's body, performs test_case calls
Packit 857059
##	uses case_setup and case_cleanup provided by caller
Packit 857059
##	no item_setup nor item_cleanup used
Packit 857059
Packit 857059
	global env
Packit 857059
Packit 857059
	#Substract 28 from the mtu, 20 Byte IP header and 8 Byte ICMP header
Packit 857059
	# because we dont want to fragment icmp packet.See PR 111259
Packit 857059
	set ping_size [ expr $mtu - 28 ]
Packit 857059
Packit 857059
	test_case "$host\_ping1" "simple ping from $host" "perform simple 1 packet $ping_size byte pings from $host using $ulp
Packit 857059
to $desthosts
Packit 857059
File: TestTools/network.exp" case_setup case_cleanup {
Packit 857059
		upvar host host
Packit 857059
		upvar ulp ulp
Packit 857059
		upvar suffix suffix
Packit 857059
		upvar ping_size ping_size
Packit 857059
		upvar desthosts desthosts
Packit 857059
		upvar punchlist punchlist
Packit 857059
Packit 857059
		target_root_sh $host
Packit 857059
		set target_os_type [target_get_os_type]
Packit 857059
Packit 857059
		foreach desthost $desthosts {
Packit 857059
			# allow ping of self
Packit 857059
		  if { [ catch { set res [
Packit 857059
			test_item "$desthost" "$host to $desthost" "simple ping from $host to $desthost" noop noop {
Packit 857059
				set netdest "[ host_basename $desthost ]$suffix"
Packit 857059
				send_unix_cmd "/usr/lib/opa/tools/opagetipaddrtype $netdest"
Packit 857059
				set out [expect_any 60 {"ipv6" "ipv4" } {"Error:" "Usage:"}]
Packit 857059
				regexp {([ip]+)([A-Za-z0-9]+)} $out iptype
Packit 857059
				if { $iptype == "ipv4" } {
Packit 857059
					set PING "ping"
Packit 857059
				} else {
Packit 857059
					set PING "ping6"
Packit 857059
				}
Packit 857059
Packit 857059
				send_unix_cmd "$PING -W 5 -c 1 -s $ping_size $netdest"
Packit 857059
Packit 857059
				# AS2.1 ping has slightly different output than 7.3 ping
Packit 857059
				expect_any 60 { "1 packets transmitted" "1 transmitted" } { "unknown" "refused" "error" "timeout" " 0 packets received" " 0 received" "nreachable" "duplicates" }
Packit 857059
				expect_any 60 { " 1 received" " 1 packets received" } { "unknown" "refused" "error" "timeout" " 0 packets received" " 0 received" "nreachable" "duplicates" }
Packit 857059
				expect_any 60 { " 0% loss" "0% packet loss" } { "unknown" "refused" "error" "timeout" " 0 packets received" " 0 received" "nreachable" "duplicates" }
Packit 857059
				expect_any 60 { "time " "round-trip" } { "unknown" "refused" "error" "timeout" " 0 packets received" " 0 received" "nreachable" "duplicates" }
Packit 857059
Packit 857059
				check_exit_status 60 0
Packit 857059
			} ] } err_str2 ] != 0  || $res != 0 } {
Packit 857059
				if { $punchlist } {
Packit 857059
					append_punchlist "$desthost" "unable to ping via $ulp"
Packit 857059
				}
Packit 857059
			}
Packit 857059
		}
Packit 857059
Packit 857059
		target_root_sh_exit
Packit 857059
	}
Packit 857059
}