* [dts] [next][PATCH V1 1/5] framework: modify dts framework to support python3
2020-01-12 22:18 [dts] [next][PATCH V1 0/5] dts: modify dts to support python3 xinfengx
@ 2020-01-12 22:18 ` xinfengx
2020-01-12 22:18 ` [dts] [next][PATCH V1 2/5] tests: modify test suites " xinfengx
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: xinfengx @ 2020-01-12 22:18 UTC (permalink / raw)
To: dts; +Cc: xinfengx
Signed-off-by: xinfengx <xinfengx.zhao@intel.com>
---
framework/checkCase.py | 40 +++++-----
framework/config.py | 48 +++++------
framework/crb.py | 10 +--
framework/debugger.py | 10 +--
framework/dts.py | 8 +-
framework/dut.py | 26 +++---
framework/etgen.py | 6 +-
framework/json_reporter.py | 2 +-
framework/logger.py | 11 ++-
framework/main.py | 8 +-
framework/multiple_vm.py | 3 +-
framework/packet.py | 61 +++++++-------
framework/pktgen.py | 14 ++--
framework/pktgen_base.py | 14 ++--
framework/pktgen_ixia.py | 36 ++++-----
framework/pktgen_trex.py | 34 ++++----
framework/plotgraph.py | 22 ++---
framework/plotting.py | 8 +-
framework/pmd_output.py | 4 +-
framework/qemu_kvm.py | 160 ++++++++++++++++++-------------------
framework/qemu_libvirt.py | 38 ++++-----
framework/rst.py | 6 +-
framework/serializer.py | 2 -
framework/settings.py | 16 ++--
framework/ssh_pexpect.py | 10 +--
framework/test_case.py | 18 ++---
framework/tester.py | 28 +++----
framework/texttable.py | 16 ++--
framework/utils.py | 10 +--
framework/virt_base.py | 40 +++++-----
framework/virt_common.py | 2 +-
framework/virt_dut.py | 12 +--
framework/virt_resource.py | 89 ++++++++++-----------
framework/virt_scene.py | 119 ++++++++++++++-------------
34 files changed, 461 insertions(+), 470 deletions(-)
diff --git a/framework/checkCase.py b/framework/checkCase.py
index 62f2643..3c1db99 100644
--- a/framework/checkCase.py
+++ b/framework/checkCase.py
@@ -26,12 +26,12 @@ class CheckCase(object):
try:
self.check_function_dict = json.load(open(filter_json_file), object_pairs_hook=collections.OrderedDict)
except:
- print RED("Can't load check list for test cases, all case will be taken as supported")
+ print(RED("Can't load check list for test cases, all case will be taken as supported"))
try:
self.support_function_dict = json.load(open(support_json_file), object_pairs_hook=collections.OrderedDict)
except:
- print RED("Can't load support list for test cases, all case will be taken as supported")
+ print(RED("Can't load support list for test cases, all case will be taken as supported"))
def check_dut(self, dut):
"""
@@ -83,16 +83,16 @@ class CheckCase(object):
self.comments = ""
if self.dut is None:
- print RED("No Dut assigned before case skip check")
+ print(RED("No Dut assigned before case skip check"))
return skip_flag
- if case_name in self.check_function_dict.keys():
+ if case_name in list(self.check_function_dict.keys()):
case_checks = self.check_function_dict[case_name]
# each case may have several checks
for case_check in case_checks:
# init result for each check
skip_flag = False
- for key in case_check.keys():
+ for key in list(case_check.keys()):
# some items like "Bug ID" and "Comments" do not need check
try:
if 'Comments' == key:
@@ -101,7 +101,7 @@ class CheckCase(object):
continue
check_function = getattr(self, '_check_%s' % key.lower())
except:
- print RED("can't check %s type" % key)
+ print(RED("can't check %s type" % key))
# skip this check if any item not matched
if check_function(case_check[key]):
@@ -112,7 +112,7 @@ class CheckCase(object):
# if all items matched, this case should skip
if skip_flag:
- if 'Comments' in case_check.keys():
+ if 'Comments' in list(case_check.keys()):
self.comments = case_check['Comments']
return skip_flag
@@ -127,16 +127,16 @@ class CheckCase(object):
self.comments = ""
if self.dut is None:
- print RED("No Dut assigned before case support check")
+ print(RED("No Dut assigned before case support check"))
return support_flag
- if case_name in self.support_function_dict.keys():
+ if case_name in list(self.support_function_dict.keys()):
# each case may have several supports
case_supports = self.support_function_dict[case_name]
for case_support in case_supports:
# init result for each check
support_flag = True
- for key in case_support.keys():
+ for key in list(case_support.keys()):
# some items like "Bug ID" and "Comments" do not need check
try:
if 'Comments' == key:
@@ -145,7 +145,7 @@ class CheckCase(object):
continue
check_function = getattr(self, '_check_%s' % key.lower())
except:
- print RED("can't check %s type" % key)
+ print(RED("can't check %s type" % key))
# skip this case if any item not matched
if check_function(case_support[key]):
@@ -155,7 +155,7 @@ class CheckCase(object):
break
if support_flag is False:
- if 'Comments' in case_support.keys():
+ if 'Comments' in list(case_support.keys()):
self.comments = case_support['Comments']
return support_flag
@@ -184,14 +184,14 @@ if __name__ == "__main__":
# check dut
case_inst.check_dut(dut)
- print case_inst.case_skip("fdir_flexword_drop_ipv4")
- print case_inst.comments
- print case_inst.case_support("Vxlan_tunnel")
- print case_inst.comments
+ print(case_inst.case_skip("fdir_flexword_drop_ipv4"))
+ print(case_inst.comments)
+ print(case_inst.case_support("Vxlan_tunnel"))
+ print(case_inst.comments)
# check other dut
case_inst.check_dut(dut1)
- print case_inst.case_skip("fdir_flexword_drop_ipv4")
- print case_inst.comments
- print case_inst.case_support("Vxlan_tunnel")
- print case_inst.comments
+ print(case_inst.case_skip("fdir_flexword_drop_ipv4"))
+ print(case_inst.comments)
+ print(case_inst.case_support("Vxlan_tunnel"))
+ print(case_inst.comments)
diff --git a/framework/config.py b/framework/config.py
index 4b6c2ba..4dc3f31 100644
--- a/framework/config.py
+++ b/framework/config.py
@@ -34,7 +34,7 @@ Generic port and crbs configuration file load function
"""
import os
import re
-import ConfigParser # config parse module
+import configparser # config parse module
import argparse # parse arguments module
from settings import (IXIA, PKTGEN, PKTGEN_DPDK, PKTGEN_TREX, PKTGEN_IXIA,
CONFIG_ROOT_PATH, SUITE_SECTION_NAME)
@@ -53,7 +53,7 @@ GLOBALCONF = "%s/global_suite.cfg" % CONFIG_ROOT_PATH
class UserConf():
def __init__(self, config):
- self.conf = ConfigParser.SafeConfigParser()
+ self.conf = configparser.SafeConfigParser()
load_files = self.conf.read(config)
if load_files == []:
self.conf = None
@@ -107,7 +107,7 @@ class GlobalConf(UserConf):
try:
section_confs = self.global_conf.load_section(section_name)
except:
- print "FAILED FIND SECTION[%s] CONFIG!!!" % section_name
+ print("FAILED FIND SECTION[%s] CONFIG!!!" % section_name)
return global_cfg
if section_confs is None:
@@ -138,14 +138,14 @@ class SuiteConf(UserConf):
try:
case_confs = self.suite_conf.load_section(case_name)
except:
- print "FAILED FIND CASE[%s] CONFIG!!!" % case_name
+ print("FAILED FIND CASE[%s] CONFIG!!!" % case_name)
return case_cfg
if case_confs is None:
return case_cfg
conf = dict(case_confs)
- for key, data_string in conf.items():
+ for key, data_string in list(conf.items()):
case_cfg[key] = eval(data_string)
return case_cfg
@@ -179,7 +179,7 @@ class VirtConf(UserConf):
try:
virt_confs = self.virt_conf.load_section(name)
except:
- print "FAILED FIND SECTION %s!!!" % name
+ print("FAILED FIND SECTION %s!!!" % name)
return
for virt_conf in virt_confs:
@@ -228,7 +228,7 @@ class PortConf(UserConf):
# port config for vm in virtualization scenario
if 'dev_idx' in port_param:
- keys = port_param.keys()
+ keys = list(port_param.keys())
keys.remove('dev_idx')
self.ports_cfg[port_param['dev_idx']] = {
key: port_param[key] for key in keys}
@@ -236,14 +236,14 @@ class PortConf(UserConf):
# check pci BDF validity
if 'pci' not in port_param:
- print "NOT FOUND CONFIG FOR NO PCI ADDRESS!!!"
+ print("NOT FOUND CONFIG FOR NO PCI ADDRESS!!!")
continue
m = re.match(self.pci_regex, port_param['pci'])
if m is None:
- print "INVALID CONFIG FOR NO PCI ADDRESS!!!"
+ print("INVALID CONFIG FOR NO PCI ADDRESS!!!")
continue
- keys = port_param.keys()
+ keys = list(port_param.keys())
keys.remove('pci')
self.ports_cfg[port_param['pci']] = {
key: port_param[key] for key in keys}
@@ -255,7 +255,7 @@ class PortConf(UserConf):
return self.ports_cfg
def check_port_available(self, pci_addr):
- if pci_addr in self.ports_cfg.keys():
+ if pci_addr in list(self.ports_cfg.keys()):
return True
else:
return False
@@ -377,13 +377,13 @@ class IxiaConf(UserConf):
ixia_group['enable_rsfec'] = value
if 'Version' not in ixia_group:
- print 'ixia configuration file request ixia_version option!!!'
+ print('ixia configuration file request ixia_version option!!!')
continue
if 'IP' not in ixia_group:
- print 'ixia configuration file request ixia_ip option!!!'
+ print('ixia configuration file request ixia_ip option!!!')
continue
if 'Ports' not in ixia_group:
- print 'ixia configuration file request ixia_ports option!!!'
+ print('ixia configuration file request ixia_ports option!!!')
continue
self.ixia_cfg[group] = ixia_group
@@ -430,13 +430,13 @@ class PktgenConf(UserConf):
ixia_group['enable_rsfec'] = value
if 'Version' not in ixia_group:
- print 'ixia configuration file request ixia_version option!!!'
+ print('ixia configuration file request ixia_version option!!!')
return
if 'IP' not in ixia_group:
- print 'ixia configuration file request ixia_ip option!!!'
+ print('ixia configuration file request ixia_ip option!!!')
return
if 'Ports' not in ixia_group:
- print 'ixia configuration file request ixia_ports option!!!'
+ print('ixia configuration file request ixia_ports option!!!')
return
self.pktgen_cfg[section.lower()] = ixia_group
@@ -485,7 +485,7 @@ if __name__ == '__main__':
try:
VirtConf('/tmp/not-existed.cfg')
except VirtConfigParseException:
- print "Capture config parse failure"
+ print("Capture config parse failure")
# example for basic use configuration file
conf = UserConf(PORTCONF)
@@ -499,23 +499,23 @@ if __name__ == '__main__':
# example for port configuration file
portconf = PortConf(PORTCONF)
portconf.load_ports_config('DUT IP')
- print portconf.get_ports_config()
+ print(portconf.get_ports_config())
portconf.check_port_available('86:00.0')
# example for global virtualization configuration file
virtconf = VirtConf(VIRTCONF)
virtconf.load_virt_config('LIBVIRT')
- print virtconf.get_virt_config()
+ print(virtconf.get_virt_config())
# example for crbs configuration file
crbsconf = CrbsConf(CRBCONF)
- print crbsconf.load_crbs_config()
+ print(crbsconf.load_crbs_config())
# example for ixia configuration file
ixiaconf = IxiaConf(IXIACONF)
- print ixiaconf.load_ixia_config()
+ print(ixiaconf.load_ixia_config())
# example for suite configure file
suiteconf = SuiteConf("suite_sample")
- print suiteconf.load_case_config("case1")
- print suiteconf.load_case_config("case2")
+ print(suiteconf.load_case_config("case1"))
+ print(suiteconf.load_case_config("case2"))
diff --git a/framework/crb.py b/framework/crb.py
index c1f2a1c..2d81550 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -292,14 +292,14 @@ class Crb(object):
if configed_pcis:
if 'tester' in str(self):
tester_pci_in_cfg = []
- for item in configed_pcis.values():
+ for item in list(configed_pcis.values()):
for pci_info in match:
if item['peer'] == pci_info[0]:
tester_pci_in_cfg.append(pci_info)
match = tester_pci_in_cfg[:]
else:
dut_pci_in_cfg = []
- for key in configed_pcis.keys():
+ for key in list(configed_pcis.keys()):
for pci_info in match:
if key == pci_info[0]:
dut_pci_in_cfg.append(pci_info)
@@ -621,7 +621,7 @@ class Crb(object):
for line in cpuinfo:
(thread, core, socket, node) = line.split(',')[0:4]
- if core not in coremap.keys():
+ if core not in list(coremap.keys()):
coremap[core] = core_id
core_id += 1
@@ -691,7 +691,7 @@ class Crb(object):
self.reserved_cores = self.remove_reserved_cores(partial_cores, rsv_list)
# return thread list
- return map(str, thread_list)
+ return list(map(str, thread_list))
def get_core_list(self, config, socket=-1, from_last = False):
"""
@@ -798,7 +798,7 @@ class Crb(object):
temp.extend(thread_list)
thread_list = temp
i += 1
- return map(str, thread_list)
+ return list(map(str, thread_list))
def get_lcore_id(self, config, inverse = False):
"""
diff --git a/framework/debugger.py b/framework/debugger.py
index 937975c..3795f89 100644
--- a/framework/debugger.py
+++ b/framework/debugger.py
@@ -61,7 +61,7 @@ def list_command():
index = 0
from ssh_connection import CONNECTIONS
for connection in CONNECTIONS:
- for name, session in connection.items():
+ for name, session in list(connection.items()):
console.push('print \'connect %d: %10s\'' % (index, name))
index += 1
@@ -72,14 +72,14 @@ def connect_command(connect):
"""
from ssh_connection import CONNECTIONS
if type(connect) == int:
- name, session = CONNECTIONS[connect].items()[0]
- print GREEN("Connecting to session[%s]" % name)
+ name, session = list(CONNECTIONS[connect].items())[0]
+ print(GREEN("Connecting to session[%s]" % name))
session.session.interact()
else:
for connection in CONNECTIONS:
- for name, session in connection.items():
+ for name, session in list(connection.items()):
if name == connect:
- print GREEN("Connecting to session[%s]" % name)
+ print(GREEN("Connecting to session[%s]" % name))
session.session.interact()
diff --git a/framework/dts.py b/framework/dts.py
index 634a569..63d9464 100644
--- a/framework/dts.py
+++ b/framework/dts.py
@@ -30,7 +30,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import re # regular expressions module
-import ConfigParser # config parse module
+import configparser # config parse module
import os # operation system module
import texttable # text format
import traceback # exception traceback
@@ -60,8 +60,8 @@ from config import CrbsConf
from checkCase import CheckCase
from utils import get_subclasses, copy_instance_attr, create_parallel_locks
import sys
-reload(sys)
-sys.setdefaultencoding('UTF8')
+import imp
+imp.reload(sys)
requested_tests = None
result = None
@@ -515,7 +515,7 @@ def run_all(config_file, pkgName, git, patch, skip_setup,
if dts_cfg_folder != '':
config_file = dts_cfg_folder + os.sep + config_file
- config = ConfigParser.SafeConfigParser()
+ config = configparser.SafeConfigParser()
load_cfg = config.read(config_file)
if len(load_cfg) == 0:
raise ConfigParseException(config_file)
diff --git a/framework/dut.py b/framework/dut.py
index 5409b93..7dea215 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -119,7 +119,7 @@ class Dut(Crb):
os_type = self.get_os_type()
if config:
# deal with cores
- if config.has_key('cores'):
+ if 'cores' in config:
if type(config['cores']) == list:
core_list = config['cores']
elif isinstance(config['cores'], str):
@@ -132,16 +132,16 @@ class Dut(Crb):
# deal with ports
w_pci_list = []
- if config.has_key('ports') and len(config['ports']) != 0:
+ if 'ports' in config and len(config['ports']) != 0:
for port in config['ports']:
if type(port) == int:
- if config.has_key('port_options') and port in config['port_options'].keys():
+ if 'port_options' in config and port in list(config['port_options'].keys()):
port_option = config['port_options'][port]
w_pci_list.append('-w %s,%s' % (self.ports_info[port]['pci'], port_option))
else:
w_pci_list.append('-w %s' % self.ports_info[port]['pci'])
else:
- if config.has_key('port_options') and port in config['port_options'].keys():
+ if 'port_options' in config and port in list(config['port_options'].keys()):
port_option = config['port_options'][port]
w_pci_list.append('-w %s,%s' % (port, port_option))
else:
@@ -150,7 +150,7 @@ class Dut(Crb):
# deal with black ports
b_pci_list = []
- if config.has_key('b_ports') and len(config['b_ports']) != 0:
+ if 'b_ports' in config and len(config['b_ports']) != 0:
for port in config['b_ports']:
if type(port) == int:
b_pci_list.append('-b %s' % self.ports_info[port]['pci'])
@@ -159,7 +159,7 @@ class Dut(Crb):
b_ports_str = ' '.join(b_pci_list)
# deal with no-pci
- if config.has_key('no_pci'):
+ if 'no_pci' in config:
if config['no_pci'] == True:
no_pci = '--no-pci'
else:
@@ -168,7 +168,7 @@ class Dut(Crb):
no_pci = ''
# deal with file prefix
- if config.has_key('prefix') and config['prefix'] != '':
+ if 'prefix' in config and config['prefix'] != '':
if fixed_prefix == True:
file_prefix = config['prefix']
else:
@@ -178,7 +178,7 @@ class Dut(Crb):
self.prefix_list.append(file_prefix)
# deal with vdev
- if config.has_key('vdevs') and len(config['vdevs']) != 0:
+ if 'vdevs' in config and len(config['vdevs']) != 0:
vdev = '--vdev ' + ' --vdev '.join(config['vdevs'])
else:
vdev = ''
@@ -190,7 +190,7 @@ class Dut(Crb):
+ blank + b_ports_str \
+ blank + no_pci \
+ blank + vdev
- self.prefix_list = []
+ self.prefix_list = []
else:
eal_str = '-l ' + ','.join(map(str, core_list)) \
+ blank + '-n %d' % self.get_memory_channels() \
@@ -215,7 +215,7 @@ class Dut(Crb):
eal_str = '-l ' + ','.join(map(str, core_list)) \
+ blank + '-n %d' % self.get_memory_channels() \
+ blank + pci_str
- self.prefix_list = []
+ self.prefix_list = []
else:
eal_str = '-l ' + ','.join(map(str, core_list)) \
+ blank + '-n %d' % self.get_memory_channels() \
@@ -786,7 +786,7 @@ class Dut(Crb):
elif self.nic_type == 'cfg':
if self.conf.check_port_available(pci_bus) is True:
return True
- elif self.nic_type not in NICS.keys():
+ elif self.nic_type not in list(NICS.keys()):
self.logger.warning("NOT SUPPORTED NIC TYPE: %s" % self.nic_type)
else:
codename = NICS[self.nic_type]
@@ -871,7 +871,7 @@ class Dut(Crb):
cached_ports_info = []
for port in self.ports_info:
port_info = {}
- for key in port.keys():
+ for key in list(port.keys()):
if type(port[key]) is str:
port_info[key] = port[key]
cached_ports_info.append(port_info)
@@ -1170,7 +1170,7 @@ class Dut(Crb):
# skip ping those not connected port
ipv6 = self.get_ipv6_address(dutPort)
if ipv6 == "Not connected":
- if self.tester.ports_info[remotePort].has_key('ipv4'):
+ if 'ipv4' in self.tester.ports_info[remotePort]:
out = self.tester.send_ping(
dutPort, self.tester.ports_info[remotePort]['ipv4'],
self.get_mac_address(dutPort))
diff --git a/framework/etgen.py b/framework/etgen.py
index a47d8cd..5fa1a66 100644
--- a/framework/etgen.py
+++ b/framework/etgen.py
@@ -72,8 +72,8 @@ class SoftwarePacketGenerator():
# assign core for ports
map_cmd = ""
- port_index = range(len(ports))
- port_map = dict(zip(ports, port_index))
+ port_index = list(range(len(ports)))
+ port_map = dict(list(zip(ports, port_index)))
self.tester.init_reserved_core()
# reserve one core for master process
@@ -190,7 +190,7 @@ class IxiaPacketGenerator(SSHConnection):
self.ixiaVersion = ixiaPorts[ixiaRef]["Version"]
self.ports = ixiaPorts[ixiaRef]["Ports"]
- if ixiaPorts[ixiaRef].has_key('force100g'):
+ if 'force100g' in ixiaPorts[ixiaRef]:
self.enable100g = ixiaPorts[ixiaRef]['force100g']
else:
self.enable100g = 'disable'
diff --git a/framework/json_reporter.py b/framework/json_reporter.py
index 80b6b7e..1b15bbe 100644
--- a/framework/json_reporter.py
+++ b/framework/json_reporter.py
@@ -73,4 +73,4 @@ class JSONReporter(object):
for dut in result.all_duts():
result_map[dut] = self.__scan_dut(result, dut)
with open(self.filename, 'w') as outfile:
- json.dump(result_map, outfile, indent=4, separators=(',', ': '), encoding="utf-8", sort_keys=True)
+ json.dump(result_map, outfile, indent=4, separators=(',', ': '), sort_keys=True)
diff --git a/framework/logger.py b/framework/logger.py
index 32dd954..4600c5f 100644
--- a/framework/logger.py
+++ b/framework/logger.py
@@ -200,7 +200,6 @@ class DTSLOG(BaseLoggerAdapter):
def __init__(self, logger, crb="suite"):
global log_dir
filename = inspect.stack()[1][1][:-3]
- self.name = filename.split('/')[-1]
self.error_lvl = logging.ERROR
self.warn_lvl = logging.WARNING
@@ -406,7 +405,7 @@ class LogParser(object):
try:
self.log_handler = open(self.log_path, 'r')
except:
- print RED("Failed to logfile %s" % log_path)
+ print(RED("Failed to logfile %s" % log_path))
return None
self.suite_pattern = re.compile(_TESTSUITE_NAME_FORMAT_PATTERN)
@@ -421,7 +420,7 @@ class LogParser(object):
begin = 0
end = len(self.loglist)
for line in self.loglist:
- m = self.suite_pattern.match(line.values()[0])
+ m = self.suite_pattern.match(list(line.values())[0])
if m:
if suite_name is None:
begin = self.loglist.index(line)
@@ -429,7 +428,7 @@ class LogParser(object):
begin = self.loglist.index(line)
for line in self.loglist[begin:]:
- m = self.end_pattern.match(line.values()[0])
+ m = self.end_pattern.match(list(line.values())[0])
if m:
if suite_name is None:
end = self.loglist.index(line)
@@ -443,7 +442,7 @@ class LogParser(object):
end = len(self.loglist)
for line in self.loglist:
# only handle case log
- m = self.case_pattern.match(line.values()[0])
+ m = self.case_pattern.match(list(line.values())[0])
if m:
# not determine case will start from beginning
if case_name is None:
@@ -453,7 +452,7 @@ class LogParser(object):
begin = self.loglist.index(line)
for line in self.loglist[begin:]:
- m = self.result_pattern.match(line.values()[0])
+ m = self.result_pattern.match(list(line.values())[0])
if m:
# not determine case will stop to the end
if case_name is None:
diff --git a/framework/main.py b/framework/main.py
index 0da946f..b5e5952 100755
--- a/framework/main.py
+++ b/framework/main.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
# BSD LICENSE
#
# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
@@ -57,12 +57,12 @@ def git_build_package(gitLabel, pkgName, depot="dep"):
if os.path.exists("%s/%s" % (depot, gitPrefix)) is True:
ret = os.system("cd %s/%s && git pull --force" % (depot, gitPrefix))
else:
- print "git clone %s %s/%s" % (gitURL, depot, gitPrefix)
+ print("git clone %s %s/%s" % (gitURL, depot, gitPrefix))
ret = os.system("git clone %s %s/%s" % (gitURL, depot, gitPrefix))
if ret is not 0:
raise EnvironmentError
- print "git archive --format=tar.gz --prefix=%s %s -o %s" % (gitPrefix, gitLabel, pkgName)
+ print("git archive --format=tar.gz --prefix=%s %s -o %s" % (gitPrefix, gitLabel, pkgName))
ret = os.system("cd %s/%s && git archive --format=tar.gz --prefix=%s/ %s -o ../%s"
% (depot, gitPrefix, gitPrefix, gitLabel, pkgName))
if ret is not 0:
@@ -158,7 +158,7 @@ if args.git is not None:
try:
git_build_package(args.git, os.path.split(args.snapshot)[1])
except Exception:
- print "FAILED TO PREPARE DPDK PACKAGE!!!"
+ print("FAILED TO PREPARE DPDK PACKAGE!!!")
sys.exit()
# Main program begins here
diff --git a/framework/multiple_vm.py b/framework/multiple_vm.py
index fdb5b3d..68d2f5e 100644
--- a/framework/multiple_vm.py
+++ b/framework/multiple_vm.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
import time
import re
import threadpool
@@ -151,7 +150,7 @@ class MultipleVM(object):
self.logger.debug("Parallel task start for DUT%d %s" % (dut_id, vm_name))
- combinations = zip(commands, expects, timeouts)
+ combinations = list(zip(commands, expects, timeouts))
for combine in combinations:
command, expect, timeout = combine
# timeout value need enlarge if vm number increased
diff --git a/framework/packet.py b/framework/packet.py
index 5e86d6d..9144731 100755
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# BSD LICENSE
#
# Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
@@ -391,11 +390,11 @@ class Packet(object):
self.pkt_opts = options
self.pkt_layers = []
- if 'pkt_gen' in self.pkt_opts.keys():
+ if 'pkt_gen' in list(self.pkt_opts.keys()):
if self.pkt_opts['pkt_gen'] == 'scapy':
self.pktgen = scapy()
else:
- print "Not support other pktgen yet!!!"
+ print("Not support other pktgen yet!!!")
else:
self.pktgen = scapy()
@@ -419,10 +418,10 @@ class Packet(object):
"""
self.pkt_len = 64
self.pkt_type = "UDP"
- if 'pkt_type' in options.keys():
+ if 'pkt_type' in list(options.keys()):
self.pkt_type = options['pkt_type']
- if self.pkt_type in self.def_packet.keys():
+ if self.pkt_type in list(self.def_packet.keys()):
self.pkt_layers = self.def_packet[self.pkt_type]['layers']
self.pkt_cfgload = self.def_packet[self.pkt_type]['cfgload']
if "IPv6" in self.pkt_type:
@@ -430,7 +429,7 @@ class Packet(object):
else:
self._load_pkt_layers()
- if 'pkt_len' in options.keys():
+ if 'pkt_len' in list(options.keys()):
self.pkt_len = options['pkt_len']
self._load_assign_layers()
@@ -449,7 +448,7 @@ class Packet(object):
if hasattr(self, 'configured_layer_raw') is False and self.pkt_cfgload is True:
payload = []
raw_confs = {}
- if 'ran_payload' in self.pkt_opts.keys():
+ if 'ran_payload' in list(self.pkt_opts.keys()):
for loop in range(payload_len):
payload.append("%02x" % random.randrange(0, 255))
else:
@@ -516,14 +515,14 @@ class Packet(object):
try:
self.update_pkt_str(i)
except:
- print("warning: packet %s update failed" % i)
+ print(("warning: packet %s update failed" % i))
elif isinstance(i, dict):
try:
self.update_pkt_dict(i)
except:
- print("warning: packet %s update failed" % i)
+ print(("warning: packet %s update failed" % i))
else:
- print("packet {} is not acceptable".format(i))
+ print(("packet {} is not acceptable".format(i)))
def generate_random_pkts(self, dstmac=None, pktnum=100, random_type=None, ip_increase=True, random_payload=False,
options=None):
@@ -562,7 +561,7 @@ class Packet(object):
self.config_layer('tcp', {'src': 65535, 'dst': 65535})
if "UDP" in self.pkt_type:
self.config_layer('udp', {'src': 65535, 'dst': 65535})
- if options.has_key('layers_config'):
+ if 'layers_config' in options:
self.config_layers(options['layers_config'])
if dstmac:
self.config_layer('ether', {'dst': '%s' % dstmac})
@@ -667,9 +666,9 @@ class Packet(object):
if send_bg: # if send_bg create a new session to execute send action
session_prefix = 'scapy_bg_session'
scapy_session = crb.create_session(session_prefix + time_stamp)
- scapy_session.send_command('python %s' % crb.tmp_file + scapy_cmd)
+ scapy_session.send_command('python3 %s' % crb.tmp_file + scapy_cmd)
else:
- crb.send_expect('python %s' % crb.tmp_file + scapy_cmd, '# ', timeout=timeout)
+ crb.send_expect('python3 %s' % crb.tmp_file + scapy_cmd, '# ', timeout=timeout)
return crb.tmp_file + scapy_cmd
def send_pkt(self, crb, tx_port='', count=1, interval=0, timeout=15):
@@ -688,13 +687,13 @@ class Packet(object):
try:
pids.append(re.search('\d+', out).group())
except AttributeError as e:
- print(e, ' :%s not killed' % file)
+ print((e, ' :%s not killed' % file))
else:
out = crb.send_expect('ps -ef |grep %s|grep -v grep' % filenames, expected='# ')
try:
pids.append(re.search('\d+', out).group())
except AttributeError as e:
- print(e, ' :%s not killed' % filenames)
+ print((e, ' :%s not killed' % filenames))
pid = ' '.join(pids)
if pid:
crb.send_expect('kill -9 %s' % pid, expected='# ')
@@ -711,14 +710,14 @@ class Packet(object):
found = False
l_type = layer.lower()
- for types in LayersTypes.values():
+ for types in list(LayersTypes.values()):
if l_type in types:
found = True
break
if found is False:
self.pkt_layers.remove(l_type)
- print "INVAILD LAYER TYPE [%s]" % l_type.upper()
+ print("INVAILD LAYER TYPE [%s]" % l_type.upper())
def assign_layers(self, layers=None):
"""
@@ -732,14 +731,14 @@ class Packet(object):
found = False
l_type = layer.lower()
- for types in LayersTypes.values():
+ for types in list(LayersTypes.values()):
if l_type in types:
found = True
break
if found is False:
self.pkt_layers.remove(l_type)
- print "INVAILD LAYER TYPE [%s]" % l_type.upper()
+ print("INVAILD LAYER TYPE [%s]" % l_type.upper())
self.pktgen.add_layers(self.pkt_layers)
if layers:
@@ -775,7 +774,7 @@ class Packet(object):
self.pkt_layers = []
self.pkt_cfgload = True
for layer in layers:
- if layer in name2type.keys():
+ if layer in list(name2type.keys()):
self.pkt_layers.append(name2type[layer])
def config_def_layers(self):
@@ -826,7 +825,7 @@ class Packet(object):
try:
idx = self.pkt_layers.index(layer)
except Exception as e:
- print "INVALID LAYER ID %s" % layer
+ print("INVALID LAYER ID %s" % layer)
return False
if self.check_layer_config() is False:
@@ -849,10 +848,10 @@ class Packet(object):
for layer in layers:
name, config = layer
if name not in self.pkt_layers:
- print "[%s] is missing in packet!!!" % name
+ print("[%s] is missing in packet!!!" % name)
raise
if self.config_layer(name, config) is False:
- print "[%s] failed to configure!!!" % name
+ print("[%s] failed to configure!!!" % name)
raise
def strip_layer_element(self, layer, element, p_index=0):
@@ -926,13 +925,13 @@ def get_filter_cmd(filters=[]):
for pktfilter in filters:
filter_cmd = ""
if pktfilter['layer'] == 'ether':
- if pktfilter['config'].keys()[0] == 'dst':
+ if list(pktfilter['config'].keys())[0] == 'dst':
dmac = pktfilter['config']['dst']
filter_cmd = "ether dst %s" % dmac
- elif pktfilter['config'].keys()[0] == 'src':
+ elif list(pktfilter['config'].keys())[0] == 'src':
smac = pktfilter['config']['src']
filter_cmd = "ether src %s" % smac
- elif pktfilter['config'].keys()[0] == 'type':
+ elif list(pktfilter['config'].keys())[0] == 'type':
eth_type = pktfilter['config']['type']
eth_format = r"(\w+) (\w+)"
m = re.match(eth_format, eth_type)
@@ -945,14 +944,14 @@ def get_filter_cmd(filters=[]):
elif m.group(1) == 'not':
filter_cmd = 'ether[12:2] != %s' % type_hex
elif pktfilter['layer'] == 'network':
- if pktfilter['config'].keys()[0] == 'srcport':
+ if list(pktfilter['config'].keys())[0] == 'srcport':
sport = pktfilter['config']['srcport']
filter_cmd = "src port %s" % sport
- elif pktfilter['config'].keys()[0] == 'dstport':
+ elif list(pktfilter['config'].keys())[0] == 'dstport':
dport = pktfilter['config']['dstport']
filter_cmd = "dst port %s" % dport
elif pktfilter['layer'] == 'userdefined':
- if pktfilter['config'].keys()[0] == 'pcap-filter':
+ if list(pktfilter['config'].keys())[0] == 'pcap-filter':
filter_cmd = pktfilter['config']['pcap-filter']
if len(filter_cmds):
@@ -998,7 +997,7 @@ def start_tcpdump(crb, intf, count=0, filters=None, lldp_forbid=True):
param = "-P" + " in"
if len(param) == 0:
- print "tcpdump not support direction choice!!!"
+ print("tcpdump not support direction choice!!!")
if lldp_forbid and (LLDP_FILTER not in filters):
filters.append(LLDP_FILTER)
@@ -1027,7 +1026,7 @@ def stop_and_load_tcpdump_packets(index='', timeout=1):
"""
Stop sniffer and return packet object
"""
- if index in SNIFF_PIDS.keys():
+ if index in list(SNIFF_PIDS.keys()):
pipe, intf, filename = SNIFF_PIDS.pop(index)
pipe.get_session_before(timeout)
pipe.send_command('^C')
diff --git a/framework/pktgen.py b/framework/pktgen.py
index 7f8223f..889e94a 100644
--- a/framework/pktgen.py
+++ b/framework/pktgen.py
@@ -119,12 +119,12 @@ class PacketGeneratorHelper(object):
fields_config = {}
# set ethernet protocol layer fields
layer_name = 'mac'
- if layer_name in suite_config.keys() and \
+ if layer_name in list(suite_config.keys()) and \
'Ethernet' in self.packetLayers:
fields_config[layer_name] = {}
suite_fields = suite_config.get(layer_name)
pcap_fields = self.packetLayers.get('Ethernet')
- for name, config in suite_fields.iteritems():
+ for name, config in suite_fields.items():
action = config.get('action') or 'default'
range = config.get('range') or 64
step = config.get('step') or 1
@@ -137,12 +137,12 @@ class PacketGeneratorHelper(object):
fields_config[layer_name][name]['action'] = action
# set ip protocol layer fields
layer_name = 'ip'
- if layer_name in suite_config.keys() and \
+ if layer_name in list(suite_config.keys()) and \
'IP' in self.packetLayers:
fields_config[layer_name] = {}
suite_fields = suite_config.get(layer_name)
pcap_fields = self.packetLayers.get('IP')
- for name, config in suite_fields.iteritems():
+ for name, config in suite_fields.items():
action = config.get('action') or 'default'
range = config.get('range') or 64
step = config.get('step') or 1
@@ -155,14 +155,14 @@ class PacketGeneratorHelper(object):
fields_config[layer_name][name]['action'] = action
# set vlan protocol layer fields, only support one layer vlan here
layer_name = 'vlan'
- if layer_name in suite_config.keys() and \
+ if layer_name in list(suite_config.keys()) and \
'802.1Q' in self.packetLayers:
fields_config[layer_name] = {}
suite_fields = suite_config.get(layer_name)
pcap_fields = self.packetLayers.get('802.1Q')
# only support one layer vlan here, so set name to `0`
name = 0
- if name in suite_fields.keys():
+ if name in list(suite_fields.keys()):
config = suite_fields[name]
action = config.get('action') or 'default'
range = config.get('range') or 64
@@ -207,7 +207,7 @@ def getPacketGenerator(tester, pktgen_type=PKTGEN_IXIA):
PKTGEN_IXIA: IxiaPacketGenerator,
PKTGEN_TREX: TrexPacketGenerator,}
- if pktgen_type in pktgen_cls.keys():
+ if pktgen_type in list(pktgen_cls.keys()):
CLS = pktgen_cls.get(pktgen_type)
return CLS(tester)
else:
diff --git a/framework/pktgen_base.py b/framework/pktgen_base.py
index 5e51b1a..7e1ff48 100644
--- a/framework/pktgen_base.py
+++ b/framework/pktgen_base.py
@@ -226,7 +226,7 @@ class PacketGenerator(object):
If set this key value, pktgen will return several throughput statistic
data within a duration traffic. If not set this key value, only
return one statistic data. It is ignored by default.
-
+
callback:
this key works with ``interval`` key. If it is set, the callback
of suite level will be executed after getting throughput statistic.
@@ -306,7 +306,7 @@ class PacketGenerator(object):
result = self._measure_loss(stream_ids, options)
# here only to make sure that return value is the same as dts/etgen format
# In real testing scenario, this method can offer more data than it
- return result.values()[0]
+ return list(result.values())[0]
def measure_latency(self, stream_ids=[], options={}):
"""
@@ -352,7 +352,7 @@ class PacketGenerator(object):
support multiple link peer, if any link peer loss rate happen set
return value to False
'''
- for port_id, _result in result.iteritems():
+ for port_id, _result in result.items():
loss_rate, _, _ = _result
if loss_rate > permit_loss_rate:
return False
@@ -393,7 +393,7 @@ class PacketGenerator(object):
# return data is the same with dts/etgen format
# In fact, multiple link peer have multiple loss rate value,
# here only pick one
- tx_num, rx_num = result.values()[0][1:]
+ tx_num, rx_num = list(result.values())[0][1:]
return rate_percent, tx_num, rx_num
_options = deepcopy(options)
# if warm up option 'delay' is set, ignore it in next work flow
@@ -421,7 +421,7 @@ class PacketGenerator(object):
# here only pick one
last_result = loss_rate_table[-1]
rate_percent = last_result[0]
- tx_num, rx_num = last_result[1].values()[0][1:]
+ tx_num, rx_num = list(last_result[1].values())[0][1:]
return rate_percent, tx_num, rx_num
def measure_rfc2544_with_pps(self, stream_ids=[], options={}):
@@ -460,7 +460,7 @@ class PacketGenerator(object):
# use last result as return data to keep the same with dts/etgen format
# In fact, multiple link peer have multiple loss rate value,
# here only pick one
- return loss_pps_table[-1][1].values()[0]
+ return list(loss_pps_table[-1][1].values())[0]
def measure_rfc2544_dichotomy(self, stream_ids=[], options={}):
""" check loss rate using dichotomy algorithm
@@ -611,4 +611,4 @@ class PacketGenerator(object):
pass
-class DpdkPacketGenerator(PacketGenerator): pass # not implemented
\ No newline at end of file
+class DpdkPacketGenerator(PacketGenerator): pass # not implemented
diff --git a/framework/pktgen_ixia.py b/framework/pktgen_ixia.py
index 14b5d5b..94432a2 100644
--- a/framework/pktgen_ixia.py
+++ b/framework/pktgen_ixia.py
@@ -73,7 +73,7 @@ class Ixia(SSHConnection):
self.ixiaVersion = ixiaPorts[ixiaRef]["Version"]
self.ports = ixiaPorts[ixiaRef]["Ports"]
- if ixiaPorts[ixiaRef].has_key('force100g'):
+ if 'force100g' in ixiaPorts[ixiaRef]:
self.enable100g = ixiaPorts[ixiaRef]['force100g']
else:
self.enable100g = 'disable'
@@ -194,7 +194,7 @@ class Ixia(SSHConnection):
'default': 'idle'}
cmds = []
- for name, config in fields.iteritems():
+ for name, config in fields.items():
default_config = default_fields.get(name)
mac_start = config.get('start') or default_config.get('start')
mac_end = config.get('end')
@@ -229,7 +229,7 @@ class Ixia(SSHConnection):
default_fields.pop(name)
# if some filed not set, set it here
if default_fields:
- for name, config in default_fields.iteritems():
+ for name, config in default_fields.items():
ip_start = config.get('start')
prefix = 'sa' if name == 'src' else 'da'
cmds.append('stream config -{0} "{1}"'.format(prefix, ip_start))
@@ -274,7 +274,7 @@ class Ixia(SSHConnection):
# set default
'default': 'ipIdle',}
cmds = []
- for name, config in fields.iteritems():
+ for name, config in fields.items():
default_config = default_fields.get(name)
fv_name = 'IP.{0}'.format(name)
ip_start = config.get('start') or default_config.get('start')
@@ -291,7 +291,7 @@ class Ixia(SSHConnection):
mask = config.get('mask')
_step = config.get('step')
- step = int(_step) if _step and isinstance(_step, (str, unicode)) else \
+ step = int(_step) if _step and isinstance(_step, str) else \
_step or 1
action = config.get('action')
# get ixia command prefix
@@ -318,7 +318,7 @@ class Ixia(SSHConnection):
if not default_fields:
return cmds
# if some filed not set, set it here
- for name, config in default_fields.iteritems():
+ for name, config in default_fields.items():
ip_start = config.get('start')
prefix = 'source' if name == 'src' else 'dest'
cmds.append('ip config -{0}IpAddr "{1}"'.format(prefix, ip_start))
@@ -426,7 +426,7 @@ class Ixia(SSHConnection):
# No change to VlanID tag regardless of repeat
'idle': 'vIdle',}
cmds = []
- for name, config in fields.iteritems():
+ for name, config in fields.items():
fv_name = '8021Q.{0}'.format(name)
vlan_start = config.get('start') or 0
vlan_end = config.get('end') or 256
@@ -533,7 +533,7 @@ class Ixia(SSHConnection):
frameType = txmode.get('frameType') or {}
time_unit = frameType.get('type', 'ns')
gapUnit = gapUnits.get(time_unit) \
- if time_unit in gapUnits.keys() else gapUnits.get('ns')
+ if time_unit in list(gapUnits.keys()) else gapUnits.get('ns')
# The inter-stream gap is the delay in clock ticks between stream.
# This delay comes after the receive trigger is enabled. Setting this
# option to 0 means no delay. (default = 960.0)
@@ -879,14 +879,14 @@ class Ixia(SSHConnection):
# calculate total streams of ports
for (txPort, rxPort, pcapFile, option) in portList:
- if txPort not in self.stream_total.keys():
+ if txPort not in list(self.stream_total.keys()):
self.stream_total[txPort] = 1
else:
self.stream_total[txPort] += 1
# stream/flow setting
for (txPort, rxPort, pcapFile, option) in portList:
- if txPort not in self.stream_index.keys():
+ if txPort not in list(self.stream_index.keys()):
self.stream_index[txPort] = 1
frame_index = self.stream_index[txPort]
self.config_stream(pcapFile, option, txPort,
@@ -1346,7 +1346,7 @@ class Ixia(SSHConnection):
'throughput': self.get_throughput_stat,
'loss': self.get_loss_stat,
'latency': self.get_latency_stat,}
- if mode not in methods.keys():
+ if mode not in list(methods.keys()):
msg = "not support mode <{0}>".format(mode)
raise Exception(msg)
# get custom mode stat
@@ -1441,7 +1441,7 @@ class IxiaPacketGenerator(PacketGenerator):
'''
check if a pci address is managed by the packet generator
'''
- for name, _port_obj in self._conn.ports.iteritems():
+ for name, _port_obj in self._conn.ports.items():
_pci = _port_obj.info['pci_addr']
self.logger.debug((_pci, pci))
if _pci == pci:
@@ -1464,14 +1464,14 @@ class IxiaPacketGenerator(PacketGenerator):
return None
conf = {}
#get the subnet range of src and dst ip
- if self.conf.has_key("ip_src"):
+ if "ip_src" in self.conf:
conf['src'] = {}
ip_src = self.conf['ip_src']
ip_src_range = ip_src.split('-')
conf['src']['start'] = ip_src_range[0]
conf['src']['end'] = ip_src_range[1]
- if self.conf.has_key("ip_dst"):
+ if "ip_dst" in self.conf:
conf['dst'] = {}
ip_dst = self.conf['ip_dst']
ip_dst_range = ip_dst.split('-')
@@ -1557,7 +1557,7 @@ class IxiaPacketGenerator(PacketGenerator):
''' convert ixia loss rate statistics format to dts PacketGenerator format '''
# tx packet
port_id = stream.get("tx_port")
- if port_id in stats.keys():
+ if port_id in list(stats.keys()):
port_stats = stats[port_id]
else:
msg = "port {0} statistics is not found".format(port_id)
@@ -1578,7 +1578,7 @@ class IxiaPacketGenerator(PacketGenerator):
def _latency_stats(self, stream, stats):
''' convert ixia latency statistics format to dts PacketGenerator format '''
port_id = stream.get("tx_port")
- if port_id in stats.keys():
+ if port_id in list(stats.keys()):
port_stats = stats[port_id]
else:
msg = "port {0} latency stats is not found".format(port_id)
@@ -1619,7 +1619,7 @@ class IxiaPacketGenerator(PacketGenerator):
self._rx_ports.append(rx_port)
# set all streams in one port to do batch configuration
options = stream['options']
- if tx_port not in port_config.keys():
+ if tx_port not in list(port_config.keys()):
port_config[tx_port] = []
config = {}
config.update(options)
@@ -1641,7 +1641,7 @@ class IxiaPacketGenerator(PacketGenerator):
raise Exception(msg)
#-------------------------------------------------------------------
port_lists = []
- for port_id, option in port_config.iteritems():
+ for port_id, option in port_config.items():
port_lists += option
self._conn.clear_tcl_buffer()
rxPortlist, txPortlist = self._conn.prepare_port_list(
diff --git a/framework/pktgen_trex.py b/framework/pktgen_trex.py
index 61c8c0c..202c778 100644
--- a/framework/pktgen_trex.py
+++ b/framework/pktgen_trex.py
@@ -81,7 +81,7 @@ class TrexConfigVm(object):
_ip_start = self.ipv4_str_to_num(self.is_valid_ipv4_ret(ip_start))
_ip_end = self.ipv4_str_to_num(self.is_valid_ipv4_ret(ip_end))
_step = self.ipv4_str_to_num(self.is_valid_ipv4_ret(step)) \
- if isinstance(step, (str, unicode)) else step
+ if isinstance(step, str) else step
if mode == 'inc' or mode == 'dec':
min_value = _ip_start
max_value = _ip_end
@@ -110,7 +110,7 @@ class TrexConfigVm(object):
###################################################################
# mac inc/dec/random
if 'mac' in option:
- for name, config in option['mac'].iteritems():
+ for name, config in option['mac'].items():
mac_start = config.get('start') or '00:00:00:00:00:00'
mac_end = config.get('end') or 'FF:FF:FF:FF:FF:FF'
step = config.get('step') or 1
@@ -124,7 +124,7 @@ class TrexConfigVm(object):
###################################################################
# src ip mask inc/dec/random
if 'ip' in option:
- for name, config in option['ip'].iteritems():
+ for name, config in option['ip'].items():
ip_start = config.get('start') or '0.0.0.1'
ip_end = config.get('end') or '0.0.0.255'
step = config.get('step') or 1
@@ -139,7 +139,7 @@ class TrexConfigVm(object):
###################################################################
# src ip mask inc/dec/random
if 'port' in option:
- for name, config in option['port'].iteritems():
+ for name, config in option['port'].items():
protocol = config.get('protocol') or 'UDP'
port_start = config.get('start') or 1
port_end = config.get('end') or 255
@@ -158,7 +158,7 @@ class TrexConfigVm(object):
###################################################################
# vlan field inc/dec/random
if 'vlan' in option:
- for name, config in option['vlan'].iteritems():
+ for name, config in option['vlan'].items():
vlan_start = config.get('start') \
if config.get('start') != None else 0
vlan_end = config.get('end') or 256
@@ -237,7 +237,7 @@ class TrexConfigStream(object):
'max_value': 255,
'size': 4,
'step': 1}
- for name, value in default.iteritems():
+ for name, value in default.items():
if name not in config:
config[name] = value
@@ -248,7 +248,7 @@ class TrexConfigStream(object):
msg = "layer <{0}> field name <{1}> is not defined".format
fv_names = []
fix_chksum = False
- for layer, _config in configs.iteritems():
+ for layer, _config in configs.items():
# set default value
if isinstance(_config, (tuple, list)):
config = _config[0]
@@ -479,7 +479,7 @@ class TrexPacketGenerator(PacketGenerator):
'''
get port pci address
'''
- for name, _port_obj in self._conn.ports.iteritems():
+ for name, _port_obj in self._conn.ports.items():
if name == port_id:
_pci = _port_obj.info['pci_addr']
return _pci
@@ -490,7 +490,7 @@ class TrexPacketGenerator(PacketGenerator):
'''
get port management id of the packet generator
'''
- for name, _port_obj in self._conn.ports.iteritems():
+ for name, _port_obj in self._conn.ports.items():
_pci = _port_obj.info['pci_addr']
if _pci == pci:
return name
@@ -501,7 +501,7 @@ class TrexPacketGenerator(PacketGenerator):
'''
check if a pci address is managed by the packet generator
'''
- for name, _port_obj in self._conn.ports.iteritems():
+ for name, _port_obj in self._conn.ports.items():
_pci = _port_obj.info['pci_addr']
self.logger.debug((_pci, pci))
if _pci == pci:
@@ -584,7 +584,7 @@ class TrexPacketGenerator(PacketGenerator):
def _prepare_generator(self):
''' start trex server '''
- if self.conf.has_key('start_trex') and self.conf['start_trex']:
+ if 'start_trex' in self.conf and self.conf['start_trex']:
app_param_temp = "-i"
# flow control
flow_control = self.conf.get('flow_control')
@@ -612,14 +612,14 @@ class TrexPacketGenerator(PacketGenerator):
return None # close it and wait for more discussion about pktgen framework
conf = {}
#get the subnet range of src and dst ip
- if self.conf.has_key("ip_src"):
+ if "ip_src" in self.conf:
conf['src'] = {}
ip_src = self.conf['ip_src']
ip_src_range = ip_src.split('-')
conf['src']['start'] = ip_src_range[0]
conf['src']['end'] = ip_src_range[1]
- if self.conf.has_key("ip_dst"):
+ if "ip_dst" in self.conf:
conf['dst'] = {}
ip_dst = self.conf['ip_dst']
ip_dst_range = ip_dst.split('-')
@@ -701,7 +701,7 @@ class TrexPacketGenerator(PacketGenerator):
def _loss_rate_stats(self, stream, stats):
# tx packet
port_id = stream.get("tx_port")
- if port_id in stats.keys():
+ if port_id in list(stats.keys()):
port_stats = stats[port_id]
else:
msg = "port {0} statistics is not found".format(port_id)
@@ -722,7 +722,7 @@ class TrexPacketGenerator(PacketGenerator):
def _latency_stats(self, stream, stats):
_stats = stats.get('latency')
port_id = stream.get("tx_port")
- if port_id in _stats.keys():
+ if port_id in list(_stats.keys()):
port_stats = _stats[port_id]['latency']
else:
msg = "port {0} latency stats is not found".format(port_id)
@@ -751,7 +751,7 @@ class TrexPacketGenerator(PacketGenerator):
self._rx_ports.append(rx_port)
# set all streams in one port to do batch configuration
options = stream['options']
- if tx_port not in port_config.keys():
+ if tx_port not in list(port_config.keys()):
port_config[tx_port] = []
config = {}
config.update(options)
@@ -777,7 +777,7 @@ class TrexPacketGenerator(PacketGenerator):
self._conn.reset(ports=self._ports)
config_inst = TrexConfigStream()
- for port_id, config in port_config.iteritems():
+ for port_id, config in port_config.items():
# add a group of streams in one port
config_inst.add_streams(self._conn, config, ports=[port_id],
latency=latency)
diff --git a/framework/plotgraph.py b/framework/plotgraph.py
index 07e849b..56fd2b7 100644
--- a/framework/plotgraph.py
+++ b/framework/plotgraph.py
@@ -309,10 +309,10 @@ class Plot2DGraph:
currGraph.graphType = graphType
if len(xData) != len(yData):
- print 'Error xData = ' + str(len(xData))
- print 'yData = ' + str(len(yData))
- print xData
- print yData
+ print('Error xData = ' + str(len(xData)))
+ print('yData = ' + str(len(yData)))
+ print(xData)
+ print(yData)
return
currGraph.xs = xData
@@ -358,13 +358,13 @@ class Plot2DGraph:
ax.set_ylabel(graph.yLabel)
if graph.xticks:
- ax.set_xticks(range(len(graph.xticks)))
+ ax.set_xticks(list(range(len(graph.xticks))))
ax.set_xticklabels(graph.xticks)
elif self.xticklabels:
ax.set_xticks(self.xticks)
ax.set_xticklabels(self.xticklabels)
if graph.yticks:
- ax.set_yticks(range(len(graph.yticks)))
+ ax.set_yticks(list(range(len(graph.yticks))))
ax.set_yticklabels(graph.yticks)
elif self.yticklabels:
ax.set_yticks(self.yticks)
@@ -392,7 +392,7 @@ class Plot2DGraph:
# deprecated
if graph.expectedXs:
- print 'DEPRECATED'
+ print('DEPRECATED')
return
if graph.graphType and graph.graphType == 'bar':
@@ -420,7 +420,7 @@ class Plot2DGraph:
newAx.spines['left'].set_facecolor('r')
newAx.spines['left'].set_edgecolor('r')
- newAx.set_yticks(range(len(oldAx.get_yticks())))
+ newAx.set_yticks(list(range(len(oldAx.get_yticks()))))
newAx.set_yticklabels(self.newYticks[0:len(oldAx.get_yticks())])
newAx.set_ylabel(self.newYLabel, color='b')
newAx.yaxis.set_visible(True)
@@ -658,7 +658,7 @@ class Plot2DGraph:
# newAx.spines['bottom'].set_facecolor('red')
# newAx.spines['bottom'].set_edgecolor('red')
- newAx.set_xticks(range(len(self.newXticks)))
+ newAx.set_xticks(list(range(len(self.newXticks))))
newAx.set_xticklabels(self.newXticks)
newAx.set_xlabel(self.newXLabel, color='b')
newAx.xaxis.set_visible(True)
@@ -695,7 +695,7 @@ class Plot2DGraph:
newAx.spines['bottom'].set_facecolor('r')
newAx.spines['bottom'].set_edgecolor('r')
- newAx.set_xticks(range(len(self.newXticks)))
+ newAx.set_xticks(list(range(len(self.newXticks))))
newAx.set_xticklabels(self.newXticks)
newAx.set_xlabel(self.newXLabel, color='b')
newAx.xaxis.set_visible(True)
@@ -754,7 +754,7 @@ class Plot2DGraph:
"""check num subplots is not too much"""
if(self.numSubPlots > 4):
- print "Max subplots exceeded: " + str(self.numSubPlots)
+ print("Max subplots exceeded: " + str(self.numSubPlots))
return
# generate graphs, write to file
diff --git a/framework/plotting.py b/framework/plotting.py
index 9e0ae54..7d036fe 100644
--- a/framework/plotting.py
+++ b/framework/plotting.py
@@ -106,7 +106,7 @@ class Plotting(object):
for yseries in ydata:
if len(xdata) != len(yseries):
- print utils.RED("The number of items in X axis (%s) and Y axis (%s) does not match." % (xdata, ydata))
+ print(utils.RED("The number of items in X axis (%s) and Y axis (%s) does not match." % (xdata, ydata)))
return ''
image_path = "%s/%s.%s" % (self.plots_path, image_filename,
@@ -124,7 +124,7 @@ class Plotting(object):
pgraph.setBarLegends(0, legend)
# For each value in the x axis add corresponding bar (array in ydata)
- for xvalue in xrange(len(xdata)):
+ for xvalue in range(len(xdata)):
yvalues = [_[xvalue] for _ in ydata]
pgraph.addBarData(0, xdata[xvalue], yvalues)
@@ -166,7 +166,7 @@ class Plotting(object):
# workaround
if numPlots > len(line_colours):
- print 'WARNING - numPlots > len(line_colours)'
+ print('WARNING - numPlots > len(line_colours)')
r = 0x00
g = 0x66
b = 0xFF
@@ -191,7 +191,7 @@ class Plotting(object):
pgraph.setBarLegends(0, legend)
# For each value in the x axis add corresponding bar (array in ydata)
- for i in list(xrange(numPlots)):
+ for i in list(range(numPlots)):
yDataStart = i * numticks
pgraph.addPlotData(i, 'Number of active pipes per output port',
ylabel,
diff --git a/framework/pmd_output.py b/framework/pmd_output.py
index dd1e40d..2d66743 100644
--- a/framework/pmd_output.py
+++ b/framework/pmd_output.py
@@ -157,7 +157,7 @@ class PmdOutput():
config['cores'] = cores
if eal_param == '':
# use configured ports if not set
- if 'ports' not in config.keys():
+ if 'ports' not in list(config.keys()):
config['ports'] = [self.dut.ports_info[i]['pci'] for i in range(len(self.dut.ports_info))]
all_eal_param = self.dut.create_eal_parameters(fixed_prefix=fixed_prefix, socket=socket, **config)
else:
@@ -173,7 +173,7 @@ class PmdOutput():
if file_prefix:
config['prefix'] = file_prefix
- if not w_pci_list and not b_pci_list and 'ports' not in config.keys():
+ if not w_pci_list and not b_pci_list and 'ports' not in list(config.keys()):
config['ports'] = [self.dut.ports_info[i]['pci'] for i in range(len(self.dut.ports_info))]
part_eal_param = self.dut.create_eal_parameters(fixed_prefix=fixed_prefix, socket=socket, **config)
all_eal_param = part_eal_param + ' ' + other_eal_str
diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py
index 849a4a7..aa92978 100644
--- a/framework/qemu_kvm.py
+++ b/framework/qemu_kvm.py
@@ -209,7 +209,7 @@ class QEMUKvm(VirtBase):
"""
path: absolute path for qemu emulator
"""
- if 'path' in options.keys():
+ if 'path' in list(options.keys()):
self.set_qemu_emulator(options['path'])
def has_virtual_ability(self):
@@ -281,7 +281,7 @@ class QEMUKvm(VirtBase):
"""
'enable': 'yes'
"""
- if 'enable' in options.keys() and \
+ if 'enable' in list(options.keys()) and \
options['enable'] == 'yes':
enable_kvm_boot_line = '-enable-kvm'
self.__add_boot_line(enable_kvm_boot_line)
@@ -302,10 +302,10 @@ class QEMUKvm(VirtBase):
"""
machine_boot_line='-machine'
separator = ','
- if 'machine' in options.keys() and \
+ if 'machine' in list(options.keys()) and \
options['machine']:
machine_boot_line += ' %s' % options['machine']
- if 'opt_gic_version' in options.keys() and \
+ if 'opt_gic_version' in list(options.keys()) and \
options['opt_gic_version']:
machine_boot_line += separator + 'gic_version=%s' % options['opt_gic_version']
@@ -328,7 +328,7 @@ class QEMUKvm(VirtBase):
"""
'name' : '/tmp/.qemu_vm0.pid'
"""
- if 'name' in options.keys():
+ if 'name' in list(options.keys()):
self.__add_boot_line('-pidfile %s' % options['name'])
def set_vm_name(self, vm_name):
@@ -345,7 +345,7 @@ class QEMUKvm(VirtBase):
"""
name: vm1
"""
- if 'name' in options.keys() and \
+ if 'name' in list(options.keys()) and \
options['name']:
name_boot_line = '-name %s' % options['name']
self.__add_boot_line(name_boot_line)
@@ -359,15 +359,15 @@ class QEMUKvm(VirtBase):
number: '4' #number of vcpus
cpupin: '3 4 5 6' # host cpu list
"""
- if 'model' in options.keys() and \
+ if 'model' in list(options.keys()) and \
options['model']:
cpu_boot_line = '-cpu %s' % options['model']
self.__add_boot_line(cpu_boot_line)
- if 'number' in options.keys() and \
+ if 'number' in list(options.keys()) and \
options['number']:
smp_cmd_line = '-smp %d' % int(options['number'])
self.__add_boot_line(smp_cmd_line)
- if 'cpupin' in options.keys() and \
+ if 'cpupin' in list(options.keys()) and \
options['cpupin']:
self.vcpus_pinned_to_vm = str(options['cpupin'])
@@ -375,10 +375,10 @@ class QEMUKvm(VirtBase):
"""
size: 1024
"""
- if 'size' in options.keys():
+ if 'size' in list(options.keys()):
mem_boot_line = '-m %s' % options['size']
self.__add_boot_line(mem_boot_line)
- if 'hugepage' in options.keys():
+ if 'hugepage' in list(options.keys()):
if options['hugepage'] == 'yes':
mem_boot_huge = '-object memory-backend-file,' \
+ 'id=mem,size=%sM,mem-path=%s,share=on' \
@@ -397,22 +397,22 @@ class QEMUKvm(VirtBase):
opt_media: disk
"""
separator = ','
- if 'file' in options.keys() and \
+ if 'file' in list(options.keys()) and \
options['file']:
disk_boot_line = '-drive file=%s' % options['file']
else:
return False
- if 'opt_format' in options.keys() and \
+ if 'opt_format' in list(options.keys()) and \
options['opt_format']:
disk_boot_line += separator + 'format=%s' % options['opt_format']
- if 'opt_if' in options.keys() and \
+ if 'opt_if' in list(options.keys()) and \
options['opt_if']:
disk_boot_line += separator + 'if=%s' % options['opt_if']
- if 'opt_index' in options.keys() and \
+ if 'opt_index' in list(options.keys()) and \
options['opt_index']:
disk_boot_line += separator + 'index=%s' % options['opt_index']
- if 'opt_media' in options.keys() and \
+ if 'opt_media' in list(options.keys()) and \
options['opt_media']:
disk_boot_line += separator + 'media=%s' % options['opt_media']
@@ -422,7 +422,7 @@ class QEMUKvm(VirtBase):
"""
file: /home/image/flash0.img
"""
- if 'file' in options.keys():
+ if 'file' in list(options.keys()):
pflash_boot_line = '-pflash %s' % options['file']
self.__add_boot_line(pflash_boot_line)
@@ -430,13 +430,13 @@ class QEMUKvm(VirtBase):
"""
Update VM start and login related settings
"""
- if 'wait_seconds' in options.keys():
+ if 'wait_seconds' in list(options.keys()):
self.START_TIMEOUT = int(options['wait_seconds'])
- if 'login_timeout' in options.keys():
+ if 'login_timeout' in list(options.keys()):
self.LOGIN_TIMEOUT = int(options['login_timeout'])
- if 'login_prompt' in options.keys():
+ if 'login_prompt' in list(options.keys()):
self.LOGIN_PROMPT = options['login_prompt']
- if 'password_prompt' in options.keys():
+ if 'password_prompt' in list(options.keys()):
self.PASSWORD_PROMPT = options['password_prompt']
def add_vm_login(self, **options):
@@ -444,11 +444,11 @@ class QEMUKvm(VirtBase):
user: login username of virtual machine
password: login password of virtual machine
"""
- if 'user' in options.keys():
+ if 'user' in list(options.keys()):
user = options['user']
self.username = user
- if 'password' in options.keys():
+ if 'password' in list(options.keys()):
password = options['password']
self.password = password
@@ -469,7 +469,7 @@ class QEMUKvm(VirtBase):
opt_[vlan | fd | br | mac | ...]
note:the sub-option will be decided according to the net type.
"""
- if 'type' in options.keys():
+ if 'type' in list(options.keys()):
if options['type'] == 'nic':
self.__add_vm_net_nic(**options)
if options['type'] == 'user':
@@ -490,18 +490,18 @@ class QEMUKvm(VirtBase):
baudrate: console access baudrate in kernel boot args
root: root partition details in kernel boot args
"""
- print options
- if 'kernel_img' in options.keys() and options['kernel_img']:
+ print(options)
+ if 'kernel_img' in list(options.keys()) and options['kernel_img']:
kernel_boot_line = '-kernel %s' % options['kernel_img']
else:
return False
self.__add_boot_line(kernel_boot_line)
kernel_args = ""
- if 'console' in options.keys() and options['console']:
+ if 'console' in list(options.keys()) and options['console']:
kernel_args = "console=%s" %options['console']
- if 'baudrate' in options.keys() and options['baudrate']:
+ if 'baudrate' in list(options.keys()) and options['baudrate']:
kernel_args += "," + options['baudrate']
- if 'root' in options.keys() and options['root']:
+ if 'root' in list(options.keys()) and options['root']:
kernel_args += " root=%s" %options['root']
if kernel_args:
append_boot_line = '--append \"%s\"' %kernel_args
@@ -516,7 +516,7 @@ class QEMUKvm(VirtBase):
net_boot_line = '-device '
separator = ','
- if 'opt_model' in options.keys() and \
+ if 'opt_model' in list(options.keys()) and \
options['opt_model']:
model = options['opt_model']
else:
@@ -547,7 +547,7 @@ class QEMUKvm(VirtBase):
self.nic_num = self.nic_num + 1
netdev = "id=nttsip%d" % netdev_id
net_boot_line += separator + netdev
- if 'opt_hostfwd' in options.keys() and \
+ if 'opt_hostfwd' in list(options.keys()) and \
options['opt_hostfwd']:
self.__check_net_user_opt_hostfwd(options['opt_hostfwd'])
opt_hostfwd = options['opt_hostfwd']
@@ -646,7 +646,7 @@ class QEMUKvm(VirtBase):
net_boot_line += separator + netdev
# add bridge info
- if 'opt_br' in options.keys() and \
+ if 'opt_br' in list(options.keys()) and \
options['opt_br']:
bridge = options['opt_br']
else:
@@ -654,7 +654,7 @@ class QEMUKvm(VirtBase):
self.__generate_net_config_script(str(bridge))
# add network configure script path
- if 'opt_script' in options.keys() and \
+ if 'opt_script' in list(options.keys()) and \
options['opt_script']:
script_path = options['opt_script']
else:
@@ -662,7 +662,7 @@ class QEMUKvm(VirtBase):
net_boot_line += separator + 'script=%s' % script_path
# add network configure downscript path
- if 'opt_downscript' in options.keys() and \
+ if 'opt_downscript' in list(options.keys()) and \
options['opt_downscript']:
net_boot_line += separator + \
'downscript=%s' % options['opt_downscript']
@@ -704,7 +704,7 @@ class QEMUKvm(VirtBase):
opt_[host | addr | ...]: value
note:the sub-option will be decided according to the driver.
"""
- if 'driver' in options.keys() and \
+ if 'driver' in list(options.keys()) and \
options['driver']:
if options['driver'] == 'pci-assign':
self.__add_vm_pci_assign(**options)
@@ -725,13 +725,13 @@ class QEMUKvm(VirtBase):
"""
dev_boot_line = '-device vfio-pci'
separator = ','
- if 'opt_host' in options.keys() and \
+ if 'opt_host' in list(options.keys()) and \
options['opt_host']:
dev_boot_line += separator + 'host=%s' % options['opt_host']
dev_boot_line += separator + 'id=pt_%d' % self.pt_idx
self.pt_idx += 1
self.pt_devices.append(options['opt_host'])
- if 'opt_addr' in options.keys() and \
+ if 'opt_addr' in list(options.keys()) and \
options['opt_addr']:
dev_boot_line += separator + 'addr=%s' % options['opt_addr']
self.assigned_pcis.append(options['opt_addr'])
@@ -747,13 +747,13 @@ class QEMUKvm(VirtBase):
"""
dev_boot_line = '-device pci-assign'
separator = ','
- if 'opt_host' in options.keys() and \
+ if 'opt_host' in list(options.keys()) and \
options['opt_host']:
dev_boot_line += separator + 'host=%s' % options['opt_host']
dev_boot_line += separator + 'id=pt_%d' % self.pt_idx
self.pt_idx += 1
self.pt_devices.append(options['opt_host'])
- if 'opt_addr' in options.keys() and \
+ if 'opt_addr' in list(options.keys()) and \
options['opt_addr']:
dev_boot_line += separator + 'addr=%s' % options['opt_addr']
self.assigned_pcis.append(options['opt_addr'])
@@ -770,8 +770,8 @@ class QEMUKvm(VirtBase):
separator = ','
# chardev parameter
netdev_id = 'netdev%d' % self.netdev_idx
- if 'opt_script' in options.keys() and options['opt_script']:
- if 'opt_br' in options.keys() and \
+ if 'opt_script' in list(options.keys()) and options['opt_script']:
+ if 'opt_br' in list(options.keys()) and \
options['opt_br']:
bridge = options['opt_br']
else:
@@ -779,10 +779,10 @@ class QEMUKvm(VirtBase):
self.__generate_net_config_script(str(bridge))
dev_boot_line = '-netdev tap,id=%s,script=%s' % (netdev_id, options['opt_script'])
self.netdev_idx += 1
- elif 'opt_path' in options.keys() and options['opt_path']:
+ elif 'opt_path' in list(options.keys()) and options['opt_path']:
dev_boot_line = '-chardev socket'
char_id = 'char%d' % self.char_idx
- if 'opt_server' in options.keys() and options['opt_server']:
+ if 'opt_server' in list(options.keys()) and options['opt_server']:
dev_boot_line += separator + 'id=%s' % char_id + separator + \
'path=%s' % options[
'opt_path'] + separator + '%s' % options['opt_server']
@@ -796,7 +796,7 @@ class QEMUKvm(VirtBase):
# netdev parameter
netdev_id = 'netdev%d' % self.netdev_idx
self.netdev_idx += 1
- if 'opt_queue' in options.keys() and options['opt_queue']:
+ if 'opt_queue' in list(options.keys()) and options['opt_queue']:
queue_num = options['opt_queue']
dev_boot_line = '-netdev type=vhost-user,id=%s,chardev=%s,vhostforce,queues=%s' % (
netdev_id, char_id, queue_num)
@@ -806,12 +806,12 @@ class QEMUKvm(VirtBase):
self.__add_boot_line(dev_boot_line)
# device parameter
opts = {'opt_netdev': '%s' % netdev_id}
- if 'opt_mac' in options.keys() and \
+ if 'opt_mac' in list(options.keys()) and \
options['opt_mac']:
opts['opt_mac'] = options['opt_mac']
- if 'opt_settings' in options.keys() and options['opt_settings']:
+ if 'opt_settings' in list(options.keys()) and options['opt_settings']:
opts['opt_settings'] = options['opt_settings']
- if 'opt_legacy' in options.keys() and options['opt_legacy']:
+ if 'opt_legacy' in list(options.keys()) and options['opt_legacy']:
opts['opt_legacy'] = options['opt_legacy']
self.__add_vm_virtio_net_pci(**opts)
@@ -822,7 +822,7 @@ class QEMUKvm(VirtBase):
"""
separator = ','
dev_boot_line = '-netdev tap'
- if 'opt_tap' in options.keys():
+ if 'opt_tap' in list(options.keys()):
cuse_id = options['opt_tap']
else:
cuse_id = 'vhost%d' % self.cuse_id
@@ -834,9 +834,9 @@ class QEMUKvm(VirtBase):
# device parameter
opts = {'opt_netdev': '%s' % cuse_id,
'opt_id': '%s_net' % cuse_id}
- if 'opt_mac' in options.keys() and options['opt_mac']:
+ if 'opt_mac' in list(options.keys()) and options['opt_mac']:
opts['opt_mac'] = options['opt_mac']
- if 'opt_settings' in options.keys() and options['opt_settings']:
+ if 'opt_settings' in list(options.keys()) and options['opt_settings']:
opts['opt_settings'] = options['opt_settings']
self.__add_vm_virtio_net_pci(**opts)
@@ -853,25 +853,25 @@ class QEMUKvm(VirtBase):
"""
dev_boot_line = '-device virtio-net-pci'
separator = ','
- if 'opt_netdev' in options.keys() and \
+ if 'opt_netdev' in list(options.keys()) and \
options['opt_netdev']:
dev_boot_line += separator + 'netdev=%s' % options['opt_netdev']
- if 'opt_id' in options.keys() and \
+ if 'opt_id' in list(options.keys()) and \
options['opt_id']:
dev_boot_line += separator + 'id=%s' % options['opt_id']
- if 'opt_mac' in options.keys() and \
+ if 'opt_mac' in list(options.keys()) and \
options['opt_mac']:
dev_boot_line += separator + 'mac=%s' % options['opt_mac']
- if 'opt_bus' in options.keys() and \
+ if 'opt_bus' in list(options.keys()) and \
options['opt_bus']:
dev_boot_line += separator + 'bus=%s' % options['opt_bus']
- if 'opt_addr' in options.keys() and \
+ if 'opt_addr' in list(options.keys()) and \
options['opt_addr']:
dev_boot_line += separator + 'addr=%s' % options['opt_addr']
- if 'opt_legacy' in options.keys() and \
+ if 'opt_legacy' in list(options.keys()) and \
options['opt_legacy']:
dev_boot_line += separator + 'disable-modern=%s' % options['opt_legacy']
- if 'opt_settings' in options.keys() and \
+ if 'opt_settings' in list(options.keys()) and \
options['opt_settings']:
dev_boot_line += separator + '%s' % options['opt_settings']
@@ -909,7 +909,7 @@ class QEMUKvm(VirtBase):
"""
path: if adding monitor to vm, need to specify unix socket path
"""
- if 'path' in options.keys():
+ if 'path' in list(options.keys()):
monitor_boot_line = '-monitor unix:%s,server,nowait' % options[
'path']
self.__add_boot_line(monitor_boot_line)
@@ -924,9 +924,9 @@ class QEMUKvm(VirtBase):
"""
migrate_cmd = "-incoming tcp::%(migrate_port)s"
- if 'enable' in options.keys():
+ if 'enable' in list(options.keys()):
if options['enable'] == 'yes':
- if 'port' in options.keys():
+ if 'port' in list(options.keys()):
self.migrate_port = options['port']
else:
self.migrate_port = str(
@@ -940,7 +940,7 @@ class QEMUKvm(VirtBase):
"""
Set control session options
"""
- if 'type' in options.keys():
+ if 'type' in list(options.keys()):
self.control_type = options['type']
else:
self.control_type = 'telnet'
@@ -1023,7 +1023,7 @@ class QEMUKvm(VirtBase):
return self.control_session
except Exception as e:
# when exception happened, force close serial connection and reconnect
- print RED("[%s:%s] exception [%s] happened" % (self.host_dut.crb['My IP'], self.vm_name, str(e)))
+ print(RED("[%s:%s] exception [%s] happened" % (self.host_dut.crb['My IP'], self.vm_name, str(e))))
self.close_control_session(dut_id=self.host_dut.dut_id)
return False
@@ -1066,7 +1066,7 @@ class QEMUKvm(VirtBase):
# login into Redhat os, not sure can work on all distributions
if ("x86_64 on an x86_64" not in out) and (self.LOGIN_PROMPT not in out):
- print RED("[%s:%s] not ready for login" % (self.host_dut.crb['My IP'], self.vm_name))
+ print(RED("[%s:%s] not ready for login" % (self.host_dut.crb['My IP'], self.vm_name)))
return False
else:
self.control_session.send_expect("%s" % self.username, "Password:", timeout=self.LOGIN_TIMEOUT)
@@ -1074,7 +1074,7 @@ class QEMUKvm(VirtBase):
return True
except Exception as e:
# when exception happened, force close serial connection and reconnect
- print RED("[%s:%s] exception [%s] happened" % (self.host_dut.crb['My IP'], self.vm_name, str(e)))
+ print(RED("[%s:%s] exception [%s] happened" % (self.host_dut.crb['My IP'], self.vm_name, str(e))))
self.close_control_session(dut_id=self.host_dut.dut_id)
return False
@@ -1093,7 +1093,7 @@ class QEMUKvm(VirtBase):
return True
except Exception as e:
# when exception happened, force close qga process and reconnect
- print RED("[%s:%s] QGA not ready" % (self.host_dut.crb['My IP'], self.vm_name))
+ print(RED("[%s:%s] QGA not ready" % (self.host_dut.crb['My IP'], self.vm_name)))
self.close_control_session(dut_id=self.host_dut.dut_id)
return False
@@ -1101,10 +1101,10 @@ class QEMUKvm(VirtBase):
"""
Add VM display option
"""
- if 'disable' in options.keys() and options['disable'] == 'True':
+ if 'disable' in list(options.keys()) and options['disable'] == 'True':
vnc_boot_line = '-display none'
else:
- if 'displayNum' in options.keys() and \
+ if 'displayNum' in list(options.keys()) and \
options['displayNum']:
display_num = options['displayNum']
else:
@@ -1118,10 +1118,10 @@ class QEMUKvm(VirtBase):
"""
Set VM display options
"""
- if 'disable' in options.keys():
+ if 'disable' in list(options.keys()):
vnc_option = [{'disable': 'True'}]
else:
- if 'displayNum' in options.keys():
+ if 'displayNum' in list(options.keys()):
vnc_option = [{'displayNum': options['displayNum']}]
else:
# will allocate vnc display later
@@ -1150,7 +1150,7 @@ class QEMUKvm(VirtBase):
By default VM will start with the daemonize status.
Not support starting it on the stdin now.
"""
- if 'daemon' in options.keys() and \
+ if 'daemon' in list(options.keys()) and \
options['enable'] == 'no':
pass
else:
@@ -1162,7 +1162,7 @@ class QEMUKvm(VirtBase):
usercmd: user self defined command line.
This command will be add into qemu boot command.
"""
- if 'cmd' in options.keys():
+ if 'cmd' in list(options.keys()):
cmd = options['cmd']
self.__add_boot_line(cmd)
@@ -1172,8 +1172,8 @@ class QEMUKvm(VirtBase):
"""
separator = ' '
- if 'enable' in options.keys() and options['enable'] == 'yes':
- if 'opt_num' in options.keys():
+ if 'enable' in list(options.keys()) and options['enable'] == 'yes':
+ if 'opt_num' in list(options.keys()):
opt_num = int(options['opt_num'])
else:
opt_num = 1
@@ -1524,7 +1524,7 @@ class QEMUKvm(VirtBase):
Check if the specified PCI dev is a VF.
"""
for port_info in self.host_dut.ports_info:
- if 'sriov_vfs_pci' in port_info.keys():
+ if 'sriov_vfs_pci' in list(port_info.keys()):
if dev_pci in port_info['sriov_vfs_pci']:
return True
return False
@@ -1534,7 +1534,7 @@ class QEMUKvm(VirtBase):
Map the specified VF to PF.
"""
for port_info in self.host_dut.ports_info:
- if 'sriov_vfs_pci' in port_info.keys():
+ if 'sriov_vfs_pci' in list(port_info.keys()):
if dev_pci in port_info['sriov_vfs_pci']:
return port_info['pci']
return None
@@ -1544,7 +1544,7 @@ class QEMUKvm(VirtBase):
Get the NetDevice instance of specified VF.
"""
for port_info in self.host_dut.ports_info:
- if 'vfs_port' in port_info.keys():
+ if 'vfs_port' in list(port_info.keys()):
for port in port_info['vfs_port']:
if dev_pci == port.pci:
return port
@@ -1554,7 +1554,7 @@ class QEMUKvm(VirtBase):
"""
Check if the specified VF has been used.
"""
- for pci in assigned_pcis_info.keys():
+ for pci in list(assigned_pcis_info.keys()):
if assigned_pcis_info[pci]['is_vf'] and \
assigned_pcis_info[pci]['pf_pci'] == pf_pci:
return pci
@@ -1751,8 +1751,8 @@ class QEMUKvm(VirtBase):
self.quit_control_session()
return out
except Exception as e:
- print RED("Exception happened on [%s] serial with cmd [%s]" % (self.vm_name, command))
- print RED(e)
+ print(RED("Exception happened on [%s] serial with cmd [%s]" % (self.vm_name, command)))
+ print(RED(e))
self.close_control_session(dut_id=self.host_dut.dut_id)
return 'Failed'
@@ -1892,7 +1892,7 @@ class QEMUKvm(VirtBase):
thread_reg = r'CPU #(\d+): .* thread_id=(\d+)'
output = self.__monitor_session('info', 'cpus')
thread_cores = re.findall(thread_reg, output)
- cores_map = zip(thread_cores, lcores)
+ cores_map = list(zip(thread_cores, lcores))
for thread_info, core_id in cores_map:
cpu_id, thread_id = thread_info
self.host_session.send_expect("taskset -pc %d %s" % (core_id, thread_id), "#")
diff --git a/framework/qemu_libvirt.py b/framework/qemu_libvirt.py
index 5b25dec..5e34590 100644
--- a/framework/qemu_libvirt.py
+++ b/framework/qemu_libvirt.py
@@ -165,10 +165,10 @@ class LibvirtKvm(VirtBase):
size : memory size, measured in MB
hugepage : guest memory allocated using hugepages
"""
- if 'size' in options.keys():
+ if 'size' in list(options.keys()):
memory = ET.SubElement(self.domain, 'memory', {'unit': 'MB'})
memory.text = options['size']
- if 'hugepage' in options.keys():
+ if 'hugepage' in list(options.keys()):
memoryBacking = ET.SubElement(self.domain, 'memoryBacking')
ET.SubElement(memoryBacking, 'hugepages')
@@ -188,10 +188,10 @@ class LibvirtKvm(VirtBase):
'cpupin' : '3 4 5 6' # host cpu list
"""
vcpu = 0
- if 'number' in options.keys():
+ if 'number' in list(options.keys()):
vmcpu = ET.SubElement(self.domain, 'vcpu', {'placement': 'static'})
vmcpu.text = options['number']
- if 'cpupin' in options.keys():
+ if 'cpupin' in list(options.keys()):
cputune = ET.SubElement(self.domain, 'cputune')
# cpu resource will be allocated
req_cpus = options['cpupin'].split()
@@ -230,11 +230,11 @@ class LibvirtKvm(VirtBase):
def add_vm_os(self, **options):
os = self.domain.find('os')
- if 'loader' in options.keys():
+ if 'loader' in list(options.keys()):
loader = ET.SubElement(
os, 'loader', {'readonly': 'yes', 'type': 'pflash'})
loader.text = options['loader']
- if 'nvram' in options.keys():
+ if 'nvram' in list(options.keys()):
nvram = ET.SubElement(os, 'nvram')
nvram.text = options['nvram']
@@ -310,7 +310,7 @@ class LibvirtKvm(VirtBase):
Options:
path: absolute path for qemu emulator
"""
- if 'path' in options.keys():
+ if 'path' in list(options.keys()):
self.set_qemu_emulator(options['path'])
# update emulator config
devices = self.domain.find('devices')
@@ -394,10 +394,10 @@ class LibvirtKvm(VirtBase):
ET.SubElement(graphics, 'listen', listen)
def add_vm_serial_port(self, **options):
- if 'enable' in options.keys():
+ if 'enable' in list(options.keys()):
if options['enable'].lower() == 'yes':
devices = self.domain.find('devices')
- if 'opt_type' in options.keys():
+ if 'opt_type' in list(options.keys()):
serial_type = options['opt_type']
else:
serial_type = 'unix'
@@ -429,11 +429,11 @@ class LibvirtKvm(VirtBase):
user: login username of virtual machine
password: login password of virtual machine
"""
- if 'user' in options.keys():
+ if 'user' in list(options.keys()):
user = options['user']
self.username = user
- if 'password' in options.keys():
+ if 'password' in list(options.keys()):
password = options['password']
self.password = password
@@ -553,7 +553,7 @@ class LibvirtKvm(VirtBase):
drv_opt = {}
guest_opt = {}
host_opt = {}
- for key, value in _sub_opt.iteritems():
+ for key, value in _sub_opt.items():
if key.startswith('host_'):
host_opt[key[5:]] = value
continue
@@ -638,7 +638,7 @@ class LibvirtKvm(VirtBase):
self.__add_vm_pci_assign,
}
driver = options.get('driver')
- if not driver or driver not in driver_table.keys():
+ if not driver or driver not in list(driver_table.keys()):
driver = 'pci-assign'
msg = 'use {0} configuration as default driver'.format(driver)
self.logger.warning(msg)
@@ -650,7 +650,7 @@ class LibvirtKvm(VirtBase):
Options:
default: create e1000 netdev and redirect ssh port
"""
- if 'type' in options.keys():
+ if 'type' in list(options.keys()):
if options['type'] == 'nic':
self.__add_vm_net_nic(**options)
elif options['type'] == 'tap':
@@ -664,12 +664,12 @@ class LibvirtKvm(VirtBase):
opt_addr: ''
note: PCI cards only.
"""
- if 'opt_model' in options.keys():
+ if 'opt_model' in list(options.keys()):
model = options['opt_model']
else:
model = 'e1000'
- if 'opt_hostfwd' in options.keys():
+ if 'opt_hostfwd' in list(options.keys()):
port = self.virt_pool.alloc_port(self.vm_name)
if port is None:
return
@@ -678,7 +678,7 @@ class LibvirtKvm(VirtBase):
qemu = ET.SubElement(self.domain, 'qemu:commandline')
ET.SubElement(qemu, 'qemu:arg', {'value': '-net'})
- if 'opt_addr' in options.keys():
+ if 'opt_addr' in list(options.keys()):
pci = self.__parse_pci(options['opt_addr'])
if pci is None:
return False
@@ -691,7 +691,7 @@ class LibvirtKvm(VirtBase):
% self.pciindex})
self.pciindex += 1
- if 'opt_hostfwd' in options.keys():
+ if 'opt_hostfwd' in list(options.keys()):
ET.SubElement(qemu, 'qemu:arg', {'value': '-net'})
ET.SubElement(qemu, 'qemu:arg', {'value': 'user,hostfwd='
'tcp:%s:%d-:22' % (dut_ip, port)})
@@ -729,7 +729,7 @@ class LibvirtKvm(VirtBase):
devices = self.domain.find('devices')
channel = ET.SubElement(devices, 'channel', {'type': 'unix'})
for opt in ['path', 'name']:
- if opt not in options.keys():
+ if opt not in list(options.keys()):
msg = "invalid virtio serial channel setting"
self.logger.error(msg)
return
diff --git a/framework/rst.py b/framework/rst.py
index 2f36ab1..2b8e613 100644
--- a/framework/rst.py
+++ b/framework/rst.py
@@ -108,9 +108,9 @@ class RstReport(object):
f.write('-' * len(line) + '\n')
def write_subtitle(self):
- if self._subtitle is not None:
- with open(self.rstName, "a") as f:
- f.write("%s\n" % self._subtitle)
+ if self._subtitle is not None:
+ with open(self.rstName, "a") as f:
+ f.write("%s\n" % self._subtitle)
def write_annex_title(self, text):
"""
diff --git a/framework/serializer.py b/framework/serializer.py
index 2f0545d..26f68d9 100644
--- a/framework/serializer.py
+++ b/framework/serializer.py
@@ -56,8 +56,6 @@ class Serializer(object):
is called it will return a reference to the same instance.
"""
- __metaclass__ = Singleton
-
def __init__(self):
self.volatile_cache = {}
self.filename = 'serializer.cache'
diff --git a/framework/settings.py b/framework/settings.py
index 7e8944e..ce9fc30 100644
--- a/framework/settings.py
+++ b/framework/settings.py
@@ -268,7 +268,7 @@ def get_nic_name(type):
"""
strip nic code name by nic type
"""
- for name, nic_type in NICS.items():
+ for name, nic_type in list(NICS.items()):
if nic_type == type:
return name
return 'Unknown'
@@ -278,7 +278,7 @@ def get_nic_driver(pci_id):
"""
Return linux driver for specified pci device
"""
- driverlist = dict(zip(NICS.values(), DRIVERS.keys()))
+ driverlist = dict(list(zip(list(NICS.values()), list(DRIVERS.keys()))))
try:
driver = DRIVERS[driverlist[pci_id]]
except Exception as e:
@@ -290,7 +290,7 @@ def get_netdev(crb, pci):
for port in crb.ports_info:
if pci == port['pci']:
return port['port']
- if 'vfs_port' in port.keys():
+ if 'vfs_port' in list(port.keys()):
for vf in port['vfs_port']:
if pci == vf.pci:
return vf
@@ -308,7 +308,7 @@ def get_host_ip(address):
result = socket.gethostbyaddr(address)
return result[2][0]
except:
- print "couldn't look up %s" % address
+ print("couldn't look up %s" % address)
return ''
@@ -333,7 +333,7 @@ def load_global_setting(key):
else:
env_key = "DTS_" + key
- if env_key in os.environ.keys():
+ if env_key in list(os.environ.keys()):
return os.environ[env_key]
else:
return ''
@@ -343,7 +343,7 @@ def report_error(error):
"""
Report error when error occurred
"""
- if error in DTS_ERR_TBL.keys():
+ if error in list(DTS_ERR_TBL.keys()):
os.environ[DTS_ERROR_ENV] = error
else:
os.environ[DTS_ERROR_ENV] = "GENERIC_ERR"
@@ -353,7 +353,7 @@ def exit_error():
"""
Set system exit value when error occurred
"""
- if DTS_ERROR_ENV in os.environ.keys():
+ if DTS_ERROR_ENV in list(os.environ.keys()):
ret_val = DTS_ERR_TBL[os.environ[DTS_ERROR_ENV]]
sys.exit(ret_val)
else:
@@ -366,7 +366,7 @@ def accepted_nic(pci_id):
it is selected in the execution file, otherwise it returns False.
"""
nic = load_global_setting(HOST_NIC_SETTING)
- if pci_id not in NICS.values():
+ if pci_id not in list(NICS.values()):
return False
if nic is 'any':
diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
index 979327c..8889016 100644
--- a/framework/ssh_pexpect.py
+++ b/framework/ssh_pexpect.py
@@ -12,7 +12,7 @@ Also supports transfer files to tester or DUT.
"""
-class SSHPexpect(object):
+class SSHPexpect:
def __init__(self, host, username, password, dut_id):
self.magic_prompt = "MAGIC PROMPT"
@@ -35,7 +35,7 @@ class SSHPexpect(object):
be modified along with MaxStartups value.
"""
try:
- self.session = pxssh.pxssh()
+ self.session = pxssh.pxssh(encoding='utf-8')
if ':' in self.host:
self.ip = self.host.split(':')[0]
self.port = int(self.host.split(':')[1])
@@ -48,11 +48,11 @@ class SSHPexpect(object):
self.send_expect('stty -echo', '#')
self.send_expect('stty columns 1000', "#")
except Exception as e:
- print RED(e)
+ print(RED(e))
if getattr(self, 'port', None):
suggestion = "\nSuggession: Check if the firewall on [ %s ] " % \
self.ip + "is stopped\n"
- print GREEN(suggestion)
+ print(GREEN(suggestion))
raise SSHConnectionException(self.host)
@@ -86,7 +86,7 @@ class SSHPexpect(object):
else:
return ret
except Exception as e:
- print RED("Exception happened in [%s] and output is [%s]" % (command, self.get_output_before()))
+ print(RED("Exception happened in [%s] and output is [%s]" % (command, self.get_output_before())))
raise(e)
def send_command(self, command, timeout=1):
diff --git a/framework/test_case.py b/framework/test_case.py
index b7952fa..0b91fed 100644
--- a/framework/test_case.py
+++ b/framework/test_case.py
@@ -162,14 +162,14 @@ class TestCase(object):
def verify(self, passed, description):
if not passed:
if self._enable_debug:
- print RED("Error happened, dump command history...")
+ print(RED("Error happened, dump command history..."))
self.dump_history()
- print "Error \"%s\" happened" % RED(description)
- print RED("History dump finished.")
+ print("Error \"%s\" happened" % RED(description))
+ print(RED("History dump finished."))
raise VerifyFailure(description)
def _get_nic_driver(self, nic_name):
- if nic_name in DRIVERS.keys():
+ if nic_name in list(DRIVERS.keys()):
return DRIVERS[nic_name]
return "Unknown"
@@ -227,8 +227,8 @@ class TestCase(object):
"""
Pass down subtitle for Rst report
"""
- self._rst_obj._subtitle = subtitle
- self._rst_obj.write_subtitle()
+ self._rst_obj._subtitle = subtitle
+ self._rst_obj.write_subtitle()
def _get_test_cases(self, test_name_regex):
"""
@@ -344,7 +344,7 @@ class TestCase(object):
finally:
# update expected
if load_global_setting(UPDATE_EXPECTED) == "yes" and \
- self.get_suite_cfg().has_key('update_expected') and \
+ 'update_expected' in self.get_suite_cfg() and \
self.get_suite_cfg()['update_expected'] == True:
self._suite_conf.update_case_config(SUITE_SECTION_NAME)
self.tear_down()
@@ -451,9 +451,9 @@ class TestCase(object):
Dump recorded command history
"""
for cmd_history in self.setup_history:
- print '%-20s: %s' % (BLUE(cmd_history['name']), cmd_history['command'])
+ print('%-20s: %s' % (BLUE(cmd_history['name']), cmd_history['command']))
for cmd_history in self.test_history:
- print '%-20s: %s' % (BLUE(cmd_history['name']), cmd_history['command'])
+ print('%-20s: %s' % (BLUE(cmd_history['name']), cmd_history['command']))
def wirespeed(self, nic, frame_size, num_ports):
"""
diff --git a/framework/tester.py b/framework/tester.py
index 7b05832..e6c951e 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -185,7 +185,7 @@ class Tester(Crb):
self.logger.error(result.strip())
for port in self.ports_info:
- if not "intf" in port.keys():
+ if not "intf" in list(port.keys()):
continue
eth = port["intf"]
out = self.send_expect("ethtool --show-priv-flags %s"
@@ -355,7 +355,7 @@ class Tester(Crb):
cached_ports_info = []
for port in self.ports_info:
port_info = {}
- for key in port.keys():
+ for key in list(port.keys()):
if type(port[key]) is str:
port_info[key] = port[key]
# need save netdev objects
@@ -432,7 +432,7 @@ class Tester(Crb):
for (pci_bus, pci_id) in self.pci_devices_info:
# ignore unknown card types
- if pci_id not in NICS.values():
+ if pci_id not in list(NICS.values()):
self.logger.info("Tester: [%s %s] %s" % (pci_bus, pci_id,
"unknow_nic"))
continue
@@ -670,7 +670,7 @@ class Tester(Crb):
"""
Callable function for parallel processes
"""
- print GREEN("Transmitting and sniffing packets, please wait few minutes...")
+ print(GREEN("Transmitting and sniffing packets, please wait few minutes..."))
return pkt.send_pkt_bg(crb=self, tx_port=intf, count=send_times, loop=0, interval=interval)
def check_random_pkts(self, portList, pktnum=2000, interval=0.01, allow_miss=True, seq_check=False, params=None):
@@ -689,7 +689,7 @@ class Tester(Crb):
for txport, rxport in portList:
txIntf = self.get_interface(txport)
rxIntf = self.get_interface(rxport)
- print GREEN("Preparing transmit packets, please wait few minutes...")
+ print(GREEN("Preparing transmit packets, please wait few minutes..."))
pkt = pkt_c()
pkt.generate_random_pkts(pktnum=pktnum, random_type=random_type, ip_increase=True, random_payload=True,
options={"layers_config": params})
@@ -721,13 +721,13 @@ class Tester(Crb):
recv_pkts = p.pktgen.pkts
# only report when received number not matched
if len(tx_pkts[txport].pktgen.pkts) > len(recv_pkts):
- print ("Pkt number not matched,%d sent and %d received\n" % (
- len(tx_pkts[txport].pktgen.pkts), len(recv_pkts)))
+ print(("Pkt number not matched,%d sent and %d received\n" % (
+ len(tx_pkts[txport].pktgen.pkts), len(recv_pkts))))
if allow_miss is False:
return False
# check each received packet content
- print GREEN("Comparing sniffed packets, please wait few minutes...")
+ print(GREEN("Comparing sniffed packets, please wait few minutes..."))
for idx in range(len(recv_pkts)):
try:
l3_type = p.strip_element_layer2('type', p_index=idx)
@@ -745,16 +745,16 @@ class Tester(Crb):
if seq_check:
if t_idx <= prev_id:
- print "Packet %d sequence not correct" % t_idx
+ print("Packet %d sequence not correct" % t_idx)
return False
else:
prev_id = t_idx
if compare_f(tx_pkts[txport].pktgen.pkts[t_idx], recv_pkts[idx], "L4") is False:
- print "Pkt received index %d not match original " \
- "index %d" % (idx, t_idx)
- print "Sent: %s" % strip_f(tx_pkts[txport].pktgen.pkts[t_idx], "L4")
- print "Recv: %s" % strip_f(recv_pkts[idx], "L4")
+ print("Pkt received index %d not match original " \
+ "index %d" % (idx, t_idx))
+ print("Sent: %s" % strip_f(tx_pkts[txport].pktgen.pkts[t_idx], "L4"))
+ print("Recv: %s" % strip_f(recv_pkts[idx], "L4"))
return False
return True
@@ -809,7 +809,7 @@ class Tester(Crb):
if self.is_pktgen and self.pktgen:
self.pktgen.quit_generator()
# only restore ports if start trex in dts
- if 'start_trex' in self.pktgen.conf.keys():
+ if 'start_trex' in list(self.pktgen.conf.keys()):
self.restore_trex_interfaces()
self.pktgen = None
elif self.ixia_packet_gen:
diff --git a/framework/texttable.py b/framework/texttable.py
index 3906d97..d4aad6f 100644
--- a/framework/texttable.py
+++ b/framework/texttable.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-#
# texttable - module for creating simple ASCII tables
# Copyright (C) 2003-2015 Gerome Fournier <jef(at)foutaise.org>
#
@@ -124,7 +122,7 @@ def len(iterable):
if sys.version >= '3.0':
return len(str)
else:
- return len(unicode(iterable, 'utf'))
+ return len(str(iterable, 'utf'))
except:
return iterable.__len__()
@@ -147,8 +145,8 @@ TEXT_CODES = {'bold': {'start': '\x1b[1m',
'end': '\x1b[24m'}}
class TextCodesStripper:
- keys = [re.escape(v['start']) for k,v in TEXT_CODES.items()]
- keys += [re.escape(v['end']) for k,v in TEXT_CODES.items()]
+ keys = [re.escape(v['start']) for k,v in list(TEXT_CODES.items())]
+ keys += [re.escape(v['end']) for k,v in list(TEXT_CODES.items())]
pattern = re.compile("|".join(keys))
@staticmethod
@@ -353,7 +351,7 @@ class Texttable:
# usable code for python 2.1
if header:
if hasattr(rows, '__iter__') and hasattr(rows, 'next'):
- self.header(rows.next())
+ self.header(next(rows))
else:
self.header(rows[0])
rows = rows[1:]
@@ -596,7 +594,7 @@ class Texttable:
if sys.version >= '3.0':
c = str(c, 'utf', 'replace')
else:
- c = unicode(c, 'utf', 'replace')
+ c = str(c, 'utf', 'replace')
# imarom - no wrap for now
#array.extend(textwrap.wrap(c, width))
@@ -625,7 +623,7 @@ if __name__ == '__main__':
table.add_rows([["Name", "Age", "Nickname"],
["Mr\nXavier\nHuon", 32, "Xav'"],
["Mr\nBaptiste\nClement", 1, "Baby"]])
- print(table.draw() + "\n")
+ print((table.draw() + "\n"))
table = Texttable()
table.set_deco(Texttable.HEADER)
@@ -640,4 +638,4 @@ if __name__ == '__main__':
["efghijk", 67.5434, .654, 89.6, 12800000000000000000000.00023],
["lmn", 5e-78, 5e-78, 89.4, .000000000000128],
["opqrstu", .023, 5e+78, 92., 12800000000000000000000]])
- print(table.draw())
+ print((table.draw()))
diff --git a/framework/utils.py b/framework/utils.py
index 516dc91..f6594b5 100644
--- a/framework/utils.py
+++ b/framework/utils.py
@@ -93,8 +93,8 @@ def parallel_lock(num=1):
# make sure when owned global lock, should also own update lock
if lock_info[name]['current_thread'] >= num:
if lock._is_owned():
- print RED("DUT%d %s waiting for func lock %s" % (dut_id,
- threading.current_thread().name, func.__name__))
+ print(RED("DUT%d %s waiting for func lock %s" % (dut_id,
+ threading.current_thread().name, func.__name__)))
lock.acquire()
else:
uplock.release()
@@ -154,7 +154,7 @@ def regexp(s, to_match, allString=False):
return scanner.findall(s)
m = scanner.search(s)
if m is None:
- print RED("Failed to match " + to_match + " in the string " + s)
+ print(RED("Failed to match " + to_match + " in the string " + s))
return None
return m.group(1)
@@ -200,7 +200,7 @@ def get_subclasses(module, clazz):
def copy_instance_attr(from_inst, to_inst):
- for key in from_inst.__dict__.keys():
+ for key in list(from_inst.__dict__.keys()):
to_inst.__dict__[key] = from_inst.__dict__[key]
@@ -249,7 +249,7 @@ def convert_mac2long(mac_str):
mac_hex = '0x'
for mac_part in mac_str.lower().split(':'):
mac_hex += mac_part
- ret = long(mac_hex, 16)
+ ret = int(mac_hex, 16)
return ret
def convert_mac2str(mac_long):
diff --git a/framework/virt_base.py b/framework/virt_base.py
index 31623be..c959ca0 100644
--- a/framework/virt_base.py
+++ b/framework/virt_base.py
@@ -33,7 +33,7 @@ import sys
import traceback
import threading
from random import randint
-from itertools import imap
+
import utils
import exception
@@ -127,7 +127,7 @@ class VirtBase(object):
conf.load_virt_config(self.virt_type)
global_conf = conf.get_virt_config()
for param in global_conf:
- for key in param.keys():
+ for key in list(param.keys()):
if self.find_option_index(key) is None:
self.__save_local_config(key, param[key])
@@ -153,11 +153,11 @@ class VirtBase(object):
# replace global configurations with local configurations
for param in self.local_conf:
- if 'virt_type' in param.keys():
+ if 'virt_type' in list(param.keys()):
# param 'virt_type' is for virt_base only
continue
# save local configurations
- for key in param.keys():
+ for key in list(param.keys()):
self.__save_local_config(key, param[key])
def __save_local_config(self, key, value):
@@ -165,7 +165,7 @@ class VirtBase(object):
Save the local config into the global dict self.param.
"""
for param in self.params:
- if key in param.keys():
+ if key in list(param.keys()):
param[key] = value
return
@@ -176,7 +176,7 @@ class VirtBase(object):
Compose all boot param for starting the VM.
"""
for param in self.params:
- key = param.keys()[0]
+ key = list(param.keys())[0]
value = param[key]
try:
param_func = getattr(self, 'add_vm_' + key)
@@ -185,10 +185,10 @@ class VirtBase(object):
for option in value:
param_func(**option)
else:
- print utils.RED("Virt %s function not callable!!!" % key)
+ print(utils.RED("Virt %s function not callable!!!" % key))
except AttributeError:
self.host_logger.error(traceback.print_exception(*sys.exc_info()))
- print utils.RED("Virt %s function not implemented!!!" % key)
+ print(utils.RED("Virt %s function not implemented!!!" % key))
except Exception:
self.host_logger.error(traceback.print_exception(*sys.exc_info()))
raise exception.VirtConfigParamException(key)
@@ -197,9 +197,9 @@ class VirtBase(object):
"""
Set default driver which may required when setup VM
"""
- if 'driver_name' in options.keys():
+ if 'driver_name' in list(options.keys()):
self.def_driver = options['driver_name']
- if 'driver_mode' in options.keys():
+ if 'driver_mode' in list(options.keys()):
self.driver_mode = options['driver_mode']
def find_option_index(self, option):
@@ -211,7 +211,7 @@ class VirtBase(object):
"""
index = 0
for param in self.params:
- key = param.keys()[0]
+ key = list(param.keys())[0]
if key.strip() == option.strip():
return index
index += 1
@@ -224,7 +224,7 @@ class VirtBase(object):
"""
mac_head = '00:00:00:'
mac_tail = ':'.join(
- ['%02x' % x for x in imap(lambda x:randint(0, 255), range(3))])
+ ['%02x' % x for x in map(lambda x:randint(0, 255), list(range(3)))])
return mac_head + mac_tail
def get_vm_ip(self):
@@ -296,9 +296,9 @@ class VirtBase(object):
except Exception as vm_except:
if self.handle_exception(vm_except):
- print utils.RED("Handled exception " + str(type(vm_except)))
+ print(utils.RED("Handled exception " + str(type(vm_except))))
else:
- print utils.RED("Unhandled exception " + str(type(vm_except)))
+ print(utils.RED("Unhandled exception " + str(type(vm_except))))
if callable(self.callback):
self.callback()
@@ -321,9 +321,9 @@ class VirtBase(object):
except Exception as vm_except:
if self.handle_exception(vm_except):
- print utils.RED("Handled exception " + str(type(vm_except)))
+ print(utils.RED("Handled exception " + str(type(vm_except))))
else:
- print utils.RED("Unhandled exception " + str(type(vm_except)))
+ print(utils.RED("Unhandled exception " + str(type(vm_except))))
if callable(self.callback):
self.callback()
@@ -341,9 +341,9 @@ class VirtBase(object):
vm_dut = self.instantiate_vm_dut(set_target, cpu_topo, bind_dev=False, autodetect_topo=False)
except Exception as vm_except:
if self.handle_exception(vm_except):
- print utils.RED("Handled exception " + str(type(vm_except)))
+ print(utils.RED("Handled exception " + str(type(vm_except))))
else:
- print utils.RED("Unhandled exception " + str(type(vm_except)))
+ print(utils.RED("Unhandled exception " + str(type(vm_except))))
return None
@@ -398,9 +398,9 @@ class VirtBase(object):
"""
param_len = len(self.params)
for i in range(param_len):
- if 'disk' in self.params[i].keys():
+ if 'disk' in list(self.params[i].keys()):
value = self.params[i]['disk'][0]
- if 'file' in value.keys():
+ if 'file' in list(value.keys()):
host_ip = self.host_dut.get_ip_address()
return host_ip + ':' + self.host_dut.test_classname + ':' + value['file']
return None
diff --git a/framework/virt_common.py b/framework/virt_common.py
index 094d9d8..628cadf 100644
--- a/framework/virt_common.py
+++ b/framework/virt_common.py
@@ -43,7 +43,7 @@ def VM(dut, vm_name, suite_name):
# Default virt_type is 'KVM'
virt_type = 'KVM'
for param in local_conf:
- if 'virt_type' in param.keys():
+ if 'virt_type' in list(param.keys()):
virt_type = param['virt_type'][0]['virt_type']
if virt_type == 'KVM':
diff --git a/framework/virt_dut.py b/framework/virt_dut.py
index a916b72..1c6554d 100644
--- a/framework/virt_dut.py
+++ b/framework/virt_dut.py
@@ -123,13 +123,13 @@ class VirtDut(DPDKdut):
"""
port_num = len(self.ports_info)
self.ports_map = [-1] * port_num
- for key in self.ports_cfg.keys():
+ for key in list(self.ports_cfg.keys()):
index = int(key)
if index >= port_num:
- print RED("Can not found [%d ]port info" % index)
+ print(RED("Can not found [%d ]port info" % index))
continue
- if 'peer' in self.ports_cfg[key].keys():
+ if 'peer' in list(self.ports_cfg[key].keys()):
tester_pci = self.ports_cfg[key]['peer']
# find tester_pci index
pci_idx = self.tester.get_local_index(tester_pci)
@@ -233,7 +233,7 @@ class VirtDut(DPDKdut):
total_phycores = socks * cores
# cores should match cpu_topo
if total != len(cpuinfo):
- print RED("Core number not matched!!!")
+ print(RED("Core number not matched!!!"))
else:
for core in range(total):
thread = core / total_phycores
@@ -281,7 +281,7 @@ class VirtDut(DPDKdut):
itf = port.get_interface_name()
self.send_expect("ifconfig %s up" % itf, "# ")
time.sleep(30)
- print self.send_expect("ip link ls %s" % itf, "# ")
+ print(self.send_expect("ip link ls %s" % itf, "# "))
else:
self.logger.info(
"NOT FOUND DRIVER FOR PORT (%s|%s)!!!" % (pci_bus, pci_id))
@@ -401,7 +401,7 @@ class VirtDut(DPDKdut):
vfs = remoteport.get_sriov_vfs_pci()
# if hostpci is vf of tester port
if hostpci == remotepci or hostpci in vfs:
- print RED("Skip ping from same PF device")
+ print(RED("Skip ping from same PF device"))
continue
ipv6 = self.get_ipv6_address(vmPort)
diff --git a/framework/virt_resource.py b/framework/virt_resource.py
index f1cbe65..4356ee5 100644
--- a/framework/virt_resource.py
+++ b/framework/virt_resource.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# BSD LICENSE
#
# Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
@@ -163,7 +162,7 @@ class VirtResource(object):
cores = []
if vm == '':
- print "Alloc cpu request virtual machine name!!!"
+ print("Alloc cpu request virtual machine name!!!")
return cores
# if vm has been allocated cores, just return them
@@ -178,12 +177,12 @@ class VirtResource(object):
cores.append(str(core))
number = number - 1
if number != 0:
- print "Can't allocated requested cpu!!!"
+ print("Can't allocated requested cpu!!!")
if corelist is not None:
for core in corelist:
if self.__core_isused(int(core)) is True:
- print "Core %s has been used!!!" % core
+ print("Core %s has been used!!!" % core)
else:
if self.__core_on_socket(int(core), socket) is True:
self.__core_used(int(core))
@@ -236,12 +235,12 @@ class VirtResource(object):
ports.append(pci)
number = number - 1
if number != 0:
- print "Can't allocated requested PF devices!!!"
+ print("Can't allocated requested PF devices!!!")
if pflist is not None:
for pci in pflist:
if self.__port_isused(pci) is True:
- print "Port %s has been used!!!" % pci
+ print("Port %s has been used!!!" % pci)
else:
if self.__port_on_socket(pci, socket) is True:
self.__port_used(core)
@@ -269,11 +268,11 @@ class VirtResource(object):
"""
vfs = []
if vm == '':
- print "Alloc VF request vitual machine name!!!"
+ print("Alloc VF request vitual machine name!!!")
return vfs
if pf_pci == '':
- print "Alloc VF request PF pci address!!!"
+ print("Alloc VF request PF pci address!!!")
return vfs
for vf_info in self.vfs_info:
@@ -344,14 +343,14 @@ class VirtResource(object):
"""
Check whether port has been pre-allocated
"""
- for vm_info in self.allocated_info.values():
- if vm_info.has_key('hostport') and port == vm_info['hostport']:
+ for vm_info in list(self.allocated_info.values()):
+ if 'hostport' in vm_info and port == vm_info['hostport']:
return True
- if vm_info.has_key('serialport') and port == vm_info['serialport']:
+ if 'serialport' in vm_info and port == vm_info['serialport']:
return True
- if vm_info.has_key('migrateport') and port == vm_info['migrateport']:
+ if 'migrateport' in vm_info and port == vm_info['migrateport']:
return True
- if vm_info.has_key('displayport') and port == (vm_info['displayport'] + 5900):
+ if 'displayport' in vm_info and port == (vm_info['displayport'] + 5900):
return True
return False
@@ -366,7 +365,7 @@ class VirtResource(object):
global INIT_DISPLAY_PORT
if vm == '':
- print "Alloc host port request vitual machine name!!!"
+ print("Alloc host port request vitual machine name!!!")
return None
if port_type == 'connect':
@@ -492,44 +491,44 @@ if __name__ == "__main__":
'peer': 'IXIA:6.8', 'type': '8086:10fb'}]
virt_pool = VirtResource(dut)
- print "Alloc two PF devices on socket 1 from VM"
- print virt_pool.alloc_pf(vm='test1', number=2, socket=1)
+ print("Alloc two PF devices on socket 1 from VM")
+ print(virt_pool.alloc_pf(vm='test1', number=2, socket=1))
virt_pool.add_vf_on_pf(pf_pci='08:00.0', vflist=[
'08:10.0', '08:10.2', '08:10.4', '08:10.6'])
virt_pool.add_vf_on_pf(pf_pci='08:00.1', vflist=[
'08:10.1', '08:10.3', '08:10.5', '08:10.7'])
- print "Add VF devices to resource pool"
- print virt_pool.vfs_info
+ print("Add VF devices to resource pool")
+ print(virt_pool.vfs_info)
- print "Alloc VF device from resource pool"
- print virt_pool.alloc_vf_from_pf(vm='test1', pf_pci='08:00.0', number=2)
- print virt_pool.used_vfs
- print "Alloc VF device from resource pool"
- print virt_pool.alloc_vf_from_pf(vm='test2', pf_pci='08:00.1', vflist=['08:10.3', '08:10.5'])
- print virt_pool.used_vfs
+ print("Alloc VF device from resource pool")
+ print(virt_pool.alloc_vf_from_pf(vm='test1', pf_pci='08:00.0', number=2))
+ print(virt_pool.used_vfs)
+ print("Alloc VF device from resource pool")
+ print(virt_pool.alloc_vf_from_pf(vm='test2', pf_pci='08:00.1', vflist=['08:10.3', '08:10.5']))
+ print(virt_pool.used_vfs)
- print "Del VF devices from resource pool"
+ print("Del VF devices from resource pool")
virt_pool.del_vf_on_pf(pf_pci='08:00.0', vflist=['08:10.4', '08:10.2'])
- print virt_pool.vfs_info
+ print(virt_pool.vfs_info)
virt_pool.reserve_cpu('e')
- print "Reserve three cores from resource pool"
- print virt_pool.unused_cores
- print "Alloc two cores on socket1 for VM-test1"
- print virt_pool.alloc_cpu(vm="test1", number=2, socket=1)
- print "Alloc two cores in list for VM-test2"
- print virt_pool.alloc_cpu(vm="test2", corelist=['4', '5'])
- print "Alloc two cores for VM-test3"
- print virt_pool.alloc_cpu(vm="test3", number=2)
- print "Alloc port for VM-test1"
- print virt_pool.alloc_port(vm='test1')
- print "Alloc information after allocated"
- print virt_pool.allocated_info
-
- print "Get cores on VM-test1"
- print virt_pool.get_cpu_on_vm("test1")
- print "Get pfs on VM-test1"
- print virt_pool.get_pfs_on_vm("test1")
- print "Get vfs on VM-test2"
- print virt_pool.get_vfs_on_vm("test2")
+ print("Reserve three cores from resource pool")
+ print(virt_pool.unused_cores)
+ print("Alloc two cores on socket1 for VM-test1")
+ print(virt_pool.alloc_cpu(vm="test1", number=2, socket=1))
+ print("Alloc two cores in list for VM-test2")
+ print(virt_pool.alloc_cpu(vm="test2", corelist=['4', '5']))
+ print("Alloc two cores for VM-test3")
+ print(virt_pool.alloc_cpu(vm="test3", number=2))
+ print("Alloc port for VM-test1")
+ print(virt_pool.alloc_port(vm='test1'))
+ print("Alloc information after allocated")
+ print(virt_pool.allocated_info)
+
+ print("Get cores on VM-test1")
+ print(virt_pool.get_cpu_on_vm("test1"))
+ print("Get pfs on VM-test1")
+ print(virt_pool.get_pfs_on_vm("test1"))
+ print("Get vfs on VM-test2")
+ print(virt_pool.get_vfs_on_vm("test2"))
diff --git a/framework/virt_scene.py b/framework/virt_scene.py
index 73f7f19..e67b3b6 100644
--- a/framework/virt_scene.py
+++ b/framework/virt_scene.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# BSD LICENSE
#
# Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
@@ -88,12 +87,12 @@ class VirtScene(object):
def prepare_vm(self):
host_cfg = None
- for conf in self.vm_confs.keys():
+ for conf in list(self.vm_confs.keys()):
if conf == 'scene':
for cfg in self.vm_confs['scene']:
- if 'suite' in cfg.keys():
+ if 'suite' in list(cfg.keys()):
self.prepare_suite(cfg['suite'])
- if 'host' in cfg.keys():
+ if 'host' in list(cfg.keys()):
self.host_bound = True
host_cfg = cfg['host'][0]
self.vm_confs.pop('scene')
@@ -111,7 +110,7 @@ class VirtScene(object):
def cleanup_vm(self):
# reload config for has been changed when handle config
self.load_config()
- for conf in self.vm_confs.keys():
+ for conf in list(self.vm_confs.keys()):
if conf != 'scene':
vm_name = conf
vm_conf = self.vm_confs[vm_name]
@@ -119,10 +118,10 @@ class VirtScene(object):
def prepare_suite(self, conf):
for param in conf:
- if 'dut' in param.keys():
+ if 'dut' in list(param.keys()):
if param['dut'] == 'vm_dut':
self.vm_dut_enable = True
- if 'type' in param.keys():
+ if 'type' in list(param.keys()):
if param['type'] == 'xen':
self.vm_type = 'xen'
# not implement yet
@@ -131,20 +130,20 @@ class VirtScene(object):
# not implement yet
if param['type'] == 'container':
self.vm_type = 'container'
- if 'portmap' in param.keys():
+ if 'portmap' in list(param.keys()):
if param['portmap'] == 'cfg':
self.auto_portmap = False
def prepare_host(self, **opts):
- if 'dpdk' not in opts.keys():
- print utils.RED("Scenario host parameter request dpdk option!!!")
+ if 'dpdk' not in list(opts.keys()):
+ print(utils.RED("Scenario host parameter request dpdk option!!!"))
raise VirtConfigParamException('host')
- if 'cores' not in opts.keys():
- print utils.RED("Scenario host parameter request cores option!!!")
+ if 'cores' not in list(opts.keys()):
+ print(utils.RED("Scenario host parameter request cores option!!!"))
raise VirtConfigParamException('host')
- if 'target' in opts.keys():
+ if 'target' in list(opts.keys()):
target = opts['target']
else:
target = self.def_target
@@ -161,11 +160,11 @@ class VirtScene(object):
def prepare_cpu(self, vm_name, conf):
cpu_param = {}
for params in conf:
- if 'cpu' in params.keys():
+ if 'cpu' in list(params.keys()):
cpu_conf = params['cpu'][0]
break
- if 'skipcores' in cpu_conf.keys():
+ if 'skipcores' in list(cpu_conf.keys()):
cpus = cpu_conf['skipcores'].split()
# remove invalid configured core
for cpu in cpus:
@@ -176,7 +175,7 @@ class VirtScene(object):
# reserve those skipped cores
self.host_dut.virt_pool.reserve_cpu(core_mask)
- if 'numa' in cpu_conf.keys():
+ if 'numa' in list(cpu_conf.keys()):
if cpu_conf['numa'] == 'auto':
numa = self.host_dut.ports_info[0]['port'].socket
else:
@@ -184,22 +183,22 @@ class VirtScene(object):
else:
numa = 0
- if 'number' in cpu_conf.keys():
+ if 'number' in list(cpu_conf.keys()):
num = int(cpu_conf['number'])
else:
num = 2
- if 'model' in cpu_conf.keys():
+ if 'model' in list(cpu_conf.keys()):
model = cpu_conf['model']
else:
model = 'host'
cpu_topo = ''
- if 'cpu_topo' in cpu_conf.keys():
+ if 'cpu_topo' in list(cpu_conf.keys()):
cpu_topo = cpu_conf['cpu_topo']
pin_cores = []
- if 'cpu_pin' in cpu_conf.keys():
+ if 'cpu_pin' in list(cpu_conf.keys()):
pin_cores = cpu_conf['cpu_pin'].split()
if len(pin_cores):
@@ -222,7 +221,7 @@ class VirtScene(object):
def prepare_devices(self, conf):
for params in conf:
- if 'dev_gen' in params.keys():
+ if 'dev_gen' in list(params.keys()):
index = conf.index(params)
for param in params['dev_gen']:
self.handle_dev_gen(**param)
@@ -231,19 +230,19 @@ class VirtScene(object):
def cleanup_devices(self, conf):
for params in conf:
- if 'dev_gen' in params.keys():
+ if 'dev_gen' in list(params.keys()):
for param in params['dev_gen']:
self.handle_dev_destroy(**param)
def prepare_vmdevice(self, conf):
for params in conf:
- if 'device' in params.keys():
+ if 'device' in list(params.keys()):
for param in params['device']:
- if 'vf_idx' in param.keys():
+ if 'vf_idx' in list(param.keys()):
new_param = self.prepare_vf_conf(param)
index = params['device'].index(param)
params['device'][index] = new_param
- elif 'pf_idx' in param.keys():
+ elif 'pf_idx' in list(param.keys()):
new_param = self.prepare_pf_conf(param)
index = params['device'].index(param)
params['device'][index] = new_param
@@ -270,7 +269,7 @@ class VirtScene(object):
def prepare_vf_conf(self, param):
vf_param = {}
# strip vf pci id
- if 'pf_dev' in param.keys():
+ if 'pf_dev' in list(param.keys()):
pf = int(param['pf_dev'])
pf_net = self.host_dut.ports_info[pf]['port']
vfs = self.host_dut.ports_info[pf]['vfs_port']
@@ -282,10 +281,10 @@ class VirtScene(object):
vf_param['opt_host'] = vf_pci
if param['guestpci'] != 'auto':
vf_param['opt_addr'] = param['guestpci']
- if 'mac' in param.keys():
+ if 'mac' in list(param.keys()):
pf_net.set_vf_mac_addr(vf_idx, param['mac'])
else:
- print utils.RED("Invalid vf device config, request pf_dev")
+ print(utils.RED("Invalid vf device config, request pf_dev"))
return vf_param
@@ -298,33 +297,33 @@ class VirtScene(object):
self.reg_postvm_cmds(command)
def handle_dev_gen(self, **opts):
- if 'pf_idx' in opts.keys():
+ if 'pf_idx' in list(opts.keys()):
port = int(opts['pf_idx'])
- if 'vf_num' in opts.keys():
+ if 'vf_num' in list(opts.keys()):
vf_num = int(opts['vf_num'])
else:
- print utils.RED("No vf_num for port %d, assum one VF" % port)
+ print(utils.RED("No vf_num for port %d, assum one VF" % port))
vf_num = 1
- if 'driver' in opts.keys():
+ if 'driver' in list(opts.keys()):
driver = opts['driver']
try:
- print utils.GREEN("create vf %d %d %s" % (port, vf_num, driver))
+ print(utils.GREEN("create vf %d %d %s" % (port, vf_num, driver)))
self.host_dut.generate_sriov_vfs_by_port(port, vf_num, driver)
self.reset_pf_cmds(port)
except:
- print utils.RED("Failed to create vf as requested!!!")
+ print(utils.RED("Failed to create vf as requested!!!"))
raise VirtDeviceCreateException
def handle_dev_destroy(self, **opts):
- if 'pf_idx' in opts.keys():
+ if 'pf_idx' in list(opts.keys()):
port = int(opts['pf_idx'])
try:
- print utils.GREEN("destroy vfs on port %d" % port)
+ print(utils.GREEN("destroy vfs on port %d" % port))
self.host_dut.destroy_sriov_vfs_by_port(port)
except:
- print utils.RED("Failed to destroy vf as requested!!!")
+ print(utils.RED("Failed to destroy vf as requested!!!"))
def reg_prevm_cmds(self, command):
"""
@@ -344,7 +343,7 @@ class VirtScene(object):
def run_pre_cmds(self):
for cmd in self.pre_cmds:
if cmd['type'] == 'vm':
- print utils.RED("Can't run vm command when vm not ready")
+ print(utils.RED("Can't run vm command when vm not ready"))
elif cmd['type'] == 'host':
crb = self.host_dut
elif cmd['type'] == 'tester':
@@ -352,17 +351,17 @@ class VirtScene(object):
else:
crb = self.host_dut
- if 'expect' not in cmd.keys():
+ if 'expect' not in list(cmd.keys()):
expect = "# "
else:
expect = cmd['expect']
- if 'verify' not in cmd.keys():
+ if 'verify' not in list(cmd.keys()):
verify = False
else:
verify = cmd['verify']
- if 'timeout' not in cmd.keys():
+ if 'timeout' not in list(cmd.keys()):
timeout = 5
else:
timeout = cmd['timeout']
@@ -371,7 +370,7 @@ class VirtScene(object):
verify=verify)
if type(ret) is int and ret != 0:
- print utils.RED("Failed to run command %s" % cmd['command'])
+ print(utils.RED("Failed to run command %s" % cmd['command']))
raise VirtVmOperationException
def reg_postvm_cmds(self, command):
@@ -399,17 +398,17 @@ class VirtScene(object):
else:
crb = self.host_dut
- if 'expect' not in cmd.keys():
+ if 'expect' not in list(cmd.keys()):
expect = "# "
else:
expect = cmd['expect']
- if 'verify' not in cmd.keys():
+ if 'verify' not in list(cmd.keys()):
verify = False
else:
verify = cmd['verify']
- if 'timeout' not in cmd.keys():
+ if 'timeout' not in list(cmd.keys()):
timeout = 5
else:
timeout = cmd['timeout']
@@ -418,12 +417,12 @@ class VirtScene(object):
verify=verify)
if type(ret) is int and ret != 0:
- print utils.RED("Failed to run command %s" % cmd['command'])
+ print(utils.RED("Failed to run command %s" % cmd['command']))
raise VirtVmOperationException
def merge_params(self, vm, params):
for param in params:
- index = vm.find_option_index(param.keys()[0])
+ index = vm.find_option_index(list(param.keys())[0])
if index is not None:
vm.params[index] = param
else:
@@ -434,14 +433,14 @@ class VirtScene(object):
def get_cputopo(self, params):
for param in params:
- if 'cpu' in param.keys():
+ if 'cpu' in list(param.keys()):
cpu_topo = param['cpu'][0]['cputopo']
return cpu_topo
def start_vms(self):
self.vms = []
if self.vm_type == 'kvm':
- for vm_name in self.vm_confs.keys():
+ for vm_name in list(self.vm_confs.keys()):
# tricky here, QEMUKvm based on suite and vm name
# suite is virt_global, vm_name just the type
vm = QEMUKvm(self.host_dut, self.vm_type.upper(),
@@ -468,12 +467,12 @@ class VirtScene(object):
self.vms.append(vm_info)
except Exception as e:
- print utils.RED("Failure for %s" % str(e))
+ print(utils.RED("Failure for %s" % str(e)))
def get_vm_duts(self):
duts = []
for vm_info in self.vms:
- for vm_obj in vm_info.keys():
+ for vm_obj in list(vm_info.keys()):
if 'session' in vm_obj:
duts.append(vm_info[vm_obj])
@@ -488,18 +487,18 @@ class VirtScene(object):
def set_target(self, target):
for vm_info in self.vms:
- for vm_obj in vm_info.keys():
+ for vm_obj in list(vm_info.keys()):
if 'session' in vm_obj:
vm_info[vm_obj].set_target(target)
def destroy_scene(self):
for vm_info in self.vms:
- for vm_obj in vm_info.keys():
+ for vm_obj in list(vm_info.keys()):
if 'session' in vm_obj:
vm_info[vm_obj].kill_all()
vm_info[vm_obj].close()
vm_info[vm_obj].logger.logger_exit()
- for vm_obj in vm_info.keys():
+ for vm_obj in list(vm_info.keys()):
if 'session' not in vm_obj:
vm_info[vm_obj].stop()
vm_info[vm_obj] = None
@@ -511,11 +510,11 @@ if __name__ == "__main__":
class QEMUKvm():
def __init__(self, dut, vm_name, suite_name):
- print vm_name
- print suite_name
+ print(vm_name)
+ print(suite_name)
def start(self):
- print self.params
+ print(self.params)
return True
class simple_dev(object):
@@ -540,7 +539,7 @@ if __name__ == "__main__":
def send_expect(self, cmds, expected, timeout=5,
alt_session=False, verify=False):
- print cmds + "---" + expected
+ print(cmds + "---" + expected)
class simple_resource(object):
@@ -548,10 +547,10 @@ if __name__ == "__main__":
pass
def reserve_cpu(self, coremask):
- print "reserve " + coremask
+ print("reserve " + coremask)
def alloc_cpu(self, vm='', number=-1, socket=-1, corelist=None):
- print "alloc %s num %d on socket %d" % (vm, number, socket)
+ print("alloc %s num %d on socket %d" % (vm, number, socket))
dut = simple_dut()
scene = VirtScene(dut, None, "vf_passthrough")
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [dts] [next][PATCH V1 2/5] tests: modify test suites to support python3
2020-01-12 22:18 [dts] [next][PATCH V1 0/5] dts: modify dts to support python3 xinfengx
2020-01-12 22:18 ` [dts] [next][PATCH V1 1/5] framework: modify dts framework " xinfengx
@ 2020-01-12 22:18 ` xinfengx
2020-01-12 22:18 ` [dts] [next][PATCH V1 3/5] dep: modify dts dep " xinfengx
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: xinfengx @ 2020-01-12 22:18 UTC (permalink / raw)
To: dts; +Cc: xinfengx
Signed-off-by: xinfengx <xinfengx.zhao@intel.com>
---
tests/TestSuite_checksum_offload.py | 17 +-
tests/TestSuite_cloud_filter.py | 18 +-
tests/TestSuite_crypto_perf_cryptodev_perf.py | 10 +-
| 14 +-
tests/TestSuite_cvl_fdir.py | 26 +-
tests/TestSuite_cvl_switch_filter.py | 265 +-----------------
tests/TestSuite_ddp_gtp.py | 34 +--
tests/TestSuite_ddp_gtp_qregion.py | 46 +--
tests/TestSuite_ddp_mpls.py | 2 +-
tests/TestSuite_ddp_ppp_l2tp.py | 86 +++---
tests/TestSuite_distributor.py | 2 +-
tests/TestSuite_dpdk_gro_lib.py | 16 +-
tests/TestSuite_dpdk_gso_lib.py | 20 +-
tests/TestSuite_dpdk_hugetlbfs_mount_size.py | 2 +-
tests/TestSuite_dual_vlan.py | 4 +-
tests/TestSuite_dynamic_config.py | 2 +-
tests/TestSuite_dynamic_flowtype.py | 28 +-
tests/TestSuite_dynamic_queue.py | 2 +-
...e_enable_package_download_in_ice_driver.py | 8 +-
tests/TestSuite_etag.py | 30 +-
tests/TestSuite_ethtool_stats.py | 27 +-
tests/TestSuite_eventdev_pipeline.py | 2 +-
tests/TestSuite_fdir.py | 49 ++--
tests/TestSuite_fips_cryptodev.py | 2 +-
tests/TestSuite_flow_classify.py | 16 +-
tests/TestSuite_flow_filtering.py | 2 +-
tests/TestSuite_fm10k_perf.py | 34 +--
| 2 +-
tests/TestSuite_ftag.py | 2 +-
tests/TestSuite_generic_filter.py | 10 +-
tests/TestSuite_generic_flow_api.py | 6 +-
tests/TestSuite_hotplug_mp.py | 2 +-
tests/TestSuite_iavf.py | 2 +-
tests/TestSuite_inline_ipsec.py | 10 +-
tests/TestSuite_ipfrag.py | 6 +-
tests/TestSuite_ipgre.py | 18 +-
tests/TestSuite_ipsec_gw_cryptodev_func.py | 2 +-
| 2 +-
tests/TestSuite_jumboframes.py | 2 +-
tests/TestSuite_keep_alive.py | 2 +-
tests/TestSuite_kernelpf_iavf.py | 14 +-
tests/TestSuite_l2fwd.py | 4 +-
tests/TestSuite_l2fwd_cryptodev_func.py | 59 ++--
tests/TestSuite_l2fwd_jobstats.py | 2 +-
tests/TestSuite_l3fwd.py | 8 +-
tests/TestSuite_l3fwd_em.py | 4 +-
tests/TestSuite_l3fwdacl.py | 6 +-
tests/TestSuite_loadbalancer.py | 2 +-
tests/TestSuite_mac_filter.py | 3 +-
tests/TestSuite_macsec_for_ixgbe.py | 4 +-
tests/TestSuite_mdd.py | 1 +
tests/TestSuite_metrics.py | 36 +--
tests/TestSuite_multicast.py | 4 +-
tests/TestSuite_multiple_pthread.py | 4 +-
tests/TestSuite_nic_single_core_perf.py | 17 +-
tests/TestSuite_nvgre.py | 16 +-
tests/TestSuite_packet_capture.py | 16 +-
tests/TestSuite_performance_thread.py | 2 +-
tests/TestSuite_pmd_bonded.py | 2 +-
tests/TestSuite_pmd_bonded_8023ad.py | 15 +-
tests/TestSuite_pmd_stacked_bonded.py | 6 +-
tests/TestSuite_pmdpcap.py | 10 +-
| 18 +-
| 16 +-
tests/TestSuite_port_control.py | 1 +
tests/TestSuite_power_empty_poll.py | 8 +-
tests/TestSuite_power_pbf.py | 16 +-
tests/TestSuite_power_pstate.py | 6 +-
tests/TestSuite_ptpclient.py | 8 +-
tests/TestSuite_ptype_mapping.py | 8 +-
tests/TestSuite_pvp_diff_qemu_version.py | 4 +-
.../TestSuite_pvp_multi_paths_performance.py | 2 +-
...lti_paths_vhost_single_core_performance.py | 2 +-
...ti_paths_virtio_single_core_performance.py | 2 +-
tests/TestSuite_pvp_vhost_user_reconnect.py | 4 +-
tests/TestSuite_pvp_virtio_bonding.py | 6 +-
tests/TestSuite_qinq_filter.py | 2 +-
tests/TestSuite_qos_api.py | 4 +-
tests/TestSuite_queue_region.py | 4 +-
tests/TestSuite_queue_start_stop.py | 22 +-
tests/TestSuite_quota_watermark.py | 2 +-
| 2 +-
tests/TestSuite_rteflow_priority.py | 3 +-
...estSuite_runtime_vf_queue_number_kernel.py | 4 +-
tests/TestSuite_rxtx_offload.py | 6 +-
tests/TestSuite_short_live.py | 8 +-
tests/TestSuite_shutdown_api.py | 14 +-
tests/TestSuite_sriov_kvm.py | 12 +-
tests/TestSuite_telemetry.py | 40 +--
tests/TestSuite_timer.py | 2 +-
tests/TestSuite_tso.py | 23 +-
tests/TestSuite_tx_preparation.py | 4 +-
tests/TestSuite_uni_pkt.py | 20 +-
tests/TestSuite_unit_tests_cryptodev_func.py | 2 +-
tests/TestSuite_unit_tests_dump.py | 10 +-
tests/TestSuite_unit_tests_loopback.py | 2 +-
tests/TestSuite_unit_tests_pmd_perf.py | 2 +-
tests/TestSuite_userspace_ethtool.py | 20 +-
tests/TestSuite_vdev_primary_secondary.py | 4 +-
tests/TestSuite_veb_switch.py | 4 +-
tests/TestSuite_vf_daemon.py | 2 +-
tests/TestSuite_vf_kernel.py | 10 +-
tests/TestSuite_vf_macfilter.py | 22 +-
tests/TestSuite_vf_offload.py | 26 +-
tests/TestSuite_vf_packet_rxtx.py | 4 +-
tests/TestSuite_vf_port_start_stop.py | 2 +-
| 12 +-
tests/TestSuite_vf_to_vf_nic_bridge.py | 4 +-
tests/TestSuite_vhost_dequeue_zero_copy.py | 10 +-
tests/TestSuite_vhost_event_idx_interrupt.py | 4 +-
tests/TestSuite_vhost_user_live_migration.py | 4 +-
tests/TestSuite_vhost_virtio_pmd_interrupt.py | 2 +-
tests/TestSuite_virtio_event_idx_interrupt.py | 6 +-
.../TestSuite_virtio_ipsec_cryptodev_func.py | 14 +-
tests/TestSuite_virtio_perf_cryptodev_func.py | 12 +-
tests/TestSuite_virtio_pvp_regression.py | 8 +-
tests/TestSuite_virtio_unit_cryptodev_func.py | 12 +-
...stSuite_virtio_user_as_exceptional_path.py | 4 +-
tests/TestSuite_vlan.py | 2 +-
tests/TestSuite_vlan_ethertype_config.py | 4 +-
tests/TestSuite_vm2vm_virtio_pmd.py | 2 +-
tests/TestSuite_vm_hotplug.py | 2 +-
tests/TestSuite_vm_power_manager.py | 12 +-
tests/TestSuite_vm_pw_mgmt_policy.py | 14 +-
tests/TestSuite_vxlan.py | 26 +-
tests/TestSuite_vxlan_gpe_support_in_i40e.py | 4 +-
tests/TestSuite_vxlan_sample.py | 42 +--
tests/bonding.py | 23 +-
tests/compress_common.py | 6 +-
tests/cryptodev_common.py | 6 +-
tests/rte_flow_common.py | 10 +-
131 files changed, 727 insertions(+), 966 deletions(-)
diff --git a/tests/TestSuite_checksum_offload.py b/tests/TestSuite_checksum_offload.py
index c890671..9bedd1e 100644
--- a/tests/TestSuite_checksum_offload.py
+++ b/tests/TestSuite_checksum_offload.py
@@ -36,7 +36,6 @@ Test support of RX/TX Checksum Offload Features by Poll Mode Drivers.
"""
-import string
import os
import re
from rst import RstReport
@@ -109,7 +108,7 @@ class TestChecksumOffload(TestCase):
self.tester.send_expect("scapy", ">>> ")
- for packet_type in packets_expected.keys():
+ for packet_type in list(packets_expected.keys()):
self.tester.send_expect("p = %s" % packets_expected[packet_type], ">>>")
out = self.tester.send_command("p.show2()", timeout=1)
chksums = checksum_pattern.findall(out)
@@ -125,7 +124,7 @@ class TestChecksumOffload(TestCase):
"""
self.dut.send_expect("start", "testpmd>")
tx_interface = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
- for packet_type in packets_sent.keys():
+ for packet_type in list(packets_sent.keys()):
self.pkt = packet.Packet(pkt_str=packets_sent[packet_type])
self.pkt.send_pkt(self.tester, tx_interface, count=4)
out = self.dut.get_session_output(timeout=1)
@@ -178,13 +177,15 @@ class TestChecksumOffload(TestCase):
filters=[{'layer': 'ether', 'config': {'src': sniff_src}}])
self.pkt = packet.Packet()
- for packet_type in packets_sent.keys():
+ for packet_type in list(packets_sent.keys()):
self.pkt.append_pkt(packets_sent[packet_type])
self.pkt.send_pkt(crb=self.tester, tx_port=tx_interface, count=4)
p = self.tester.load_tcpdump_sniff_packets(inst)
nr_packets = len(p)
+ print(p)
packets_received = [p[i].sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%") for i in range(nr_packets)]
+ print(len(packets_sent), len(packets_received))
self.verify(len(packets_sent)*4 == len(packets_received), "Unexpected Packets Drop")
for packet_received in packets_received:
@@ -241,7 +242,7 @@ class TestChecksumOffload(TestCase):
self.dut.send_expect("start", "testpmd>")
result = self.checksum_validate(pktsChkErr, pkts)
self.dut.send_expect("stop", "testpmd>")
- self.verify(len(result) == 0, string.join(result.values(), ","))
+ self.verify(len(result) == 0, ",".join(list(result.values())))
def test_rx_checksum_valid_flags(self):
"""
@@ -319,7 +320,7 @@ class TestChecksumOffload(TestCase):
self.dut.send_expect("stop", "testpmd>")
- self.verify(len(result) == 0, string.join(result.values(), ","))
+ self.verify(len(result) == 0, ",".join(list(result.values())))
def test_checksum_offload_disable(self):
"""
@@ -346,7 +347,7 @@ class TestChecksumOffload(TestCase):
self.dut.send_expect("start", "testpmd>")
result = self.checksum_validate(sndPkts, expPkts)
- self.verify(len(result) == 0, string.join(result.values(), ","))
+ self.verify(len(result) == 0, ",".join(list(result.values())))
self.dut.send_expect("stop", "testpmd>")
@@ -436,7 +437,7 @@ class TestChecksumOffload(TestCase):
self.checksum_enablesw(self.dut_ports[1])
self.dut.send_expect("start", "testpmd> ", 3)
- for ptype in pkts.keys():
+ for ptype in list(pkts.keys()):
self.benchmark(
lcore, ptype, mode, pkts[ptype], sizes, self.nic)
diff --git a/tests/TestSuite_cloud_filter.py b/tests/TestSuite_cloud_filter.py
index 51647ef..ae4fc4e 100644
--- a/tests/TestSuite_cloud_filter.py
+++ b/tests/TestSuite_cloud_filter.py
@@ -153,7 +153,7 @@ class CloudFilterConfig(object):
'QUEUE': self.cf_rule['queue'],
'ID': self.rule_idx}
- print ethtool_cmd
+ print(ethtool_cmd)
out = self.case.dut.send_expect(ethtool_cmd, "# ", alt_session=True)
self.case.verify("ethtool" not in out, "Add cloud filter failed!!!")
@@ -179,18 +179,18 @@ class CloudFilterConfig(object):
"""
ether_cfg = {'src': self.case.tester_mac}
if match:
- if 'iip' in self.cf_rule.keys():
+ if 'iip' in list(self.cf_rule.keys()):
self.pkt.config_layer(
'inner_ipv4', {'dst': self.cf_rule['iip']})
- if 'imac' in self.cf_rule.keys():
+ if 'imac' in list(self.cf_rule.keys()):
self.pkt.config_layer(
'inner_mac', {'dst': self.cf_rule['imac']})
- if 'omac' in self.cf_rule.keys():
+ if 'omac' in list(self.cf_rule.keys()):
ether_cfg['dst'] = self.cf_rule['omac']
- if 'ivlan' in self.cf_rule.keys():
+ if 'ivlan' in list(self.cf_rule.keys()):
self.pkt.config_layer(
'inner_vlan', {'vlan': self.cf_rule['ivlan']})
- if 'vni' in self.cf_rule.keys():
+ if 'vni' in list(self.cf_rule.keys()):
self.pkt.config_layer('vxlan', {'vni': self.cf_rule['vni']})
self.pkt.config_layer('ether', ether_cfg)
@@ -317,11 +317,11 @@ class TestCloudFilter(TestCase):
self.verify("VXLAN packet" in out, "Vxlan packet not detected")
self.verify("Inner L4 type: TCP" in out,
"Vxlan inner L4 type not detected")
- if 'vni' in cloud_cfg.cf_rule.keys():
+ if 'vni' in list(cloud_cfg.cf_rule.keys()):
vni = cloud_cfg.cf_rule['vni']
self.verify("VNI = %d" %
vni in out, "Vxlan vni value not correct")
- if 'ivlan' in cloud_cfg.cf_rule.keys():
+ if 'ivlan' in list(cloud_cfg.cf_rule.keys()):
self.verify("Inner L2 type: ETHER_VLAN" in out,
"Vxlan inner vlan not detected")
else:
@@ -353,7 +353,7 @@ class TestCloudFilter(TestCase):
self.verify(inner_ip == cloud_cfg.cf_rule['iip'],
"Inner ip not matched")
except:
- print "Kernel VF captured packet not match rule"
+ print("Kernel VF captured packet not match rule")
raise
self.logger.info("Verified vxlan %s filter pass" % cloud_cfg.cf_rule['type'])
diff --git a/tests/TestSuite_crypto_perf_cryptodev_perf.py b/tests/TestSuite_crypto_perf_cryptodev_perf.py
index 6b0fffb..defb7c2 100644
--- a/tests/TestSuite_crypto_perf_cryptodev_perf.py
+++ b/tests/TestSuite_crypto_perf_cryptodev_perf.py
@@ -87,7 +87,7 @@ class PerfTestsCryptodev(TestCase):
return
with open(self.logger.log_path + "/" + "perf_cryptodev_result.json", "w") as fv:
- json.dump(self._perf_result, fv, indent=4, encoding="utf-8")
+ json.dump(self._perf_result, fv, indent=4)
def set_up(self):
pass
@@ -435,7 +435,7 @@ class PerfTestsCryptodev(TestCase):
self.logger.debug(results)
return results
- except Exception, ex:
+ except Exception as ex:
self.logger.error(ex)
raise ex
@@ -479,7 +479,7 @@ class PerfTestsCryptodev(TestCase):
self.logger.info(cmd_str)
try:
out = self.dut.send_expect(cmd_str, "#", 600)
- except Exception, ex:
+ except Exception as ex:
self.logger.error(ex)
raise ex
@@ -515,7 +515,7 @@ class PerfTestsCryptodev(TestCase):
return False
json_result = []
- for buf_size, values in stats_results.items():
+ for buf_size, values in list(stats_results.items()):
status, delta = "PASS", 0
# delta, status
if 'accepted_tolerance' in self.get_suite_cfg():
@@ -587,6 +587,6 @@ class PerfTestsCryptodev(TestCase):
self._perf_result[case_name] = json_result
self.logger.debug(self._perf_result)
return True
- except Exception, ex:
+ except Exception as ex:
self.logger.error(ex)
return False
--git a/tests/TestSuite_cvl_advanced_rss.py b/tests/TestSuite_cvl_advanced_rss.py
index 27c67b3..b38fb8d 100644
--- a/tests/TestSuite_cvl_advanced_rss.py
+++ b/tests/TestSuite_cvl_advanced_rss.py
@@ -859,7 +859,7 @@ class AdvancedRSSTest(TestCase):
"""
#Prepare testpmd EAL and parameters
all_eal_param = self.dut.create_eal_parameters()
- print all_eal_param #print eal parameters
+ print(all_eal_param) #print eal parameters
command = "./%s/app/testpmd %s -- -i %s" % (self.dut.target, all_eal_param, "--rxq=64 --txq=64")
return command
@@ -880,11 +880,11 @@ class AdvancedRSSTest(TestCase):
self.mac_count=100
for tv in test_vectors:
out = self.dut.send_expect(tv["rte_flow_pattern"], "testpmd> ", 15) #create a rule
- print out
+ print(out)
self.dut.send_expect("start", "testpmd> ", 15)
time.sleep(2)
tv["check_func_param"]["expect_port"] = self.dut_ports[0]
- print "expect_port is", self.dut_ports[0]
+ print("expect_port is", self.dut_ports[0])
#send a packet
if isinstance(tv["scapy_str"], list):
@@ -895,13 +895,13 @@ class AdvancedRSSTest(TestCase):
for index in range(10):
pkt = Packet(pkt_str=tv["scapy_str"])
pkt.send_pkt(self.tester, tx_port=self.__tx_iface, count=self.count)
- print "packet:"
- print tv["scapy_str"]
+ print("packet:")
+ print(tv["scapy_str"])
out = self.dut.send_expect("stop", "testpmd> ",60)
- print out
+ print(out)
log_msg = tv["check_func"](out)
- print log_msg
+ print(log_msg)
rfc.check_rx_tx_packets_match(out, self.mac_count)
self.dut.send_expect("flow flush %d" % self.dut_ports[0], "testpmd> ")
diff --git a/tests/TestSuite_cvl_fdir.py b/tests/TestSuite_cvl_fdir.py
index 391547e..a8e3ef8 100644
--- a/tests/TestSuite_cvl_fdir.py
+++ b/tests/TestSuite_cvl_fdir.py
@@ -536,7 +536,7 @@ tv_mac_ipv4_tcp_queue_group = {
"rule": "flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 / ipv4 src is 192.168.0.20 dst is 192.168.0.21 ttl is 2 tos is 4 / tcp src is 22 dst is 23 / end actions rss queues 56 57 58 59 60 61 62 63 end / end",
"scapy_str": MAC_IPV4_TCP,
"check_func": rfc.check_queue,
- "check_param": {"port_id": 0, "queue": range(56, 64)}
+ "check_param": {"port_id": 0, "queue": list(range(56, 64))}
}
tv_mac_ipv4_sctp_queue_group = {
@@ -544,7 +544,7 @@ tv_mac_ipv4_sctp_queue_group = {
"rule": "flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 / ipv4 src is 192.168.0.20 dst is 192.168.0.21 ttl is 2 tos is 4 / sctp src is 22 dst is 23 tag is 1 / end actions rss queues 0 1 2 3 end / end",
"scapy_str": MAC_IPV4_SCTP,
"check_func": rfc.check_queue,
- "check_param": {"port_id": 0, "queue": range(4)}
+ "check_param": {"port_id": 0, "queue": list(range(4))}
}
tv_mac_ipv6_pay_queue_group = {
@@ -584,7 +584,7 @@ tv_mac_ipv4_tun_ipv4_pay_queue_group = {
"rule": "flow create 0 ingress pattern eth / ipv4 / udp / vxlan / ipv4 src is 192.168.0.20 dst is 192.168.0.21 / end actions rss queues 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 end / end",
"scapy_str": MAC_IPV4_TUN_IPV4_PAY_MAC_IPV4_TUN_MAC_IPV4_PAY,
"check_func": rfc.check_queue,
- "check_param": {"port_id": 0, "queue": range(9, 25)}
+ "check_param": {"port_id": 0, "queue": list(range(9, 25))}
}
tv_mac_ipv4_tun_ipv4_udp_queue_group = {
@@ -861,7 +861,7 @@ class TestCVLFdir(TestCase):
if rule_list:
p = re.compile("^(\d+)\s")
li = out.splitlines()
- res = filter(bool, map(p.match, li))
+ res = list(filter(bool, list(map(p.match, li))))
result = [i.group(1) for i in res]
self.verify(sorted(result) == sorted(rule_list),
"check rule list failed. expect %s, result %s" % (rule_list, result))
@@ -924,13 +924,13 @@ class TestCVLFdir(TestCase):
# check not rule exists
self.check_rule(port_id=port_id, stats=False)
test_results[tv["name"]] = True
- print(GREEN("case passed: %s" % tv["name"]))
+ print((GREEN("case passed: %s" % tv["name"])))
except Exception as e:
- print(RED(e))
+ print((RED(e)))
test_results[tv["name"]] = False
continue
failed_cases = []
- for k, v in test_results.items():
+ for k, v in list(test_results.items()):
if not v:
failed_cases.append(k)
self.verify(all(test_results.values()), "{} failed.".format(failed_cases))
@@ -1035,7 +1035,7 @@ class TestCVLFdir(TestCase):
if rule_list:
p = re.compile("^(\d+)\s")
li = out.splitlines()
- res = filter(bool, map(p.match, li))
+ res = list(filter(bool, list(map(p.match, li))))
result = [i.group(1) for i in res]
self.verify(sorted(result) == sorted(rule_list),
"check rule list failed. expect %s, result %s" % (rule_list, result))
@@ -1122,12 +1122,12 @@ class TestCVLFdir(TestCase):
try:
self.create_fdir_rule(rule5, check_stats=True)
out = self.send_pkts_getouput(pkts=MAC_IPV4_PAY["match"])
- rfc.check_queue(out, pkt_num=len(MAC_IPV4_PAY["match"]), check_param={"port_id": 0, "queue": range(64)})
+ rfc.check_queue(out, pkt_num=len(MAC_IPV4_PAY["match"]), check_param={"port_id": 0, "queue": list(range(64))})
out = self.send_pkts_getouput(pkts=MAC_IPV4_PAY["unmatch"])
- rfc.check_queue(out, pkt_num=len(MAC_IPV4_PAY["unmatch"]), check_param={"port_id": 0, "queue": range(64)})
+ rfc.check_queue(out, pkt_num=len(MAC_IPV4_PAY["unmatch"]), check_param={"port_id": 0, "queue": list(range(64))})
except Exception as e:
result = False
- print(RED("failed:" + str(e)))
+ print((RED("failed:" + str(e))))
finally:
# restore testpmd config to default, then verify results
self.config_testpmd()
@@ -1140,7 +1140,7 @@ class TestCVLFdir(TestCase):
# create fdir rule
rule_li = self.create_fdir_rule(rule, check_stats=True)
out = self.send_pkts_getouput(pkts=p_gtpu1, port_id=1, mark=True)
- check_param = {"port_id": 1, "queue": range(64), "mark_id": 100}
+ check_param = {"port_id": 1, "queue": list(range(64)), "mark_id": 100}
rfc.check_mark(out, pkt_num=1, check_param=check_param)
out = self.send_pkts_getouput(pkts=p_gtpu2, port_id=1, mark=True)
@@ -1316,7 +1316,7 @@ class TestCVLFdir(TestCase):
self.check_fdir_rule(0, stats=True, rule_list=res)
self.dut.send_command("flow flush 0", timeout=1)
out = self.send_pkts_getouput(pkts=[pkt1, pkt2, pkt3, pkt4, pkt5])
- rfc.check_queue(out, pkt_num=5, check_param={"port_id": 0, "queue": range(1, 6)}, stats=False)
+ rfc.check_queue(out, pkt_num=5, check_param={"port_id": 0, "queue": list(range(1, 6))}, stats=False)
out6 = self.send_pkts_getouput(pkt6, count=10)
rfc.check_drop(out6, pkt_num=10, check_param={"port_id": 0}, stats=False)
out7 = self.send_pkts_getouput(pkt7, count=10)
diff --git a/tests/TestSuite_cvl_switch_filter.py b/tests/TestSuite_cvl_switch_filter.py
index d060ec9..6d6e696 100644
--- a/tests/TestSuite_cvl_switch_filter.py
+++ b/tests/TestSuite_cvl_switch_filter.py
@@ -2265,224 +2265,6 @@ tvs_mac_ipv6_tcp_pipeline_mode = [
tv_mac_ipv6_tcp_pipeline_mode_drop_03
]
-tv_mac_ipv4_in_queue_01 = {
- "name":"tv_mac_ipv4_in_queue_01",
- "rte_flow_pattern":"flow create 0 ingress pattern eth dst is 68:05:ca:8d:ed:a8 / ipv4 src is 192.168.0.1 dst is 192.168.0.2 tos is 4 ttl is 2 / end actions queue index 4 / end",
- "matched":{"scapy_str":['Ether(dst="68:05:ca:8d:ed:a8")/IP(src="192.168.0.1",dst="192.168.0.2",tos=4,ttl=2)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_in_queue,
- "param":{"expect_port":0, "expect_queues":4}},
- "expect_results":{"expect_pkts":1}},
- "mismatched":{"scapy_str":['Ether(dst="68:05:ca:8d:ed:a9")/IP(src="192.168.9",dst="192.168.6.12",tos=4,ttl=2)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_in_queue_mismatched,
- "param":{"expect_port":0, "expect_queues":4}},
- "expect_results":{"expect_pkts":1}}
-}
-
-tv_mac_ipv4_drop_queue_02 = {
- "name":"tv_mac_ipv4_drop_queue_02",
- "rte_flow_pattern":"flow create 0 ingress pattern eth dst is 68:05:ca:8d:ed:a8 / ipv4 src is 192.168.0.1 dst is 192.168.0.3 tos is 4 ttl is 2 / end actions drop / end",
- "matched":{"scapy_str":['Ether(dst="68:05:ca:8d:ed:a8")/IP(src="192.168.0.1",dst="192.168.0.3",tos=4,ttl=2)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_drop,
- "param":{"expect_port":0, "expect_queues":"null"}},
- "expect_results":{"expect_pkts":1}},
- "mismatched":{"scapy_str":['Ether(dst="68:05:ca:8d:ed:a8")/IP(src="192.168.5.6",dst="192.168.5.15",tos=2,ttl=5)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_drop_mismatched,
- "param":{"expect_port":0, "expect_queues":"null"}},
- "expect_results":{"expect_pkts":1}}
-}
-
-tv_mac_ipv4_udp_in_queue_01 = {
- "name":"tv_mac_ipv4_udp_in_queue_01",
- "rte_flow_pattern":"flow create 0 ingress pattern eth dst is 68:05:ca:8d:ed:a8 / ipv4 src is 192.168.0.1 dst is 192.168.0.2 tos is 4 ttl is 3 / udp src is 25 dst is 23 / end actions queue index 2 / end",
- "matched":{"scapy_str":['Ether(dst="68:05:ca:8d:ed:a8")/IP(src="192.168.0.1",dst="192.168.0.2",tos=4,ttl=3)/UDP(sport=25,dport=23)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_in_queue,
- "param":{"expect_port":0, "expect_queues":2}},
- "expect_results":{"expect_pkts":1}},
- "mismatched":{"scapy_str":['Ether(dst="68:05:ca:8d:ed:a9")/IP(src="192.168.6.56",dst="192.168.5.83",tos=2,ttl=1)/UDP(sport=20,dport=33)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_in_queue_mismatched,
- "param":{"expect_port":0, "expect_queues":2}},
- "expect_results":{"expect_pkts":1}}
-}
-
-tv_mac_ipv4_udp_drop_queue_02 = {
- "name":"tv_mac_ipv4_udp_drop_queue_02",
- "rte_flow_pattern":"flow create 0 ingress pattern eth dst is 68:05:ca:8d:ed:a8 / ipv4 src is 192.168.0.1 dst is 192.168.0.3 tos is 4 / udp src is 25 dst is 23 / end actions drop / end",
- "matched":{"scapy_str":['Ether(dst="68:05:ca:8d:ed:a8")/IP(src="192.168.0.1",dst="192.168.0.3",tos=4)/UDP(sport=25,dport=23)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_drop,
- "param":{"expect_port":0, "expect_queues":"null"}},
- "expect_results":{"expect_pkts":1}},
- "mismatched":{"scapy_str":['Ether(dst="68:05:ca:8d:ed:98")/IP(src="192.168.6.3",dst="192.168.8.5",tos=4)/UDP(sport=85,dport=62)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_drop_mismatched,
- "param":{"expect_port":0, "expect_queues":"null"}},
- "expect_results":{"expect_pkts":1}}
-}
-
-tv_mac_ipv4_tcp_in_queue_01 = {
- "name":"tv_mac_ipv4_tcp_in_queue_01",
- "rte_flow_pattern":"flow create 0 ingress pattern eth dst is 68:05:ca:8d:ed:a8 / ipv4 src is 192.168.0.1 dst is 192.168.0.32 tos is 4 / tcp src is 25 dst is 23 / end actions queue index 6 / end",
- "matched":{"scapy_str":['Ether(dst="68:05:ca:8d:ed:a8")/IP(src="192.168.0.1",dst="192.168.0.32",tos=4)/TCP(sport=25,dport=23)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_in_queue,
- "param":{"expect_port":0, "expect_queues":6}},
- "expect_results":{"expect_pkts":1}},
- "mismatched":{"scapy_str":['Ether(dst="68:05:ca:8d:ed:a9")/IP(src="192.168.8.3",dst="192.168.15.26",tos=3)/UDP(sport=62,dport=88)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_in_queue_mismatched,
- "param":{"expect_port":0, "expect_queues":6}},
- "expect_results":{"expect_pkts":1}}
-}
-
-tv_mac_ipv4_tcp_drop_queue_02 = {
- "name":"tv_mac_ipv4_tcp_drop_queue_02",
- "rte_flow_pattern":"flow create 0 ingress pattern eth dst is 68:05:ca:8d:ed:a8 / ipv4 src is 192.168.0.1 dst is 192.168.0.3 tos is 4 / tcp src is 25 dst is 23 / end actions drop / end",
- "matched":{"scapy_str":['Ether(dst="68:05:ca:8d:ed:a8")/IP(src="192.168.0.1",dst="192.168.0.3",tos=4)/TCP(sport=25,dport=23)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_drop,
- "param":{"expect_port":0, "expect_queues":"null"}},
- "expect_results":{"expect_pkts":1}},
- "mismatched":{"scapy_str":['Ether(dst="68:05:ca:8d:ed:a9")/IP(src="192.168.5.6",dst="192.168.5.5",tos=8)/UDP(sport=55,dport=36)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_drop_mismatched,
- "param":{"expect_port":0, "expect_queues":"null"}},
- "expect_results":{"expect_pkts":1}}
-}
-
-tv_mac_ipv6_in_queue_01 = {
- "name":"tv_mac_ipv6_in_queue_01",
- "rte_flow_pattern":"flow create 0 ingress pattern eth / ipv6 src is CDCD:910A:2222:5498:8475:1111:3900:1536 dst is CDCD:910A:2222:5498:8475:1111:3900:2020 / end actions queue index 7 / end",
- "matched":{"scapy_str":['Ether()/IPv6(src="CDCD:910A:2222:5498:8475:1111:3900:1536", dst="CDCD:910A:2222:5498:8475:1111:3900:2020")/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_in_queue,
- "param":{"expect_port":0, "expect_queues":7}},
- "expect_results":{"expect_pkts":1}},
- "mismatched":{"scapy_str":['Ether()/IPv6(src="BCBC:910A:2222:5498:8475:1111:3900:8220", dst="ABAB:910A:2222:5498:8475:1111:3900:1520")/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_in_queue_mismatched,
- "param":{"expect_port":0, "expect_queues":7}},
- "expect_results":{"expect_pkts":1}}
-}
-
-tv_mac_ipv6_drop_queue_02 = {
- "name":"tv_mac_ipv6_drop_queue_02",
- "rte_flow_pattern":"flow create 0 ingress pattern eth / ipv6 src is CDCD:910A:2222:5498:8475:1111:3900:1536 dst is CDCD:910A:2222:5498:8475:1111:3900:2020 / end actions drop / end",
- "matched":{"scapy_str":['Ether()/IPv6(src="CDCD:910A:2222:5498:8475:1111:3900:1536", dst="CDCD:910A:2222:5498:8475:1111:3900:2020")/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_drop,
- "param":{"expect_port":0, "expect_queues":"null"}},
- "expect_results":{"expect_pkts":1}},
- "mismatched":{"scapy_str":['Ether()/IPv6(src="BCBC:910A:2222:5498:8475:1111:3900:8220", dst="ABAB:910A:2222:5498:8475:1111:3900:1520")/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_drop_mismatched,
- "param":{"expect_port":0, "expect_queues":"null"}},
- "expect_results":{"expect_pkts":1}}
-}
-
-
-tv_mac_ipv6_frag_in_queue_01 = {
- "name":"tv_mac_ipv6_frag_in_queue_01",
- "rte_flow_pattern":"flow create 0 ingress pattern eth / ipv6 src is CDCD:910A:2222:5498:8475:1111:3900:1536 dst is CDCD:910A:2222:5498:8475:1111:3900:2020 / end actions queue index 7 / end",
- "matched":{"scapy_str":['Ether()/IPv6(src="CDCD:910A:2222:5498:8475:1111:3900:1536", dst="CDCD:910A:2222:5498:8475:1111:3900:2020")/IPv6ExtHdrFragment()/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_in_queue,
- "param":{"expect_port":0, "expect_queues":7}},
- "expect_results":{"expect_pkts":1}},
- "mismatched":{"scapy_str":['Ether()/IPv6(src="BCBC:910A:2222:5498:8475:1111:3900:8220", dst="ABAB:910A:2222:5498:8475:1111:3900:1520")/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_in_queue_mismatched,
- "param":{"expect_port":0, "expect_queues":7}},
- "expect_results":{"expect_pkts":1}}
-}
-
-tv_mac_ipv6_frag_drop_queue_02 = {
- "name":"tv_mac_ipv6_frag_drop_queue_02",
- "rte_flow_pattern":"flow create 0 ingress pattern eth / ipv6 src is CDCD:910A:2222:5498:8475:1111:3900:1536 dst is CDCD:910A:2222:5498:8475:1111:3900:2020 / end actions drop / end",
- "matched":{"scapy_str":['Ether()/IPv6(src="CDCD:910A:2222:5498:8475:1111:3900:1536", dst="CDCD:910A:2222:5498:8475:1111:3900:2020")/IPv6ExtHdrFragment()/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_drop,
- "param":{"expect_port":0, "expect_queues":"null"}},
- "expect_results":{"expect_pkts":1}},
- "mismatched":{"scapy_str":['Ether()/IPv6(src="BCBC:910A:2222:5498:8475:1111:3900:8220", dst="ABAB:910A:2222:5498:8475:1111:3900:1520")/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_drop_mismatched,
- "param":{"expect_port":0, "expect_queues":"null"}},
- "expect_results":{"expect_pkts":1}}
-}
-
-tv_mac_ipv6_udp_in_queue_01 = {
- "name":"tv_mac_ipv6_udp_in_queue_01",
- "rte_flow_pattern":"flow create 0 ingress pattern eth / ipv6 src is CDCD:910A:2222:5498:8475:1111:3900:1518 / udp src is 25 dst is 23 / end actions queue index 7 / end",
- "matched":{"scapy_str":['Ether()/IPv6(src="CDCD:910A:2222:5498:8475:1111:3900:1518")/UDP(sport=25,dport=23)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_in_queue,
- "param":{"expect_port":0, "expect_queues":7}},
- "expect_results":{"expect_pkts":1}},
- "mismatched":{"scapy_str":['Ether()/IPv6(src="ABAB:910A:2222:5498:8475:1111:3900:1520")/UDP(sport=22,dport=12)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_in_queue_mismatched,
- "param":{"expect_port":0, "expect_queues":7}},
- "expect_results":{"expect_pkts":1}}
-}
-
-tv_mac_ipv6_udp_drop_queue_02 = {
- "name":"tv_mac_ipv6_udp_drop_queue_02",
- "rte_flow_pattern":"flow create 0 ingress pattern eth / ipv6 src is CDCD:910A:2222:5498:8475:1111:3900:1518 / udp src is 25 dst is 23 / end actions drop / end",
- "matched":{"scapy_str":['Ether()/IPv6(src="CDCD:910A:2222:5498:8475:1111:3900:1518")/UDP(sport=25,dport=23)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_drop,
- "param":{"expect_port":0, "expect_queues":"null"}},
- "expect_results":{"expect_pkts":1}},
- "mismatched":{"scapy_str":['Ether()/IPv6(src="BCBC:910A:2222:5498:8475:1111:3900:8220")/UDP(sport=62,dport=11)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_drop_mismatched,
- "param":{"expect_port":0, "expect_queues":"null"}},
- "expect_results":{"expect_pkts":1}}
-}
-
-tv_mac_ipv6_tcp_in_queue_01 = {
- "name":"tv_mac_ipv6_tcp_in_queue_01",
- "rte_flow_pattern":"flow create 0 ingress pattern eth / ipv6 src is CDCD:910A:2222:5498:8475:1111:3900:1518 / tcp src is 25 dst is 23 / end actions queue index 7 / end",
- "matched":{"scapy_str":['Ether()/IPv6(src="CDCD:910A:2222:5498:8475:1111:3900:1518")/TCP(sport=25,dport=23)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_in_queue,
- "param":{"expect_port":0, "expect_queues":7}},
- "expect_results":{"expect_pkts":1}},
- "mismatched":{"scapy_str":['Ether()/IPv6(src="ABAB:910A:2222:5498:8475:1111:3900:1520")/UDP(sport=22,dport=12)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_in_queue_mismatched,
- "param":{"expect_port":0, "expect_queues":7}},
- "expect_results":{"expect_pkts":1}}
-}
-
-tv_mac_ipv6_tcp_drop_queue_02 = {
- "name":"tv_mac_ipv6_tcp_drop_queue_02",
- "rte_flow_pattern":"flow create 0 ingress pattern eth / ipv6 src is CDCD:910A:2222:5498:8475:1111:3900:1518 / tcp src is 25 dst is 23 / end actions drop / end",
- "matched":{"scapy_str":['Ether()/IPv6(src="CDCD:910A:2222:5498:8475:1111:3900:1518")/TCP(sport=25,dport=23)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_drop,
- "param":{"expect_port":0, "expect_queues":"null"}},
- "expect_results":{"expect_pkts":1}},
- "mismatched":{"scapy_str":['Ether()/IPv6(src="BCBC:910A:2222:5498:8475:1111:3900:8220")/TCP(sport=62,dport=11)/("X"*480)'],
- "check_func":{"func":rfc.check_output_log_drop_mismatched,
- "param":{"expect_port":0, "expect_queues":"null"}},
- "expect_results":{"expect_pkts":1}}
-}
-
-tvs_mac_ipv4_non_pipeline_mode = [
- tv_mac_ipv4_in_queue_01,
- tv_mac_ipv4_drop_queue_02
- ]
-
-tvs_mac_ipv4_udp_non_pipeline_mode = [
- tv_mac_ipv4_udp_in_queue_01,
- tv_mac_ipv4_udp_drop_queue_02
- ]
-
-tvs_mac_ipv4_tcp_non_pipeline_mode = [
- tv_mac_ipv4_tcp_in_queue_01,
- tv_mac_ipv4_tcp_drop_queue_02
- ]
-
-tvs_mac_ipv6_non_pipeline_mode = [
- tv_mac_ipv6_in_queue_01,
- tv_mac_ipv6_drop_queue_02
- ]
-
-tvs_mac_ipv6_frag_non_pipeline_mode = [
- tv_mac_ipv6_frag_in_queue_01,
- tv_mac_ipv6_frag_drop_queue_02
- ]
-
-tvs_mac_ipv6_udp_non_pipeline_mode = [
- tv_mac_ipv6_udp_in_queue_01,
- tv_mac_ipv6_udp_drop_queue_02
- ]
-
-tvs_mac_ipv6_tcp_non_pipeline_mode = [
- tv_mac_ipv6_tcp_in_queue_01,
- tv_mac_ipv6_tcp_drop_queue_02
- ]
-
test_results = OrderedDict()
class SwitchFilterTest(TestCase):
@@ -2587,7 +2369,7 @@ class SwitchFilterTest(TestCase):
global test_results
- out = self.dut.send_expect(command, "testpmd> ", 350)
+ out = self.dut.send_expect(command, "testpmd> ", 300)
self.dut.send_expect("port config 0 rss-hash-key ipv4 1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd", "testpmd> ", 15)
if is_vxlan:
self.dut.send_expect("rx_vxlan_port add 4789 0", "testpmd> ", 15)
@@ -2630,7 +2412,7 @@ class SwitchFilterTest(TestCase):
#mismatched part
mismatched_dic = tv["mismatched"]
- if len(mismatched_dic.keys()) != 0:
+ if len(list(mismatched_dic.keys())) != 0:
result_flag, log_msg = self.send_and_check_packets(mismatched_dic, self.dut_ports[0])
overall_result = self.save_results(pattern_name, "mismatched", result_flag, log_msg, overall_result)
@@ -2667,23 +2449,23 @@ class SwitchFilterTest(TestCase):
self.dut.send_expect("quit", "#")
#print the results of the test case
count = 1
- for pattern in test_results.keys():
- print str(count)+". "+pattern
+ for pattern in list(test_results.keys()):
+ print(str(count)+". "+pattern)
- for flag in test_results[pattern].keys():
+ for flag in list(test_results[pattern].keys()):
result_flag = test_results[pattern][flag]["result_flag"]
log_msg = test_results[pattern][flag]["log_msg"]
- print flag+": ",
+ print(flag+": ", end=' ')
result = ""
if result_flag:
result = "Passed"
- print GREEN(result), log_msg
+ print(GREEN(result), log_msg)
else:
result = "failed"
- print RED(result+", "+log_msg)
+ print(RED(result+", "+log_msg))
- print
+ print()
count += 1
self.verify(overall_result == True, "Some test case failed.")
@@ -2865,32 +2647,3 @@ class SwitchFilterTest(TestCase):
def test_mac_ipv6_tcp_pipeline_mode(self):
command = self.create_testpmd_command_pipeline_mode()
self._rte_flow_validate_pattern(tvs_mac_ipv6_tcp_pipeline_mode, command, is_vxlan = False)
-
- def test_mac_ipv4_non_pipeline_mode(self):
- command = self.create_testpmd_command()
- self._rte_flow_validate_pattern(tvs_mac_ipv4_non_pipeline_mode, command, is_vxlan = False)
-
- def test_mac_ipv4_udp_non_pipeline_mode(self):
- command = self.create_testpmd_command()
- self._rte_flow_validate_pattern(tvs_mac_ipv4_udp_non_pipeline_mode, command, is_vxlan = False)
-
- def test_mac_ipv4_tcp_non_pipeline_mode(self):
- command = self.create_testpmd_command()
- self._rte_flow_validate_pattern(tvs_mac_ipv4_tcp_non_pipeline_mode, command, is_vxlan = False)
-
- def test_mac_ipv6_non_pipeline_mode(self):
- command = self.create_testpmd_command()
- self._rte_flow_validate_pattern(tvs_mac_ipv6_non_pipeline_mode, command, is_vxlan = False)
-
- def test_mac_ipv6_frag_non_pipeline_mode(self):
- command = self.create_testpmd_command()
- self._rte_flow_validate_pattern(tvs_mac_ipv6_frag_non_pipeline_mode, command, is_vxlan = False)
-
- def test_mac_ipv6_udp_non_pipeline_mode(self):
- command = self.create_testpmd_command()
- self._rte_flow_validate_pattern(tvs_mac_ipv6_udp_non_pipeline_mode, command, is_vxlan = False)
-
- def test_mac_ipv6_tcp_non_pipeline_mode(self):
- command = self.create_testpmd_command()
- self._rte_flow_validate_pattern(tvs_mac_ipv6_tcp_non_pipeline_mode, command, is_vxlan = False)
-
diff --git a/tests/TestSuite_ddp_gtp.py b/tests/TestSuite_ddp_gtp.py
index b8f6817..e7aa96e 100644
--- a/tests/TestSuite_ddp_gtp.py
+++ b/tests/TestSuite_ddp_gtp.py
@@ -61,7 +61,7 @@ class TestDdpGtp(TestCase):
s = re.compile(pattern)
res = s.search(out)
if res is None:
- print utils.RED('Search no queue number.')
+ print((utils.RED('Search no queue number.')))
return None
else:
if Q_strip is self.VF_Q_strip:
@@ -229,30 +229,30 @@ class TestDdpGtp(TestCase):
if type is 'fdir':
if tunnel_pkt is 'gtpc' and inner_L3 is None:
pkts = dict(
- pkts_gtpu_pay.items() +
- pkts_gtpu_ipv4.items() +
- pkts_gtpu_ipv6.items())
+ list(pkts_gtpu_pay.items()) +
+ list(pkts_gtpu_ipv4.items()) +
+ list(pkts_gtpu_ipv6.items()))
if tunnel_pkt is 'gtpu' and inner_L3 is None:
pkts = dict(
- pkts_gtpc_pay.items() +
- pkts_gtpu_ipv4.items() +
- pkts_gtpu_ipv6.items())
+ list(pkts_gtpc_pay.items()) +
+ list(pkts_gtpu_ipv4.items()) +
+ list(pkts_gtpu_ipv6.items()))
if tunnel_pkt is 'gtpu' and inner_L3 is 'ipv4':
pkts = dict(
- pkts_gtpc_pay.items() +
- pkts_gtpu_pay.items() +
- pkts_gtpu_ipv6.items())
+ list(pkts_gtpc_pay.items()) +
+ list(pkts_gtpu_pay.items()) +
+ list(pkts_gtpu_ipv6.items()))
if tunnel_pkt is 'gtpu' and inner_L3 is 'ipv6':
pkts = dict(
- pkts_gtpc_pay.items() +
- pkts_gtpu_pay.items() +
- pkts_gtpu_ipv4.items())
+ list(pkts_gtpc_pay.items()) +
+ list(pkts_gtpu_pay.items()) +
+ list(pkts_gtpu_ipv4.items()))
if type is 'clfter':
if tunnel_pkt is 'gtpc':
pkts = dict(
- pkts_gtpu_pay.items() +
- pkts_gtpu_ipv4.items() +
- pkts_gtpu_ipv6.items())
+ list(pkts_gtpu_pay.items()) +
+ list(pkts_gtpu_ipv4.items()) +
+ list(pkts_gtpu_ipv6.items()))
if tunnel_pkt is 'gtpu':
pkts = pkts_gtpc_pay
return pkts
@@ -294,7 +294,7 @@ class TestDdpGtp(TestCase):
for chksum_opt in ['good chksum', 'bad chksum']:
pkts = self.gtp_packets(
type, tunnel_pkt, inner_L3, match_opt, chk, teid)
- for packet_type in pkts.keys():
+ for packet_type in list(pkts.keys()):
count = count + 1
self.tester.scapy_append(
'sendp([%s], iface="%s")'
diff --git a/tests/TestSuite_ddp_gtp_qregion.py b/tests/TestSuite_ddp_gtp_qregion.py
index 4963f5f..5ef708e 100644
--- a/tests/TestSuite_ddp_gtp_qregion.py
+++ b/tests/TestSuite_ddp_gtp_qregion.py
@@ -38,7 +38,7 @@ class TestDdpGtpQregion(TestCase):
s = re.compile(pattern)
res = s.search(out)
if res is None:
- print utils.RED('Search no queue number.')
+ print((utils.RED('Search no queue number.')))
return None
else:
result = res.group(2)
@@ -134,7 +134,7 @@ class TestDdpGtpQregion(TestCase):
a = Ether()/IPv6()/UDP(dport=2152)/GTP_U_Header(teid=0xfe)/IPv6(dst="1001:0db8:85a3:0000:0000:8a2e:0370:0001", src="2001:0db8:85a3:0000:0000:8a2e:0370:0001")/UDP(dport=100, sport=200)/Raw("X"*20)
if flowtype == 26:
a = Ether()/IPv6()/UDP(dport=2152)/GTP_U_Header(teid=0xfe)/IP(dst="1.1.1.1", src="2.2.2.2")/UDP(dport=100, sport=200)/Raw("X"*20)
- ba = bytearray(str(a))
+ ba = bytearray(bytes(a))
rawfile_src = '/tmp/test_gtp.raw'
File = open("%s" % rawfile_src, "wb")
File.write(ba)
@@ -147,7 +147,7 @@ class TestDdpGtpQregion(TestCase):
Send packets and verify result.
"""
pkts = self.gtp_pkts(flowtype, keyword, opt)
- for packet_type in pkts.keys():
+ for packet_type in list(pkts.keys()):
self.tester.scapy_append(
'sendp([%s], iface="%s")'
% (pkts[packet_type], self.tester_intf))
@@ -209,7 +209,7 @@ class TestDdpGtpQregion(TestCase):
'dst_ipv6_32pre']:
keyword = 'src_ipv6'
pkts = self.gtp_pkts(flowtype, keyword, opt)
- for packet_type in pkts.keys():
+ for packet_type in list(pkts.keys()):
self.tester.scapy_append(
'sendp([%s], iface="%s")'
% (pkts[packet_type], self.tester_intf))
@@ -370,7 +370,7 @@ class TestDdpGtpQregion(TestCase):
outer dst could control queue, also queue number is between the queue
range(40,55).
"""
- crlwords = range(50, 58)
+ crlwords = list(range(50, 58))
self.run_gtp_test(crlwords, 25, 25, 40, 55, "dst_ipv6")
def test_teid_contrl_gtpcq(self):
@@ -380,7 +380,7 @@ class TestDdpGtpQregion(TestCase):
set configuration for teid words 44~45, enable rss, check teid could
control queue, also queue number is between the queue range(40,55).
"""
- crlwords = range(44, 46)
+ crlwords = list(range(44, 46))
self.run_gtp_test(crlwords, 25, 25, 40, 55, "teid")
def test_teid_contrl_gtpu_ipv4q(self):
@@ -391,7 +391,7 @@ class TestDdpGtpQregion(TestCase):
could control queue, also queue number is between the queue
range(1,8).
"""
- crlwords = range(44, 46)
+ crlwords = list(range(44, 46))
self.run_gtp_test(crlwords, 26, 22, 1, 8, "teid")
def test_sport_contrl_gtpu_ipv4q(self):
@@ -402,7 +402,7 @@ class TestDdpGtpQregion(TestCase):
sport could control queue, also queue number is between the queue
range(1,8).
"""
- crlwords = range(29, 30)
+ crlwords = list(range(29, 30))
self.run_gtp_test(crlwords, 26, 22, 1, 8, "sport")
def test_dport_contrl_gtpu_ipv4q(self):
@@ -413,7 +413,7 @@ class TestDdpGtpQregion(TestCase):
dport could control queue, also queue number is between the queue
range(1,8).
"""
- crlwords = range(30, 31)
+ crlwords = list(range(30, 31))
self.run_gtp_test(crlwords, 26, 22, 1, 8, "dport")
def test_inner_src_contrl_gtpu_ipv4q(self):
@@ -424,7 +424,7 @@ class TestDdpGtpQregion(TestCase):
inner src could control queue, also queue number is between the
queue range(1,8).
"""
- crlwords = range(15, 17)
+ crlwords = list(range(15, 17))
self.run_gtp_test(crlwords, 26, 22, 1, 8, "src_ip")
def test_inner_dst_contrl_gtpu_ipv4q(self):
@@ -435,7 +435,7 @@ class TestDdpGtpQregion(TestCase):
inner dst could control queue, also queue number is between the queue
range(1,8).
"""
- crlwords = range(27, 29)
+ crlwords = list(range(27, 29))
self.run_gtp_test(crlwords, 26, 22, 1, 8, "dst_ip")
def test_teid_contrl_gtpu_ipv6q(self):
@@ -446,7 +446,7 @@ class TestDdpGtpQregion(TestCase):
could control queue, also queue number is between the queue
range(10,25).
"""
- crlwords = range(44, 46)
+ crlwords = list(range(44, 46))
self.run_gtp_test(crlwords, 23, 23, 10, 25, "teid")
def test_sport_contrl_gtpu_ipv6q(self):
@@ -457,7 +457,7 @@ class TestDdpGtpQregion(TestCase):
sport could control queue, also queue number is between the queue
range(10,25).
"""
- crlwords = range(29, 30)
+ crlwords = list(range(29, 30))
self.run_gtp_test(crlwords, 23, 23, 10, 25, "sport")
def test_dport_contrl_gtpu_ipv6q(self):
@@ -468,7 +468,7 @@ class TestDdpGtpQregion(TestCase):
dport could control queue, also queue number is between the queue
range(10,25).
"""
- crlwords = range(30, 31)
+ crlwords = list(range(30, 31))
self.run_gtp_test(crlwords, 23, 23, 10, 25, "dport")
def test_inner_src_contrl_gtpu_ipv6q(self):
@@ -479,7 +479,7 @@ class TestDdpGtpQregion(TestCase):
inner src could control queue, also queue number is between the queue
range(10,25).
"""
- crlwords = range(13, 21)
+ crlwords = list(range(13, 21))
self.run_gtp_test(crlwords, 23, 23, 10, 25, "src_ipv6")
def test_inner_dst_contrl_gtpu_ipv6q(self):
@@ -490,7 +490,7 @@ class TestDdpGtpQregion(TestCase):
inner dst could control queue, also queue number is between the queue
range(10,25).
"""
- crlwords = range(21, 29)
+ crlwords = list(range(21, 29))
self.run_gtp_test(crlwords, 23, 23, 10, 25, "dst_ipv6")
def test_fd_gtpu_ipv4(self):
@@ -515,7 +515,7 @@ class TestDdpGtpQregion(TestCase):
work when sending matched dst IPv4 packets to configured queue,
otherwise direct packets to queue 0.
"""
- crlwords = range(27, 29)
+ crlwords = list(range(27, 29))
keywords = ['src_ip', 'sport', 'dport', 'dst_ip']
qchecks = ['sameq', 'sameq', 'sameq', 'difq']
self.run_fd_test(crlwords, 26, 22, keywords, qchecks)
@@ -529,7 +529,7 @@ class TestDdpGtpQregion(TestCase):
work when sending matched src IPv4 packets to configured queue,
otherwise direct packets to queue 0.
"""
- crlwords = range(15, 17)
+ crlwords = list(range(15, 17))
keywords = ['dst_ip', 'sport', 'dport', 'src_ip']
qchecks = ['sameq', 'sameq', 'sameq', 'difq']
self.run_fd_test(crlwords, 26, 22, keywords, qchecks)
@@ -556,7 +556,7 @@ class TestDdpGtpQregion(TestCase):
work when sending matched dst IPv6 packets to configured queue,
otherwise direct packets to queue 0.
"""
- crlwords = range(21, 29)
+ crlwords = list(range(21, 29))
keywords = ['src_ipv6', 'sport', 'dport', 'teid', 'dst_ipv6']
qchecks = ['sameq', 'sameq', 'sameq', 'sameq', 'difq']
self.run_fd_test(crlwords, 23, 23, keywords, qchecks)
@@ -570,7 +570,7 @@ class TestDdpGtpQregion(TestCase):
work when sending matched src IPv6 packets to configured queue,
otherwise direct packets to queue 0.
"""
- crlwords = range(13, 21)
+ crlwords = list(range(13, 21))
keywords = ['dst_ipv6', 'sport', 'dport', 'teid', 'src_ipv6']
qchecks = ['sameq', 'sameq', 'sameq', 'sameq', 'difq']
self.run_fd_test(crlwords, 23, 23, keywords, qchecks)
@@ -583,7 +583,7 @@ class TestDdpGtpQregion(TestCase):
50~53, enable rss, check dst 64 bit prefixes could control queue,
also queue number is between the queue range(40,55).
"""
- crlwords = range(50, 54)
+ crlwords = list(range(50, 54))
self.run_gtp_test(crlwords, 25, 25, 40, 55, "dst_ipv6_64pre")
def test_inner_48pre_src_contrl_gtpuq(self):
@@ -594,7 +594,7 @@ class TestDdpGtpQregion(TestCase):
13~15, enable rss, check src 48 bit prefixes could control queue,
also queue number is between the queue range(10,25).
"""
- crlwords = range(13, 16)
+ crlwords = list(range(13, 16))
self.run_gtp_test(crlwords, 23, 23, 10, 25, "src_ipv6_48pre")
def test_inner_32pre_dst_contrl_gtpuq(self):
@@ -605,7 +605,7 @@ class TestDdpGtpQregion(TestCase):
21~22, enable rss, check dst 32 bit prefixes could control queue,
also queue number is between the queue range(10,25).
"""
- crlwords = range(21, 23)
+ crlwords = list(range(21, 23))
self.run_gtp_test(crlwords, 23, 23, 10, 25, "dst_ipv6_32pre")
def tear_down(self):
diff --git a/tests/TestSuite_ddp_mpls.py b/tests/TestSuite_ddp_mpls.py
index 599e5cd..ca36adb 100644
--- a/tests/TestSuite_ddp_mpls.py
+++ b/tests/TestSuite_ddp_mpls.py
@@ -174,7 +174,7 @@ class Testddp_mpls(TestCase):
/MPLS(label=%s)/Ether()/IP()/UDP()'% label,
'mpls/bad chksum gre': 'Ether()/IP(proto=47)/GRE(chksum=0x1234,\
proto=0x8847)/MPLS(label=%s)/Ether()/IP()/UDP()'% label }
- for packet_type in pkts.keys():
+ for packet_type in list(pkts.keys()):
self.tester.scapy_append('sendp([%s], iface="%s")'
% (pkts[packet_type], self.tester_intf))
self.tester.scapy_execute()
diff --git a/tests/TestSuite_ddp_ppp_l2tp.py b/tests/TestSuite_ddp_ppp_l2tp.py
index 2dd8baf..dc011e4 100644
--- a/tests/TestSuite_ddp_ppp_l2tp.py
+++ b/tests/TestSuite_ddp_ppp_l2tp.py
@@ -38,7 +38,7 @@ class TestDdpPppL2tp(TestCase):
s = re.compile(pattern)
res = s.search(out)
if res is None:
- print utils.RED('Search no queue number.')
+ print((utils.RED('Search no queue number.')))
return None
else:
result = res.group(2)
@@ -73,7 +73,7 @@ class TestDdpPppL2tp(TestCase):
dst_ip = "2.2.2.2"
src_ipv6 = "1001:0db8:85a3:0000:0000:8a2e:0370:0001"
dst_ipv6 = "2001:0db8:85a3:0000:0000:8a2e:0370:0001"
- sessionid = hex(0x7)
+ session_id = hex(0x7)
sport = 4000
dport = 8000
if keyword is not 'def':
@@ -89,30 +89,30 @@ class TestDdpPppL2tp(TestCase):
src_ipv6 = "1001:0db8:85a3:0000:0000:8a2e:0370:0002"
if keyword is 'dst_ipv6':
dst_ipv6 = "2001:0db8:85a3:0000:0000:8a2e:0370:0002"
- if keyword is 'sessionid':
- sessionid = hex(0x8)
+ if keyword is 'session_id':
+ session_id = hex(0x8)
if keyword is 'sport':
sport = 4001
if keyword is 'dport':
dport = 8001
if flowtype == 23:
- pkts = {'IPV4/L2TP/IPV4/UDP': 'Ether()/IP()/UDP(sport=1701,dport=1701)/PPP_L2TP(proto=0x0021,sessionid=%s)/IP(src="%s",dst="%s")/UDP(sport=%d, dport=%d)/Raw("X"* 20)'
- % (sessionid, src_ip, dst_ip, sport, dport)}
+ pkts = {'IPV4/L2TP/IPV4/UDP': 'Ether()/IP()/UDP(sport=1701,dport=1701)/PPP_L2TP(proto=0x0021,session_id=%s)/IP(src="%s",dst="%s")/UDP(sport=%d, dport=%d)/Raw("X"* 20)'
+ % (session_id, src_ip, dst_ip, sport, dport)}
if flowtype == 24:
- pkts = {'IPV4/L2TP/IPV6/UDP': 'Ether()/IP()/UDP(sport=1701, dport=1701)/PPP_L2TP(proto=0x0057,sessionid=%s)/IPv6(src="%s", dst="%s")/UDP(sport=%d, dport=%d)/Raw("X"* 20)'
- % (sessionid, src_ipv6, dst_ipv6, sport, dport)}
+ pkts = {'IPV4/L2TP/IPV6/UDP': 'Ether()/IP()/UDP(sport=1701, dport=1701)/PPP_L2TP(proto=0x0057,session_id=%s)/IPv6(src="%s", dst="%s")/UDP(sport=%d, dport=%d)/Raw("X"* 20)'
+ % (session_id, src_ipv6, dst_ipv6, sport, dport)}
if flowtype == 26:
- pkts = {'IPV4/L2TP': 'Ether(src="%s", dst="%s")/IP()/UDP(dport=1701, sport=1701)/L2TP(sessionid=%s)/Raw("X"*20)'
- % (src_mac, dst_mac, sessionid)}
+ pkts = {'IPV4/L2TP': 'Ether(src="%s", dst="%s")/IP()/UDP(dport=1701, sport=1701)/L2TP(session_id=%s)/Raw("X"*20)'
+ % (src_mac, dst_mac, session_id)}
if flowtype == 28:
- pkts = {'PPPOE/IPV4/UDP': 'Ether()/PPPoE(sessionid=%s)/PPP(proto=0x21)/IP(src="%s",dst="%s")/UDP(sport=%d,dport=%d)/Raw("X"*20)'
- % (sessionid, src_ip, dst_ip, sport, dport)}
+ pkts = {'PPPOE/IPV4/UDP': 'Ether()/PPPoE(session_id=%s)/PPP(proto=0x21)/IP(src="%s",dst="%s")/UDP(sport=%d,dport=%d)/Raw("X"*20)'
+ % (session_id, src_ip, dst_ip, sport, dport)}
if flowtype == 29:
- pkts = {'PPPOE/IPV6/UDP': 'Ether()/PPPoE(sessionid=%s)/PPP(proto=0x57)/IPv6(src="%s",dst="%s")/UDP(sport=%d,dport=%d)/Raw("X"*20)'
- % (sessionid, src_ipv6, dst_ipv6, sport, dport)}
+ pkts = {'PPPOE/IPV6/UDP': 'Ether()/PPPoE(session_id=%s)/PPP(proto=0x57)/IPv6(src="%s",dst="%s")/UDP(sport=%d,dport=%d)/Raw("X"*20)'
+ % (session_id, src_ipv6, dst_ipv6, sport, dport)}
if flowtype == 30:
- pkts = {'PPPOE': 'Ether(src="%s", dst="%s")/PPPoE(sessionid=%s)'
- % (src_mac, dst_mac, sessionid)}
+ pkts = {'PPPOE': 'Ether(src="%s", dst="%s")/PPPoE(session_id=%s)'
+ % (src_mac, dst_mac, session_id)}
return pkts
def raw_packet_generate(self, flowtype):
@@ -122,18 +122,18 @@ class TestDdpPppL2tp(TestCase):
template file and packets sent to NIC.
"""
if flowtype == 23:
- a = Ether()/IP()/UDP(dport=1701, sport=1701)/PPP_L2TP(proto=0x0021, sessionid=0x7)/IP(dst="1.1.1.1", src="2.2.2.2")/UDP(dport=4000, sport=8000)
+ a = Ether()/IP()/UDP(dport=1701, sport=1701)/PPP_L2TP(proto=0x0021, session_id=0x7)/IP(dst="1.1.1.1", src="2.2.2.2")/UDP(dport=4000, sport=8000)
if flowtype == 24:
- a = Ether()/IP()/UDP(dport=1701, sport=1701)/PPP_L2TP(proto=0x0057, sessionid=0x7)/IPv6(dst="1001:0db8:85a3:0000:0000:8a2e:0370:0001", src="2001:0db8:85a3:0000:0000:8a2e:0370:0001")/UDP(dport=4000, sport=8000)/Raw("X"*20)
+ a = Ether()/IP()/UDP(dport=1701, sport=1701)/PPP_L2TP(proto=0x0057, session_id=0x7)/IPv6(dst="1001:0db8:85a3:0000:0000:8a2e:0370:0001", src="2001:0db8:85a3:0000:0000:8a2e:0370:0001")/UDP(dport=4000, sport=8000)/Raw("X"*20)
if flowtype == 26:
- a = Ether(dst="3C:FD:FE:A3:A0:01", src="4C:FD:FE:A3:A0:01")/IP()/UDP(dport=1701, sport=1701)/L2TP(sessionid=0x7)/Raw("X"*20)
+ a = Ether(dst="3C:FD:FE:A3:A0:01", src="4C:FD:FE:A3:A0:01")/IP()/UDP(dport=1701, sport=1701)/L2TP(session_id=0x7)/Raw("X"*20)
if flowtype == 28:
- a = Ether()/PPPoE(sessionid=0x7)/PPP(proto=0x21)/IP(dst="1.1.1.1", src="2.2.2.2")/UDP(dport=4000, sport=8000)/Raw("X"*20)
+ a = Ether()/PPPoE(session_id=0x7)/PPP(proto=0x21)/IP(dst="1.1.1.1", src="2.2.2.2")/UDP(dport=4000, sport=8000)/Raw("X"*20)
if flowtype == 29:
- a = Ether()/PPPoE(sessionid=0x7)/PPP(proto=0x57)/IPv6(dst="1001:0db8:85a3:0000:0000:8a2e:0370:0001", src="2001:0db8:85a3:0000:0000:8a2e:0370:0001")/UDP(dport=4000, sport=8000)/Raw("X"*20)
+ a = Ether()/PPPoE(session_id=0x7)/PPP(proto=0x57)/IPv6(dst="1001:0db8:85a3:0000:0000:8a2e:0370:0001", src="2001:0db8:85a3:0000:0000:8a2e:0370:0001")/UDP(dport=4000, sport=8000)/Raw("X"*20)
if flowtype == 30:
- a = Ether(dst="3C:FD:FE:A3:A0:01", src="4C:FD:FE:A3:A0:01")/PPPoE(sessionid=0x7)
- ba = bytearray(str(a))
+ a = Ether(dst="3C:FD:FE:A3:A0:01", src="4C:FD:FE:A3:A0:01")/PPPoE(session_id=0x7)
+ ba = bytearray(bytes(a))
rawfile_src = '/tmp/test.raw'
File = open("%s" % rawfile_src, "wb")
File.write(ba)
@@ -146,13 +146,13 @@ class TestDdpPppL2tp(TestCase):
Send packets and verify result.
"""
pkts = self.ppp_l2tp_pkts(flowtype, keyword)
- for packet_type in pkts.keys():
+ for packet_type in list(pkts.keys()):
self.tester.scapy_append(
'sendp([%s], iface="%s")'
% (pkts[packet_type], self.tester_intf))
self.tester.scapy_execute()
out = self.dut.get_session_output(timeout=2)
- print out
+ print(out)
if type is 'rss':
self.verify("PKT_RX_RSS_HASH" in out, "Failed to test RSS!!!")
pattern = "port (\d)/queue (\d{1,2}): received (\d) packets"
@@ -292,7 +292,7 @@ class TestDdpPppL2tp(TestCase):
them.
"""
crlwords = None
- keywords = ['sessionid', 'src_mac', 'dst_mac']
+ keywords = ['session_id', 'src_mac', 'dst_mac']
qchecks = ['difq', 'difq', 'sameq']
self.run_rss_test(crlwords, 30, 17, keywords, qchecks)
@@ -304,7 +304,7 @@ class TestDdpPppL2tp(TestCase):
when changing them.
"""
crlwords = None
- keywords = ['src_ip', 'dst_ip', 'sport', 'dport', 'sessionid']
+ keywords = ['src_ip', 'dst_ip', 'sport', 'dport', 'session_id']
qchecks = ['difq', 'difq', 'difq', 'difq', 'sameq']
self.run_rss_test(crlwords, 28, 15, keywords, qchecks)
@@ -316,7 +316,7 @@ class TestDdpPppL2tp(TestCase):
when changing them.
"""
crlwords = None
- keywords = ['src_ipv6', 'dst_ipv6', 'sport', 'dport', 'sessionid']
+ keywords = ['src_ipv6', 'dst_ipv6', 'sport', 'dport', 'session_id']
qchecks = ['difq', 'difq', 'difq', 'difq', 'sameq']
self.run_rss_test(crlwords, 29, 16, keywords, qchecks)
@@ -328,7 +328,7 @@ class TestDdpPppL2tp(TestCase):
them.
"""
crlwords = None
- keywords = ['sessionid', 'src_mac', 'dst_mac']
+ keywords = ['session_id', 'src_mac', 'dst_mac']
qchecks = ['difq', 'difq', 'sameq']
self.run_rss_test(crlwords, 26, 21, keywords, qchecks)
@@ -339,8 +339,8 @@ class TestDdpPppL2tp(TestCase):
configuration for session ID word 47, enable RSS, check RSS could
work and queue could change when changing session ID.
"""
- crlwords = range(47, 48)
- keywords = ['sessionid']
+ crlwords = list(range(47, 48))
+ keywords = ['session_id']
qchecks = ['difq']
self.run_rss_test(crlwords, 30, 17, keywords, qchecks)
@@ -351,7 +351,7 @@ class TestDdpPppL2tp(TestCase):
configuration for source mac words 3~5, enable RSS, check RSS could
work and queue could change when changing SA.
"""
- crlwords = range(3, 6)
+ crlwords = list(range(3, 6))
keywords = ['src_mac', 'dst_mac']
qchecks = ['difq', 'sameq']
self.run_rss_test(crlwords, 30, 17, keywords, qchecks)
@@ -364,7 +364,7 @@ class TestDdpPppL2tp(TestCase):
could change when changing them.
"""
crlwords = None
- keywords = ['src_ip', 'dst_ip', 'sport', 'dport', 'sessionid']
+ keywords = ['src_ip', 'dst_ip', 'sport', 'dport', 'session_id']
qchecks = ['difq', 'difq', 'difq', 'difq', 'sameq']
self.run_rss_test(crlwords, 23, 18, keywords, qchecks)
@@ -375,7 +375,7 @@ class TestDdpPppL2tp(TestCase):
input set configuration for IPv4 SA words 15~16, enable RSS, check
RSS could work and queue could change when changing IPv4 SA.
"""
- crlwords = range(15, 17)
+ crlwords = list(range(15, 17))
keywords = ['src_ip', 'dst_ip']
qchecks = ['difq', 'sameq']
self.run_rss_test(crlwords, 23, 18, keywords, qchecks)
@@ -387,7 +387,7 @@ class TestDdpPppL2tp(TestCase):
input set configuration for IPv4 DA words 27~28, enable RSS, check
RSS could work and queue could change when changing IPv4 DA.
"""
- crlwords = range(27, 29)
+ crlwords = list(range(27, 29))
keywords = ['dst_ip', 'src_ip']
qchecks = ['difq', 'sameq']
self.run_rss_test(crlwords, 23, 18, keywords, qchecks)
@@ -399,7 +399,7 @@ class TestDdpPppL2tp(TestCase):
input set configuration for S-Port word 29, enable RSS, check
RSS could work and queue could change when changing S-Port.
"""
- crlwords = range(29, 30)
+ crlwords = list(range(29, 30))
keywords = ['sport', 'dport']
qchecks = ['difq', 'sameq']
self.run_rss_test(crlwords, 23, 18, keywords, qchecks)
@@ -411,7 +411,7 @@ class TestDdpPppL2tp(TestCase):
input set configuration for D-Port word 30, enable RSS, check
RSS could work and queue could change when changing D-Port.
"""
- crlwords = range(30, 31)
+ crlwords = list(range(30, 31))
keywords = ['dport', 'sport']
qchecks = ['difq', 'sameq']
self.run_rss_test(crlwords, 23, 18, keywords, qchecks)
@@ -425,7 +425,7 @@ class TestDdpPppL2tp(TestCase):
queue, otherwise direct packets to queue 0.
"""
crlwords = None
- keywords = ['src_mac', 'sessionid', 'dst_mac']
+ keywords = ['src_mac', 'session_id', 'dst_mac']
qchecks = ['difq', 'difq', 'sameq']
self.run_fd_test(crlwords, 30, 17, keywords, qchecks)
@@ -438,7 +438,7 @@ class TestDdpPppL2tp(TestCase):
queue, otherwise direct packets to queue 0.
"""
crlwords = None
- keywords = ['src_mac', 'sessionid', 'dst_mac']
+ keywords = ['src_mac', 'session_id', 'dst_mac']
qchecks = ['difq', 'difq', 'sameq']
self.run_fd_test(crlwords, 26, 21, keywords, qchecks)
@@ -451,7 +451,7 @@ class TestDdpPppL2tp(TestCase):
packets to configured queue, otherwise direct packets to queue 0.
"""
crlwords = None
- keywords = ['src_ip', 'dst_ip', 'sport', 'dport', 'sessionid']
+ keywords = ['src_ip', 'dst_ip', 'sport', 'dport', 'session_id']
qchecks = ['difq', 'difq', 'difq', 'difq', 'sameq']
self.run_fd_test(crlwords, 28, 15, keywords, qchecks)
@@ -464,7 +464,7 @@ class TestDdpPppL2tp(TestCase):
packets to configured queue, otherwise direct packets to queue 0.
"""
crlwords = None
- keywords = ['src_ipv6', 'dst_ipv6', 'sport', 'dport', 'sessionid']
+ keywords = ['src_ipv6', 'dst_ipv6', 'sport', 'dport', 'session_id']
qchecks = ['difq', 'difq', 'difq', 'difq', 'sameq']
self.run_fd_test(crlwords, 29, 16, keywords, qchecks)
@@ -503,7 +503,7 @@ class TestDdpPppL2tp(TestCase):
work when sending matched IPv4 DA packets to configured queue,
otherwise direct packets to queue 0.
"""
- crlwords = range(27, 29)
+ crlwords = list(range(27, 29))
keywords = ['src_ip', 'sport', 'dport', 'dst_ip']
qchecks = ['sameq', 'sameq', 'sameq', 'difq']
self.run_fd_test(crlwords, 23, 18, keywords, qchecks)
@@ -517,7 +517,7 @@ class TestDdpPppL2tp(TestCase):
work when sending matched IPv6 DA packets to configured queue,
otherwise direct packets to queue 0.
"""
- crlwords = range(21, 29)
+ crlwords = list(range(21, 29))
keywords = ['src_ipv6', 'sport', 'dport', 'dst_ipv6']
qchecks = ['sameq', 'sameq', 'sameq', 'difq']
self.run_fd_test(crlwords, 24, 19, keywords, qchecks)
diff --git a/tests/TestSuite_distributor.py b/tests/TestSuite_distributor.py
index 3494254..aaad6c7 100644
--- a/tests/TestSuite_distributor.py
+++ b/tests/TestSuite_distributor.py
@@ -212,7 +212,7 @@ class TestDistributor(TestCase):
def _get_thread_lcore(self, core_num):
def strip_core(x):
return(int(x['thread']))
- cores = map(strip_core, self.dut.cores[0:core_num])
+ cores = list(map(strip_core, self.dut.cores[0:core_num]))
return cores
def hook_transmission_func(self):
diff --git a/tests/TestSuite_dpdk_gro_lib.py b/tests/TestSuite_dpdk_gro_lib.py
index c0fca39..f9b7d76 100644
--- a/tests/TestSuite_dpdk_gro_lib.py
+++ b/tests/TestSuite_dpdk_gro_lib.py
@@ -238,7 +238,7 @@ class TestDPDKGROLib(TestCase):
# config the cpupin only have one core
params_number = len(vm_config.params)
for i in range(params_number):
- if vm_config.params[i].keys()[0] == 'cpu':
+ if list(vm_config.params[i].keys())[0] == 'cpu':
vm_config.params[i]['cpu'][0]['number'] = 1
vm_config.params[i]['cpu'][0]['cpupin'] = self.qemu_cpupin
@@ -258,7 +258,7 @@ class TestDPDKGROLib(TestCase):
if self.vm1_dut is None:
raise Exception("Set up VM ENV failed")
except Exception as e:
- print utils.RED("Failure for %s" % str(e))
+ print((utils.RED("Failure for %s" % str(e))))
self.vm1_dut.restore_interfaces()
def iperf_result_verify(self, run_info):
@@ -266,9 +266,9 @@ class TestDPDKGROLib(TestCase):
Get the iperf test result
'''
fmsg = self.dut.send_expect("cat /root/iperf_client.log", "#")
- print fmsg
+ print(fmsg)
iperfdata = re.compile('[\d+]*.[\d+]* [M|G|K]bits/sec').findall(fmsg)
- print iperfdata
+ print(iperfdata)
self.verify(iperfdata, 'There no data about this case')
self.result_table_create(['Data', 'Unit'])
results_row = [run_info]
@@ -302,7 +302,7 @@ class TestDPDKGROLib(TestCase):
(self.virtio_ip1), '', 180)
time.sleep(30)
self.iperf_result_verify('GRO lib')
- print "the GRO lib %s " % (self.output_result)
+ print(("the GRO lib %s " % (self.output_result)))
self.dut.send_expect('rm /root/iperf_client.log', '#', 10)
# Turn off DPDK GRO lib and Kernel GRO off
self.set_testpmd_gro_off()
@@ -311,7 +311,7 @@ class TestDPDKGROLib(TestCase):
(self.virtio_ip1), '', 180)
time.sleep(30)
self.iperf_result_verify('Kernel GRO')
- print "the Kernel GRO %s " % (self.output_result)
+ print(("the Kernel GRO %s " % (self.output_result)))
self.dut.send_expect('rm /root/iperf_client.log', '#', 10)
self.quit_testpmd()
self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
@@ -342,7 +342,7 @@ class TestDPDKGROLib(TestCase):
(self.virtio_ip1), '', 180)
time.sleep(30)
self.iperf_result_verify('GRO lib')
- print "the GRO lib %s " % (self.output_result)
+ print(("the GRO lib %s " % (self.output_result)))
self.dut.send_expect('rm /root/iperf_client.log', '#', 10)
self.quit_testpmd()
self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
@@ -373,7 +373,7 @@ class TestDPDKGROLib(TestCase):
(self.virtio_ip1), '', 180)
time.sleep(30)
self.iperf_result_verify('GRO lib')
- print "the GRO lib %s " % (self.output_result)
+ print(("the GRO lib %s " % (self.output_result)))
self.dut.send_expect('rm /root/iperf_client.log', '#', 10)
self.quit_testpmd()
self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
diff --git a/tests/TestSuite_dpdk_gso_lib.py b/tests/TestSuite_dpdk_gso_lib.py
index f2307a7..28258f6 100644
--- a/tests/TestSuite_dpdk_gso_lib.py
+++ b/tests/TestSuite_dpdk_gso_lib.py
@@ -233,7 +233,7 @@ class TestDPDKGsoLib(TestCase):
# config the cpupin only have one core
params_number = len(vm_config.params)
for i in range(params_number):
- if vm_config.params[i].keys()[0] == 'cpu':
+ if list(vm_config.params[i].keys())[0] == 'cpu':
vm_config.params[i]['cpu'][0]['number'] = 1
vm_config.params[i]['cpu'][0]['cpupin'] = self.qemu_cpupin
@@ -270,7 +270,7 @@ class TestDPDKGsoLib(TestCase):
if self.vm1_dut is None:
raise Exception("Set up VM ENV failed")
except Exception as e:
- print utils.RED("Failure for %s" % str(e))
+ print((utils.RED("Failure for %s" % str(e))))
self.vm1_dut.restore_interfaces()
def iperf_result_verify(self, vm_client):
@@ -278,9 +278,9 @@ class TestDPDKGsoLib(TestCase):
Get the iperf test result
'''
fmsg = vm_client.send_expect("cat /root/iperf_client.log", "#")
- print fmsg
+ print(fmsg)
iperfdata = re.compile('[\d+]*.[\d+]* [M|G|K]bits/sec').findall(fmsg)
- print iperfdata
+ print(iperfdata)
self.verify(iperfdata, 'There no data about this case')
self.result_table_create(['Data', 'Unit'])
results_row = ['GSO']
@@ -313,7 +313,7 @@ class TestDPDKGsoLib(TestCase):
time.sleep(30)
self.dut.send_expect('^C', '#', 10)
self.iperf_result_verify(self.vm1_dut)
- print "the GSO lib for TCP traffic %s " % (self.output_result)
+ print(("the GSO lib for TCP traffic %s " % (self.output_result)))
self.vm1_dut.send_expect('rm /root/iperf_client.log', '#', 10)
self.dut.send_expect("ip netns del ns1", "#")
self.quit_testpmd()
@@ -346,7 +346,7 @@ class TestDPDKGsoLib(TestCase):
time.sleep(30)
self.dut.send_expect('^C', '#', 10)
self.iperf_result_verify(self.vm1_dut)
- print "the GSO lib for UDP traffic %s " % (self.output_result)
+ print(("the GSO lib for UDP traffic %s " % (self.output_result)))
self.vm1_dut.send_expect('rm /root/iperf_client.log', '#', 10)
self.dut.send_expect("ip netns del ns1", "#")
self.quit_testpmd()
@@ -382,7 +382,7 @@ class TestDPDKGsoLib(TestCase):
time.sleep(30)
self.dut.send_expect('^C', '#', 10)
self.iperf_result_verify(self.vm1_dut)
- print "the TSO lib %s " % (self.output_result)
+ print(("the TSO lib %s " % (self.output_result)))
self.vm1_dut.send_expect('rm /root/iperf_client.log', '#', 10)
self.quit_testpmd()
self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
@@ -418,7 +418,7 @@ class TestDPDKGsoLib(TestCase):
time.sleep(30)
self.dut.send_expect('^C', '#', 10)
self.iperf_result_verify(self.vm1_dut)
- print "Kernel GSO %s " % (self.output_result)
+ print(("Kernel GSO %s " % (self.output_result)))
self.vm1_dut.send_expect('rm /root/iperf_client.log', '#', 10)
self.quit_testpmd()
self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
@@ -453,7 +453,7 @@ class TestDPDKGsoLib(TestCase):
time.sleep(30)
self.dut.send_expect('^C', '#', 10)
self.iperf_result_verify(self.vm1_dut)
- print "NO GSO/TSO %s " % (self.output_result)
+ print(("NO GSO/TSO %s " % (self.output_result)))
self.vm1_dut.send_expect('rm /root/iperf_client.log', '#', 10)
self.quit_testpmd()
self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
@@ -484,7 +484,7 @@ class TestDPDKGsoLib(TestCase):
time.sleep(30)
self.dut.send_expect('^C', '#', 10)
self.iperf_result_verify(self.vm1_dut)
- print "the GSO lib for Vxlan traffic %s " % (self.output_result)
+ print(("the GSO lib for Vxlan traffic %s " % (self.output_result)))
self.vm1_dut.send_expect('rm /root/iperf_client.log', '#', 10)
self.dut.send_expect("ip netns del ns1", "#")
self.quit_testpmd()
diff --git a/tests/TestSuite_dpdk_hugetlbfs_mount_size.py b/tests/TestSuite_dpdk_hugetlbfs_mount_size.py
index ace73ad..de52323 100644
--- a/tests/TestSuite_dpdk_hugetlbfs_mount_size.py
+++ b/tests/TestSuite_dpdk_hugetlbfs_mount_size.py
@@ -230,7 +230,7 @@ class DpdkHugetlbfsMountSize(TestCase):
self.verify(0, 'the expect str: %s ,not in output info' % expect_str)
self.logger.info('the third testpmd start failed as expect : %s' % expect_str)
result = self.dut.get_session_output(timeout=2)
- print result
+ print(result)
# start send packet and verify the session can receive the packet.
self.send_pkg(0)
diff --git a/tests/TestSuite_dual_vlan.py b/tests/TestSuite_dual_vlan.py
index 185c35b..8f22d98 100644
--- a/tests/TestSuite_dual_vlan.py
+++ b/tests/TestSuite_dual_vlan.py
@@ -256,7 +256,7 @@ class TestDualVlan(TestCase):
"""
Check results of synthetic test.
"""
- print "vlan flage config:%s" % errorString
+ print(("vlan flage config:%s" % errorString))
out = self.get_tcpdump_package()
if allResult[resultKey][0] == "No":
self.verify("vlan" not in out, errorString)
@@ -283,7 +283,7 @@ class TestDualVlan(TestCase):
self.mode_config(extend="off")
self.vlan_send_packet(outvlan)
out = self.get_tcpdump_package()
- print out
+ print(out)
self.verify(out is not None and "vlan %s" % outvlan not in out, "Vlan filter enable error: " + out)
if self.nic not in ["columbiaville_25g", "columbiaville_100g", "fortville_eagle", "fortville_spirit", "fortville_spirit_single", "fortville_25g", "fortpark_TLV", "carlsville"]:
diff --git a/tests/TestSuite_dynamic_config.py b/tests/TestSuite_dynamic_config.py
index dbafe49..dd5e4b2 100644
--- a/tests/TestSuite_dynamic_config.py
+++ b/tests/TestSuite_dynamic_config.py
@@ -92,7 +92,7 @@ class TestDynamicConfig(TestCase):
ret = utils.regexp(out, mac_scanner)
self.verify(ret is not None, "MAC address not found")
- self.verify(cmp(ret.lower(), self.dest) == 0, "MAC address wrong")
+ self.verify(ret.lower() == self.dest, "MAC address wrong")
self.verify("Promiscuous mode: enabled" in out,
"wrong default promiscuous value")
diff --git a/tests/TestSuite_dynamic_flowtype.py b/tests/TestSuite_dynamic_flowtype.py
index 1a1cf5f..b12a429 100644
--- a/tests/TestSuite_dynamic_flowtype.py
+++ b/tests/TestSuite_dynamic_flowtype.py
@@ -46,7 +46,7 @@ class TestDynamicFlowtype(TestCase):
s = re.compile(pattern)
res = s.search(out)
if res is None:
- print utils.RED('Search no queue number.')
+ print((utils.RED('Search no queue number.')))
return None
else:
queue = res.group(2)
@@ -149,21 +149,21 @@ class TestDynamicFlowtype(TestCase):
if match_opt == 'not matched':
if flowtype == 23:
- pkts = dict(pkts_gtpc_pay.items() +
- pkts_gtpu_pay.items() +
- pkts_gtpu_ipv4.items())
+ pkts = dict(list(pkts_gtpc_pay.items()) +
+ list(pkts_gtpu_pay.items()) +
+ list(pkts_gtpu_ipv4.items()))
if flowtype == 24:
- pkts = dict(pkts_gtpc_pay.items() +
- pkts_gtpu_ipv4.items() +
- pkts_gtpu_ipv6.items())
+ pkts = dict(list(pkts_gtpc_pay.items()) +
+ list(pkts_gtpu_ipv4.items()) +
+ list(pkts_gtpu_ipv6.items()))
if flowtype == 25:
- pkts = dict(pkts_gtpu_pay.items() +
- pkts_gtpu_ipv4.items() +
- pkts_gtpu_ipv6.items())
+ pkts = dict(list(pkts_gtpu_pay.items()) +
+ list(pkts_gtpu_ipv4.items()) +
+ list(pkts_gtpu_ipv6.items()))
if flowtype == 26:
- pkts = dict(pkts_gtpc_pay.items() +
- pkts_gtpu_pay.items() +
- pkts_gtpu_ipv6.items())
+ pkts = dict(list(pkts_gtpc_pay.items()) +
+ list(pkts_gtpu_pay.items()) +
+ list(pkts_gtpu_ipv6.items()))
return pkts
@@ -172,7 +172,7 @@ class TestDynamicFlowtype(TestCase):
Send packet and verify rss function.
"""
pkts = self.gtp_packets(flowtype, match_opt)
- for packet_type in pkts.keys():
+ for packet_type in list(pkts.keys()):
self.tester.scapy_append(
'sendp([%s], iface="%s")'
% (pkts[packet_type], self.tester_intf))
diff --git a/tests/TestSuite_dynamic_queue.py b/tests/TestSuite_dynamic_queue.py
index 1f86d1f..356ebfd 100644
--- a/tests/TestSuite_dynamic_queue.py
+++ b/tests/TestSuite_dynamic_queue.py
@@ -52,7 +52,7 @@ class TestDynamicQueue(TestCase):
s = re.compile(pattern, re.DOTALL)
res = s.search(out)
if res is None:
- print utils.RED('Fail to search number.')
+ print((utils.RED('Fail to search number.')))
return None
else:
result = res.group(1)
diff --git a/tests/TestSuite_enable_package_download_in_ice_driver.py b/tests/TestSuite_enable_package_download_in_ice_driver.py
index f28f0e6..5364975 100644
--- a/tests/TestSuite_enable_package_download_in_ice_driver.py
+++ b/tests/TestSuite_enable_package_download_in_ice_driver.py
@@ -137,7 +137,7 @@ class TestEnable_Package_Download_In_Ice_Driver(TestCase):
Sends a tcpdump related command and returns an integer from the output
"""
result = self.tester.send_expect(command, '#')
- print result
+ print(result)
return int(result.strip())
def number_of_packets(self, iface):
@@ -216,7 +216,7 @@ class TestEnable_Package_Download_In_Ice_Driver(TestCase):
self.tester.scapy_execute()
time.sleep(.5)
else:
- print "\ntran_type error!\n"
+ print("\ntran_type error!\n")
self.verifyResult(tran_type=tran_type, flag=flag)
@@ -242,7 +242,7 @@ class TestEnable_Package_Download_In_Ice_Driver(TestCase):
if(item.startswith("port 0/queue ")):
queue_id = item.split(" ", 2)[-1]
queue_list.append(queue_id)
- print list(set(queue_list))
+ print(list(set(queue_list)))
if flag == "true":
self.verify(len(list(set(queue_list))) > 1, "All packets enter the same queue: %s" % queue_list)
else:
@@ -268,7 +268,7 @@ class TestEnable_Package_Download_In_Ice_Driver(TestCase):
self.dut_testpmd.execute_cmd('set fwd rxonly')
self.dut_testpmd.execute_cmd('start')
for tran_types in ["ipv4-tcp", "ipv4-udp", "ipv4-sctp", "ipv6-tcp", "ipv6-udp", "ipv6-sctp"]:
- print tran_types
+ print(tran_types)
self.send_packet(tran_type=tran_types, flag=ice_pkg)
def test_download_the_package_successfully(self):
diff --git a/tests/TestSuite_etag.py b/tests/TestSuite_etag.py
index 8a67222..e095f82 100644
--- a/tests/TestSuite_etag.py
+++ b/tests/TestSuite_etag.py
@@ -114,7 +114,7 @@ class TestEtag(TestCase):
raise Exception('Set up VM0 ENV failed!')
except Exception as e:
- print e
+ print(e)
self.destroy_vm_env()
raise Exception(e)
@@ -151,44 +151,44 @@ class TestEtag(TestCase):
def check_packet_transmission(self, pkt_types):
time.sleep(1)
- for pkt_type in pkt_types.keys():
+ for pkt_type in list(pkt_types.keys()):
intf = self.src_intf
pkt = Packet(pkt_type=pkt_type)
# set packet every layer's input parameters
- if 'layer_configs' in pkt_types[pkt_type].keys():
+ if 'layer_configs' in list(pkt_types[pkt_type].keys()):
pkt_configs = pkt_types[pkt_type]['layer_configs']
if pkt_configs:
- for layer in pkt_configs.keys():
+ for layer in list(pkt_configs.keys()):
pkt.config_layer(layer, pkt_configs[layer])
pkt.send_pkt(self.tester, tx_port=self.src_intf)
# check vm testpmd packet received information
- if 'vm' in pkt_types[pkt_type].keys():
+ if 'vm' in list(pkt_types[pkt_type].keys()):
out = self.vm0_testpmd.get_output(timeout=2)
if self.printFlag: # debug output
- print out
+ print(out)
for pkt_attribute in pkt_types[pkt_type]['vm']:
if self.printFlag:# debug output
- print pkt_attribute
+ print(pkt_attribute)
if pkt_attribute not in out:
- print utils.RED('Fail to detect %s' % pkt_attribute)
+ print(utils.RED('Fail to detect %s' % pkt_attribute))
if not self.printFlag:# print out all info in debug mode
raise VerifyFailure('Failed to detect %s' % pkt_attribute)
- print utils.GREEN('VM detected %s successfully' % pkt_type)
+ print(utils.GREEN('VM detected %s successfully' % pkt_type))
# check dut testpmd packet received information
- if 'dut' in pkt_types[pkt_type].keys():
+ if 'dut' in list(pkt_types[pkt_type].keys()):
out = self.host_testpmd.get_output(timeout=2)
if self.printFlag: # debug output
- print out
+ print(out)
for pkt_attribute in pkt_types[pkt_type]['dut']:
if self.printFlag:# debug output
- print pkt_attribute
+ print(pkt_attribute)
if pkt_attribute not in out:
- print utils.RED('Fail to detect %s' % pkt_attribute)
+ print(utils.RED('Fail to detect %s' % pkt_attribute))
if not self.printFlag:# print out all info in debug mode
raise VerifyFailure('Failed to detect %s' % pkt_attribute)
- print utils.GREEN('DUT detected %s successfully' % pkt_type)
+ print(utils.GREEN('DUT detected %s successfully' % pkt_type))
time.sleep(1)
def preset_host_testpmd(self, core_mask, eal_param):
@@ -358,7 +358,7 @@ class TestEtag(TestCase):
out = fp.read()
fp.close()
if self.printFlag:# debug output
- print out
+ print(out)
self.verify( "Dot1BR" in out, "tester %s hasn't receiver etag packet"% intf)
def test_etag_strip(self):
diff --git a/tests/TestSuite_ethtool_stats.py b/tests/TestSuite_ethtool_stats.py
index e8ea941..4f56885 100644
--- a/tests/TestSuite_ethtool_stats.py
+++ b/tests/TestSuite_ethtool_stats.py
@@ -47,6 +47,7 @@ from exception import VerifyFailure
from packet import Packet
from scapy.sendrecv import sendp
from settings import HEADER_SIZE
+from functools import reduce
class TestEthtoolStats(TestCase):
@@ -60,19 +61,19 @@ class TestEthtoolStats(TestCase):
return target_dir
def d_a_con(self, cmd):
- _cmd = [cmd, '# ', 10] if isinstance(cmd, (str, unicode)) else cmd
+ _cmd = [cmd, '# ', 10] if isinstance(cmd, str) else cmd
output = self.dut.alt_session.send_expect(*_cmd)
output2 = self.dut.alt_session.session.get_session_before(1)
return output + os.linesep + output2
def send_packet(self, pkt_config, src_intf):
- for pkt_type in pkt_config.keys():
+ for pkt_type in list(pkt_config.keys()):
pkt = Packet(pkt_type=pkt_type)
# set packet every layer's input parameters
- if 'layer_configs' in pkt_config[pkt_type].keys():
+ if 'layer_configs' in list(pkt_config[pkt_type].keys()):
pkt_configs = pkt_config[pkt_type]['layer_configs']
if pkt_configs:
- for layer in pkt_configs.keys():
+ for layer in list(pkt_configs.keys()):
pkt.config_layer(layer, pkt_configs[layer])
pkt.send_pkt(crb=self.tester, tx_port=src_intf, count=1)
time.sleep(1)
@@ -85,7 +86,7 @@ class TestEthtoolStats(TestCase):
# send out packet
for frame_size in self.frame_sizes:
headers_size = sum(
- map(lambda x: HEADER_SIZE[x], ['eth', 'ip', 'udp']))
+ [HEADER_SIZE[x] for x in ['eth', 'ip', 'udp']])
payload_size = frame_size - headers_size
config_layers = {
'ether': {'src': src_mac},
@@ -156,7 +157,7 @@ class TestEthtoolStats(TestCase):
def init_proc_info(self):
ports_count = len(self.dut_ports)
ports_mask = reduce(lambda x, y: x | y,
- map(lambda x: 0x1 << x, range(ports_count)))
+ [0x1 << x for x in range(ports_count)])
self.query_tool = os.path.join(
self.target_dir, self.target, 'app', 'dpdk-procinfo')
self.dpdk_proc_info = "%s -v -- -p %s" % (self.query_tool, ports_mask)
@@ -221,7 +222,7 @@ class TestEthtoolStats(TestCase):
def check_single_stats_result(self, sub_stat_data, all_xstat_data):
execept_msgs = []
- for port, infos in sub_stat_data.items():
+ for port, infos in list(sub_stat_data.items()):
for item in infos:
if not port or \
port not in all_xstat_data or \
@@ -240,7 +241,7 @@ class TestEthtoolStats(TestCase):
def get_xstat_single_statistic(self, stat, all_xstat_data):
option = "xstats-id"
execept_msgs = []
- for id in stat.values():
+ for id in list(stat.values()):
cmd = self.dpdk_proc_info + " --%s %s" % (option, id)
msg = self.d_a_con(cmd)
sub_stat_data = self.parse_proc_info_xstat_output(msg)
@@ -291,7 +292,7 @@ class TestEthtoolStats(TestCase):
execept_msgs = []
for port in all_xstat_data:
stats_info = all_xstat_data[port]
- for stat_name, value in stats_info.items():
+ for stat_name, value in list(stats_info.items()):
if int(value) != 0:
msg = "port {0} <{1}> [{2}] has not been reset"
execept_msgs.append(msg.format(port, stat_name, value))
@@ -305,14 +306,14 @@ class TestEthtoolStats(TestCase):
execept_msgs = []
option = "xstats-id"
sub_option = reduce(lambda x, y: str(x) + "," + str(y),
- range(len(all_xstat_data['0'].keys())))
+ list(range(len(list(all_xstat_data['0'].keys())))))
cmd = self.dpdk_proc_info + " --%s %s" % (option, sub_option)
msg = self.d_a_con(cmd)
sub_stat_data = self.parse_proc_info_xstat_output(msg)
if not sub_stat_data or not len(sub_stat_data):
execept_msgs.append([option, msg])
else:
- for port, infos in sub_stat_data.items():
+ for port, infos in list(sub_stat_data.items()):
for item in infos:
if not port or \
port not in all_xstat_data or \
@@ -331,7 +332,7 @@ class TestEthtoolStats(TestCase):
def check_xstat_name_cmd(self, all_xstat_data):
option = "xstats-name"
- _sub_options = all_xstat_data['0'].keys()
+ _sub_options = list(all_xstat_data['0'].keys())
execept_msgs = []
for sub_option in _sub_options:
cmd = self.dpdk_proc_info + " --%s %s" % (option, sub_option)
@@ -368,7 +369,7 @@ class TestEthtoolStats(TestCase):
def check_xstat_single_statistic(self, sub_options_ex=None):
all_xstat_data = self.get_pmd_xstat_data()
self.logger.info("total stat names [%d]" % len(all_xstat_data['0']))
- for stat_name in all_xstat_data['0'].keys():
+ for stat_name in list(all_xstat_data['0'].keys()):
# firstly, get statistic name.
stats, execept_msgs = self.get_xstat_statistic_id(stat_name)
if len(execept_msgs):
diff --git a/tests/TestSuite_eventdev_pipeline.py b/tests/TestSuite_eventdev_pipeline.py
index 1e99389..29a42be 100644
--- a/tests/TestSuite_eventdev_pipeline.py
+++ b/tests/TestSuite_eventdev_pipeline.py
@@ -193,7 +193,7 @@ class TestEventdevPipeline(TestCase):
for i in range(len(self.pkts)):
pay_load = "0000%.2d" % (packet_index)
if self.pkts[i]['IP'].src == src_ip:
- print(self.pkts[i].show)
+ print((self.pkts[i].show))
# get the start index load info of each queue
if packet_index == 0:
packet_index = int(self.pkts[i]['Raw'].load[-2:])
diff --git a/tests/TestSuite_fdir.py b/tests/TestSuite_fdir.py
index aa40e79..38d96be 100644
--- a/tests/TestSuite_fdir.py
+++ b/tests/TestSuite_fdir.py
@@ -48,12 +48,7 @@ from settings import HEADER_SIZE
from pmd_output import PmdOutput
import sys
-reload(sys)
-sys.setdefaultencoding('utf8')
-#
-#
-# Test class.
-#
+import imp
class TestFdir(TestCase, IxiaPacketGenerator):
@@ -115,26 +110,26 @@ class TestFdir(TestCase, IxiaPacketGenerator):
scanner = re.compile(result_scanner, re.DOTALL)
m = scanner.search(out)
- print "**************Print sub-case result****************"
+ print("**************Print sub-case result****************")
if m:
m.groups()
if (self.queue == int(m.group(2))):
- print utils.GREEN("Pass: queue id is " + m.group(2))
+ print(utils.GREEN("Pass: queue id is " + m.group(2)))
self.verify(1, "Pass")
else:
- print utils.RED("Fail: queue id is " + m.group(2))
+ print(utils.RED("Fail: queue id is " + m.group(2)))
self.verify(0, "Fail")
- print out
+ print(out)
else:
- print "not match"
+ print("not match")
if (-1 == self.queue):
- print utils.GREEN("Pass: fdir should not match ")
+ print(utils.GREEN("Pass: fdir should not match "))
self.verify(1, "Pass")
else:
- print utils.RED("Fail")
+ print(utils.RED("Fail"))
self.verify(0, "Fail")
- print out
- print "**************Print sub-case result****************"
+ print(out)
+ print("**************Print sub-case result****************")
#
#
@@ -1182,7 +1177,7 @@ class TestFdir(TestCase, IxiaPacketGenerator):
flows = []
src_ip_temp = self.src_ip
dst_ip_temp = self.dst_ip
- print "*src_ip_temp = " + src_ip_temp + "dst_ip_temp = " + dst_ip_temp
+ print("*src_ip_temp = " + src_ip_temp + "dst_ip_temp = " + dst_ip_temp)
flows.append('Ether(src="52:00:00:00:00:00", dst="00:1B:21:8E:B2:30")/IP(src="%s",dst="%s")/UDP(sport=%d,dport=%d)/Raw(load="%s" + "X"*(%d - 42 - %d))' % (src_ip_temp, dst_ip_temp, 1021, 1021, self.payload, frame_size, self.flexlength))
self.scapyCmds.append('wrpcap("/root/test.pcap", [%s])' % string.join(flows, ','))
@@ -1200,10 +1195,10 @@ class TestFdir(TestCase, IxiaPacketGenerator):
self.tester.get_local_port(self.dut_ports[0]),
"/root/test.pcap"))
- print "self.ports_socket=%s" % (self.ports_socket)
+ print("self.ports_socket=%s" % (self.ports_socket))
# run testpmd for each core config
for test_cycle in self.test_cycles:
- print "******************test cycles*********************\n"
+ print("******************test cycles*********************\n")
core_config = test_cycle['cores']
core_list = self.dut.get_core_list(core_config, socket=self.ports_socket)
@@ -1231,7 +1226,7 @@ class TestFdir(TestCase, IxiaPacketGenerator):
self.rst_report(command_line + "\n\n", frame=True, annex=True)
out = self.dut.send_expect(command_line, "testpmd> ", 100)
- print out
+ print(out)
self.dut.send_expect("set verbose 1", "testpmd>")
self.fdir_get_flexbytes()
@@ -1240,9 +1235,9 @@ class TestFdir(TestCase, IxiaPacketGenerator):
self.fdir_set_rule()
self.fdir_perf_set_rules(num_rules)
out = self.dut.send_expect("start", "testpmd> ")
- print out
+ print(out)
for frame_size in self.frame_sizes:
- print "******************frame size = %d*********************\n" % (frame_size)
+ print("******************frame size = %d*********************\n" % (frame_size))
wirespeed = self.wirespeed(self.nic, frame_size, 2)
# create pcap file
self.logger.info("Running with frame size %d " % frame_size)
@@ -1274,7 +1269,7 @@ class TestFdir(TestCase, IxiaPacketGenerator):
"""
out = self.dut.send_expect("show port stats all", "testpmd> ")
- print out
+ print(out)
pps /= 1000000.0
test_cycle['Mpps'][frame_size] = pps
@@ -1326,19 +1321,19 @@ class TestFdir(TestCase, IxiaPacketGenerator):
fdir Performance Benchmarking with 2 ports.
"""
for test_type in self.test_types:
- print "***************\n"
- print test_type
- print "***************\n"
+ print("***************\n")
+ print(test_type)
+ print("***************\n")
if test_type in ["fdir_enable", "fdir_disable"]:
num_rules = 0
num_flows = 64
- print "************%d rules/%d flows********************" % (num_rules, num_flows)
+ print("************%d rules/%d flows********************" % (num_rules, num_flows))
self.perf_fdir_performance_2ports(test_type, num_rules, num_flows)
elif test_type in ["fdir_noflexbytes", "fdir_2flexbytes", "fdir_16flexbytes"]:
for flows in self.flows:
num_rules = flows["rules"]
num_flows = flows["flows"]
- print "************%d rules/%d flows********************" % (num_rules, num_flows)
+ print("************%d rules/%d flows********************" % (num_rules, num_flows))
self.perf_fdir_performance_2ports(test_type, num_rules, num_flows)
def tear_down(self):
diff --git a/tests/TestSuite_fips_cryptodev.py b/tests/TestSuite_fips_cryptodev.py
index 44f6557..aab2167 100644
--- a/tests/TestSuite_fips_cryptodev.py
+++ b/tests/TestSuite_fips_cryptodev.py
@@ -76,7 +76,7 @@ class FipCryptodev(TestCase):
self.logger.info(cmd_str)
try:
out = self.dut.send_expect(cmd_str, "#", 600)
- except Exception, ex:
+ except Exception as ex:
self.logger.error(ex)
raise ex
return out
diff --git a/tests/TestSuite_flow_classify.py b/tests/TestSuite_flow_classify.py
index c51b0a2..7f6eba5 100644
--- a/tests/TestSuite_flow_classify.py
+++ b/tests/TestSuite_flow_classify.py
@@ -42,6 +42,7 @@ from utils import create_mask as dts_create_mask
from test_case import TestCase
from exception import VerifyFailure
from settings import HEADER_SIZE
+from functools import reduce
class TestFlowClassify(TestCase):
@@ -59,7 +60,7 @@ class TestFlowClassify(TestCase):
def get_cores_mask(self, config='all'):
sockets = [self.dut.get_numa_id(index) for index in self.dut_ports]
socket_count = Counter(sockets)
- port_socket = socket_count.keys()[0] if len(socket_count) == 1 else -1
+ port_socket = list(socket_count.keys())[0] if len(socket_count) == 1 else -1
mask = dts_create_mask(self.dut.get_core_list(config,
socket=port_socket))
return mask
@@ -108,7 +109,7 @@ class TestFlowClassify(TestCase):
console, msg_pipe = self.get_console(con_name)
if len(cmds) == 0:
return
- if isinstance(cmds, (str, unicode)):
+ if isinstance(cmds, str):
cmds = [cmds, '# ', 5]
if not isinstance(cmds[0], list):
cmds = [cmds]
@@ -140,8 +141,7 @@ class TestFlowClassify(TestCase):
# packet size
frame_size = 256
headers_size = sum(
- map(lambda x: 132 if x == 'sctp' else HEADER_SIZE[x],
- ['eth', 'ip', pkt_type]))
+ [132 if x == 'sctp' else HEADER_SIZE[x] for x in ['eth', 'ip', pkt_type]])
pktlen = frame_size - headers_size
return pktlen
@@ -235,7 +235,7 @@ class TestFlowClassify(TestCase):
# create packet for send
streams = []
for stm_name in stm_names:
- if stm_name not in pkt_configs.keys():
+ if stm_name not in list(pkt_configs.keys()):
continue
values = pkt_configs[stm_name]
savePath = os.sep.join([self.output_path,
@@ -243,7 +243,7 @@ class TestFlowClassify(TestCase):
pkt_type = values.get('type')
pkt_layers = values.get('pkt_layers')
pkt = Packet(pkt_type=pkt_type)
- for layer in pkt_layers.keys():
+ for layer in list(pkt_layers.keys()):
pkt.config_layer(layer, pkt_layers[layer])
pkt.pktgen.pkt.show()
streams.append(pkt.pktgen.pkt)
@@ -317,7 +317,7 @@ class TestFlowClassify(TestCase):
timestamp = dt.strftime('%Y-%m-%d_%H%M%S')
self.test_data = '{0}/{1}_{2}.log'.format(
self.output_path, 'flow_classify', timestamp)
- with open(self.test_data, 'wb') as fp:
+ with open(self.test_data, 'w') as fp:
fp.write(output)
cmds = ['killall flow_classify', '# ', 10]
self.d_a_console(cmds)
@@ -368,7 +368,7 @@ class TestFlowClassify(TestCase):
pat = "rule\[{0}\] count=(\d+)".format(rule_priority) \
if rule_priority is not None else \
"rule\[\d+\] count=(\d+)"
- with open(log, 'rb') as fp:
+ with open(log, 'r') as fp:
content = fp.read()
if content:
grp = re.findall(pat, content, re.M)
diff --git a/tests/TestSuite_flow_filtering.py b/tests/TestSuite_flow_filtering.py
index 29ae1ed..079435d 100644
--- a/tests/TestSuite_flow_filtering.py
+++ b/tests/TestSuite_flow_filtering.py
@@ -66,7 +66,7 @@ class TestFlowFiltering(TestCase):
Send packets according to parameters.
"""
self.pkt = packet.Packet()
- for packet_type in pkg.keys():
+ for packet_type in list(pkg.keys()):
self.pkt.append_pkt(pkg[packet_type])
self.pkt.send_pkt(crb=self.tester, tx_port=self.txitf, count=1)
diff --git a/tests/TestSuite_fm10k_perf.py b/tests/TestSuite_fm10k_perf.py
index a991ee9..5ff411d 100644
--- a/tests/TestSuite_fm10k_perf.py
+++ b/tests/TestSuite_fm10k_perf.py
@@ -254,14 +254,14 @@ class TestFM10kL3fwd(TestCase):
self.fm10k_rxmode_set(mode = mode['rxmode'])
if mode['txmode'] == 'default':
# need --enable-jumbo parameter
- for key in TestFM10kL3fwd.test_cases_2_ports.keys():
+ for key in list(TestFM10kL3fwd.test_cases_2_ports.keys()):
if "--enable-jumbo" not in TestFM10kL3fwd.test_cases_2_ports[key]:
TestFM10kL3fwd.test_cases_2_ports[key] += " --enable-jumbo"
else:
- for key in TestFM10kL3fwd.test_cases_2_ports.keys():
+ for key in list(TestFM10kL3fwd.test_cases_2_ports.keys()):
TestFM10kL3fwd.test_cases_2_ports[key].replace(" --enable-jumbo", "")
- print GREEN("Performance test for rxmode %s txmode %s" % (mode['rxmode'], mode['txmode']))
+ print((GREEN("Performance test for rxmode %s txmode %s" % (mode['rxmode'], mode['txmode']))))
self.perf_l3fwd_2ports()
# remove setting for scatter
@@ -277,14 +277,14 @@ class TestFM10kL3fwd(TestCase):
self.fm10k_rxmode_set(mode = mode['rxmode'])
if mode['txmode'] == 'default':
# need --enable-jumbo parameter
- for key in TestFM10kL3fwd.test_cases_2_ports.keys():
+ for key in list(TestFM10kL3fwd.test_cases_2_ports.keys()):
if "--enable-jumbo" not in TestFM10kL3fwd.test_cases_2_ports[key]:
TestFM10kL3fwd.test_cases_2_ports[key] += " --enable-jumbo"
else:
- for key in TestFM10kL3fwd.test_cases_2_ports.keys():
+ for key in list(TestFM10kL3fwd.test_cases_2_ports.keys()):
TestFM10kL3fwd.test_cases_2_ports[key].replace(" --enable-jumbo", "")
- print GREEN("Performance test for rxmode %s txmode %s" % (mode['rxmode'], mode['txmode']))
+ print((GREEN("Performance test for rxmode %s txmode %s" % (mode['rxmode'], mode['txmode']))))
self.perf_l3fwd_2ports()
# remove setting for scatter
@@ -339,7 +339,7 @@ class TestFM10kL3fwd(TestCase):
coreMask = {}
rtCmdLines = dict(TestFM10kL3fwd.test_cases_2_ports)
- for key in rtCmdLines.keys():
+ for key in list(rtCmdLines.keys()):
corelist = []
while pat.search(rtCmdLines[key]):
# Change the socket to the NIC's socket
@@ -358,7 +358,7 @@ class TestFM10kL3fwd(TestCase):
# start l3fwd
index = 0
subtitle = []
- for cores in rtCmdLines.keys():
+ for cores in list(rtCmdLines.keys()):
info = "Executing l3fwd using %s mode, 2 ports, %s and %d frame size.\n" % (
mode, cores, frame_size)
@@ -415,7 +415,7 @@ class TestFM10kL3fwd(TestCase):
# Stop l3fwd
self.dut.send_expect("^C", "#")
- print latencys
+ print(latencys)
for latency in latencys:
if latency['max'] > 0:
@@ -472,7 +472,7 @@ class TestFM10kL3fwd(TestCase):
coreMask = {}
rtCmdLines = dict(TestFM10kL3fwd.test_cases_2_ports)
- for key in rtCmdLines.keys():
+ for key in list(rtCmdLines.keys()):
corelist = []
while pat.search(rtCmdLines[key]):
# Change the socket to the NIC's socket
@@ -489,7 +489,7 @@ class TestFM10kL3fwd(TestCase):
# start l3fwd
index = 0
subtitle = []
- for cores in rtCmdLines.keys():
+ for cores in list(rtCmdLines.keys()):
# in order to save time, only some of the cases will be run.
if mode == "lpm" and (cores == "1S/1C/1T" or cores == "1S/4C/1T"):
@@ -561,14 +561,14 @@ class TestFM10kL3fwd(TestCase):
self.fm10k_rxmode_set(mode = mode['rxmode'])
if mode['txmode'] == 'default':
# need --enable-jumbo parameter
- for key in TestFM10kL3fwd.test_cases_2_ports.keys():
+ for key in list(TestFM10kL3fwd.test_cases_2_ports.keys()):
if "--enable-jumbo" not in TestFM10kL3fwd.test_cases_2_ports[key]:
TestFM10kL3fwd.test_cases_2_ports[key] += " --enable-jumbo"
else:
- for key in TestFM10kL3fwd.test_cases_2_ports.keys():
+ for key in list(TestFM10kL3fwd.test_cases_2_ports.keys()):
TestFM10kL3fwd.test_cases_2_ports[key].replace(" --enable-jumbo", "")
- print GREEN("Performance test for rxmode %s txmode %s" % (mode['rxmode'], mode['txmode']))
+ print((GREEN("Performance test for rxmode %s txmode %s" % (mode['rxmode'], mode['txmode']))))
self.perf_rfc2544()
# remove setting for scatter
@@ -583,14 +583,14 @@ class TestFM10kL3fwd(TestCase):
self.fm10k_rxmode_set(mode = mode['rxmode'])
if mode['txmode'] == 'default':
# need --enable-jumbo parameter
- for key in TestFM10kL3fwd.test_cases_2_ports.keys():
+ for key in list(TestFM10kL3fwd.test_cases_2_ports.keys()):
if "--enable-jumbo" not in TestFM10kL3fwd.test_cases_2_ports[key]:
TestFM10kL3fwd.test_cases_2_ports[key] += " --enable-jumbo"
else:
- for key in TestFM10kL3fwd.test_cases_2_ports.keys():
+ for key in list(TestFM10kL3fwd.test_cases_2_ports.keys()):
TestFM10kL3fwd.test_cases_2_ports[key].replace(" --enable-jumbo", "")
- print GREEN("Performance test for rxmode %s txmode %s" % (mode['rxmode'], mode['txmode']))
+ print((GREEN("Performance test for rxmode %s txmode %s" % (mode['rxmode'], mode['txmode']))))
self.perf_rfc2544()
# remove setting for scatter
--git a/tests/TestSuite_fortville_rss_granularity_config.py b/tests/TestSuite_fortville_rss_granularity_config.py
index 7f881e9..1f2e6d2 100644
--- a/tests/TestSuite_fortville_rss_granularity_config.py
+++ b/tests/TestSuite_fortville_rss_granularity_config.py
@@ -142,7 +142,7 @@ class TestFortvilleRssGranularityConfig(TestCase):
self.tester.scapy_execute()
time.sleep(.5)
else:
- print "\ntran_type error!\n"
+ print("\ntran_type error!\n")
out = self.dut.get_session_output(timeout=1)
self.dut.send_expect("stop", "testpmd>")
diff --git a/tests/TestSuite_ftag.py b/tests/TestSuite_ftag.py
index 9d30918..2f5c6c7 100644
--- a/tests/TestSuite_ftag.py
+++ b/tests/TestSuite_ftag.py
@@ -149,7 +149,7 @@ class TestFtag(TestCase):
self.dut.send_expect("fm10k_ftag_autotest", "Dump", 100)
self.check_forwarding(txport, rxport, self.nic, received=False)
out = self.dut.get_session_output()
- print "out:%s" %out
+ print(("out:%s" %out))
self.verify("Test OK" in out, "Fail to do fm10k ftag test")
self.dut.send_expect("quit", "# ")
diff --git a/tests/TestSuite_generic_filter.py b/tests/TestSuite_generic_filter.py
index 24e2dfb..8d674ee 100644
--- a/tests/TestSuite_generic_filter.py
+++ b/tests/TestSuite_generic_filter.py
@@ -777,7 +777,7 @@ class TestGeneric_filter(TestCase):
self.pmdout.start_testpmd(
"%s" % self.cores, "--disable-rss --rxq=4 --txq=4 --portmask=%s --nb-cores=4 --nb-ports=1" % portMask)
self.port_config()
- print valports[0], valports[1]
+ print(valports[0], valports[1])
tx_port = self.tester.get_local_port(valports[0])
tx_mac = self.dut.get_mac_address(valports[0])
txItf = self.tester.get_interface(tx_port)
@@ -785,8 +785,8 @@ class TestGeneric_filter(TestCase):
rx_port = self.tester.get_local_port(valports[1])
rxItf = self.tester.get_interface(rx_port)
package_sizes = [64, 128, 256, 512, 1024, 1280, 1518]
- print tx_mac
- print self.dut.ports_info[valports[0]], self.dut.ports_info[valports[1]]
+ print(tx_mac)
+ print(self.dut.ports_info[valports[0]], self.dut.ports_info[valports[1]])
test_type = {
"syn": ["syn_filter add 0 priority high queue 1", "syn_filter del 0 priority high queue 1"],
"ethertype": ["add_ethertype_filter 0 ethertype 0x0806 priority disable 0 queue 2 index 1", "remove_ethertype_filter 0 index 1"],
@@ -799,7 +799,7 @@ class TestGeneric_filter(TestCase):
}
self.result_table_create(
['pack_size', "filter_type", "enable", "disable", "perf_compare"])
- for key in test_type.keys():
+ for key in list(test_type.keys()):
if "5tuple" != key:
pps_lists = []
for i in range(2):
@@ -840,7 +840,7 @@ class TestGeneric_filter(TestCase):
# tgen_input.append((txItf, rxItf, "generic_firlter.pcap"))
tgen_input.append(
(tx_port, rx_port, "generic_firlter.pcap"))
- print tgen_input
+ print(tgen_input)
_, pps = self.tester.traffic_generator_throughput(
tgen_input)
pps_lists.append(pps)
diff --git a/tests/TestSuite_generic_flow_api.py b/tests/TestSuite_generic_flow_api.py
index b118b96..bb42bf7 100644
--- a/tests/TestSuite_generic_flow_api.py
+++ b/tests/TestSuite_generic_flow_api.py
@@ -234,10 +234,10 @@ class TestGeneric_flow_api(TestCase):
result_scanner = r'\d*.*?\d*.*?\d*.*?=>*'
scanner = re.compile(result_scanner, re.DOTALL)
m = scanner.findall(outstring)
- print "All flow entries are: "
+ print("All flow entries are: ")
for i in range(len(m)):
- print m[i]
- print 'Expected rules are: %d - actual are: %d' % (expectedRules, len(m))
+ print(m[i])
+ print('Expected rules are: %d - actual are: %d' % (expectedRules, len(m)))
self.verify(expectedRules == len(m), 'Total rules number mismatched')
def all_flows_process(self, basic_flow_actions):
diff --git a/tests/TestSuite_hotplug_mp.py b/tests/TestSuite_hotplug_mp.py
index 42bbee9..c756ca8 100644
--- a/tests/TestSuite_hotplug_mp.py
+++ b/tests/TestSuite_hotplug_mp.py
@@ -150,7 +150,7 @@ class TestHotplugMp(TestCase):
elif opt_plug == "plugout":
self.dut.bind_interfaces_linux(self.drivername)
self.multi_process_setup()
-
+ time.sleep(3)
if opt_plug in ["plugin", "plugout"]:
self.attach_detach(process, 1, opt_plug, flg_loop, dev)
elif opt_plug in ["hotplug", "crossplug"]:
diff --git a/tests/TestSuite_iavf.py b/tests/TestSuite_iavf.py
index af8c747..e227a76 100644
--- a/tests/TestSuite_iavf.py
+++ b/tests/TestSuite_iavf.py
@@ -715,7 +715,7 @@ class TestIavf(TestCase):
def test_vf_rss(self):
self.vm0_testpmd.start_testpmd(VM_CORES_MASK, "--txq=4 --rxq=4")
self.vm0_testpmd.execute_cmd("set verbose 1")
- for i, j in zip(range(64), [0, 1, 2, 3]*16):
+ for i, j in zip(list(range(64)), [0, 1, 2, 3]*16):
self.vm0_testpmd.execute_cmd("port config 1 rss reta (%d,%d)" % (i, j))
pkt_types = ["ip", "tcp", "udp"]
for pkt_type in pkt_types:
diff --git a/tests/TestSuite_inline_ipsec.py b/tests/TestSuite_inline_ipsec.py
index 4f078c9..3cbdcae 100644
--- a/tests/TestSuite_inline_ipsec.py
+++ b/tests/TestSuite_inline_ipsec.py
@@ -184,12 +184,12 @@ class TestInlineIpsec(TestCase):
p = IP(str(p))
if do_encrypt == True:
- print "send encrypt package"
+ print("send encrypt package")
print("before encrypt, the package info is like below: ")
p.show()
e = sa_gcm.encrypt(p)
else:
- print "send normal package"
+ print("send normal package")
e = p
eth_e = Ether() / e
@@ -249,9 +249,9 @@ class TestInlineIpsec(TestCase):
out = session_receive.send_expect("results", ">>>", 10)
if verify:
- print('received packet content is %s' % out)
- print('send pkt src ip is %s, dst ip is %s, payload is %s' % (
- send_package[1], send_package[2], send_package[0]))
+ print(('received packet content is %s' % out))
+ print(('send pkt src ip is %s, dst ip is %s, payload is %s' % (
+ send_package[1], send_package[2], send_package[0])))
self.verify(send_package[0] in out,
"Unreceived package or get other package")
else:
diff --git a/tests/TestSuite_ipfrag.py b/tests/TestSuite_ipfrag.py
index 5edd6c4..52e2cb0 100644
--- a/tests/TestSuite_ipfrag.py
+++ b/tests/TestSuite_ipfrag.py
@@ -132,7 +132,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
# run ipv4_frag
self.dut.send_expect("examples/ip_fragmentation/build/ip_fragmentation -c %s -n %d -- -p %s -q %s" % (
- coremask, self.dut.get_memory_channels(), portmask, numPortThread), "Link Up", 120)
+ coremask, self.dut.get_memory_channels(), portmask, int(numPortThread)), "Link Up", 120)
time.sleep(2)
self.txItf = self.tester.get_interface(self.tester.get_local_port(P0))
@@ -157,7 +157,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
# simulate to set TG properties
if flag == 'frag':
# do fragment, each packet max length 1518 - 18 - 20 = 1480
- expPkts = (size - HEADER_SIZE['eth'] - HEADER_SIZE['ip']) / 1480
+ expPkts = int((size - HEADER_SIZE['eth'] - HEADER_SIZE['ip']) / 1480)
if (size - HEADER_SIZE['eth'] - HEADER_SIZE['ip']) % 1480:
expPkts += 1
val = 0
@@ -209,7 +209,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
# simulate to set TG properties
if flag == 'frag':
# each packet max len: 1518 - 18 (eth) - 40 (ipv6) - 8 (ipv6 ext hdr) = 1452
- expPkts = (size - HEADER_SIZE['eth'] - HEADER_SIZE['ipv6']) / 1452
+ expPkts = int((size - HEADER_SIZE['eth'] - HEADER_SIZE['ipv6']) / 1452)
if (size - HEADER_SIZE['eth'] - HEADER_SIZE['ipv6']) % 1452:
expPkts += 1
val = 0
diff --git a/tests/TestSuite_ipgre.py b/tests/TestSuite_ipgre.py
index 71f26cd..1e4edae 100644
--- a/tests/TestSuite_ipgre.py
+++ b/tests/TestSuite_ipgre.py
@@ -94,11 +94,11 @@ class TestIpgre(TestCase):
def check_packet_transmission(self, pkt_types, layer_configs=None, queue=None, add_filter=0):
time.sleep(1)
- for pkt_type in pkt_types.keys():
+ for pkt_type in list(pkt_types.keys()):
pkt_names = pkt_types[pkt_type]
pkt = Packet(pkt_type=pkt_type)
if layer_configs:
- for layer in layer_configs.keys():
+ for layer in list(layer_configs.keys()):
pkt.config_layer(layer, layer_configs[layer])
inst = self.tester.tcpdump_sniff_packets(self.tester_iface, count=1)
pkt.send_pkt(crb=self.tester, tx_port=self.tester_iface, count=4)
@@ -106,16 +106,16 @@ class TestIpgre(TestCase):
time.sleep(1)
pkt = self.tester.load_tcpdump_sniff_packets(inst)
if self.printFlag: # debug output
- print out
+ print(out)
for pkt_layer_name in pkt_names:
if self.printFlag:# debug output
- print pkt_layer_name
+ print(pkt_layer_name)
if pkt_layer_name not in out:
- print utils.RED("Fail to detect %s" % pkt_layer_name)
+ print(utils.RED("Fail to detect %s" % pkt_layer_name))
if not self.printFlag:
raise VerifyFailure("Failed to detect %s" % pkt_layer_name)
else:
- print utils.GREEN("Detected %s successfully" % pkt_type)
+ print(utils.GREEN("Detected %s successfully" % pkt_type))
time.sleep(1)
if queue == None: # no filter
pass
@@ -128,11 +128,11 @@ class TestIpgre(TestCase):
def save_ref_packet(self, pkt_types, layer_configs=None):
- for pkt_type in pkt_types.keys():
+ for pkt_type in list(pkt_types.keys()):
pkt_names = pkt_types[pkt_type]
pkt = Packet(pkt_type=pkt_type)
if layer_configs:
- for layer in layer_configs.keys():
+ for layer in list(layer_configs.keys()):
pkt.config_layer(layer, layer_configs[layer])
wrpcap("/tmp/ref_pkt.pcap", pkt.pktgen.pkt)
time.sleep(1)
@@ -182,7 +182,7 @@ class TestIpgre(TestCase):
# verify saved pcap checksum same to expected checksum
for key in chksums_ref:
self.verify(int(chksums[key], 16) == int(chksums_ref[key], 16), "%s not matched to %s" % (key, chksums_ref[key]))
- print utils.GREEN("Checksum is ok")
+ print(utils.GREEN("Checksum is ok"))
def test_GRE_ipv4_packet_detect(self):
"""
diff --git a/tests/TestSuite_ipsec_gw_cryptodev_func.py b/tests/TestSuite_ipsec_gw_cryptodev_func.py
index 9800886..c6bf6a9 100644
--- a/tests/TestSuite_ipsec_gw_cryptodev_func.py
+++ b/tests/TestSuite_ipsec_gw_cryptodev_func.py
@@ -710,7 +710,7 @@ class TestIPsecGW(TestCase):
self.verify(result, "FAIL")
def _get_ipsec_gw_opt_str(self, override_ipsec_gw_opts={}):
- if "librte_ipsec" in self.get_suite_cfg().keys() and self.get_suite_cfg()["librte_ipsec"]:
+ if "librte_ipsec" in list(self.get_suite_cfg().keys()) and self.get_suite_cfg()["librte_ipsec"]:
override_ipsec_gw_opts={"l": ""}
return cc.get_opt_str(self, self._default_ipsec_gw_opts,
override_ipsec_gw_opts)
--git a/tests/TestSuite_ixgbe_vf_get_extra_queue_information.py b/tests/TestSuite_ixgbe_vf_get_extra_queue_information.py
index c712942..57db70f 100644
--- a/tests/TestSuite_ixgbe_vf_get_extra_queue_information.py
+++ b/tests/TestSuite_ixgbe_vf_get_extra_queue_information.py
@@ -130,7 +130,7 @@ class TestIxgbeVfGetExtraInfo(TestCase):
elif rev_num_added1 == 100 and rev_byte_added1 != 0:
queue = 1
else:
- print utils.RED("There is no packet received.")
+ print(utils.RED("There is no packet received."))
return queue
diff --git a/tests/TestSuite_jumboframes.py b/tests/TestSuite_jumboframes.py
index a883e3e..8555dd9 100644
--- a/tests/TestSuite_jumboframes.py
+++ b/tests/TestSuite_jumboframes.py
@@ -164,7 +164,7 @@ class TestJumboframes(TestCase):
"""
# RRC has no ability to set the max pkt len to hardware
if self.kdriver == "fm10k":
- print utils.RED("fm10k not support this case\n")
+ print(utils.RED("fm10k not support this case\n"))
return
self.pmdout.start_testpmd("Default", "--max-pkt-len=%d --port-topology=loop --tx-offloads=0x8000" % (ETHER_STANDARD_MTU))
self.dut.send_expect("set fwd mac", "testpmd> ")
diff --git a/tests/TestSuite_keep_alive.py b/tests/TestSuite_keep_alive.py
index d9fc9b2..1cab9c8 100644
--- a/tests/TestSuite_keep_alive.py
+++ b/tests/TestSuite_keep_alive.py
@@ -75,7 +75,7 @@ class TestKeepAlive(TestCase):
self.scapy_send_packet(2000)
out = self.dut.get_session_output(timeout=10)
- print out
+ print(out)
p = re.compile(r'\d+')
result = p.findall(out)
amount = 2000 * len(self.dut_ports)
diff --git a/tests/TestSuite_kernelpf_iavf.py b/tests/TestSuite_kernelpf_iavf.py
index 3995238..1ad3272 100644
--- a/tests/TestSuite_kernelpf_iavf.py
+++ b/tests/TestSuite_kernelpf_iavf.py
@@ -362,7 +362,7 @@ class TestKernelpfIavf(TestCase):
self.send_random_pkt(broadcast_mac, count=1)
time.sleep(1)
out = self.vm_dut.get_session_output()
- print out
+ print(out)
self.verify(broadcast_mac.upper() in out and self.tester_mac.upper() in out, 'vf receive pkt fail with broadcast mac')
def test_vf_add_pvid(self):
@@ -492,7 +492,7 @@ class TestKernelpfIavf(TestCase):
out = self.send_and_getout(pkt_type="UDP")
tcpdump_out = self.get_tcpdump_package()
receive_pkt = re.findall('vlan %s' % random_vlan, tcpdump_out)
- print out
+ print(out)
self.verify(len(receive_pkt) == 1, 'Failed to received vlan packet!!!')
def test_vf_vlan_strip(self):
@@ -574,7 +574,7 @@ class TestKernelpfIavf(TestCase):
self.vm_testpmd.start_testpmd("all", "--txq=4 --rxq=4")
self.vm_testpmd.execute_cmd("set fwd mac")
self.vm_testpmd.execute_cmd("set verbose 1")
- for i, j in zip(range(64), [0, 1, 2, 3]*16):
+ for i, j in zip(list(range(64)), [0, 1, 2, 3]*16):
self.vm_testpmd.execute_cmd("port config 0 rss reta (%d,%d)" % (i, j))
self.vm_testpmd.execute_cmd("port config all rss ip")
self.vm_testpmd.execute_cmd("port config all rss tcp")
@@ -662,7 +662,7 @@ class TestKernelpfIavf(TestCase):
# Send packet.
self.tester.scapy_foreground()
- for packet_type in packets_sent.keys():
+ for packet_type in list(packets_sent.keys()):
self.tester.scapy_append('sendp([%s], iface="%s")' % (packets_sent[packet_type], self.tester_intf))
self.start_tcpdump(self.tester_intf)
self.tester.scapy_execute()
@@ -791,13 +791,13 @@ class TestKernelpfIavf(TestCase):
out = self.vm_testpmd.execute_cmd("show port info 0")
self.verify('Link status: up' in out, 'link stats has error')
self.verify('Link speed: %s' % self.speed in out, 'link speed has error')
- print out
+ print(out)
self.vm_testpmd.execute_cmd("set fwd mac")
self.vm_testpmd.execute_cmd("set verbose 1")
self.vm_testpmd.execute_cmd("start")
self.send_random_pkt(self.vf_mac, count=100)
out = self.vm_testpmd.execute_cmd("show port stats all")
- print out
+ print(out)
self.verify("RX-packets: 100" in out and "TX-packets: 100" in out, "receive packet fail")
def test_vf_rx_interrupt(self):
@@ -814,7 +814,7 @@ class TestKernelpfIavf(TestCase):
"'(0,0,6),(1,0,7)'"
self.dut.send_expect(cmd, "POWER", timeout=40)
out = self.dut.get_session_output()
- print out
+ print(out)
pattern = re.compile(r"(([a-f0-9]{2}:){5}[a-f0-9]{2})")
mac_list = pattern.findall(out.lower())
vf0_mac = mac_list[0][0]
diff --git a/tests/TestSuite_l2fwd.py b/tests/TestSuite_l2fwd.py
index ace5dff..92f49d1 100644
--- a/tests/TestSuite_l2fwd.py
+++ b/tests/TestSuite_l2fwd.py
@@ -163,7 +163,7 @@ class TestL2fwd(TestCase):
Benchmark performance for frame_sizes.
"""
ports = []
- for port in xrange(self.number_of_ports):
+ for port in range(self.number_of_ports):
ports.append(self.dut_ports[port])
port_mask = utils.create_mask(ports)
@@ -176,7 +176,7 @@ class TestL2fwd(TestCase):
tgen_input = []
cnt = 1
- for port in xrange(self.number_of_ports):
+ for port in range(self.number_of_ports):
rx_port = self.tester.get_local_port(self.dut_ports[port % self.number_of_ports])
tx_port = self.tester.get_local_port(self.dut_ports[(port + 1) % self.number_of_ports])
destination_mac = self.dut.get_mac_address(self.dut_ports[(port + 1) % self.number_of_ports])
diff --git a/tests/TestSuite_l2fwd_cryptodev_func.py b/tests/TestSuite_l2fwd_cryptodev_func.py
index 84658d6..4a8d31f 100644
--- a/tests/TestSuite_l2fwd_cryptodev_func.py
+++ b/tests/TestSuite_l2fwd_cryptodev_func.py
@@ -703,7 +703,7 @@ class TestL2fwdCrypto(TestCase):
"null": ["NULL"]
}
- for index, value in test_vectors.iteritems():
+ for index, value in list(test_vectors.items()):
test_vector_list = self.__test_vector_to_vector_list(value,
core_mask="-1", port_mask=self.port_mask)
count = count + len(test_vector_list)
@@ -727,11 +727,11 @@ class TestL2fwdCrypto(TestCase):
map_combine[temp_str] += len(test_vector_list)
else:
map_combine[temp_str] = len(test_vector_list)
- for k, v in alg_map.iteritems():
+ for k, v in list(alg_map.items()):
self.logger.info("Total {name} cases:\t\t\t{number}".format(name=k, number=v))
- for k, v in pmd_map.iteritems():
+ for k, v in list(pmd_map.items()):
self.logger.info("Total {name} cases:\t\t\t{number}".format(name=k, number=v))
- for k, v in map_combine.iteritems():
+ for k, v in list(map_combine.items()):
self.logger.info("Total {name} cases:\t\t\t{number}".format(name=k, number=v))
self.logger.info("Total cases:\t\t\t {0}".format(count))
@@ -779,36 +779,37 @@ class TestL2fwdCrypto(TestCase):
result = False
self.logger.info("no payload !")
continue
- cipher_text = binascii.b2a_hex(packet_hex)
- if str.lower(cipher_text) == str.lower(test_vector["output_cipher"]):
+ cipher_text = str(binascii.b2a_hex(packet_hex), encoding='utf-8')
+ if cipher_text.lower() == test_vector["output_cipher"].lower():
+
self.logger.debug(cipher_text)
self.logger.info("Cipher Matched.")
else:
if test_vector["output_cipher"] != "":
result = False
self.logger.info("Cipher NOT Matched.")
- self.logger.info("Cipher text in packet = " + cipher_text)
+ self.logger.info("Cipher text in packet = " + str(cipher_text))
self.logger.info("Ref Cipher text = " + test_vector["output_cipher"])
else:
self.logger.info("Skip Cipher, Since no cipher text set")
- hash_length = len(test_vector["output_hash"])/2
+ hash_length = len(test_vector["output_hash"])//2
if hash_length != 0:
if test_vector["auth_algo"] == "null":
- hash_text = binascii.b2a_hex(pkt_rec[i]["Raw"].getfieldval("load"))
+ hash_text = str(binascii.b2a_hex(pkt_rec.pktgen.pkt["Raw"].getfieldval("load")), encoding='utf-8')
else:
- hash_text = binascii.b2a_hex(pkt_rec[i]["Padding"].getfieldval("load"))
- if str.lower(hash_text) == str.lower(test_vector["output_hash"]):
+ hash_text = str(binascii.b2a_hex(pkt_rec.pktgen.pkt["Padding"].getfieldval("load")), encoding='utf-8')
+ if hash_text.lower() == test_vector["output_hash"].lower():
self.logger.info("Hash Matched")
else:
result = False
self.logger.info("Hash NOT Matched")
- self.logger.info("Hash text in packet = " + hash_text)
+ self.logger.info("Hash text in packet = " + str(hash_text))
self.logger.info("Ref Hash text = " + test_vector["output_hash"])
else:
self.logger.info("Skip Hash, Since no hash text set")
- self.logger.info("Packet Size : %d " % (len(test_vector["input"]) / 2))
+ self.logger.info("Packet Size : %d " % (len(test_vector["input"]) // 2))
# Close l2fwd-crypto process
self.dut.kill_all()
@@ -1045,10 +1046,11 @@ class TestL2fwdCrypto(TestCase):
out_str = ""
cipher_algo = vector['cipher_algo']
- mBitlen = 8 * (len(vector['input']) / 2)
+ mBitlen = 8 * (len(vector['input']) // 2)
bin_input = bytearray.fromhex(vector["input"])
- str_input = str(bin_input)
+ str_input = str(bin_input, encoding='utf-8')
bin_key = binascii.a2b_hex(vector["cipher_key"])
+ bin_key = str(bin_key, encoding='utf-8')
if ((cipher_algo.upper()).find("KASUMI") != -1):
vector["iv"] = vector["iv"][:10] + "000000"
@@ -1064,7 +1066,7 @@ class TestL2fwdCrypto(TestCase):
out_str = cm.EEA3(key=bin_key, count=0x10203, bearer=0, dir=1,
data=str_input, bitlen=mBitlen)
- cipher_str = out_str.encode("hex").upper()
+ cipher_str = out_str.upper()
return cipher_str
@@ -1097,7 +1099,7 @@ class TestL2fwdCrypto(TestCase):
elif (vector['cipher_algo']).upper() == "NULL":
cipher_str = vector["input"] if vector["chain"].upper().find("HASH_") == -1 else vector["output_hash"]
else:
- cipher_str = self.__cryptography_cipher(vector)
+ cipher_str = str(self.__cryptography_cipher(vector), encoding='utf-8')
vector["output_cipher"] = cipher_str.lower()
def __gen_kasumi_hash(self, vector):
@@ -1105,12 +1107,13 @@ class TestL2fwdCrypto(TestCase):
auth_algo = vector['auth_algo']
mBitlen = 8 * (len(vector['input']) / 2)
bin_input = bytearray.fromhex(vector["input"])
- str_input = str(bin_input)
+ str_input = str(bin_input, encoding='utf-8')
bin_key = binascii.a2b_hex(vector["auth_key"])
+ bin_key = str(bin_key, encoding='utf-8')
hash_out = cm.UIA1(key=bin_key, count=0X10203, fresh=0X4050607, dir=0,
data=str_input)
- auth_str = hash_out.encode("hex").lower()
+ auth_str = hash_out.lower()
vector["input"] = '0001020304050607' + vector["input"] + '40'
return auth_str
@@ -1120,14 +1123,15 @@ class TestL2fwdCrypto(TestCase):
auth_algo = vector['auth_algo']
mBitlen = 8 * (len(vector['input']) / 2)
bin_input = bytearray.fromhex(vector["input"])
- str_input = str(bin_input)
+ str_input = str(bin_input, encoding='utf-8')
bin_key = binascii.a2b_hex(vector["auth_key"])
+ bin_key = str(bin_key, encoding='utf-8')
vector["aad"] = "00000000000000000000000000000000"
hash_out = cm.UIA2(key=bin_key, count=0, fresh=0, dir=0,
data=str_input)
- auth_str = hash_out.encode("hex").lower()
+ auth_str = hash_out.lower()
return auth_str
@@ -1136,13 +1140,14 @@ class TestL2fwdCrypto(TestCase):
auth_algo = vector['auth_algo']
mBitlen = 8 * (len(vector['input']) / 2)
bin_input = bytearray.fromhex(vector["input"])
- str_input = str(bin_input)
+ str_input = str(bin_input, encoding='utf-8')
bin_key = binascii.a2b_hex(vector["auth_key"])
+ bin_key = str(bin_key, encoding='utf-8')
vector["aad"] = "00000000000000000000000000000000"
hash_out = cm.EIA3(key=bin_key, count=0, bearer=0, dir=0, data=str_input, bitlen=mBitlen)
- auth_str = hash_out.encode("hex").lower()
+ auth_str = hash_out.lower()
return auth_str
@@ -1235,6 +1240,8 @@ class TestL2fwdCrypto(TestCase):
hash_str = hashlib.sha512(binascii.a2b_hex(vector["auth_key"])).hexdigest()
else:
pass
+ if not isinstance(hash_str, str):
+ hash_str = str(hash_str, encoding='utf-8')
vector["output_hash"] = hash_str.lower()
self.__actually_pmd_hash(vector)
@@ -1431,7 +1438,7 @@ class TestL2fwdCrypto(TestCase):
]
if vector["auth_algo"] in auth_algo_dgst_map:
digest = vector["digest_size"]
- if digest >= (len(vector["output_hash"]) / 2):
+ if digest >= (len(vector["output_hash"]) // 2):
vector["output_hash"] = vector["output_hash"]
else:
vector["output_hash"] = (vector["output_hash"])[0:2*digest]
@@ -2057,7 +2064,7 @@ fc2ab337f7031a0f20636c82074a6bebcf91f06e04d45fa1dcc8454b6be54e53e3f9c99f0f830b16
},
"aesni_mb_h_MD_SHA_00": {
- "vdev": "crypto_aesni_mb_pmd",
+ "vdev": "crypto_aesni_mb",
"chain": ["HASH_ONLY"],
"cdev_type": "SW",
"cipher_algo": "",
@@ -2078,7 +2085,7 @@ fc2ab337f7031a0f20636c82074a6bebcf91f06e04d45fa1dcc8454b6be54e53e3f9c99f0f830b16
},
"aesni_mb_aead_AES_GCM_00": {
- "vdev": "crypto_aesni_mb_pmd",
+ "vdev": "crypto_aesni_mb",
"chain": ["AEAD"],
"cdev_type": "SW",
"cipher_algo": ["aes-gcm"],
diff --git a/tests/TestSuite_l2fwd_jobstats.py b/tests/TestSuite_l2fwd_jobstats.py
index 18c25d4..0881d05 100644
--- a/tests/TestSuite_l2fwd_jobstats.py
+++ b/tests/TestSuite_l2fwd_jobstats.py
@@ -82,7 +82,7 @@ class TestL2fwdJobstats(TestCase):
self.scapy_send_packet(100000)
out = self.dut.get_session_output(timeout=10)
- print out
+ print(out)
send_packets = re.findall(r"Total packets sent:\s+?(\d+?)\r", out)[-1]
receive_packets = re.findall(r"Total packets received:\s+?(\d+?)\r", out)[-1]
self.verify(send_packets == receive_packets == str(100000*len(self.tx_ports)), "Wrong: can't receive enough packages")
diff --git a/tests/TestSuite_l3fwd.py b/tests/TestSuite_l3fwd.py
index a9016d4..ae6a5cb 100644
--- a/tests/TestSuite_l3fwd.py
+++ b/tests/TestSuite_l3fwd.py
@@ -188,10 +188,10 @@ class TestL3fwd(TestCase):
elif ports == 4:
rtCmdLines = dict(TestL3fwd.cmdline_4_ports)
- for key in rtCmdLines.keys():
+ for key in list(rtCmdLines.keys()):
corelist = []
while pat.search(rtCmdLines[key]):
- print rtCmdLines[key]
+ print(rtCmdLines[key])
rtCmdLines[key] = pat.sub(self.repl, rtCmdLines[key])
core_mask[key] = utils.create_mask(set(corelist))
return rtCmdLines, core_mask
@@ -260,7 +260,7 @@ class TestL3fwd(TestCase):
for frame_size in self.frame_sizes:
if l3_proto == "ipv6" and frame_size == 64:
frame_size += 2
- for cores in rtCmdLines.keys():
+ for cores in list(rtCmdLines.keys()):
# Start L3fwd appliction
command_line = rtCmdLines[cores] % (TestL3fwd.path + l3_proto + "_l3fwd_" + mode, core_mask[cores],
self.dut.get_memory_channels(), utils.create_mask(valports))
@@ -314,7 +314,7 @@ class TestL3fwd(TestCase):
for frame_size in self.frame_sizes:
if l3_proto == "ipv6" and frame_size == 64:
frame_size += 2
- for cores in rtCmdLines.keys():
+ for cores in list(rtCmdLines.keys()):
# in order to save time, only some of the cases will be run.
if cores in ["1S/2C/1T", "1S/4C/1T"]:
# Start L3fwd appliction
diff --git a/tests/TestSuite_l3fwd_em.py b/tests/TestSuite_l3fwd_em.py
index ee50fcc..33acbd5 100644
--- a/tests/TestSuite_l3fwd_em.py
+++ b/tests/TestSuite_l3fwd_em.py
@@ -196,7 +196,7 @@ class TestL3fwdEM(TestCase):
coreMask = {}
rtCmdLines = dict(TestL3fwdEM.test_cases_2_ports)
- for key in rtCmdLines.keys():
+ for key in list(rtCmdLines.keys()):
corelist = []
while pat.search(rtCmdLines[key]):
# Change the socket to the NIC's socket
@@ -213,7 +213,7 @@ class TestL3fwdEM(TestCase):
# start l3fwd
index = 0
subtitle = []
- for cores in rtCmdLines.keys():
+ for cores in list(rtCmdLines.keys()):
info = "Executing l3fwd using %s mode, 2 ports, %s and %d frame size.\n" % (
mode, cores, frame_size)
diff --git a/tests/TestSuite_l3fwdacl.py b/tests/TestSuite_l3fwdacl.py
index 8b3c84e..1ab72a6 100644
--- a/tests/TestSuite_l3fwdacl.py
+++ b/tests/TestSuite_l3fwdacl.py
@@ -638,17 +638,17 @@ class TestL3fwdacl(TestCase):
self.verify(cores is not None, "Insufficient cores for speed testing")
self.core_mask = utils.create_mask(cores)
- print "Core mask: %s" % self.core_mask
+ print("Core mask: %s" % self.core_mask)
valid_ports = [port for port in ports if self.tester.get_local_port(port) != -1]
self.verify(
len(valid_ports) >= 2, "Insufficient active dut_ports for speed testing")
self.dut_ports = valid_ports
- print "Valid ports found in DUT: %s" % self.dut_ports
+ print("Valid ports found in DUT: %s" % self.dut_ports)
self.port_mask = utils.create_mask([self.dut_ports[0], self.dut_ports[1]])
- print "Port mask: %s" % self.port_mask
+ print("Port mask: %s" % self.port_mask)
TestL3fwdacl.default_rule["Port"] = self.dut_ports[1]
diff --git a/tests/TestSuite_loadbalancer.py b/tests/TestSuite_loadbalancer.py
index 934e291..238ca1e 100644
--- a/tests/TestSuite_loadbalancer.py
+++ b/tests/TestSuite_loadbalancer.py
@@ -84,7 +84,7 @@ class TestLoadbalancer(TestCase):
self.dut.send_expect(cmd, 'main loop.')
# Verify the traffic flow according to Ipv4 route table
- for flow in trafficFlow.keys():
+ for flow in list(trafficFlow.keys()):
rx_port = trafficFlow[flow][0]
for i in range(len(dutPorts)):
diff --git a/tests/TestSuite_mac_filter.py b/tests/TestSuite_mac_filter.py
index 19d250b..9912d23 100644
--- a/tests/TestSuite_mac_filter.py
+++ b/tests/TestSuite_mac_filter.py
@@ -39,6 +39,7 @@ import time
from test_case import TestCase
from pmd_output import PmdOutput
from packet import Packet
+import operator
class TestMacFilter(TestCase):
@@ -70,7 +71,7 @@ class TestMacFilter(TestCase):
ret = utils.regexp(out, mac_scanner)
self.verify(ret is not None, "MAC address not found")
- self.verify(cmp(ret.lower(), self.dest) == 0, "MAC address wrong")
+ self.verify(operator.eq(ret.lower(), self.dest), "MAC address wrong")
self.max_mac_addr = utils.regexp(out, "Maximum number of MAC addresses: ([0-9]+)")
diff --git a/tests/TestSuite_macsec_for_ixgbe.py b/tests/TestSuite_macsec_for_ixgbe.py
index 276db4d..a50173a 100644
--- a/tests/TestSuite_macsec_for_ixgbe.py
+++ b/tests/TestSuite_macsec_for_ixgbe.py
@@ -113,8 +113,8 @@ class TestMacsecForIxgbe(TestCase):
'in_pkts_ok', 'in_octets_decrypted', 'in_octets_validated', 'in_pkts_late', 'in_pkts_notvalid', 'in_pkts_nosci', 'in_pkts_notusingsa']
list_2 = [out_pkts_encrypted, out_octets_encrypted, out_pkts_protected, out_octets_protected, tx_good_packets, rx_good_packets,
in_pkts_ok, in_octets_decrypted, in_octets_validated, in_pkts_late, in_pkts_notvalid, in_pkts_nosci, in_pkts_notusingsa]
- result_dict = dict(zip(list_1, list_2))
- print result_dict
+ result_dict = dict(list(zip(list_1, list_2)))
+ print(result_dict)
if self.ol_flags == 0:
return result_dict, pkts_content
diff --git a/tests/TestSuite_mdd.py b/tests/TestSuite_mdd.py
index a7570c2..8aad1a7 100644
--- a/tests/TestSuite_mdd.py
+++ b/tests/TestSuite_mdd.py
@@ -34,6 +34,7 @@ DPDK Test suite.
Test the support of Malicious Driver Detection
"""
+
import re
import time
from packet import Packet
diff --git a/tests/TestSuite_metrics.py b/tests/TestSuite_metrics.py
index d098ccd..357395e 100644
--- a/tests/TestSuite_metrics.py
+++ b/tests/TestSuite_metrics.py
@@ -70,7 +70,7 @@ class TestMetrics(TestCase):
'jitter_ns'], }
def d_a_con(self, cmd):
- _cmd = [cmd, '# ', 10] if isinstance(cmd, (str, unicode)) else cmd
+ _cmd = [cmd, '# ', 10] if isinstance(cmd, str) else cmd
output = self.dut.alt_session.send_expect(*_cmd)
output2 = self.dut.alt_session.session.get_session_before(2)
return output + os.linesep + output2
@@ -85,7 +85,7 @@ class TestMetrics(TestCase):
def get_pkt_len(self, pkt_type, frame_size=64):
headers_size = sum(
- map(lambda x: HEADER_SIZE[x], ['eth', 'ip', pkt_type]))
+ [HEADER_SIZE[x] for x in ['eth', 'ip', pkt_type]])
pktlen = frame_size - headers_size
return pktlen
@@ -100,7 +100,7 @@ class TestMetrics(TestCase):
pkt_type = pkt_config.get('type')
pkt_layers = pkt_config.get('pkt_layers')
pkt = Packet(pkt_type=pkt_type)
- for layer in pkt_layers.keys():
+ for layer in list(pkt_layers.keys()):
pkt.config_layer(layer, pkt_layers[layer])
self.logger.debug(pformat(pkt.pktgen.pkt.command()))
@@ -239,7 +239,7 @@ class TestMetrics(TestCase):
def display_metrics_data(self, port_status, mode=None):
mode = mode if mode else self.BIT_RATE
display_seq = self.display_seq.get(mode)
- textLength = max(map(lambda x: len(x), display_seq))
+ textLength = max([len(x) for x in display_seq])
for port in sorted(port_status.keys()):
port_value = port_status[port]
if port != 'non port':
@@ -249,7 +249,7 @@ class TestMetrics(TestCase):
self.logger.info("{0} = [{1}]".format(
key.ljust(textLength), value))
else:
- maxvalue = max(map(lambda x: int(x), port_value.values()))
+ maxvalue = max([int(x) for x in list(port_value.values())])
if not maxvalue:
continue
self.logger.info("port {0}".format(port))
@@ -323,9 +323,9 @@ class TestMetrics(TestCase):
title = ['No', 'port']
values = []
for index, result in enumerate(metrics_data):
- for port, data in sorted(result.iteritems()):
+ for port, data in sorted(result.items()):
_value = [index, port]
- for key, value in data.iteritems():
+ for key, value in data.items():
if key not in title:
title.append(key)
_value.append(value)
@@ -386,8 +386,8 @@ class TestMetrics(TestCase):
# display test content
test_content = data.get('test_content')
test_cfg = {
- 'title': test_content.keys(),
- 'values': [test_content.values()]}
+ 'title': list(test_content.keys()),
+ 'values': [list(test_content.values())]}
self.display_suite_result(test_cfg)
# display pktgen bit rate statistics on traffic
self.logger.info("pktgen bit rate statistics:")
@@ -480,8 +480,8 @@ class TestMetrics(TestCase):
# display test content
test_content = data.get('test_content')
test_cfg = {
- 'title': test_content.keys(),
- 'values': [test_content.values()]}
+ 'title': list(test_content.keys()),
+ 'values': [list(test_content.values())]}
self.display_suite_result(test_cfg)
# display pktgen bit rate statistics on traffic
self.logger.info("pktgen bit rate statistics :")
@@ -565,9 +565,9 @@ class TestMetrics(TestCase):
title = ['No', 'port']
values = []
for index, result in enumerate(metrics_data):
- for port_id, data in result.iteritems():
+ for port_id, data in result.items():
_value = [index, port_id]
- for key, value in data.iteritems():
+ for key, value in data.items():
if key not in title:
title.append(key)
_value.append(value)
@@ -615,15 +615,15 @@ class TestMetrics(TestCase):
# display test content
test_content = data.get('test_content')
test_cfg = {
- 'title': test_content.keys(),
- 'values': [test_content.values()]}
+ 'title': list(test_content.keys()),
+ 'values': [list(test_content.values())]}
self.display_suite_result(test_cfg)
# display pktgen latency statistics on traffic
self.logger.info("pktgen line latency statistics :")
pktgen_results = data.get('pktgen_stats_on_traffic')
self.display_metrics_latency([pktgen_results])
# check if the value is reasonable, no reference data
- for port, value in pktgen_results.iteritems():
+ for port, value in pktgen_results.items():
max_value = value.get('max')
min_value = value.get('min')
average = value.get('average')
@@ -645,7 +645,7 @@ class TestMetrics(TestCase):
self.display_metrics_latency(metrics_results)
# check if the value is reasonable, no reference data
for index, result in enumerate(metrics_results):
- for port, value in result.iteritems():
+ for port, value in result.items():
if port != 'non port':
continue
max_value = value.get('max_latency_ns')
@@ -754,7 +754,7 @@ class TestMetrics(TestCase):
for item in [item.split(':') for item in frames_cfg.split(',')]]
frames_info = dict(info)
test_content = {
- 'frame_sizes': frames_info.keys(),
+ 'frame_sizes': list(frames_info.keys()),
'duration': int(cfg_content.get('duration') or 0),
'sample_number': int(cfg_content.get('sample_number') or 0),
'rates': [int(item)
diff --git a/tests/TestSuite_multicast.py b/tests/TestSuite_multicast.py
index b9dc4e8..bab1b1e 100644
--- a/tests/TestSuite_multicast.py
+++ b/tests/TestSuite_multicast.py
@@ -103,7 +103,7 @@ class TestMulticast(TestCase):
self.dut.send_expect("examples/ipv4_multicast/build/ipv4_multicast -c %s -n 4 -- -p %s -q 2" % (
coremask, '0x5'), "IPv4_MULTICAST:", 60)
- for flow in trafficFlow.keys():
+ for flow in list(trafficFlow.keys()):
for tx_port in trafficFlow[flow][0].split(","):
for rx_port in trafficFlow[flow][1].split(","):
sniff_src = "not 00:00:00:00:00:00"
@@ -122,7 +122,7 @@ class TestMulticast(TestCase):
for i in range(len(pkts)):
result = str(pkts[i].show)
- print result
+ print(result)
self.verify("Ether" in result, "No packet received")
self.verify("src=" + trafficFlow[flow][2] + " dst=" + trafficFlow[flow][3] in result,
"Wrong IP address")
diff --git a/tests/TestSuite_multiple_pthread.py b/tests/TestSuite_multiple_pthread.py
index 6c6a070..fb55de2 100644
--- a/tests/TestSuite_multiple_pthread.py
+++ b/tests/TestSuite_multiple_pthread.py
@@ -95,7 +95,7 @@ class TestMultiplePthread(TestCase):
if data != '':
data_row = re.findall(r'[\d\.]+', data)
if data_row[0] == data_row[1]:
- self.verify(data_row[2] > 0, "master thread are not running")
+ self.verify(float(data_row[2]) > 0, "master thread are not running")
# add data to the table
self.result_table_add(data_row)
self.out_view['data'].append(data_row)
@@ -109,7 +109,7 @@ class TestMultiplePthread(TestCase):
data_row = re.findall(r'[\d\.]+', data)
for lcore in lcore_list:
if data_row[3] == lcore:
- self.verify(data_row[2] > 0, "TID:%s not running" % data_row[1])
+ self.verify(float(data_row[2]) > 0, "TID:%s not running" % data_row[1])
self.result_table_add(data_row)
self.out_view['data'].append(data_row)
# print table
diff --git a/tests/TestSuite_nic_single_core_perf.py b/tests/TestSuite_nic_single_core_perf.py
index f43b5db..5e00f59 100644
--- a/tests/TestSuite_nic_single_core_perf.py
+++ b/tests/TestSuite_nic_single_core_perf.py
@@ -40,7 +40,6 @@ from test_case import TestCase
from exception import VerifyFailure
from settings import HEADER_SIZE, UPDATE_EXPECTED, load_global_setting
from pmd_output import PmdOutput
-from pktgen import TRANSMIT_CONT
from copy import deepcopy
import rst
from pktgen import PacketGeneratorHelper
@@ -109,7 +108,7 @@ class TestNicSingleCorePerf(TestCase):
self.expected_throughput = self.get_suite_cfg()[
'expected_throughput'][self.nic]
- # initialize throughput attribution
+ # initilize throughput attribution
# {'$framesize':{"$nb_desc": 'throughput'}
self.throughput = {}
@@ -184,7 +183,7 @@ class TestNicSingleCorePerf(TestCase):
# check the gap between expected throughput and actual throughput
try:
- for frame_size in self.test_parameters.keys():
+ for frame_size in list(self.test_parameters.keys()):
for nb_desc in self.test_parameters[frame_size]:
cur_gap = (self.expected_throughput[frame_size][nb_desc] - self.throughput[frame_size][nb_desc])
self.verify(cur_gap < self.gap, "Beyond Gap, Possible regression")
@@ -201,7 +200,7 @@ class TestNicSingleCorePerf(TestCase):
Update expected numbers to configurate file: conf/$suite_name.cfg
"""
if load_global_setting(UPDATE_EXPECTED) == "yes":
- for frame_size in self.test_parameters.keys():
+ for frame_size in list(self.test_parameters.keys()):
for nb_desc in self.test_parameters[frame_size]:
self.expected_throughput[frame_size][nb_desc] = \
round(self.throughput[frame_size][nb_desc], 3)
@@ -227,7 +226,7 @@ class TestNicSingleCorePerf(TestCase):
if self.nic in ["fortville_25g", "fortville_spirit"]:
param += " --rxq=2 --txq=2"
- for frame_size in self.test_parameters.keys():
+ for frame_size in list(self.test_parameters.keys()):
self.throughput[frame_size] = dict()
pcaps = self.create_pacap_file(frame_size)
tgenInput = self.prepare_stream(pcaps)
@@ -258,7 +257,7 @@ class TestNicSingleCorePerf(TestCase):
self.verify(throughput,
"No traffic detected, please check your configuration")
- self.logger.info("Throughput of " +
+ self.logger.info("Trouthput of " +
"framesize: {}, rxd/txd: {} is :{} Mpps".format(
frame_size, nb_desc, throughput))
@@ -274,7 +273,7 @@ class TestNicSingleCorePerf(TestCase):
# save test results to self.test_result
header = self.table_header
- for frame_size in self.test_parameters.keys():
+ for frame_size in list(self.test_parameters.keys()):
wirespeed = self.wirespeed(self.nic, frame_size, self.nb_ports)
ret_datas = {}
for nb_desc in self.test_parameters[frame_size]:
@@ -296,7 +295,7 @@ class TestNicSingleCorePerf(TestCase):
# Create test results table
self.result_table_create(header)
- for frame_size in self.test_parameters.keys():
+ for frame_size in list(self.test_parameters.keys()):
for nb_desc in self.test_parameters[frame_size]:
table_row = list()
for i in range(len(header)):
@@ -319,7 +318,7 @@ class TestNicSingleCorePerf(TestCase):
json_obj = dict()
json_obj['nic_type'] = self.nic
json_obj['results'] = list()
- for frame_size in self.test_parameters.keys():
+ for frame_size in list(self.test_parameters.keys()):
for nb_desc in self.test_parameters[frame_size]:
row_in = self.test_result[frame_size][nb_desc]
row_dict = dict()
diff --git a/tests/TestSuite_nvgre.py b/tests/TestSuite_nvgre.py
index 5734652..a841e85 100644
--- a/tests/TestSuite_nvgre.py
+++ b/tests/TestSuite_nvgre.py
@@ -366,7 +366,7 @@ class TestNvgre(TestCase):
elif self.nic in ["sageville", "sagepond"]:
self.compile_switch = 'CONFIG_RTE_IXGBE_INC_VECTOR'
elif self.nic in ["columbiaville_25g","columbiaville_100g"]:
- print "CVL support default none VECTOR"
+ print("CVL support default none VECTOR")
else:
self.verify(False, "%s not support NVGRE case" % self.nic)
# Based on h/w type, choose how many ports to use
@@ -471,7 +471,7 @@ class TestNvgre(TestCase):
config.send_pcap()
# check whether detect nvgre type
out = self.dut.get_session_output()
- print out
+ print(out)
self.verify(config.packet_type(self.nic) in out, "Nvgre Packet not detected")
self.dut.send_expect("show port stats all", "testpmd>", 10)
self.dut.send_expect("stop", "testpmd>", 10)
@@ -502,7 +502,7 @@ class TestNvgre(TestCase):
out = self.dut.send_expect("tunnel_filter add %d %s %s %s %d nvgre %s %d %d"
% (self.dut_rx_port, config.outer_mac_dst, config.inner_mac_dst, config.inner_ip_dst, vlan_id, filter_type, config.tni, queue_id),
"testpmd>", 10)
- print out
+ print(out)
# invalid case request to remove tunnel filter
if remove is True:
queue_id = 0
@@ -515,7 +515,7 @@ class TestNvgre(TestCase):
self.dut.send_expect("start", "testpmd>", 10)
config.send_pcap()
out = self.dut.get_session_output()
- print out
+ print(out)
queue = -1
pattern = re.compile("- Receive queue=0x(\d)")
m = pattern.search(out)
@@ -624,7 +624,7 @@ class TestNvgre(TestCase):
"""
# packet type detect must used without VECTOR pmd
if self.nic in ["columbiaville_25g","columbiaville_100g"]:
- print "CVL support default none VECTOR"
+ print("CVL support default none VECTOR")
src_vec_model = 'n'
else:
out = self.dut.send_expect("cat config/common_base", "]# ", 10)
@@ -650,7 +650,7 @@ class TestNvgre(TestCase):
# check vlan nvgre + vlan inner and outer packet
self.nvgre_detect(outer_l3_type = "IPv6", inner_l3_type="IPv6", outer_vlan=1, inner_vlan=1)
if self.nic in ["columbiaville_25g","columbiaville_100g"]:
- print "CVL support default none VECTOR"
+ print("CVL support default none VECTOR")
src_vec_model = 'n'
else:
out = self.dut.send_expect("cat config/common_base", "]# ", 10)
@@ -699,7 +699,7 @@ class TestNvgre(TestCase):
"""
# packet type detect must used without VECTOR pmd
if self.nic in ["columbiaville_25g","columbiaville_100g"]:
- print "CVL support default none VECTOR"
+ print("CVL support default none VECTOR")
src_vec_model = 'n'
else:
out = self.dut.send_expect("cat config/common_base", "]# ", 10)
@@ -723,7 +723,7 @@ class TestNvgre(TestCase):
# check vlan nvgre + vlan inner packet
self.nvgre_detect(outer_vlan=1, inner_vlan=1)
if self.nic in ["columbiaville_25g","columbiaville_100g"]:
- print "CVL support default none VECTOR"
+ print("CVL support default none VECTOR")
src_vec_model = 'n'
else:
out = self.dut.send_expect("cat config/common_base", "]# ", 10)
diff --git a/tests/TestSuite_packet_capture.py b/tests/TestSuite_packet_capture.py
index b1fbff4..6a6a5ea 100644
--- a/tests/TestSuite_packet_capture.py
+++ b/tests/TestSuite_packet_capture.py
@@ -74,7 +74,7 @@ def sniff_packets(intf, count=0, timeout=5, pcap=None):
param = "-" + m.group(2) + " in"
if len(param) == 0:
- print "tcpdump not support direction choice!!!"
+ print("tcpdump not support direction choice!!!")
sniff_cmd = 'tcpdump -i %(INTF)s %(IN_PARAM)s -w %(FILE)s'
options = {'INTF': intf, 'COUNT': count, 'IN_PARAM': param,
@@ -96,7 +96,7 @@ def sniff_packets(intf, count=0, timeout=5, pcap=None):
def load_sniff_packets(index=''):
pkts = []
child_exit = False
- if index in SNIFF_PIDS.keys():
+ if index in list(SNIFF_PIDS.keys()):
pipe, intf, timeout = SNIFF_PIDS[index]
time_elapse = int(time.time() - float(index))
while time_elapse < timeout:
@@ -178,7 +178,7 @@ class parsePacket(object):
self.pcapFile, number)
return warning
self.get_valid_packet(pcap_pkts, number)
- except Exception, e:
+ except Exception as e:
print (e)
return None
@@ -392,7 +392,7 @@ class TestPacketCapture(TestCase):
return warning
# remove some fields, which are filled by dpdk automatically
# if packet is filled with `Padding`, remove this
- if "Padding" in targetObj.packetLayers.keys():
+ if "Padding" in list(targetObj.packetLayers.keys()):
targetObj.packetLayers.pop("Padding")
if len(refObj.packetLayers) != len(targetObj.packetLayers):
refObj_layer = pformat(refObj.packetLayers)
@@ -402,8 +402,8 @@ class TestPacketCapture(TestCase):
warning = "packet {0} layers are not as expected".format(targetPkt)
return warning
- for layer in refObj.packetLayers.keys():
- if layer not in targetObj.packetLayers.keys():
+ for layer in list(refObj.packetLayers.keys()):
+ if layer not in list(targetObj.packetLayers.keys()):
warning = "{0} has no [{1}] layer".format(targetPkt, layer)
return warning
@@ -417,10 +417,10 @@ class TestPacketCapture(TestCase):
targetPkt, layer)
return warning
- for field in refLayerFields.keys():
+ for field in list(refLayerFields.keys()):
if field == 'src' or field == 'dst':
continue
- if field not in targetLayerFields.keys():
+ if field not in list(targetLayerFields.keys()):
warning = ("{0} layer [{1}] "
"has no [{2}] field").format(
targetPkt, layer, field)
diff --git a/tests/TestSuite_performance_thread.py b/tests/TestSuite_performance_thread.py
index 4d4cfe0..5e6b74b 100644
--- a/tests/TestSuite_performance_thread.py
+++ b/tests/TestSuite_performance_thread.py
@@ -157,7 +157,7 @@ class TestPerformanceThread(TestCase):
for layer in self.flows()[_port * 2:(_port + 1) * 2]:
flow = ['Ether(dst="%s", src="%s")/%s/("X"*%d)' % (dmac[index], smac[index], layer, payload_size)]
pcap = os.sep.join([self.output_path, "dst{0}_{1}.pcap".format(index, cnt)])
- self.tester.scapy_append('wrpcap("%s", [%s])' % (pcap, string.join(flow, ',')))
+ self.tester.scapy_append('wrpcap("%s", [%s])' % (pcap, ','.join(flow)))
self.tester.scapy_execute()
if index not in pcaps:
pcaps[index] = []
diff --git a/tests/TestSuite_pmd_bonded.py b/tests/TestSuite_pmd_bonded.py
index f0c39d8..877fc8a 100644
--- a/tests/TestSuite_pmd_bonded.py
+++ b/tests/TestSuite_pmd_bonded.py
@@ -129,7 +129,7 @@ class TestPmdBonded(TestCase):
try:
dut_dest_port = self.dut_ports[dest_port]
- except Exception, e:
+ except Exception as e:
dut_dest_port = dest_port
if not ether_ip.get('ether'):
diff --git a/tests/TestSuite_pmd_bonded_8023ad.py b/tests/TestSuite_pmd_bonded_8023ad.py
index 33f7403..6267406 100644
--- a/tests/TestSuite_pmd_bonded_8023ad.py
+++ b/tests/TestSuite_pmd_bonded_8023ad.py
@@ -315,7 +315,7 @@ class TestBonding8023AD(TestCase):
self.bond_inst.d_console(cmds)
self.set_8023ad_agg_mode(bond_port, mode)
except Exception as e:
- check_results.append(e); print traceback.format_exc()
+ check_results.append(e); print(traceback.format_exc())
finally:
self.bond_inst.close_testpmd()
time.sleep(2)
@@ -335,7 +335,7 @@ class TestBonding8023AD(TestCase):
bond_port = self.set_8023ad_bonded(slaves, bond_mode)
self.set_8023ad_dedicated_queues(bond_port, mode)
except Exception as e:
- check_results.append(e); print traceback.format_exc()
+ check_results.append(e); print(traceback.format_exc())
finally:
self.bond_inst.close_testpmd()
time.sleep(2)
@@ -419,7 +419,7 @@ class TestBonding8023AD(TestCase):
msgs.append(msg)
# check bonded slaves
_cur_slaves = [int(id) for id in cur_slaves]
- if not _cur_slaves or cmp(sorted(slaves), sorted(_cur_slaves)) != 0:
+ if not _cur_slaves or sorted(slaves) != sorted(_cur_slaves):
slaves_str = ' '.join([str(id) for id in slaves])
cur_slaves_str = ' '.join([str(id) for id in _cur_slaves]) \
if _cur_slaves else ''
@@ -430,7 +430,7 @@ class TestBonding8023AD(TestCase):
if self.kdriver is 'i40e':
if cur_active_slaves:
check_active_slaves = [int(id) for id in cur_active_slaves]
- if cmp(sorted(slaves), sorted(check_active_slaves)) != 0:
+ if sorted(slaves) != sorted(check_active_slaves):
slaves_str = ' '.join([str(id) for id in slaves])
msg_fmt = ('expected active slaves is [{0}], '
'current active slaves is [{1}]')
@@ -452,8 +452,7 @@ class TestBonding8023AD(TestCase):
cur_active_slaves = [
int(id) for id in self.bond_inst.get_bonding_info(
bond_port, 'active_slaves')]
- if not cur_active_slaves or cmp(sorted(slaves),
- sorted(cur_active_slaves)) != 0:
+ if not cur_active_slaves or sorted(slaves) != sorted(cur_active_slaves):
slaves_str = ' '.join([str(id) for id in slaves])
active_str = ' '.join([str(id) for id in cur_active_slaves]) \
if cur_active_slaves else ''
@@ -525,7 +524,7 @@ class TestBonding8023AD(TestCase):
self.check_bonded_device_start(bond_port)
self.stop_bonded_device(bond_port)
except Exception as e:
- print traceback.format_exc()
+ print(traceback.format_exc())
msg = "bonding 8023ad check start/stop failed"
self.run_dpdk_functional_post()
if msg:
@@ -596,4 +595,4 @@ class TestBonding8023AD(TestCase):
def test_basic_dedicated_queues(self):
''' test 802.3ad dedicated queues setting '''
mode = MODE_LACP
- self.check_8023ad_dedicated_queues(self.dut_ports, mode)
\ No newline at end of file
+ self.check_8023ad_dedicated_queues(self.dut_ports, mode)
diff --git a/tests/TestSuite_pmd_stacked_bonded.py b/tests/TestSuite_pmd_stacked_bonded.py
index de126b9..12c384f 100644
--- a/tests/TestSuite_pmd_stacked_bonded.py
+++ b/tests/TestSuite_pmd_stacked_bonded.py
@@ -64,7 +64,7 @@ class TestBondingStacked(TestCase):
# get slave device queue configuration
for port_id in devices[1:]:
config = self.bond_inst.get_port_info(port_id, 'queue_config')
- if cmp(config, master) == 0:
+ if config == master:
continue
msg = ("slave bonded port [{0}] is "
"different to top bonded port [{1}]").format(
@@ -378,7 +378,7 @@ class TestBondingStacked(TestCase):
num_ports = len(self.dut_ports)
self.verify(num_ports == 2 or num_ports == 4, "Insufficient ports")
# separate ports into two group as first level bond ports' slaves
- sep_index = len(self.dut_ports)/2
+ sep_index = len(self.dut_ports)//2
self.slaveGrpOne = self.dut_ports[:sep_index]
self.slaveGrpTwo = self.dut_ports[sep_index:]
self.bond_slave = self.dut_ports[0]
@@ -531,4 +531,4 @@ class TestBondingStacked(TestCase):
slave_down_port_limit)
self.logger.warning(msg)
return
- self.xor_check_stacked_rx_one_slave_down()
\ No newline at end of file
+ self.xor_check_stacked_rx_one_slave_down()
diff --git a/tests/TestSuite_pmdpcap.py b/tests/TestSuite_pmdpcap.py
index 8f20693..4f6c426 100644
--- a/tests/TestSuite_pmdpcap.py
+++ b/tests/TestSuite_pmdpcap.py
@@ -74,11 +74,11 @@ class TestPmdPcap(TestCase):
else:
raise Exception(
"Unknow os type, please check to make sure pcap can work in OS [ %s ]" % os_type)
- out = self.dut.send_command("cat config/%s" % (config_head + config_tail))
- if "CONFIG_RTE_LIBRTE_PMD_PCAP" in out:
- return config_head + config_tail
- else:
- return config_head + "base"
+ out = self.dut.send_command("cat config/%s" % (config_head + config_tail))
+ if "CONFIG_RTE_LIBRTE_PMD_PCAP" in out:
+ return config_head + config_tail
+ else:
+ return config_head + "base"
def create_pcap_file(self, filename, number_of_packets):
flow = []
--git a/tests/TestSuite_pmdrss_hash.py b/tests/TestSuite_pmdrss_hash.py
index faae080..e160364 100644
--- a/tests/TestSuite_pmdrss_hash.py
+++ b/tests/TestSuite_pmdrss_hash.py
@@ -159,7 +159,7 @@ class TestPmdrssHash(TestCase):
self.tester.scapy_execute()
time.sleep(.5)
else:
- print "\ntran_type error!\n"
+ print("\ntran_type error!\n")
out = self.dut.get_session_output(timeout=1)
self.dut.send_expect("stop", "testpmd>")
@@ -206,7 +206,7 @@ class TestPmdrssHash(TestCase):
status = "false"
# compute the hash result of five tuple into the 7 LSBs value.
hash_index = int(tmp_reta_line["RSS hash"], 16) % reta_num
- print reta_entries[hash_index], tmp_reta_line
+ print(reta_entries[hash_index], tmp_reta_line)
if(reta_entries[hash_index] == int(tmp_reta_line["queue"])):
status = "true"
result.insert(i, 0)
@@ -341,7 +341,7 @@ class TestPmdrssHash(TestCase):
self.tester.scapy_execute()
time.sleep(.5)
else:
- print "\ntran_type error!\n"
+ print("\ntran_type error!\n")
out = self.dut.get_session_output(timeout=1)
self.dut.send_expect("stop", "testpmd>")
@@ -392,10 +392,10 @@ class TestPmdrssHash(TestCase):
if(i % 2 == 1):
if(pre_RSS_hash == tmp_reta_line["RSS hash"]):
status = "true"
- result.insert(len(reta_lines) + (i - 1) / 2, 0)
+ result.insert(len(reta_lines) + (i - 1) // 2, 0)
else:
status = "fail"
- result.insert(len(reta_lines) + (i - 1) / 2, 1)
+ result.insert(len(reta_lines) + (i - 1) // 2, 1)
pre_RSS_hash = tmp_reta_line["RSS hash"]
else:
status = "fail"
@@ -461,7 +461,7 @@ class TestPmdrssHash(TestCase):
"./%s/app/testpmd -c %s -n %d -- -i --rxq=%d --txq=%d" %
(self.target, self.coremask, self.dut.get_memory_channels(), queue, queue), "testpmd> ", 120)
- for iptype, rsstype in iptypes.items():
+ for iptype, rsstype in list(iptypes.items()):
self.dut.send_expect("set verbose 8", "testpmd> ")
self.dut.send_expect("set fwd rxonly", "testpmd> ")
self.dut.send_expect("set promisc all off", "testpmd> ")
@@ -499,7 +499,7 @@ class TestPmdrssHash(TestCase):
"./%s/app/testpmd -c %s -n %d -- -i --rxq=%d --txq=%d" %
(self.target, self.coremask, self.dut.get_memory_channels(), queue, queue), "testpmd> ", 120)
- for iptype, rsstype in iptypes.items():
+ for iptype, rsstype in list(iptypes.items()):
self.dut.send_expect("set verbose 8", "testpmd> ")
self.dut.send_expect("set fwd rxonly", "testpmd> ")
self.dut.send_expect("set promisc all off", "testpmd> ")
@@ -544,7 +544,7 @@ class TestPmdrssHash(TestCase):
"./%s/app/testpmd -c %s -n %d -- -i --rxq=%d --txq=%d" %
(self.target, self.coremask, self.dut.get_memory_channels(), queue, queue), "testpmd> ", 120)
- for iptype, rsstype in iptypes.items():
+ for iptype, rsstype in list(iptypes.items()):
self.logger.info("***********************%s rss test********************************" % iptype)
self.dut.send_expect("set verbose 8", "testpmd> ")
self.dut.send_expect("set fwd rxonly", "testpmd> ")
@@ -584,7 +584,7 @@ class TestPmdrssHash(TestCase):
"./%s/app/testpmd -c %s -n %d -- -i --rxq=%d --txq=%d" %
(self.target, self.coremask, self.dut.get_memory_channels(), queue, queue), "testpmd> ", 120)
- for iptype, rsstype in iptypes.items():
+ for iptype, rsstype in list(iptypes.items()):
self.dut.send_expect("set verbose 8", "testpmd> ")
self.dut.send_expect("set fwd rxonly", "testpmd> ")
self.dut.send_expect("set promisc all off", "testpmd> ")
--git a/tests/TestSuite_pmdrssreta.py b/tests/TestSuite_pmdrssreta.py
index a2f2d3e..05e4e42 100644
--- a/tests/TestSuite_pmdrssreta.py
+++ b/tests/TestSuite_pmdrssreta.py
@@ -104,7 +104,7 @@ class TestPmdrssreta(TestCase):
self.tester.scapy_execute()
time.sleep(.5)
else:
- print "\ntran_type error!\n"
+ print("\ntran_type error!\n")
out = self.dut.get_session_output(timeout=1)
self.dut.send_expect("stop", "testpmd>")
lines = out.split("\r\n")
@@ -118,7 +118,7 @@ class TestPmdrssreta(TestCase):
item = item.strip()
if(item.startswith("RSS hash")):
name, value = item.split("=", 1)
- print name + "-" + value
+ print(name + "-" + value)
reta_line[name.strip()] = value.strip()
reta_lines.append(reta_line)
@@ -184,8 +184,8 @@ class TestPmdrssreta(TestCase):
"""
Run at the start of each test suite.
"""
- cores = self.dut.get_core_list("all")
- self.coremask = utils.create_mask(cores)
+ cores = self.dut.get_core_list("all")
+ self.coremask = utils.create_mask(cores)
ports = self.dut.get_ports(self.nic)
self.ports_socket = self.dut.get_numa_id(ports[0])
@@ -222,7 +222,7 @@ class TestPmdrssreta(TestCase):
self.pmdout.start_testpmd(
"all", "--mbcache=128 --rxq=%d --txq=%d" % (queue, queue), socket=self.ports_socket)
- for iptype, rsstype in iptypes.items():
+ for iptype, rsstype in list(iptypes.items()):
self.dut.send_expect("set verbose 8", "testpmd> ")
self.dut.send_expect("set fwd rxonly", "testpmd> ")
self.dut.send_expect(
@@ -260,7 +260,7 @@ class TestPmdrssreta(TestCase):
def test_rss_key_size(self):
nic_rss_key_size = {"columbiaville_25g": 52, "columbiaville_100g": 52, "fortville_eagle": 52, "fortville_spirit": 52, "fortville_spirit_single": 52, "fortville_25g": 52, "niantic": 40, "e1000": 40, "redrockcanyou": 40, "atwood": 40, "boulderrapid": 40, "fortpark_TLV": 52, "hi1822": 40, "cavium_a063": 48, "cavium_a064": 48, "carlsville": 52, "sagepond": 40, "sageville": 40}
- self.verify(self.nic in nic_rss_key_size.keys(), "Not supporte rss key on %s" % self.nic)
+ self.verify(self.nic in list(nic_rss_key_size.keys()), "Not supporte rss key on %s" % self.nic)
dutPorts = self.dut.get_ports(self.nic)
localPort = self.tester.get_local_port(dutPorts[0])
@@ -276,8 +276,8 @@ class TestPmdrssreta(TestCase):
m = pattern.search(out)
if m is not None:
size = m.group(1)
- print utils.GREEN("******************")
- print utils.GREEN("NIC %s hash size %d and expected %d" % (self.nic, int(size), nic_rss_key_size[self.nic]))
+ print(utils.GREEN("******************"))
+ print(utils.GREEN("NIC %s hash size %d and expected %d" % (self.nic, int(size), nic_rss_key_size[self.nic])))
if (nic_rss_key_size[self.nic] == int(size)):
self.verify(True, "pass")
else:
diff --git a/tests/TestSuite_port_control.py b/tests/TestSuite_port_control.py
index f006ddb..ff55f9c 100644
--- a/tests/TestSuite_port_control.py
+++ b/tests/TestSuite_port_control.py
@@ -171,6 +171,7 @@ class TestPortControl(TestCase):
else:
self.verify(ret == "down", "port not down!")
+
def reset_pmd_port(self, terminal):
terminal.execute_cmd("port reset all")
ret = terminal.get_port_link_status(self.port_id_0)
diff --git a/tests/TestSuite_power_empty_poll.py b/tests/TestSuite_power_empty_poll.py
index 3556e74..3be5146 100644
--- a/tests/TestSuite_power_empty_poll.py
+++ b/tests/TestSuite_power_empty_poll.py
@@ -64,11 +64,11 @@ class TestPowerEmptPoll(TestCase):
return target_dir
def d_con(self, cmd):
- _cmd = [cmd, '# ', 10] if isinstance(cmd, (str, unicode)) else cmd
+ _cmd = [cmd, '# ', 10] if isinstance(cmd, str) else cmd
return self.dut.send_expect(*_cmd)
def d_a_con(self, cmd):
- _cmd = [cmd, '# ', 10] if isinstance(cmd, (str, unicode)) else cmd
+ _cmd = [cmd, '# ', 10] if isinstance(cmd, str) else cmd
return self.dut.alt_session.send_expect(*_cmd)
def prepare_binary(self, name):
@@ -135,13 +135,13 @@ class TestPowerEmptPoll(TestCase):
# create packet instance for send
streams = []
for stm_name in stm_names:
- if stm_name not in pkt_configs.keys():
+ if stm_name not in list(pkt_configs.keys()):
continue
values = pkt_configs[stm_name]
pkt_type = values.get('type')
pkt_layers = values.get('pkt_layers')
pkt = Packet(pkt_type=pkt_type)
- for layer in pkt_layers.keys():
+ for layer in list(pkt_layers.keys()):
pkt.config_layer(layer, pkt_layers[layer])
streams.append(pkt.pktgen.pkt)
diff --git a/tests/TestSuite_power_pbf.py b/tests/TestSuite_power_pbf.py
index c0422fa..3c281bc 100644
--- a/tests/TestSuite_power_pbf.py
+++ b/tests/TestSuite_power_pbf.py
@@ -87,7 +87,7 @@ class TestPowerPbf(TestCase):
console, msg_pipe = self.get_console(con_name)
if len(cmds) == 0:
return
- if isinstance(cmds, (str, unicode)):
+ if isinstance(cmds, str):
cmds = [cmds, '# ', 5]
if not isinstance(cmds[0], list):
cmds = [cmds]
@@ -129,7 +129,7 @@ class TestPowerPbf(TestCase):
def get_cores_mask(self, config='all'):
sockets = [self.dut.get_numa_id(index) for index in self.dut_ports]
socket_count = Counter(sockets)
- port_socket = socket_count.keys()[0] if len(socket_count) == 1 else -1
+ port_socket = list(socket_count.keys())[0] if len(socket_count) == 1 else -1
mask = create_mask(self.dut.get_core_list(config, socket=port_socket))
return mask
@@ -302,14 +302,14 @@ class TestPowerPbf(TestCase):
# get high priority core and normal core
base_freqs_info = {}
- for core_index, value in cpu_info.iteritems():
+ for core_index, value in list(cpu_info.items()):
base_frequency = value.get('base_frequency')
base_freqs_info.setdefault(base_frequency, []).append(core_index)
- base_freqs = base_freqs_info.keys()
+ base_freqs = list(base_freqs_info.keys())
# cpu should have high priority core and normal core
# high priority core frequency is higher than normal core frequency
if len(base_freqs) <= 1 or \
- not all([len(value) for value in base_freqs_info.values()]):
+ not all([len(value) for value in list(base_freqs_info.values())]):
msg = 'current cpu has no high priority core'
raise Exception(msg)
@@ -406,14 +406,14 @@ class TestPowerPbf(TestCase):
cores_info = self.parse_vm_power_cores_freq(output)
# get high priority core and normal core
base_freqs_info = {}
- for core_index, value in cores_info.iteritems():
+ for core_index, value in list(cores_info.items()):
base_frequency = value.get('base_frequency')
base_freqs_info.setdefault(base_frequency, []).append(core_index)
- base_freqs = base_freqs_info.keys()
+ base_freqs = list(base_freqs_info.keys())
# cpu should have high priority core and normal core
# high priority core frequency is higher than normal core frequency
if len(base_freqs) <= 1 or \
- not all([len(value) for value in base_freqs_info.values()]):
+ not all([len(value) for value in list(base_freqs_info.values())]):
msg = 'current cpu has no high priority core'
raise Exception(msg)
diff --git a/tests/TestSuite_power_pstate.py b/tests/TestSuite_power_pstate.py
index 74dedc6..67ddae5 100644
--- a/tests/TestSuite_power_pstate.py
+++ b/tests/TestSuite_power_pstate.py
@@ -86,7 +86,7 @@ class TestPowerPbf(TestCase):
console, msg_pipe = self.get_console(con_name)
if len(cmds) == 0:
return
- if isinstance(cmds, (str, unicode)):
+ if isinstance(cmds, str):
cmds = [cmds, '# ', 5]
if not isinstance(cmds[0], list):
cmds = [cmds]
@@ -129,7 +129,7 @@ class TestPowerPbf(TestCase):
def get_cores_mask(self, config='all'):
sockets = [self.dut.get_numa_id(index) for index in self.dut_ports]
socket_count = Counter(sockets)
- port_socket = socket_count.keys()[0] if len(socket_count) == 1 else -1
+ port_socket = list(socket_count.keys())[0] if len(socket_count) == 1 else -1
mask = create_mask(self.dut.get_core_list(config, socket=port_socket))
return mask
@@ -217,7 +217,7 @@ class TestPowerPbf(TestCase):
@property
def is_hyper_threading(self):
- cpu_index = self.cpu_info.keys()[-1]
+ cpu_index = list(self.cpu_info.keys())[-1]
core_num = self.cpu_info[cpu_index].get('core')
return (cpu_index + 1) / 2 == (core_num + 1)
diff --git a/tests/TestSuite_ptpclient.py b/tests/TestSuite_ptpclient.py
index 461abf1..5a524b9 100644
--- a/tests/TestSuite_ptpclient.py
+++ b/tests/TestSuite_ptpclient.py
@@ -113,11 +113,11 @@ class TestPtpClient(TestCase):
utils.regexp(out, r'Delta between master and slave clocks\:(-?\d+)ns')
pat = re.compile(r'Delta between master and slave clocks\:(-?\d+)ns')
Delta_list = pat.findall(out)
- Delta = map(int, Delta_list)
+ Delta = list(map(int, Delta_list))
Delta_ns = self.average(Delta)
Delta_us = Delta_ns / 1000.0
- print "Delta:", Delta
+ print("Delta:", Delta)
self.creat_table(Delta_us)
@@ -144,11 +144,11 @@ class TestPtpClient(TestCase):
utils.regexp(out, r'Delta between master and slave clocks\:(-?\d+)ns')
pat = re.compile(r'Delta between master and slave clocks\:(-?\d+)ns')
Delta_list = pat.findall(out)
- Delta = map(int, Delta_list)
+ Delta = list(map(int, Delta_list))
Delta_ns = self.average(Delta)
Delta_us = Delta_ns / 1000.0
- print "Delta:", Delta
+ print("Delta:", Delta)
self.creat_table(Delta_us)
diff --git a/tests/TestSuite_ptype_mapping.py b/tests/TestSuite_ptype_mapping.py
index b352724..f9e6ec6 100644
--- a/tests/TestSuite_ptype_mapping.py
+++ b/tests/TestSuite_ptype_mapping.py
@@ -79,7 +79,7 @@ class TestPtype_Mapping(TestCase):
Generate and send packet according to packet type, detect each packet
layer.
"""
- for pkt_type in pkt_types.keys():
+ for pkt_type in list(pkt_types.keys()):
if chk_types != None:
pkt_names = chk_types[pkt_type]
else:
@@ -92,9 +92,9 @@ class TestPtype_Mapping(TestCase):
"Failed to detect correct ptype value")
for pkt_layer_name in pkt_names:
if pkt_layer_name not in out:
- print utils.RED("Fail to detect %s" % pkt_layer_name)
+ print(utils.RED("Fail to detect %s" % pkt_layer_name))
raise VerifyFailure("Failed to detect %s" % pkt_layer_name)
- print utils.GREEN("Detected %s successfully" % pkt_type)
+ print(utils.GREEN("Detected %s successfully" % pkt_type))
def strip_ptype(self, table, hw_ptype):
"""
@@ -106,7 +106,7 @@ class TestPtype_Mapping(TestCase):
s = re.compile(pattern)
res = s.search(table)
if res is None:
- print utils.RED("search none ptype")
+ print(utils.RED("search none ptype"))
return None
else:
ptype = res.group(3)
diff --git a/tests/TestSuite_pvp_diff_qemu_version.py b/tests/TestSuite_pvp_diff_qemu_version.py
index 9e8259b..226693f 100644
--- a/tests/TestSuite_pvp_diff_qemu_version.py
+++ b/tests/TestSuite_pvp_diff_qemu_version.py
@@ -111,7 +111,7 @@ class TestVhostPVPDiffQemuVersion(TestCase):
config_qemu = False
params_num = len(self.vm.params)
for qemu_index in range(params_num):
- if self.vm.params[qemu_index].keys()[0] == "qemu":
+ if list(self.vm.params[qemu_index].keys())[0] == "qemu":
qemu_num = len(self.vm.params[qemu_index]["qemu"])
config_qemu = True
break
@@ -164,7 +164,7 @@ class TestVhostPVPDiffQemuVersion(TestCase):
"""
params_num = len(self.vm.params)
for qemu_index in range(params_num):
- if self.vm.params[qemu_index].keys()[0] == "qemu":
+ if list(self.vm.params[qemu_index].keys())[0] == "qemu":
qemu_num = len(self.vm.params[qemu_index]["qemu"])
break
self.verify(qemu_index < params_num, "Please config qemu path in conf gile")
diff --git a/tests/TestSuite_pvp_multi_paths_performance.py b/tests/TestSuite_pvp_multi_paths_performance.py
index fe6bd11..e1a3113 100644
--- a/tests/TestSuite_pvp_multi_paths_performance.py
+++ b/tests/TestSuite_pvp_multi_paths_performance.py
@@ -89,7 +89,7 @@ class TestPVPMultiPathPerformance(TestCase):
"""
for frame_size in self.frame_sizes:
tgen_input = []
- for port in xrange(self.number_of_ports):
+ for port in range(self.number_of_ports):
rx_port = self.tester.get_local_port(
self.dut_ports[port % self.number_of_ports])
tx_port = self.tester.get_local_port(
diff --git a/tests/TestSuite_pvp_multi_paths_vhost_single_core_performance.py b/tests/TestSuite_pvp_multi_paths_vhost_single_core_performance.py
index fbdb939..5313b57 100644
--- a/tests/TestSuite_pvp_multi_paths_vhost_single_core_performance.py
+++ b/tests/TestSuite_pvp_multi_paths_vhost_single_core_performance.py
@@ -88,7 +88,7 @@ class TestPVPMultiPathVhostPerformance(TestCase):
"""
for frame_size in self.frame_sizes:
tgen_input = []
- for port in xrange(self.number_of_ports):
+ for port in range(self.number_of_ports):
rx_port = self.tester.get_local_port(
self.dut_ports[port % self.number_of_ports])
tx_port = self.tester.get_local_port(
diff --git a/tests/TestSuite_pvp_multi_paths_virtio_single_core_performance.py b/tests/TestSuite_pvp_multi_paths_virtio_single_core_performance.py
index 8850b10..eb24474 100644
--- a/tests/TestSuite_pvp_multi_paths_virtio_single_core_performance.py
+++ b/tests/TestSuite_pvp_multi_paths_virtio_single_core_performance.py
@@ -89,7 +89,7 @@ class TestPVPMultiPathVirtioPerformance(TestCase):
"""
for frame_size in self.frame_sizes:
tgen_input = []
- for port in xrange(self.number_of_ports):
+ for port in range(self.number_of_ports):
rx_port = self.tester.get_local_port(
self.dut_ports[port % self.number_of_ports])
tx_port = self.tester.get_local_port(
diff --git a/tests/TestSuite_pvp_vhost_user_reconnect.py b/tests/TestSuite_pvp_vhost_user_reconnect.py
index 16a93b0..06d081f 100644
--- a/tests/TestSuite_pvp_vhost_user_reconnect.py
+++ b/tests/TestSuite_pvp_vhost_user_reconnect.py
@@ -155,7 +155,7 @@ class TestPVPVhostUserReconnect(TestCase):
self.vm_qemu_version = vm_config.qemu_emulator
params_number = len(vm_config.params)
for i in range(params_number):
- if vm_config.params[i].keys()[0] == 'qemu':
+ if list(vm_config.params[i].keys())[0] == 'qemu':
self.vm_qemu_version = vm_config.params[i]['qemu'][0]['path']
out = self.dut.send_expect("%s --version" % self.vm_qemu_version, "#")
@@ -193,7 +193,7 @@ class TestPVPVhostUserReconnect(TestCase):
if vm_dut is None:
raise Exception("Set up VM ENV failed")
except Exception as e:
- print utils.RED("Failure for %s" % str(e))
+ print(utils.RED("Failure for %s" % str(e)))
self.verify(vm_dut is not None, "start vm failed")
self.vm_dut.append(vm_dut)
self.vm.append(vm_info)
diff --git a/tests/TestSuite_pvp_virtio_bonding.py b/tests/TestSuite_pvp_virtio_bonding.py
index 874c058..1405b0b 100644
--- a/tests/TestSuite_pvp_virtio_bonding.py
+++ b/tests/TestSuite_pvp_virtio_bonding.py
@@ -135,7 +135,7 @@ class TestPVPVirtIOBonding(TestCase):
"""
out = self.vhost_testpmd.execute_cmd('stop')
self.vhost_testpmd.execute_cmd('start')
- print out
+ print(out)
rx, tx = self.get_port_stats(out, 0)
self.verify(rx > 0 and tx > 0, "vhost port 0 can not receive or fwd data")
@@ -151,7 +151,7 @@ class TestPVPVirtIOBonding(TestCase):
port 4 can rx packets,while port 3 tx packets
"""
out = self.vm_testpmd.execute_cmd('stop')
- print out
+ print(out)
rx, tx = self.get_port_stats(out, 4)
self.verify(rx > 0, "vm port 4 can not receive data")
@@ -181,7 +181,7 @@ class TestPVPVirtIOBonding(TestCase):
"""
params_number = len(self.vm.params)
for i in range(params_number):
- if self.vm.params[i].keys()[0] == 'cpu':
+ if list(self.vm.params[i].keys())[0] == 'cpu':
self.vm.params[i]['cpu'][0]['number'] = 6
def start_one_vm(self):
diff --git a/tests/TestSuite_qinq_filter.py b/tests/TestSuite_qinq_filter.py
index 738e5e4..fac8488 100644
--- a/tests/TestSuite_qinq_filter.py
+++ b/tests/TestSuite_qinq_filter.py
@@ -53,7 +53,7 @@ class TestQinqFilter(TestCase):
self.verify(self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single", "fortville_25g"],
"NIC %s not support this test" % self.nic)
- print 'this case only supports fortville with 6.0.0+ firmware and dpdk17.05+'
+ print('this case only supports fortville with 6.0.0+ firmware and dpdk17.05+')
ports = self.dut.get_ports()
# Verify that enough ports are available
self.verify(len(ports) >= 1, "Insufficient ports")
diff --git a/tests/TestSuite_qos_api.py b/tests/TestSuite_qos_api.py
index c25d263..da2c544 100644
--- a/tests/TestSuite_qos_api.py
+++ b/tests/TestSuite_qos_api.py
@@ -123,7 +123,7 @@ class TestQosApi(TestCase):
dmac = self.dut.get_mac_address(P0)
queues_4tc = [0, 32, 64, 96]
queues_8tc = [0, 16, 32, 48, 64, 80, 96, 112]
- print dmac
+ print(dmac)
for i in range(n):
pkt = "Ether(dst='%s', src='00:02:00:00:00:01')/Dot1Q(prio=%s)/IP()/Raw('x'*20)" % (dmac, i)
self.tester.scapy_append('sendp([%s], iface="%s")' % (pkt, self.txItf))
@@ -240,7 +240,7 @@ class TestQosApi(TestCase):
traffic_opt = {'delay': 10}
bps, pps = self.tester.pktgen.measure_throughput(stream_ids=streams, options=traffic_opt)
bps_rate = abs(float(self.bps) - bps)/self.bps
- print "bps_rate", bps_rate
+ print("bps_rate", bps_rate)
self.verify(round(self.bps_rate[1] >= bps_rate, 3) >= self.bps_rate[0], 'rx bps is not match 200M')
def add_queue_leaf_node(self, n):
diff --git a/tests/TestSuite_queue_region.py b/tests/TestSuite_queue_region.py
index 7d01dfb..518a050 100644
--- a/tests/TestSuite_queue_region.py
+++ b/tests/TestSuite_queue_region.py
@@ -95,7 +95,7 @@ class TestQueue_region(TestCase):
scanner = re.compile(result_scanner, re.DOTALL)
m = scanner.search(outstring)
queue_id = m.group(1)
- print "queue is %s" % queue_id
+ print("queue is %s" % queue_id)
self.dut.send_expect("start", "testpmd> ")
return queue_id
@@ -185,7 +185,7 @@ class TestQueue_region(TestCase):
dump all queue region rules that have been created in memory and compare that total rules number with the given expected number
to see if they are equal, as to get your conclusion after you have deleted any queue region rule entry.
"""
- print out
+ print(out)
self.verify("error" not in out, "the queue region settings has error.")
actual_QRnum = re.findall("region_id.*", out)
actual_FTnum = re.findall("flowtype_num\D*(\d*).*", out)
diff --git a/tests/TestSuite_queue_start_stop.py b/tests/TestSuite_queue_start_stop.py
index 48f9c1a..cb59c95 100644
--- a/tests/TestSuite_queue_start_stop.py
+++ b/tests/TestSuite_queue_start_stop.py
@@ -83,7 +83,7 @@ class TestQueueStartStop(TestCase):
self.dut.session.copy_file_to(patch_file, patch_dst)
self.patch_hotfix_dpdk(patch_dst + "macfwd_log.patch", True)
self.dut.build_dpdk_apps('./app/test-pmd')
- except Exception, e:
+ except Exception as e:
raise IOError("dpdk setup failure: %s" % e)
def check_forwarding(self, ports, nic, pktSize=64, received=True):
@@ -121,7 +121,7 @@ class TestQueueStartStop(TestCase):
self.dut.send_expect("patch -p0 < %s" % patch_dir, "#")
else:
self.dut.send_expect("patch -p0 -R < %s" % patch_dir, "#")
- except Exception, e:
+ except Exception as e:
raise ValueError("patch_hotfix_dpdk failure: %s" % e)
def test_queue_start_stop(self):
@@ -135,26 +135,26 @@ class TestQueueStartStop(TestCase):
self.dut.send_expect("set fwd mac", "testpmd>")
self.dut.send_expect("start", "testpmd>")
self.check_forwarding([0, 0], self.nic)
- except Exception, e:
+ except Exception as e:
raise IOError("dpdk start and first forward failure: %s" % e)
# stop rx queue test
try:
- print "test stop rx queue"
+ print("test stop rx queue")
self.dut.send_expect("stop", "testpmd>")
self.dut.send_expect("port 0 rxq 0 stop", "testpmd>")
self.dut.send_expect("start", "testpmd>")
self.check_forwarding([0, 0], self.nic, received=False)
# start rx queue test
- print "test start rx queue stop tx queue"
+ print("test start rx queue stop tx queue")
self.dut.send_expect("stop", "testpmd>")
self.dut.send_expect("port 0 rxq 0 start", "testpmd>")
self.dut.send_expect("port 0 txq 0 stop", "testpmd>")
self.dut.send_expect("start", "testpmd>")
self.check_forwarding([0, 0], self.nic, received=False)
out = self.dut.get_session_output()
- except Exception, e:
+ except Exception as e:
raise IOError("queue start/stop forward failure: %s" % e)
if self.nic == "cavium_a063":
@@ -164,12 +164,12 @@ class TestQueueStartStop(TestCase):
try:
# start tx queue test
- print "test start rx and tx queue"
+ print("test start rx and tx queue")
self.dut.send_expect("stop", "testpmd>")
self.dut.send_expect("port 0 txq 0 start", "testpmd>")
self.dut.send_expect("start", "testpmd>")
self.check_forwarding([0, 0], self.nic)
- except Exception, e:
+ except Exception as e:
raise IOError("queue start/stop forward failure: %s" % e)
def tear_down(self):
@@ -182,14 +182,14 @@ class TestQueueStartStop(TestCase):
self.dut.send_expect("stop", "testpmd>")
self.dut.send_expect("quit", "#")
except:
- print "Failed to quit testpmd"
+ print("Failed to quit testpmd")
self.dut.kill_all()
try:
self.patch_hotfix_dpdk(patch_dst + "macfwd_log.patch", False)
- except Exception, e:
- print "patch_hotfix_dpdk remove failure :%s" %e
+ except Exception as e:
+ print(("patch_hotfix_dpdk remove failure :%s" %e))
def tear_down_all(self):
"""
diff --git a/tests/TestSuite_quota_watermark.py b/tests/TestSuite_quota_watermark.py
index 1a81784..5f66727 100644
--- a/tests/TestSuite_quota_watermark.py
+++ b/tests/TestSuite_quota_watermark.py
@@ -249,7 +249,7 @@ class TestQuotaWatermark(TestCase, IxiaPacketGenerator):
def send_pcap_pkt_by_scapy(self, tester=None, file='', intf=''):
if intf == '' or file == '' or tester is None:
- print "Invalid option for send packet by scapy"
+ print("Invalid option for send packet by scapy")
return
content = 'pkts=rdpcap(\"%s\");sendp(pkts, iface=\"%s\");exit()' % (file, intf)
--git a/tests/TestSuite_rss_to_rte_flow.py b/tests/TestSuite_rss_to_rte_flow.py
index 1198c3e..d062dd5 100644
--- a/tests/TestSuite_rss_to_rte_flow.py
+++ b/tests/TestSuite_rss_to_rte_flow.py
@@ -97,7 +97,7 @@ class TestRSS_to_Rteflow(TestCase):
scanner = re.compile(result_scanner, re.DOTALL)
m = scanner.search(outstring)
queue_id = m.group(1)
- print("queue is %s" % queue_id)
+ print(("queue is %s" % queue_id))
self.pmdout.execute_cmd("clear port stats all")
return queue_id
diff --git a/tests/TestSuite_rteflow_priority.py b/tests/TestSuite_rteflow_priority.py
index 258dbac..e72524f 100644
--- a/tests/TestSuite_rteflow_priority.py
+++ b/tests/TestSuite_rteflow_priority.py
@@ -47,7 +47,8 @@ from test_case import TestCase
from settings import HEADER_SIZE
from pmd_output import PmdOutput
import sys
-reload(sys)
+import imp
+imp.reload(sys)
sys.setdefaultencoding('utf8')
diff --git a/tests/TestSuite_runtime_vf_queue_number_kernel.py b/tests/TestSuite_runtime_vf_queue_number_kernel.py
index 73d40c2..c37d418 100644
--- a/tests/TestSuite_runtime_vf_queue_number_kernel.py
+++ b/tests/TestSuite_runtime_vf_queue_number_kernel.py
@@ -185,8 +185,8 @@ class TestRuntimeVfQueueNumberKernel(TestCase):
self.vm0_testpmd.execute_cmd('set verbose 1')
self.vm0_testpmd.execute_cmd('set promisc all off')
- #set rss-hash-key to a fixed value instead of default random value on vf
- self.vm0_testpmd.execute_cmd('port config 0 rss-hash-key ipv4 6EA6A420D5138E712433B813AE45B3C4BECB2B405F31AD6C331835372D15E2D5E49566EE0ED1962AFA1B7932F3549520FD71C75E')
+ #set rss-hash-key to a fixed value instead of default random value on vf
+ self.vm0_testpmd.execute_cmd('port config 0 rss-hash-key ipv4 6EA6A420D5138E712433B813AE45B3C4BECB2B405F31AD6C331835372D15E2D5E49566EE0ED1962AFA1B7932F3549520FD71C75E')
time.sleep(1)
self.vm0_testpmd.execute_cmd('set fwd mac')
self.vm0_testpmd.execute_cmd("clear port stats all")
diff --git a/tests/TestSuite_rxtx_offload.py b/tests/TestSuite_rxtx_offload.py
index 2166c16..7facbf2 100644
--- a/tests/TestSuite_rxtx_offload.py
+++ b/tests/TestSuite_rxtx_offload.py
@@ -142,7 +142,7 @@ class TestRxTx_Offload(TestCase):
m = scanner.search(outstring)
i = 0
offload_value = m.group(1).split()
- for key, value in offloads.items():
+ for key, value in list(offloads.items()):
if value in offload_value:
offload_keys.insert(i, key)
i = i + 1
@@ -172,7 +172,7 @@ class TestRxTx_Offload(TestCase):
exp_offload = m.group(1).split()
self.verify(exp_offload != None, "There is no offload configured.")
for each_offload in offload:
- self.verify(each_offload in offloads.keys(), "Offload type error!")
+ self.verify(each_offload in list(offloads.keys()), "Offload type error!")
self.verify(offloads[each_offload] in exp_offload, "There is wrong offload configured.")
def check_queue_config(self, rxtx, offload):
@@ -225,7 +225,7 @@ class TestRxTx_Offload(TestCase):
scanner = re.compile(result_scanner, re.DOTALL)
m = scanner.search(outstring)
queue_id = m.group(1)
- print "queue is %s" % queue_id
+ print(("queue is %s" % queue_id))
return queue_id
def check_flag(self, packet, queue):
diff --git a/tests/TestSuite_short_live.py b/tests/TestSuite_short_live.py
index 47a68ee..31adf0d 100644
--- a/tests/TestSuite_short_live.py
+++ b/tests/TestSuite_short_live.py
@@ -159,7 +159,7 @@ class TestShortLiveApp(TestCase):
time = regex.findall(out)
if time != []:
- print "start time: %s s"%time[0]
+ print("start time: %s s"%time[0])
else:
self.verify(0, "start_up_time failed")
@@ -167,7 +167,7 @@ class TestShortLiveApp(TestCase):
repeat_time = 5
for i in range(repeat_time):
#dpdk start
- print "clean_up_with_signal_testpmd round %d" % (i + 1)
+ print("clean_up_with_signal_testpmd round %d" % (i + 1))
self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 -- -i --portmask=0x3" % self.target, "link state change event", 120)
self.dut.send_expect("set fwd mac", "testpmd>")
self.dut.send_expect("set promisc all off", "testpmd>")
@@ -192,7 +192,7 @@ class TestShortLiveApp(TestCase):
self.compile_examples("l2fwd")
for i in range(repeat_time):
#dpdk start
- print "clean_up_with_signal_l2fwd round %d" % (i + 1)
+ print("clean_up_with_signal_l2fwd round %d" % (i + 1))
self.dut.send_expect("./examples/l2fwd/build/app/l2fwd -n 4 -c 0xf -- -p 0x3 &", "L2FWD: entering main loop", 60)
self.check_forwarding([0, 1], self.nic)
@@ -208,7 +208,7 @@ class TestShortLiveApp(TestCase):
self.compile_examples("l3fwd")
for i in range(repeat_time):
#dpdk start
- print "clean_up_with_signal_l3fwd round %d" % (i + 1)
+ print("clean_up_with_signal_l3fwd round %d" % (i + 1))
self.dut.send_expect("./examples/l3fwd/build/app/l3fwd -n 4 -c 0xf -- -p 0x3 --config='(0,0,1),(1,0,2)' &", "L3FWD: entering main loop", 120)
self.check_forwarding([0, 0], self.nic)
diff --git a/tests/TestSuite_shutdown_api.py b/tests/TestSuite_shutdown_api.py
index 58daad1..03a7e86 100644
--- a/tests/TestSuite_shutdown_api.py
+++ b/tests/TestSuite_shutdown_api.py
@@ -229,9 +229,9 @@ class TestShutdownApi(TestCase):
try:
self.check_forwarding(ports)
except VerifyFailure as e:
- print 'promiscuous mode is working correctly'
+ print('promiscuous mode is working correctly')
except Exception as e:
- print " !!! DEBUG IT: " + e.message
+ print((" !!! DEBUG IT: " + e.message))
self.verify(False, e.message)
self.dut.send_expect("port stop all", "testpmd> ", 100)
@@ -312,7 +312,7 @@ class TestShutdownApi(TestCase):
Change Link Speed.
"""
if self.kdriver == "fm10k":
- print utils.RED("RRC not support\n")
+ print((utils.RED("RRC not support\n")))
return
self.pmdout.start_testpmd("Default", "--portmask=%s --port-topology=loop" % utils.create_mask(self.ports), socket=self.ports_socket)
@@ -326,9 +326,9 @@ class TestShutdownApi(TestCase):
result_scanner = r"([0-9]+)baseT/([A-Za-z]+)"
scanner = re.compile(result_scanner, re.DOTALL)
m = scanner.findall(out)
- configs = m[:-(len(m) / 2)]
+ configs = m[:-int(len(m) / 2)]
for config in configs:
- print config
+ print(config)
if self.nic in ["ironpond"]:
if config[0] != '1000' or '10000':
continue
@@ -362,7 +362,7 @@ class TestShutdownApi(TestCase):
Enable/Disable Jumbo Frames.
"""
if self.kdriver == "fm10k":
- print utils.RED("RRC not support\n")
+ print((utils.RED("RRC not support\n")))
return
jumbo_size = 2048
@@ -538,7 +538,7 @@ class TestShutdownApi(TestCase):
port link stats test
"""
if self.kdriver == "fm10k":
- print utils.RED("RRC not support\n")
+ print((utils.RED("RRC not support\n")))
return
self.pmdout.start_testpmd("Default", "--portmask=%s --port-topology=loop" % utils.create_mask(self.ports), socket=self.ports_socket)
diff --git a/tests/TestSuite_sriov_kvm.py b/tests/TestSuite_sriov_kvm.py
index 54148af..109b72b 100644
--- a/tests/TestSuite_sriov_kvm.py
+++ b/tests/TestSuite_sriov_kvm.py
@@ -111,7 +111,7 @@ class TestSriovKvm(TestCase):
try:
dut_dest_port = dut_ports[dest_port]
except Exception as e:
- print
+ print()
e
# using api get_local_port() to get the correct tester port.
@@ -377,7 +377,7 @@ class TestSriovKvm(TestCase):
def make_port_new_ruleid(self, port):
port = self.transform_integer(port)
- if port not in self.port_mirror_ref.keys():
+ if port not in list(self.port_mirror_ref.keys()):
max_rule_id = 0
else:
rule_ids = sorted(self.port_mirror_ref[port])
@@ -391,7 +391,7 @@ class TestSriovKvm(TestCase):
port = self.transform_integer(port)
rule_id = self.transform_integer(rule_id)
- if port not in self.port_mirror_ref.keys():
+ if port not in list(self.port_mirror_ref.keys()):
self.port_mirror_ref[port] = [rule_id]
else:
self.verify(rule_id not in self.port_mirror_ref[port],
@@ -401,7 +401,7 @@ class TestSriovKvm(TestCase):
def remove_port_ruleid(self, port, rule_id):
port = self.transform_integer(port)
rule_id = self.transform_integer(rule_id)
- if port not in self.port_mirror_ref.keys():
+ if port not in list(self.port_mirror_ref.keys()):
pass
else:
if rule_id not in self.port_mirror_ref[port]:
@@ -472,7 +472,7 @@ class TestSriovKvm(TestCase):
"""
port = self.transform_integer(port)
- if port not in self.port_mirror_ref.keys():
+ if port not in list(self.port_mirror_ref.keys()):
pass
else:
for rule_id in self.port_mirror_ref[port][:]:
@@ -555,7 +555,7 @@ class TestSriovKvm(TestCase):
def calculate_stats(self, start_stats, end_stats):
ret_stats = {}
- for key in start_stats.keys():
+ for key in list(start_stats.keys()):
try:
start_stats[key] = int(start_stats[key])
end_stats[key] = int(end_stats[key])
diff --git a/tests/TestSuite_telemetry.py b/tests/TestSuite_telemetry.py
index 13a0729..e8ef6b7 100644
--- a/tests/TestSuite_telemetry.py
+++ b/tests/TestSuite_telemetry.py
@@ -123,7 +123,7 @@ class TestTelemetry(TestCase):
fileName = 'query_tool.py'
query_script = os.path.join(self.output_path, fileName)
with open(query_script, 'wb') as fp:
- fp.write('#! /usr/bin/env python' + os.linesep + script_content)
+ fp.write(('#! /usr/bin/env python' + os.linesep + script_content).encode())
self.dut.session.copy_file_to(query_script, self.target_dir)
self.query_tool = ';'.join([
'cd {}'.format(self.target_dir),
@@ -189,7 +189,7 @@ class TestTelemetry(TestCase):
console, msg_pipe = self.get_console(con_name)
if not cmds:
return
- if isinstance(cmds, (str, unicode)):
+ if isinstance(cmds, str):
cmds = [cmds, '# ', 5]
if not isinstance(cmds[0], list):
cmds = [cmds]
@@ -228,7 +228,7 @@ class TestTelemetry(TestCase):
self.used_ports = self.dut_ports
return None
pci_addrs = [
- pci_addr for pci_addrs in self.nic_grp.values()[:nic_types]
+ pci_addr for pci_addrs in list(self.nic_grp.values())[:nic_types]
for pci_addr in pci_addrs[:num]]
for index in self.dut_ports:
info = self.dut.ports_info[index]
@@ -250,7 +250,7 @@ class TestTelemetry(TestCase):
socket=socket)
self.testpmd_status = 'running'
self.testpmd.execute_cmd('start')
- if not self.change_flag:
+ if not self.change_flag:
self.change_run_fileprefix(output)
return output
@@ -363,7 +363,7 @@ class TestTelemetry(TestCase):
metric_data = self.get_metric_data()
msg = "haven't get all ports metric data"
self.verify(len(self.used_ports) == len(metric_data), msg)
- port_index_list = range(len(self.used_ports))
+ port_index_list = list(range(len(self.used_ports)))
for port_index in metric_data:
msg = '<{}> is not the expected port'.format(port_index)
self.verify(
@@ -389,13 +389,13 @@ class TestTelemetry(TestCase):
if len(metric[0]) == len(xstat[0]):
continue
xstat_missed_paras = []
- for keyname in metric[0].keys():
- if keyname in xstat[0].keys():
+ for keyname in list(metric[0].keys()):
+ if keyname in list(xstat[0].keys()):
continue
xstat_missed_paras.append(keyname)
metric_missed_paras = []
- for keyname in xstat[0].keys():
- if keyname in metric[0].keys():
+ for keyname in list(xstat[0].keys()):
+ if keyname in list(metric[0].keys()):
continue
metric_missed_paras.append(keyname)
msg = os.linesep.join([
@@ -409,21 +409,21 @@ class TestTelemetry(TestCase):
msg = 'telemetry metric data is not the same as testpmd xstat data'
error_msg.append(msg)
msg_fmt = 'port {} <{}>: metric is <{}>, xstat is is <{}>'.format
- for port_index, info in metric.iteritems():
- for name, value in info.iteritems():
+ for port_index, info in list(metric.items()):
+ for name, value in list(info.items()):
if value == xstat[port_index][str(name)]:
continue
error_msg.append(msg_fmt(port_index, name,
value, xstat[port_index][name]))
# check if metric parameters value should be zero
# ensure extended NIC stats are 0
- is_clear = any([any(data.values()) for data in metric.values()])
+ is_clear = any([any(data.values()) for data in list(metric.values())])
if is_clear:
msg = 'telemetry metric data are not default value'
error_msg.append(msg)
msg_fmt = 'port {} <{}>: metric is <{}>'.format
- for port_index, info in metric.iteritems():
- for name, value in info.iteritems():
+ for port_index, info in list(metric.items()):
+ for name, value in list(info.items()):
if not value:
continue
error_msg.append(msg_fmt(port_index, name, value))
@@ -478,7 +478,7 @@ class TestTelemetry(TestCase):
try:
self.start_telemetry_server()
metric_data = self.get_metric_data()
- port_index_list = range(len(self.dut_ports))
+ port_index_list = list(range(len(self.dut_ports)))
msg = "haven't get all ports metric data"
self.verify(len(self.dut_ports) == len(metric_data), msg)
for port_index in metric_data:
@@ -495,7 +495,7 @@ class TestTelemetry(TestCase):
def verify_same_nic_with_2ports(self):
msg = os.linesep.join(['no enough ports', pformat(self.nic_grp)])
- self.verify(len(self.nic_grp.values()[0]) >= 2, msg)
+ self.verify(len(list(self.nic_grp.values())[0]) >= 2, msg)
try:
# check and verify error show on testpmd
whitelist = self.get_whitelist(num=2, nic_types=1)
@@ -510,7 +510,7 @@ class TestTelemetry(TestCase):
def verify_same_nic_with_4ports(self):
msg = os.linesep.join(['no enough ports, 4 ports at least',
pformat(self.nic_grp)])
- self.verify(len(self.nic_grp.values()[0]) >= 4, msg)
+ self.verify(len(list(self.nic_grp.values())[0]) >= 4, msg)
try:
self.used_ports = self.dut_ports
self.start_telemetry_server()
@@ -525,7 +525,7 @@ class TestTelemetry(TestCase):
# check ports total number
msg = os.linesep.join(['no enough nic types, 2 nic types at least',
pformat(self.nic_grp)])
- self.verify(len(self.nic_grp.keys()) >= 2, msg)
+ self.verify(len(list(self.nic_grp.keys())) >= 2, msg)
try:
whitelist = self.get_whitelist()
self.start_telemetry_server(whitelist)
@@ -539,12 +539,12 @@ class TestTelemetry(TestCase):
def verify_different_nic_with_4ports(self):
msg = os.linesep.join(['no enough nic types, 2 nic types at least',
pformat(self.nic_grp)])
- self.verify(len(self.nic_grp.keys()) >= 2, msg)
+ self.verify(len(list(self.nic_grp.keys())) >= 2, msg)
msg = os.linesep.join(['no enough ports, 2 ports/nic type at least',
pformat(self.nic_grp)])
self.verify(
all([pci_addrs and len(pci_addrs) >= 2
- for pci_addrs in self.nic_grp.values()]),
+ for pci_addrs in list(self.nic_grp.values())]),
msg)
try:
diff --git a/tests/TestSuite_timer.py b/tests/TestSuite_timer.py
index 42b60e3..f73bb77 100644
--- a/tests/TestSuite_timer.py
+++ b/tests/TestSuite_timer.py
@@ -88,7 +88,7 @@ class TestTimer(TestCase):
# verify timer1
pat = re.compile(r'timer1_cb\(\) on lcore (\d+)')
matchlist = sorted(pat.findall(out))
- self.verify(cmp(list(set(matchlist)), cores) == 0, "timer1 error")
+ self.verify(list(set(matchlist)) == cores, "timer1 error")
def tear_down(self):
"""
diff --git a/tests/TestSuite_tso.py b/tests/TestSuite_tso.py
index e1b912b..51c0961 100644
--- a/tests/TestSuite_tso.py
+++ b/tests/TestSuite_tso.py
@@ -204,7 +204,6 @@ class TestTSO(TestCase):
self.verify(cores is not None, "Insufficient cores for speed testing")
self.coreMask = utils.create_mask(cores)
-
self.tester.send_expect("ethtool -K %s rx off tx off tso off gso off gro off lro off" % tx_interface, "# ")
self.tester.send_expect("ip l set %s up" % tx_interface, "# ")
@@ -212,6 +211,7 @@ class TestTSO(TestCase):
cmd = "./%s/app/testpmd -c %s -n %d %s -- -i --rxd=512 --txd=512 --burst=32 --rxfreet=64 --mbcache=128 --portmask=%s --max-pkt-len=%s --txpt=36 --txht=0 --txwt=0 --txfreet=32 --txrst=32 --tx-offloads=0x8000" % (self.target, self.coreMask, self.dut.get_memory_channels(), self.blacklist, self.portMask, TSO_MTU)
else:
cmd = "./%s/app/testpmd -c %s -n %d %s -- -i --rxd=512 --txd=512 --burst=32 --rxfreet=64 --mbcache=128 --portmask=%s --max-pkt-len=%s --txpt=36 --txht=0 --txwt=0 --txfreet=32 --txrst=32 " % (self.target, self.coreMask, self.dut.get_memory_channels(), self.blacklist, self.portMask, TSO_MTU)
+
self.dut.send_expect(cmd, "testpmd> ", 120)
self.dut.send_expect("set verbose 1", "testpmd> ", 120)
self.dut.send_expect("port stop all", "testpmd> ", 120)
@@ -221,6 +221,7 @@ class TestTSO(TestCase):
if (self.nic not in ["cavium_a063", "cavium_a064"]):
self.dut.send_expect("csum set sctp hw %d" % self.dut_ports[0], "testpmd> ", 120)
self.dut.send_expect("csum set outer-ip hw %d" % self.dut_ports[0], "testpmd> ", 120)
+
self.dut.send_expect("csum parse-tunnel on %d" % self.dut_ports[0], "testpmd> ", 120)
self.dut.send_expect("csum set ip hw %d" % self.dut_ports[1], "testpmd> ", 120)
@@ -247,7 +248,7 @@ class TestTSO(TestCase):
self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")' % (mac, loading_size, tx_interface))
out = self.tester.scapy_execute()
out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
- print out
+ print(out)
self.tcpdump_stop_sniff()
rx_stats = self.number_of_packets(rx_interface)
tx_stats = self.number_of_packets(tx_interface)
@@ -256,7 +257,7 @@ class TestTSO(TestCase):
if (loading_size <= 800):
self.verify(rx_stats == tx_stats and int(tx_outlist[0]) == loading_size, "IPV6 RX or TX packet number not correct")
else:
- num = loading_size/800
+ num = int(loading_size/800)
for i in range(num):
self.verify(int(tx_outlist[i]) == 800, "the packet segmentation incorrect, %s" % tx_outlist)
if loading_size% 800 != 0:
@@ -269,7 +270,7 @@ class TestTSO(TestCase):
self.tester.scapy_append('sendp([Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")' % (mac, loading_size, tx_interface))
out = self.tester.scapy_execute()
out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
- print out
+ print(out)
self.tcpdump_stop_sniff()
rx_stats = self.number_of_packets(rx_interface)
tx_stats = self.number_of_packets(tx_interface)
@@ -278,7 +279,7 @@ class TestTSO(TestCase):
if (loading_size <= 800):
self.verify(rx_stats == tx_stats and int(tx_outlist[0]) == loading_size, "IPV6 RX or TX packet number not correct")
else:
- num = loading_size/800
+ num = int(loading_size/800)
for i in range(num):
self.verify(int(tx_outlist[i]) == 800, "the packet segmentation incorrect, %s" % tx_outlist)
if loading_size% 800 != 0:
@@ -348,7 +349,7 @@ class TestTSO(TestCase):
self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/UDP(sport=1021,dport=4789)/VXLAN()/Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")' % (mac, mac, loading_size, tx_interface))
out = self.tester.scapy_execute()
out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
- print out
+ print(out)
self.tcpdump_stop_sniff()
rx_stats = self.number_of_packets(rx_interface)
tx_stats = self.number_of_packets(tx_interface)
@@ -357,7 +358,7 @@ class TestTSO(TestCase):
if (loading_size <= 800):
self.verify(rx_stats == tx_stats and int(tx_outlist[0]) == loading_size, "Vxlan RX or TX packet number not correct")
else:
- num = loading_size/800
+ num = int(loading_size/800)
for i in range(num):
self.verify(int(tx_outlist[i]) == 800, "the packet segmentation incorrect, %s" % tx_outlist)
if loading_size% 800 != 0:
@@ -372,7 +373,7 @@ class TestTSO(TestCase):
self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2",proto=47)/NVGRE()/Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")' % (mac, mac, loading_size, tx_interface))
out = self.tester.scapy_execute()
out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
- print out
+ print(out)
self.tcpdump_stop_sniff()
rx_stats = self.number_of_packets(rx_interface)
tx_stats = self.number_of_packets(tx_interface)
@@ -381,7 +382,7 @@ class TestTSO(TestCase):
if (loading_size <= 800):
self.verify(rx_stats == tx_stats and int(tx_outlist[0]) == loading_size, "Nvgre RX or TX packet number not correct")
else:
- num = loading_size/800
+ num = int(loading_size/800)
for i in range(num):
self.verify(int(tx_outlist[i]) == 800, "the packet segmentation incorrect, %s" % tx_outlist)
if loading_size% 800 != 0:
@@ -402,7 +403,7 @@ class TestTSO(TestCase):
cores = self.dut.get_core_list(core_config, socket=self.ports_socket)
self.coreMask = utils.create_mask(cores)
if len(cores) > 2:
- queues = len(cores) / 2
+ queues = len(cores) // 2
else:
queues = 1
@@ -456,7 +457,7 @@ class TestTSO(TestCase):
pps /= 1000000.0
test_cycle['Mpps'][loading_size] = pps
- test_cycle['pct'][loading_size] = pps * 100 / wirespeed
+ test_cycle['pct'][loading_size] = pps * 100 // wirespeed
self.dut.send_expect("stop", "testpmd> ")
self.dut.send_expect("quit", "# ", 30)
diff --git a/tests/TestSuite_tx_preparation.py b/tests/TestSuite_tx_preparation.py
index 215e961..070290e 100644
--- a/tests/TestSuite_tx_preparation.py
+++ b/tests/TestSuite_tx_preparation.py
@@ -141,7 +141,7 @@ class TestTX_preparation(TestCase):
'IPv6/large pkt': 'Ether(dst="%s")/IPv6()/TCP(flags=0x10)\
/Raw(RandString(%s))' %(self.dmac, LrgLength) }
- for packet_type in pkts.keys():
+ for packet_type in list(pkts.keys()):
self.start_tcpdump(self.tester_intf)
self.tester.scapy_append(
'sendp([%s], iface="%s", count=%d)' % (pkts[packet_type], self.tester_intf, count))
@@ -158,7 +158,7 @@ class TestTX_preparation(TestCase):
if tsoflag == 1:
if packet_type in\
['IPv4/large pkt', 'IPv6/large pkt', 'IPv4/bad cksum/large pkt']:
- segnum = LrgLength / TSO_value
+ segnum = int(LrgLength / TSO_value)
LastLength = LrgLength % TSO_value
num = out.count('length %s' %TSO_value)
self.verify("length %s" %TSO_value in out and num == segnum * count,
diff --git a/tests/TestSuite_uni_pkt.py b/tests/TestSuite_uni_pkt.py
index e6bd42b..c3db28e 100644
--- a/tests/TestSuite_uni_pkt.py
+++ b/tests/TestSuite_uni_pkt.py
@@ -78,16 +78,16 @@ class TestUniPacket(TestCase):
def run_test(self, pkt_types):
time.sleep(1)
- for pkt_type in pkt_types.keys():
+ for pkt_type in list(pkt_types.keys()):
pkt_names = pkt_types[pkt_type]
pkt = Packet(pkt_type=pkt_type)
pkt.send_pkt(self.tester, tx_port=self.tester_iface, count=4)
out = self.dut.get_session_output(timeout=2)
for pkt_layer_name in pkt_names:
if pkt_layer_name not in out:
- print utils.RED("Fail to detect %s" % pkt_layer_name)
+ print((utils.RED("Fail to detect %s" % pkt_layer_name)))
raise VerifyFailure("Failed to detect %s" % pkt_layer_name)
- print utils.GREEN("Detected %s successfully" % pkt_type)
+ print((utils.GREEN("Detected %s successfully" % pkt_type)))
def test_l2pkt_detect(self):
"""
@@ -108,13 +108,13 @@ class TestUniPacket(TestCase):
"LLDP": "L2_ETHER_LLDP",
}
#Change this code end for DPDK-15109, the share code doest not support TIMESYNC, once supported then will enable
- for l2_type in self.L2_types.keys():
+ for l2_type in list(self.L2_types.keys()):
pkt_name = self.L2_types[l2_type]
pkt = Packet(pkt_type=l2_type)
pkt.send_pkt(self.tester, tx_port=self.tester_iface)
out = self.dut.get_session_output(timeout=2)
if pkt_name in out:
- print(utils.GREEN("Detected L2 %s successfully" % l2_type))
+ print((utils.GREEN("Detected L2 %s successfully" % l2_type)))
else:
raise VerifyFailure("Failed to detect L2 %s" % l2_type)
@@ -292,11 +292,11 @@ class TestUniPacket(TestCase):
"NVGRE in IPv6 detect only support by Fortville")
nvgre_base_packet_type = ["L2_ETHER", "L3_IPV6_EXT_UNKNOWN", "TUNNEL_GRENAT"]
# INNER IPV4 not with vlan
- nvgre_ipv4_default_packet_type = nvgre_base_packet_type + ["INNER_L2_ETHER", "INNER_L3_IPV4_EXT_UNKNOWN"]
+ nvgre_ipv4_default_packet_type = nvgre_base_packet_type + ["INNER_L2_ETHER", "INNER_L3_IPV4_EXT_UNKNOWN"]
# INNER IPV6 not with vlan
nvgre_ipv6_default_packet_type = nvgre_base_packet_type + ["INNER_L2_ETHER", "INNER_L3_IPV6_EXT_UNKNOWN"]
# INNER IPV4 with vlan
- nvgre_ipv4_vlan_packet_type = nvgre_base_packet_type + ["INNER_L2_ETHER_VLAN", "INNER_L3_IPV4_EXT_UNKNOWN"]
+ nvgre_ipv4_vlan_packet_type = nvgre_base_packet_type + ["INNER_L2_ETHER_VLAN", "INNER_L3_IPV4_EXT_UNKNOWN"]
# INNER IPV6 with vlan
nvgre_ipv6_vlan_packet_type = nvgre_base_packet_type + ["INNER_L2_ETHER_VLAN", "INNER_L3_IPV6_EXT_UNKNOWN"]
@@ -351,9 +351,9 @@ class TestUniPacket(TestCase):
out = self.dut.get_session_output(timeout=2)
for pkt_layer_name in pkts[1]:
if pkt_layer_name not in out:
- print utils.RED("Fail to detect %s" % pkt_layer_name)
+ print((utils.RED("Fail to detect %s" % pkt_layer_name)))
raise VerifyFailure("Failed to detect %s" % pkt_layer_name)
- print utils.GREEN("Detected %s successfully" % pkts[0])
+ print((utils.GREEN("Detected %s successfully" % pkts[0])))
def test_GRE_tunnel(self):
"""
@@ -448,7 +448,7 @@ class TestUniPacket(TestCase):
pk.send_pkt(self.tester, self.tester_iface)
out = self.dut.get_session_output(timeout=2)
self.verify(nsh_detect_message[packet] in out, "Packet Detection Error for : %s" % packet)
- print utils.GREEN("Detected packet %s Successfully" % packet)
+ print((utils.GREEN("Detected packet %s Successfully" % packet)))
def tear_down(self):
"""
diff --git a/tests/TestSuite_unit_tests_cryptodev_func.py b/tests/TestSuite_unit_tests_cryptodev_func.py
index d6b01f0..a370fc4 100644
--- a/tests/TestSuite_unit_tests_cryptodev_func.py
+++ b/tests/TestSuite_unit_tests_cryptodev_func.py
@@ -131,7 +131,7 @@ class UnitTestsCryptodev(TestCase):
try:
out = self.dut.send_expect(testsuite, "RTE>>", timeout)
self.dut.send_expect("quit", "# ", 30)
- except Exception, ex:
+ except Exception as ex:
self.logger.error("Cryptodev Unit Tests Exception")
dmesg = self.dut.alt_session.send_expect("dmesg", "# ", 30)
self.logger.error("dmesg info:")
diff --git a/tests/TestSuite_unit_tests_dump.py b/tests/TestSuite_unit_tests_dump.py
index b519714..7772223 100644
--- a/tests/TestSuite_unit_tests_dump.py
+++ b/tests/TestSuite_unit_tests_dump.py
@@ -143,7 +143,7 @@ class TestUnitTestsDump(TestCase):
results = m.findall(out)
phy_info = []
for result in results:
- phy_info.append(dict(zip(elements, result)))
+ phy_info.append(dict(list(zip(elements, result))))
self.verify(len(phy_info) > 0, "Test failed")
@@ -166,7 +166,7 @@ class TestUnitTestsDump(TestCase):
results = m.findall(out)
memzone_info = []
for result in results:
- memzone_info.append(dict(zip(elements, result)))
+ memzone_info.append(dict(list(zip(elements, result))))
self.verify(len(memzone_info) > 0, "Test failed")
@@ -186,7 +186,7 @@ class TestUnitTestsDump(TestCase):
m = re.compile(r"%s" % match_regex, re.S)
result = m.search(out)
- struct_info = dict(zip(elements, result.groups()))
+ struct_info = dict(list(zip(elements, result.groups())))
def test_dump_devargs(self):
"""
@@ -240,7 +240,7 @@ class TestUnitTestsDump(TestCase):
results = m.findall(out)
memzone_info = []
for result in results:
- memzone_info.append(dict(zip(elements, result)))
+ memzone_info.append(dict(list(zip(elements, result))))
self.verify(len(memzone_info) > 0, "Dump malloc heaps failed")
def test_dump_log_types(self):
@@ -258,7 +258,7 @@ class TestUnitTestsDump(TestCase):
results = m.findall(out)
memzone_info = []
for result in results:
- memzone_info.append(dict(zip(elements, result)))
+ memzone_info.append(dict(list(zip(elements, result))))
self.verify(len(memzone_info) > 0, "Dump log types failed")
def tear_down(self):
diff --git a/tests/TestSuite_unit_tests_loopback.py b/tests/TestSuite_unit_tests_loopback.py
index b52b1c2..bc459d4 100644
--- a/tests/TestSuite_unit_tests_loopback.py
+++ b/tests/TestSuite_unit_tests_loopback.py
@@ -99,7 +99,7 @@ class TestUnitTestsLoopback(TestCase):
self.tester.send_expect("tcpdump -i %s -w ./getPackageByTcpdump.cap 2> /dev/null& " % self.tester_itf, "#")
self.dut.send_expect("./app/test/test -n 1 -c %s" % self.coremask, "R.*T.*E.*>.*>", 60)
out = self.dut.send_expect("pmd_perf_autotest", "RTE>>", 120)
- print out
+ print(out)
self.dut.send_expect("quit", "# ")
self.verify("Test OK" in out, "Test failed")
diff --git a/tests/TestSuite_unit_tests_pmd_perf.py b/tests/TestSuite_unit_tests_pmd_perf.py
index c9a18dc..eccc864 100644
--- a/tests/TestSuite_unit_tests_pmd_perf.py
+++ b/tests/TestSuite_unit_tests_pmd_perf.py
@@ -127,7 +127,7 @@ class TestUnitTestsPmdPerf(TestCase):
self.table_header = ['Mode']
self.table_header += self.anchors
self.result_table_create(self.table_header)
- print self.table_header
+ print((self.table_header))
for mode in self.rxtx_modes:
if mode is "scalar":
diff --git a/tests/TestSuite_userspace_ethtool.py b/tests/TestSuite_userspace_ethtool.py
index 53e37d2..44135cd 100644
--- a/tests/TestSuite_userspace_ethtool.py
+++ b/tests/TestSuite_userspace_ethtool.py
@@ -172,7 +172,7 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
for port_no in nic_infos:
nic_info = nic_infos[port_no]
for item in check_content:
- if item not in nic_info.keys():
+ if item not in list(nic_info.keys()):
status.append("port {0} get {1} failed".format(port_no, item))
break
# if there is error in status, clear nic_infos
@@ -206,8 +206,8 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
def check_driver_info(self, port_name, sys_nic_info, dpdk_drv_info):
# compare dpdk query nic information with linux query nic information
- for item, value in dpdk_drv_info.items():
- if item not in sys_nic_info.keys():
+ for item, value in list(dpdk_drv_info.items()):
+ if item not in list(sys_nic_info.keys()):
msg = "linux ethtool failed to dump driver info"
status = False
break
@@ -404,8 +404,8 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
for index in range(len(self.ports)):
md5 = self.strip_md5(portsinfo[index]['eeprom_file'])
md5_ref = self.strip_md5(portsinfo[index]['ethtool_eeprom'])
- print utils.GREEN("Reference eeprom md5 %s" % md5)
- print utils.GREEN("Reference eeprom md5_ref %s" % md5_ref)
+ print(utils.GREEN("Reference eeprom md5 %s" % md5))
+ print(utils.GREEN("Reference eeprom md5_ref %s" % md5_ref))
self.verify(md5 == md5_ref, "Dumped eeprom not same as linux dumped")
def test_ring_parameter(self):
@@ -424,7 +424,8 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
pkt = Packet(pkt_type='UDP')
tester_port = self.tester.get_local_port(port)
self.verify(self.ethapp_check_link_status(index, 'Up') == True,
- 'Fail to Open port{}'.format(index))
+ 'Fail to Open port{}'.format(index))
+
intf = self.tester.get_interface(tester_port)
pkt.send_pkt(self.tester, tx_port=intf, count=4)
rx_pkts, tx_pkts = self.strip_portstats(index)
@@ -459,7 +460,8 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
tester_port = self.tester.get_local_port(port)
intf = self.tester.get_interface(tester_port)
self.verify(self.ethapp_check_link_status(index, 'Up') == True,
- 'Fail to Open port{}'.format(index))
+ 'Fail to Open port{}'.format(index))
+
pkt.send_pkt(self.tester, tx_port=intf, count=4)
rx_pkts, tx_pkts = self.strip_portstats(port)
self.verify(rx_pkts == ori_rx_pkts + 4, "Failed to Rx vlan packet")
@@ -506,7 +508,7 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
tester_port = self.tester.get_local_port(port)
intf = self.tester.get_interface(tester_port)
self.verify(self.ethapp_check_link_status(index, 'Up') == True,
- 'Fail to Open port{}'.format(index))
+ 'Fail to Open port{}'.format(index))
# send and sniff packet
inst = self.tester.tcpdump_sniff_packets(intf)
pkt.send_pkt(self.tester, tx_port=intf, count=4)
@@ -651,7 +653,7 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
"""
# sleep a while when receive packets
main_file = "examples/ethtool/ethtool-app/main.c"
- self.dut.send_expect("sed -i -e '/if (cnt_recv_frames > 0) {$/i\usleep(10);' %s" % main_file, "# ")
+ self.dut.send_expect("sed -i -e '/if (cnt_recv_frames > 0) {$/i\\usleep(10);' %s" % main_file, "# ")
# build sample app
self.build_ethtool()
self.dut.send_expect(self.cmd, "EthApp>", 60)
diff --git a/tests/TestSuite_vdev_primary_secondary.py b/tests/TestSuite_vdev_primary_secondary.py
index 9728985..c380bec 100644
--- a/tests/TestSuite_vdev_primary_secondary.py
+++ b/tests/TestSuite_vdev_primary_secondary.py
@@ -156,10 +156,10 @@ class TestVdevPrimarySecondary(TestCase):
self.launch_examples()
time.sleep(3)
vhost_first_out = self.vhost_first.send_expect("^c", "#", 15)
- print vhost_first_out
+ print(vhost_first_out)
time.sleep(3)
vhost_secondary_out = self.vhost_secondary.send_expect("^c", "#", 15)
- print vhost_secondary_out
+ print(vhost_secondary_out)
result_first = re.findall(r'Port \d: RX - (\w+)', vhost_first_out)
result_secondary = re.findall(r'Port \d: RX - (\w+)', vhost_secondary_out)
self.verify(len(result_first[0]) != 0 and len(result_first[1]) != 0 and len(result_secondary[0]) != 0 and len(result_secondary[1]) != 0, "RX no data")
diff --git a/tests/TestSuite_veb_switch.py b/tests/TestSuite_veb_switch.py
index e60a618..9450f49 100644
--- a/tests/TestSuite_veb_switch.py
+++ b/tests/TestSuite_veb_switch.py
@@ -148,7 +148,7 @@ class TestVEBSwitching(TestCase):
if (cnt == 2):
count_pkt = count_pkt + 1
cnt = 0
- print utils.GREEN("The number of UDP packets received by pf is %d." % count_pkt)
+ print(utils.GREEN("The number of UDP packets received by pf is %d." % count_pkt))
return count_pkt
# Test cases.
@@ -395,7 +395,7 @@ class TestVEBSwitching(TestCase):
self.session_secondary.send_expect("stop", "testpmd>", 2)
vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
- print utils.GREEN("The number of UDP packets received by vf is %d." % vf0_rx_stats[0])
+ print(utils.GREEN("The number of UDP packets received by vf is %d." % vf0_rx_stats[0]))
self.verify(vf0_rx_stats[0] > 100, "no packet was received by VF0")
self.session_secondary.send_expect("quit", "# ")
time.sleep(2)
diff --git a/tests/TestSuite_vf_daemon.py b/tests/TestSuite_vf_daemon.py
index 5b738c7..b91de9e 100644
--- a/tests/TestSuite_vf_daemon.py
+++ b/tests/TestSuite_vf_daemon.py
@@ -45,7 +45,7 @@ class TestVfDaemon(TestCase):
self.vm0_testpmd.start_testpmd(VM_CORES_MASK, '--port-topology=chained')
for i in range(10):
out = self.vm0_testpmd.execute_cmd('show port info 0')
- print out
+ print(out)
if 'Link status: down' in out:
self.dut_testpmd.execute_cmd('port stop all')
self.dut_testpmd.execute_cmd('port start all')
diff --git a/tests/TestSuite_vf_kernel.py b/tests/TestSuite_vf_kernel.py
index 9a280b1..00634c4 100644
--- a/tests/TestSuite_vf_kernel.py
+++ b/tests/TestSuite_vf_kernel.py
@@ -250,7 +250,7 @@ class TestVfKernel(TestCase):
out = session.send_expect(
"ping -w 5 -c 5 -A -I %s %s" % (intf, ipv4), "# ")
if '64 bytes from' not in out:
- print GREEN("%s ping %s failed, retry" % (intf, ipv4))
+ print(GREEN("%s ping %s failed, retry" % (intf, ipv4)))
else:
return True
return False
@@ -495,8 +495,8 @@ class TestVfKernel(TestCase):
# SIOCSIFFLAGS: Network is down
# i think the pf link abnormal
if "Link detected: no" in out:
- print GREEN(out)
- print GREEN("Try again")
+ print(GREEN(out))
+ print(GREEN("Try again"))
session.restore_interfaces_linux()
else:
return True
@@ -689,7 +689,7 @@ class TestVfKernel(TestCase):
# Send multi-threaded traffics to the DUT with a number of threads
# Check kernel VF each queue can receive packets
vm0_vf0_mac = self.vm0_dut.ports_info[0]['port'].get_mac_addr()
- for i in xrange(5):
+ for i in range(5):
mythread = threading.Thread(target=self.send_packet(vm0_vf0_mac))
mythread.start()
@@ -1046,7 +1046,7 @@ class TestVfKernel(TestCase):
"""
Load kernel driver stress
"""
- for i in xrange(100):
+ for i in range(100):
out = self.vm0_dut.send_expect("rmmod %svf" % self.kdriver, "#")
self.verify('error' not in out,
"stress error for rmmod %svf:%s" % (self.kdriver, out))
diff --git a/tests/TestSuite_vf_macfilter.py b/tests/TestSuite_vf_macfilter.py
index 01da9b4..fe64f44 100644
--- a/tests/TestSuite_vf_macfilter.py
+++ b/tests/TestSuite_vf_macfilter.py
@@ -154,16 +154,16 @@ class TestVfMacFilter(TestCase):
src_mac = self.tester.get_mac(tx_port)
pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
- print "\nfirst send packets to the PF set MAC, expected result is RX packets=TX packets\n"
+ print("\nfirst send packets to the PF set MAC, expected result is RX packets=TX packets\n")
result1 = self.tester.check_random_pkts(tgen_ports, pktnum=100, allow_miss=False, params=pkt_param)
- print "\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all')
+ print("\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all'))
self.verify(result1 != False, "VF0 failed to forward packets to VF1")
- print "\nSecondly, negative test, send packets to a wrong MAC, expected result is RX packets=0\n"
+ print("\nSecondly, negative test, send packets to a wrong MAC, expected result is RX packets=0\n")
dst_mac = self.vf0_wrongmac
pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
result2 = self.tester.check_random_pkts(tgen_ports, pktnum=100, allow_miss=False, params=pkt_param)
- print "\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all')
+ print("\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all'))
self.verify(result2 != True, "VF0 failed to forward packets to VF1")
def test_kernel_2pf_2vf_1vm_mac_add_filter(self):
@@ -218,7 +218,7 @@ class TestVfMacFilter(TestCase):
self.vm0_testpmd.execute_cmd('set promisc all off')
ret = self.vm0_testpmd.execute_cmd('mac_addr add 0 %s' %self.vf0_setmac)
# check the operation is supported or not.
- print ret
+ print(ret)
self.vm0_testpmd.execute_cmd('set fwd mac')
self.vm0_testpmd.execute_cmd('start')
@@ -233,23 +233,23 @@ class TestVfMacFilter(TestCase):
dst_mac = pmd_vf0_mac
pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
- print "\nfirst send packets to the random generated VF MAC, expected result is RX packets=TX packets\n"
+ print("\nfirst send packets to the random generated VF MAC, expected result is RX packets=TX packets\n")
result1 = self.tester.check_random_pkts(tgen_ports, pktnum=100, allow_miss=False, params=pkt_param)
- print "\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all')
+ print("\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all'))
self.verify(result1 != False, "VF0 failed to forward packets to VF1")
- print "\nsecondly, send packets to the new added MAC, expected result is RX packets=TX packets\n"
+ print("\nsecondly, send packets to the new added MAC, expected result is RX packets=TX packets\n")
dst_mac = self.vf0_setmac
pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
result2 = self.tester.check_random_pkts(tgen_ports, pktnum=100, allow_miss=False, params=pkt_param)
- print "\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all')
+ print("\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all'))
self.verify(result2 != False, "VF0 failed to forward packets to VF1")
- print "\nThirdly, negative test, send packets to a wrong MAC, expected result is RX packets=0\n"
+ print("\nThirdly, negative test, send packets to a wrong MAC, expected result is RX packets=0\n")
dst_mac = self.vf0_wrongmac
pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
result3 = self.tester.check_random_pkts(tgen_ports, pktnum=100, allow_miss=False, params=pkt_param)
- print "\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all')
+ print("\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all'))
self.verify(result3 != True, "VF0 failed to forward packets to VF1")
diff --git a/tests/TestSuite_vf_offload.py b/tests/TestSuite_vf_offload.py
index 421d9c4..0ebe636 100644
--- a/tests/TestSuite_vf_offload.py
+++ b/tests/TestSuite_vf_offload.py
@@ -149,12 +149,12 @@ class TestVfOffload(TestCase):
self.tester.send_expect("scapy", ">>> ")
- for packet_type in packets_expected.keys():
+ for packet_type in list(packets_expected.keys()):
self.tester.send_expect("p = %s" % packets_expected[packet_type], ">>>")
out = self.tester.send_expect("p.show2()", ">>>")
chksums = checksum_pattern.findall(out)
chksum[packet_type] = chksums
- print packet_type, ": ", chksums
+ print(packet_type, ": ", chksums)
self.tester.send_expect("exit()", "#")
@@ -163,12 +163,12 @@ class TestVfOffload(TestCase):
self.tester.scapy_append('nr_packets=len(p)')
self.tester.scapy_append('reslist = [p[i].sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%") for i in range(nr_packets)]')
self.tester.scapy_append('import string')
- self.tester.scapy_append('RESULT = string.join(reslist, ",")')
+ self.tester.scapy_append('RESULT = ",".join(reslist)')
# Send packet.
self.tester.scapy_foreground()
- for packet_type in packets_sent.keys():
+ for packet_type in list(packets_sent.keys()):
self.tester.scapy_append('sendp([%s], iface="%s")' % (packets_sent[packet_type], tx_interface))
self.tester.scapy_execute()
@@ -178,7 +178,7 @@ class TestVfOffload(TestCase):
for packet_received in packets_received:
ip_checksum, tcp_checksum, udp_checksup, sctp_checksum = packet_received.split(';')
- print "ip_checksum: ", ip_checksum, "tcp_checksum:, ", tcp_checksum, "udp_checksup: ", udp_checksup, "sctp_checksum: ", sctp_checksum
+ print("ip_checksum: ", ip_checksum, "tcp_checksum:, ", tcp_checksum, "udp_checksup: ", udp_checksup, "sctp_checksum: ", sctp_checksum)
packet_type = ''
l4_checksum = ''
@@ -251,7 +251,7 @@ class TestVfOffload(TestCase):
self.verify(bad_ipcsum == 3, "Bad-ipcsum check error")
self.verify(bad_l4csum == 5, "Bad-l4csum check error")
- self.verify(len(result) == 0, string.join(result.values(), ","))
+ self.verify(len(result) == 0, ",".join(list(result.values())))
def test_checksum_offload_disable(self):
"""
@@ -293,7 +293,7 @@ class TestVfOffload(TestCase):
self.verify(bad_ipcsum == 2, "Bad-ipcsum check error")
self.verify(bad_l4csum == 4, "Bad-l4csum check error")
- self.verify(len(result) == 0, string.join(result.values(), ","))
+ self.verify(len(result) == 0, ",".join(list(result.values())))
def tcpdump_start_sniffing(self, ifaces=[]):
"""
@@ -323,7 +323,7 @@ class TestVfOffload(TestCase):
"""
result = self.tester.send_expect(command, '#')
- print result
+ print(result)
return int(result.strip())
def number_of_packets(self, iface):
@@ -402,7 +402,7 @@ class TestVfOffload(TestCase):
self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")' % (mac, loading_size, tx_interface))
out = self.tester.scapy_execute()
out = self.vm0_testpmd.execute_cmd("show port stats all")
- print out
+ print(out)
self.tcpdump_stop_sniff()
rx_stats = self.number_of_packets(rx_interface)
tx_stats = self.number_of_packets(tx_interface)
@@ -411,7 +411,7 @@ class TestVfOffload(TestCase):
if (loading_size <= 800):
self.verify(rx_stats == tx_stats and int(tx_outlist[0]) == loading_size, "IPV4 RX or TX packet number not correct")
else:
- num = loading_size/800
+ num = loading_size // 800
for i in range(num):
self.verify(int(tx_outlist[i]) == 800, "the packet segmentation incorrect, %s" % tx_outlist)
if loading_size% 800 != 0:
@@ -424,7 +424,7 @@ class TestVfOffload(TestCase):
self.tester.scapy_append('sendp([Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")' % (mac, loading_size, tx_interface))
out = self.tester.scapy_execute()
out = self.vm0_testpmd.execute_cmd("show port stats all")
- print out
+ print(out)
self.tcpdump_stop_sniff()
rx_stats = self.number_of_packets(rx_interface)
tx_stats = self.number_of_packets(tx_interface)
@@ -433,7 +433,7 @@ class TestVfOffload(TestCase):
if (loading_size <= 800):
self.verify(rx_stats == tx_stats and int(tx_outlist[0]) == loading_size, "IPV6 RX or TX packet number not correct")
else:
- num = loading_size/800
+ num = loading_size // 800
for i in range(num):
self.verify(int(tx_outlist[i]) == 800, "the packet segmentation incorrect, %s" % tx_outlist)
if loading_size% 800 != 0:
@@ -444,7 +444,7 @@ class TestVfOffload(TestCase):
self.dut.send_expect("ifconfig %s mtu %s" % (self.dut.ports_info[0]['intf'], DEFAULT_MTU), "# ")
def tear_down_all(self):
- print "tear_down_all"
+ print("tear_down_all")
if self.setup_2pf_2vf_1vm_env_flag == 1:
self.destroy_2pf_2vf_1vm_env()
self.tester.send_expect("ifconfig %s mtu %s" % (self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0])), DEFAULT_MTU), "# ")
diff --git a/tests/TestSuite_vf_packet_rxtx.py b/tests/TestSuite_vf_packet_rxtx.py
index c111c9e..8fc2a5f 100644
--- a/tests/TestSuite_vf_packet_rxtx.py
+++ b/tests/TestSuite_vf_packet_rxtx.py
@@ -149,7 +149,7 @@ class TestVfPacketRxtx(TestCase):
pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
result = self.tester.check_random_pkts(tgen_ports, allow_miss=False, params=pkt_param)
- print self.vm0_testpmd.execute_cmd('show port stats all')
+ print(self.vm0_testpmd.execute_cmd('show port stats all'))
self.verify(result != False, "VF0 failed to forward packets to VF1")
@@ -172,7 +172,7 @@ class TestVfPacketRxtx(TestCase):
try:
for port in self.sriov_vfs_port:
- print port.pci
+ print(port.pci)
port.bind_driver(self.vf_driver)
time.sleep(1)
diff --git a/tests/TestSuite_vf_port_start_stop.py b/tests/TestSuite_vf_port_start_stop.py
index 945c671..933b1e2 100644
--- a/tests/TestSuite_vf_port_start_stop.py
+++ b/tests/TestSuite_vf_port_start_stop.py
@@ -60,7 +60,7 @@ class TestVfPortStartStop(TestCase):
'IPv6/UDP': 'Ether(dst="%s", src="%s")/IPv6(src="::2")/UDP()/("X"*46)' % (dst_mac, src_mac),
'IPv6/TCP': 'Ether(dst="%s", src="%s")/IPv6(src="::2")/TCP()/("X"*46)' % (dst_mac, src_mac),}
- for key in def_pkts.keys():
+ for key in list(def_pkts.keys()):
self.pkts.append_pkt(def_pkts[key])
self.send_pks_session = self.pkts.send_pkt_bg(self.tester, self.tester_tintf)
--git a/tests/TestSuite_vf_rss.py b/tests/TestSuite_vf_rss.py
index 95d13cd..002c37e 100644
--- a/tests/TestSuite_vf_rss.py
+++ b/tests/TestSuite_vf_rss.py
@@ -149,11 +149,11 @@ class TestVfRss(TestCase):
time.sleep(.5)
else:
- print "\ntran_type error!\n"
+ print("\ntran_type error!\n")
out = self.vm_dut_0.get_session_output()
- print '*******************************************'
- print out
+ print('*******************************************')
+ print(out)
if not reta_entries:
# for test_vfpmd_rss, check every queue can receive packet.
for i in range(queue):
@@ -174,7 +174,7 @@ class TestVfRss(TestCase):
item = item.strip()
if item.startswith("RSS hash"):
name, value = item.split("=", 1)
- print name + "-" + value
+ print(name + "-" + value)
reta_line[name.strip()] = value.strip()
reta_lines.append(reta_line)
reta_line = {}
@@ -350,7 +350,7 @@ class TestVfRss(TestCase):
self.vm0_testpmd.start_testpmd(
"all", "--rxq=%d --txq=%d %s" % (queue, queue, eal_param), socket=self.vm0_ports_socket)
- for iptype, rss_type in iptypes.items():
+ for iptype, rss_type in list(iptypes.items()):
self.vm_dut_0.send_expect("set verbose 8", "testpmd> ")
self.vm_dut_0.send_expect("set fwd rxonly", "testpmd> ")
self.vm_dut_0.send_expect(
@@ -409,7 +409,7 @@ class TestVfRss(TestCase):
self.vm0_testpmd.start_testpmd(
"all", "--rxq=%d --txq=%d %s" % (queue, queue, eal_param), socket=self.vm0_ports_socket)
- for iptype, rsstype in iptypes.items():
+ for iptype, rsstype in list(iptypes.items()):
self.vm_dut_0.send_expect("set verbose 8", "testpmd> ")
self.vm_dut_0.send_expect("set fwd rxonly", "testpmd> ")
if self.nic in ['sageville', 'sagepond'] and rsstype == 'sctp':
diff --git a/tests/TestSuite_vf_to_vf_nic_bridge.py b/tests/TestSuite_vf_to_vf_nic_bridge.py
index 1e7374c..b7b749b 100644
--- a/tests/TestSuite_vf_to_vf_nic_bridge.py
+++ b/tests/TestSuite_vf_to_vf_nic_bridge.py
@@ -100,7 +100,7 @@ class TestVF2VFBridge(TestCase):
if self.vm0_dut is None:
raise Exception('Set up VM0 failed')
except Exception as e:
- print utils.RED(str(e))
+ print(utils.RED(str(e)))
self.vm1 = VM(self.dut, 'vm1', 'vf_to_vf_bridge')
self.vm1.set_vm_device(driver=self.vf_assign_method, **vf1_prop)
@@ -109,7 +109,7 @@ class TestVF2VFBridge(TestCase):
if self.vm1_dut is None:
raise Exception('Set up VM1 failed')
except Exception as e:
- print utils.RED(str(e))
+ print(utils.RED(str(e)))
def clear_vf_to_vf_env(self):
if self.vm0 is not None:
diff --git a/tests/TestSuite_vhost_dequeue_zero_copy.py b/tests/TestSuite_vhost_dequeue_zero_copy.py
index 4052437..0bce1ae 100644
--- a/tests/TestSuite_vhost_dequeue_zero_copy.py
+++ b/tests/TestSuite_vhost_dequeue_zero_copy.py
@@ -191,10 +191,10 @@ class TestVhostDequeueZeroCopy(TestCase):
"""
params_number = len(self.vm.params)
for i in range(params_number):
- if self.vm.params[i].keys()[0] == 'cpu':
- if 'number' in self.vm.params[i]['cpu'][0].keys():
+ if list(self.vm.params[i].keys())[0] == 'cpu':
+ if 'number' in list(self.vm.params[i]['cpu'][0].keys()):
self.vm.params[i]['cpu'][0]['number'] = 5
- if 'cpupin' in self.vm.params[i]['cpu'][0].keys():
+ if 'cpupin' in list(self.vm.params[i]['cpu'][0].keys()):
self.vm.params[i]['cpu'][0].pop('cpupin')
def start_one_vm(self, mode='client', packed=False):
@@ -352,9 +352,9 @@ class TestVhostDequeueZeroCopy(TestCase):
"""
value_with_zero_copy = 0
value_without_zero_copy = 0
- if 'dequeue-zero-copy=1' in self.big_pkt_record.keys():
+ if 'dequeue-zero-copy=1' in list(self.big_pkt_record.keys()):
value_with_zero_copy = self.big_pkt_record['dequeue-zero-copy=1']
- if 'dequeue-zero-copy=0' in self.big_pkt_record.keys():
+ if 'dequeue-zero-copy=0' in list(self.big_pkt_record.keys()):
value_without_zero_copy = self.big_pkt_record['dequeue-zero-copy=0']
self.verify(value_with_zero_copy != 0 and value_without_zero_copy != 0,
'can not get the value of big pkts, please check self.frame_sizes')
diff --git a/tests/TestSuite_vhost_event_idx_interrupt.py b/tests/TestSuite_vhost_event_idx_interrupt.py
index 88822c0..9676ed7 100644
--- a/tests/TestSuite_vhost_event_idx_interrupt.py
+++ b/tests/TestSuite_vhost_event_idx_interrupt.py
@@ -136,7 +136,7 @@ class TestVhostEventIdxInterrupt(TestCase):
return
params_number = len(vm_config.params)
for i in range(params_number):
- if vm_config.params[i].keys()[0] == 'cpu':
+ if list(vm_config.params[i].keys())[0] == 'cpu':
vm_config.params[i]['cpu'][0]['number'] = self.queues
def check_qemu_version(self, vm_config):
@@ -146,7 +146,7 @@ class TestVhostEventIdxInterrupt(TestCase):
self.vm_qemu_version = vm_config.qemu_emulator
params_number = len(vm_config.params)
for i in range(params_number):
- if vm_config.params[i].keys()[0] == 'qemu':
+ if list(vm_config.params[i].keys())[0] == 'qemu':
self.vm_qemu_version = vm_config.params[i]['qemu'][0]['path']
out = self.dut.send_expect("%s --version" % self.vm_qemu_version, "#")
diff --git a/tests/TestSuite_vhost_user_live_migration.py b/tests/TestSuite_vhost_user_live_migration.py
index 521f3f5..414f00e 100644
--- a/tests/TestSuite_vhost_user_live_migration.py
+++ b/tests/TestSuite_vhost_user_live_migration.py
@@ -313,7 +313,7 @@ class TestVhostUserLiveMigration(TestCase):
vm_dut.send_expect("clear port stats all", "testpmd> ")
time.sleep(5)
out = vm_dut.send_expect("show port stats 0", "testpmd> ")
- print out
+ print(out)
m = stats_pat.search(out)
if m:
num_received = int(m.group(1))
@@ -334,7 +334,7 @@ class TestVhostUserLiveMigration(TestCase):
vm_dut.get_session_output(timeout=1)
time.sleep(5)
out = vm_dut.get_session_output(timeout=1)
- print out
+ print(out)
num = out.count('UDP')
self.verify(num > 0, "Not receive packets as expected!!!")
vm_dut.send_command('^a')
diff --git a/tests/TestSuite_vhost_virtio_pmd_interrupt.py b/tests/TestSuite_vhost_virtio_pmd_interrupt.py
index 0ad6d61..f35f9a1 100644
--- a/tests/TestSuite_vhost_virtio_pmd_interrupt.py
+++ b/tests/TestSuite_vhost_virtio_pmd_interrupt.py
@@ -167,7 +167,7 @@ class TestVhostVirtioPmdInterrupt(TestCase):
# config the vcpu numbers
params_number = len(self.vm.params)
for i in range(params_number):
- if self.vm.params[i].keys()[0] == 'cpu':
+ if list(self.vm.params[i].keys())[0] == 'cpu':
self.vm.params[i]['cpu'][0]['number'] = self.queues
def start_vms(self, mode=0):
diff --git a/tests/TestSuite_virtio_event_idx_interrupt.py b/tests/TestSuite_virtio_event_idx_interrupt.py
index 8e5564d..022cb6d 100644
--- a/tests/TestSuite_virtio_event_idx_interrupt.py
+++ b/tests/TestSuite_virtio_event_idx_interrupt.py
@@ -36,7 +36,7 @@ Virtio idx interrupt need test with l3fwd-power sample
import utils
import time
-import thread
+import _thread
import re
from virt_common import VM
from test_case import TestCase
@@ -163,7 +163,7 @@ class TestVirtioIdxInterrupt(TestCase):
"""
# ixia send packets times equal to reload_times * wait_times
start_time = time.time()
- thread.start_new_thread(self.start_to_send_packets, (reload_times*20,))
+ _thread.start_new_thread(self.start_to_send_packets, (reload_times*20,))
# wait the ixia begin to send packets
time.sleep(10)
self.vm_pci = self.vm_dut.ports_info[0]['pci']
@@ -203,7 +203,7 @@ class TestVirtioIdxInterrupt(TestCase):
check each queue has receive packets on vhost side
"""
out = self.vhost.send_expect("stop", "testpmd> ", 60)
- print out
+ print(out)
for queue_index in range(0, self.queues):
queue = re.search("Port= 0/Queue=\s*%d" % queue_index, out)
queue = queue.group()
diff --git a/tests/TestSuite_virtio_ipsec_cryptodev_func.py b/tests/TestSuite_virtio_ipsec_cryptodev_func.py
index 6f6aa19..efbc48a 100644
--- a/tests/TestSuite_virtio_ipsec_cryptodev_func.py
+++ b/tests/TestSuite_virtio_ipsec_cryptodev_func.py
@@ -35,7 +35,7 @@ Test DPDK vhost + virtio scenarios
import os
import utils
import time
-import commands
+import subprocess
import binascii
from test_case import TestCase
from qemu_kvm import QEMUKvm
@@ -133,13 +133,13 @@ class VirtioCryptodevIpsecTest(TestCase):
opts = default_eal_opts.copy()
# Update options with test suite/case config file
- for key in opts.keys():
+ for key in list(opts.keys()):
if key in self.get_suite_cfg():
opts[key] = self.get_suite_cfg()[key]
# Generate option string
opt_str = ""
- for key,value in opts.items():
+ for key,value in list(opts.items()):
if value is None:
continue
dash = "-" if len(key) == 1 else "--"
@@ -202,8 +202,8 @@ class VirtioCryptodevIpsecTest(TestCase):
self.dut_execut_cmd(self.vhost_switch_cmd, "socket created", 30)
def bind_vfio_pci(self):
- commands.getoutput("modprobe vfio-pci")
- commands.getoutput('%s -b vfio-pci %s' % (os.path.join(self.dut.base_dir, self.bind_script_path), self.vfio_pci))
+ subprocess.getoutput("modprobe vfio-pci")
+ subprocess.getoutput('%s -b vfio-pci %s' % (os.path.join(self.dut.base_dir, self.bind_script_path), self.vfio_pci))
def set_virtio_pci(self, dut):
out = dut.send_expect("lspci -d:1054|awk '{{print $1}}'", "# ", 10)
@@ -223,7 +223,7 @@ class VirtioCryptodevIpsecTest(TestCase):
try:
vm_dut = vm.start(set_target=False)
if vm_dut is None:
- print('{} start failed'.format(vm_name))
+ print(('{} start failed'.format(vm_name)))
except Exception as err:
raise err
vm_dut.restore_interfaces()
@@ -338,7 +338,7 @@ class VirtioCryptodevIpsecTest(TestCase):
self.logger.info(cmd_str)
try:
out = vm_dut.send_expect(cmd_str, "IPSEC", 600)
- except Exception, ex:
+ except Exception as ex:
self.logger.error(ex)
raise ex
diff --git a/tests/TestSuite_virtio_perf_cryptodev_func.py b/tests/TestSuite_virtio_perf_cryptodev_func.py
index b0b23d5..a8cbdf2 100644
--- a/tests/TestSuite_virtio_perf_cryptodev_func.py
+++ b/tests/TestSuite_virtio_perf_cryptodev_func.py
@@ -34,7 +34,7 @@ Test DPDK vhost + virtio scenarios
"""
import os
import utils
-import commands
+import subprocess
from test_case import TestCase
from qemu_kvm import QEMUKvm
import cryptodev_common as cc
@@ -141,13 +141,13 @@ class VirtioCryptodevPerfTest(TestCase):
opts = default_eal_opts.copy()
# Update options with test suite/case config file
- for key in opts.keys():
+ for key in list(opts.keys()):
if key in self.get_suite_cfg():
opts[key] = self.get_suite_cfg()[key]
# Generate option string
opt_str = ""
- for key,value in opts.items():
+ for key,value in list(opts.items()):
if value is None:
continue
dash = "-" if len(key) == 1 else "--"
@@ -165,8 +165,8 @@ class VirtioCryptodevPerfTest(TestCase):
self.dut_execut_cmd(self.vhost_switch_cmd, "socket created", 30)
def bind_vfio_pci(self):
- commands.getoutput("modprobe vfio-pci")
- commands.getoutput('%s -b vfio-pci %s' % (os.path.join(self.dut.base_dir, self.bind_script_path), self.vfio_pci))
+ subprocess.getoutput("modprobe vfio-pci")
+ subprocess.getoutput('%s -b vfio-pci %s' % (os.path.join(self.dut.base_dir, self.bind_script_path), self.vfio_pci))
def set_virtio_pci(self, dut):
out = dut.send_expect("lspci -d:1054|awk '{{print $1}}'", "# ", 10)
@@ -185,7 +185,7 @@ class VirtioCryptodevPerfTest(TestCase):
try:
vm_dut = vm.start(set_target=False)
if vm_dut is None:
- print('{} start failed'.format(vm_name))
+ print(('{} start failed'.format(vm_name)))
except Exception as err:
raise err
diff --git a/tests/TestSuite_virtio_pvp_regression.py b/tests/TestSuite_virtio_pvp_regression.py
index 84bf8c2..e03048e 100644
--- a/tests/TestSuite_virtio_pvp_regression.py
+++ b/tests/TestSuite_virtio_pvp_regression.py
@@ -119,7 +119,7 @@ class TestVirtioPVPRegression(TestCase):
config_qemu = False
params_num = len(self.vm.params)
for qemu_index in range(params_num):
- if self.vm.params[qemu_index].keys()[0] == "qemu":
+ if list(self.vm.params[qemu_index].keys())[0] == "qemu":
qemu_num = len(self.vm.params[qemu_index]["qemu"])
config_qemu = True
break
@@ -179,7 +179,7 @@ class TestVirtioPVPRegression(TestCase):
"""
params_num = len(self.vm.params)
for qemu_index in range(params_num):
- if self.vm.params[qemu_index].keys()[0] == "qemu":
+ if list(self.vm.params[qemu_index].keys())[0] == "qemu":
qemu_num = len(self.vm.params[qemu_index]["qemu"])
break
self.verify(qemu_index < params_num, "Please config qemu path in conf gile")
@@ -195,8 +195,8 @@ class TestVirtioPVPRegression(TestCase):
"""
params_number = len(self.vm.params)
for i in range(params_number):
- if self.vm.params[i].keys()[0] == 'cpu':
- if 'cpupin' in self.vm.params[i]['cpu'][0].keys():
+ if list(self.vm.params[i].keys())[0] == 'cpu':
+ if 'cpupin' in list(self.vm.params[i]['cpu'][0].keys()):
self.vm.params[i]['cpu'][0].pop('cpupin')
def start_vm(self, qemu_path, qemu_version, modem, virtio_path):
diff --git a/tests/TestSuite_virtio_unit_cryptodev_func.py b/tests/TestSuite_virtio_unit_cryptodev_func.py
index 4a61448..a9d1ee1 100644
--- a/tests/TestSuite_virtio_unit_cryptodev_func.py
+++ b/tests/TestSuite_virtio_unit_cryptodev_func.py
@@ -36,7 +36,7 @@ Test DPDK vhost + virtio scenarios
import os
import utils
-import commands
+import subprocess
from test_case import TestCase
from qemu_kvm import QEMUKvm
import cryptodev_common as cc
@@ -113,13 +113,13 @@ class VirtioCryptodevUnitTest(TestCase):
opts = default_eal_opts.copy()
# Update options with test suite/case config file
- for key in opts.keys():
+ for key in list(opts.keys()):
if key in self.get_suite_cfg():
opts[key] = self.get_suite_cfg()[key]
# Generate option string
opt_str = ""
- for key,value in opts.items():
+ for key,value in list(opts.items()):
if value is None:
continue
dash = "-" if len(key) == 1 else "--"
@@ -137,8 +137,8 @@ class VirtioCryptodevUnitTest(TestCase):
self.dut_execut_cmd(self.vhost_switch_cmd, "socket created", 30)
def bind_vfio_pci(self):
- commands.getoutput("modprobe vfio-pci")
- commands.getoutput('%s -b vfio-pci %s' % (os.path.join(self.dut.base_dir, self.bind_script_path), self.vfio_pci))
+ subprocess.getoutput("modprobe vfio-pci")
+ subprocess.getoutput('%s -b vfio-pci %s' % (os.path.join(self.dut.base_dir, self.bind_script_path), self.vfio_pci))
def set_virtio_pci(self, dut):
out = dut.send_expect("lspci -d:1054|awk '{{print $1}}'", "# ", 10)
@@ -157,7 +157,7 @@ class VirtioCryptodevUnitTest(TestCase):
try:
vm_dut = vm.start(set_target=False)
if vm_dut is None:
- print('{} start failed'.format(vm_name))
+ print(('{} start failed'.format(vm_name)))
except Exception as err:
raise err
diff --git a/tests/TestSuite_virtio_user_as_exceptional_path.py b/tests/TestSuite_virtio_user_as_exceptional_path.py
index 2ca29ed..3605900 100644
--- a/tests/TestSuite_virtio_user_as_exceptional_path.py
+++ b/tests/TestSuite_virtio_user_as_exceptional_path.py
@@ -204,9 +204,9 @@ class TestVirtioUserAsExceptionalPath(TestCase):
Get the iperf test result
'''
fmsg = vm_client.send_expect("cat /root/iperf_client.log", "#")
- print fmsg
+ print(fmsg)
iperfdata = re.compile('[\d+]*.[\d+]* [M|G]bits/sec').findall(fmsg)
- print iperfdata
+ print(iperfdata)
self.verify(iperfdata, 'There no data about this case')
self.result_table_create(['Data', 'Unit'])
results_row = ['exception path']
diff --git a/tests/TestSuite_vlan.py b/tests/TestSuite_vlan.py
index 0ade7f0..95e8cff 100644
--- a/tests/TestSuite_vlan.py
+++ b/tests/TestSuite_vlan.py
@@ -130,7 +130,7 @@ class TestVlan(TestCase):
"""
if self.kdriver == "fm10k":
- print utils.RED("fm10k not support this case\n")
+ print((utils.RED("fm10k not support this case\n")))
return
self.dut.send_expect("rx_vlan add %d %s" % (self.vlan, dutRxPortId), "testpmd> ")
self.dut.send_expect("vlan set strip off %s" % dutRxPortId, "testpmd> ")
diff --git a/tests/TestSuite_vlan_ethertype_config.py b/tests/TestSuite_vlan_ethertype_config.py
index c6640c3..a18f7c8 100644
--- a/tests/TestSuite_vlan_ethertype_config.py
+++ b/tests/TestSuite_vlan_ethertype_config.py
@@ -155,7 +155,7 @@ class TestVlanEthertypeConfig(TestCase):
self.vlan_send_packet(vlan, tpid)
out = self.get_tcpdump_packet(self.rxItf)
tpid_vlan = str("%04x" % tpid) + str("%04x" % vlan)
- print "tpid_vlan: %s" % tpid_vlan
+ print(("tpid_vlan: %s" % tpid_vlan))
if(result):
self.verify(tpid_vlan in out, "Wrong vlan:" + str(out))
else:
@@ -166,7 +166,7 @@ class TestVlanEthertypeConfig(TestCase):
Test Case 1: change VLAN TPID
"""
if self.kdriver == "fm10k":
- print dts.RED("fm10k not support this case\n")
+ print((dts.RED("fm10k not support this case\n")))
return
random_vlan = random.randint(1, MAX_VLAN - 1)
self.dut.send_expect("set fwd rxonly", "testpmd> ")
diff --git a/tests/TestSuite_vm2vm_virtio_pmd.py b/tests/TestSuite_vm2vm_virtio_pmd.py
index 99715bc..c1703b9 100644
--- a/tests/TestSuite_vm2vm_virtio_pmd.py
+++ b/tests/TestSuite_vm2vm_virtio_pmd.py
@@ -209,7 +209,7 @@ class TestVM2VMVirtioPMD(TestCase):
if vm_dut is None:
raise Exception("Set up VM ENV failed")
except Exception as e:
- print utils.RED("Failure for %s" % str(e))
+ print((utils.RED("Failure for %s" % str(e))))
raise e
self.vm_dut.append(vm_dut)
diff --git a/tests/TestSuite_vm_hotplug.py b/tests/TestSuite_vm_hotplug.py
index 864a996..276a0b8 100644
--- a/tests/TestSuite_vm_hotplug.py
+++ b/tests/TestSuite_vm_hotplug.py
@@ -135,7 +135,7 @@ class TestVmHotplug(TestCase):
while time_diff < 120:
try:
out = self.vm_net_session.send_expect('~/QMP/qemu-ga-client --address=/tmp/vm0_qga0.sock ifconfig', '#')
- except Exception, EnvironmentError:
+ except Exception as EnvironmentError:
pass
if '10.0.2' in out:
pos = self.vm0.hostfwd_addr.find(':')
diff --git a/tests/TestSuite_vm_power_manager.py b/tests/TestSuite_vm_power_manager.py
index 1b9a965..c34d38c 100644
--- a/tests/TestSuite_vm_power_manager.py
+++ b/tests/TestSuite_vm_power_manager.py
@@ -151,7 +151,7 @@ class TestVmPowerManager(TestCase, IxiaPacketGenerator):
self.vm_dut.send_expect(
"set_cpu_freq %d down" % vcpu, "vmpower\(guest\)>")
cur_freq = self.get_cpu_frequency(self.vcpu_map[vcpu])
- print utils.GREEN("After frequency down, freq is %d\n" % cur_freq)
+ print((utils.GREEN("After frequency down, freq is %d\n" % cur_freq)))
self.verify(
ori_freq > cur_freq, "Cpu freqenecy can not scale down")
ori_freq = cur_freq
@@ -178,7 +178,7 @@ class TestVmPowerManager(TestCase, IxiaPacketGenerator):
self.vm_dut.send_expect(
"set_cpu_freq %d up" % vcpu, "vmpower\(guest\)>")
cur_freq = self.get_cpu_frequency(self.vcpu_map[vcpu])
- print utils.GREEN("After frequency up, freq is %d\n" % cur_freq)
+ print((utils.GREEN("After frequency up, freq is %d\n" % cur_freq)))
self.verify(
cur_freq > ori_freq, "Cpu freqenecy can not scale up")
ori_freq = cur_freq
@@ -205,7 +205,7 @@ class TestVmPowerManager(TestCase, IxiaPacketGenerator):
max_freq = int(out)
self.verify(freq == max_freq, "Cpu max frequency not correct")
- print utils.GREEN("After frequency max, freq is %d\n" % max_freq)
+ print((utils.GREEN("After frequency max, freq is %d\n" % max_freq)))
self.vm_dut.send_expect("quit", "# ")
def test_vm_power_managment_freqmin(self):
@@ -228,7 +228,7 @@ class TestVmPowerManager(TestCase, IxiaPacketGenerator):
min_freq = int(out)
self.verify(freq == min_freq, "Cpu min frequency not correct")
- print utils.GREEN("After frequency min, freq is %d\n" % min_freq)
+ print((utils.GREEN("After frequency min, freq is %d\n" % min_freq)))
self.vm_dut.send_expect("quit", "# ")
def test_vm_power_multivms(self):
@@ -322,7 +322,7 @@ class TestVmPowerManager(TestCase, IxiaPacketGenerator):
"vmpower.pcap"))
# run traffic generator
[latency] = self.tester.traffic_generator_latency(tgen_input)
- print latency
+ print(latency)
table_row = [frame_size, latency['max'], latency['min'],
latency['average']]
self.result_table_add(table_row)
@@ -390,7 +390,7 @@ class TestVmPowerManager(TestCase, IxiaPacketGenerator):
def get_freq_in_transmission(self):
self.cur_freq = self.get_cpu_frequency(self.vcpu_map[1])
- print utils.GREEN("Current cpu frequency %d" % self.cur_freq)
+ print((utils.GREEN("Current cpu frequency %d" % self.cur_freq)))
def get_max_freq(self, core_num):
freq_path = "cat /sys/devices/system/cpu/cpu%d/cpufreq/" + \
diff --git a/tests/TestSuite_vm_pw_mgmt_policy.py b/tests/TestSuite_vm_pw_mgmt_policy.py
index b0f1503..076046b 100644
--- a/tests/TestSuite_vm_pw_mgmt_policy.py
+++ b/tests/TestSuite_vm_pw_mgmt_policy.py
@@ -39,7 +39,7 @@ import time
import textwrap
import random
import traceback
-from itertools import product, izip
+from itertools import product
from datetime import datetime, timedelta
from copy import deepcopy
from pprint import pformat
@@ -108,7 +108,7 @@ class TestVmPwMgmtPolicy(TestCase):
console, msg_pipe = self.get_console(name)
if len(cmds) == 0:
return
- if isinstance(cmds, (str, unicode)):
+ if isinstance(cmds, str):
cmds = [cmds, '# ', 5]
if not isinstance(cmds[0], list):
cmds = [cmds]
@@ -164,13 +164,13 @@ class TestVmPwMgmtPolicy(TestCase):
# create packet for send
streams = []
for stm_name in stm_names:
- if stm_name not in pkt_configs.keys():
+ if stm_name not in list(pkt_configs.keys()):
continue
values = pkt_configs[stm_name]
pkt_type = values.get('type')
pkt_layers = values.get('pkt_layers')
pkt = Packet(pkt_type=pkt_type)
- for layer in pkt_layers.keys():
+ for layer in list(pkt_layers.keys()):
pkt.config_layer(layer, pkt_layers[layer])
streams.append(pkt.pktgen.pkt)
@@ -829,11 +829,11 @@ class TestVmPwMgmtPolicy(TestCase):
_common_config['opt_fmt'] += option_cfg.get('opt_fmt', [])
_common_config['option'].update(option_cfg['option'])
config.pop('cmd')
- values = _common_config['option'].values()
- keys = _common_config['option'].keys()
+ values = list(_common_config['option'].values())
+ keys = list(_common_config['option'].keys())
opt_fmt = _common_config['opt_fmt']
for item in product(*values):
- _options = dict(izip(keys, item))
+ _options = dict(zip(keys, item))
_options['policy'] = policy_name
_opt_fmt = " ".join(opt_fmt)
_config = deepcopy(config)
diff --git a/tests/TestSuite_vxlan.py b/tests/TestSuite_vxlan.py
index 6570364..1aa98c6 100644
--- a/tests/TestSuite_vxlan.py
+++ b/tests/TestSuite_vxlan.py
@@ -262,7 +262,7 @@ class TestVxlan(TestCase, IxiaPacketGenerator):
elif self.nic in ["sageville", "sagepond"]:
self.compile_switch = 'CONFIG_RTE_IXGBE_INC_VECTOR'
elif self.nic in ["columbiaville_25g","columbiaville_100g"]:
- print "CVL support default none VECTOR"
+ print("CVL support default none VECTOR")
else:
self.verify(False, "%s not support this vxlan" % self.nic)
# Based on h/w type, choose how many ports to use
@@ -385,7 +385,7 @@ class TestVxlan(TestCase, IxiaPacketGenerator):
# check whether detect vxlan type
out = self.dut.get_session_output(timeout=2)
- print out
+ print(out)
self.verify(config.packet_type() in out, "Vxlan Packet not detected")
def send_and_check(self, **kwargs):
@@ -453,7 +453,7 @@ class TestVxlan(TestCase, IxiaPacketGenerator):
self.logger.info("chksums" + str(chksums))
out = self.dut.send_expect("stop", "testpmd>", 10)
- print out
+ print(out)
# verify detected l4 invalid checksum
if "inner_l4_invalid" in kwargs:
@@ -506,7 +506,7 @@ class TestVxlan(TestCase, IxiaPacketGenerator):
self.dut.send_expect("start", "testpmd>", 10)
config.send_pcap(self.tester_iface)
out = self.dut.get_session_output(timeout=2)
- print out
+ print(out)
queue = -1
pattern = re.compile("- Receive queue=0x(\d)")
@@ -524,7 +524,7 @@ class TestVxlan(TestCase, IxiaPacketGenerator):
verify vxlan packet detection
"""
if self.nic in ["columbiaville_25g","columbiaville_100g"]:
- print "CVL support default none VECTOR"
+ print("CVL support default none VECTOR")
src_vec_model = 'n'
else:
out = self.dut.send_expect("cat config/common_base", "]# ", 10)
@@ -566,7 +566,7 @@ class TestVxlan(TestCase, IxiaPacketGenerator):
self.dut.send_expect("quit", "#", 10)
if self.nic in ["columbiaville_25g","columbiaville_100g"]:
- print "CVL support default none VECTOR"
+ print("CVL support default none VECTOR")
src_vec_model = 'n'
else:
out = self.dut.send_expect("cat config/common_base", "]# ", 10)
@@ -582,7 +582,7 @@ class TestVxlan(TestCase, IxiaPacketGenerator):
verify vxlan packet detection with ipv6 header
"""
if self.nic in ["columbiaville_25g","columbiaville_100g"]:
- print "CVL support default none VECTOR"
+ print("CVL support default none VECTOR")
src_vec_model = 'n'
else:
out = self.dut.send_expect("cat config/common_base", "]# ", 10)
@@ -628,7 +628,7 @@ class TestVxlan(TestCase, IxiaPacketGenerator):
self.dut.send_expect("quit", "#", 10)
if self.nic in ["columbiaville_25g","columbiaville_100g"]:
- print "CVL support default none VECTOR"
+ print("CVL support default none VECTOR")
src_vec_model = 'n'
else:
out = self.dut.send_expect("cat config/common_base", "]# ", 10)
@@ -880,7 +880,7 @@ class TestVxlan(TestCase, IxiaPacketGenerator):
recv_queue = perf_config['recvqueue']
# there's known bug that if enable vxlan, rss will be disabled
if tun_filter == "None" and recv_queue == 'Multi':
- print utils.RED("RSS and Tunel filter can't enable in the same time")
+ print((utils.RED("RSS and Tunel filter can't enable in the same time")))
else:
self.enable_vxlan(dut_port)
@@ -969,8 +969,8 @@ class TestVxlan(TestCase, IxiaPacketGenerator):
for perf_config in self.tunnel_perf:
tun_filter = perf_config['tunnel_filter']
recv_queue = perf_config['recvqueue']
- print utils.GREEN("Measure tunnel performance of [%s %s %s]"
- % (perf_config['Packet'], tun_filter, recv_queue))
+ print((utils.GREEN("Measure tunnel performance of [%s %s %s]"
+ % (perf_config['Packet'], tun_filter, recv_queue))))
if tun_filter == "None" and recv_queue == "Multi":
pmd_temp = "./%(TARGET)s/app/testpmd -c %(COREMASK)s -n " + \
@@ -1062,8 +1062,8 @@ class TestVxlan(TestCase, IxiaPacketGenerator):
tgen_tester = self.tester.get_local_port(self.recv_port)
for cal in self.cal_type:
recv_queue = cal['recvqueue']
- print utils.GREEN("Measure checksum performance of [%s %s %s]"
- % (cal['Type'], recv_queue, cal['csum']))
+ print((utils.GREEN("Measure checksum performance of [%s %s %s]"
+ % (cal['Type'], recv_queue, cal['csum']))))
# configure flows
tgen_input = []
diff --git a/tests/TestSuite_vxlan_gpe_support_in_i40e.py b/tests/TestSuite_vxlan_gpe_support_in_i40e.py
index aa3ee82..bbf0260 100644
--- a/tests/TestSuite_vxlan_gpe_support_in_i40e.py
+++ b/tests/TestSuite_vxlan_gpe_support_in_i40e.py
@@ -238,7 +238,7 @@ class TestVxlanGpeSupportInI40e(TestCase):
self.tester.scapy_append(packet)
self.tester.scapy_execute()
out = self.dut.get_session_output(timeout=5)
- print out
+ print(out)
self.verify('L3_IPV4_EXT_UNKNOWN' in out and '%s' % VXLAN_GPE_PORT in out, 'no detect vxlan-gpe packet')
# delete the VXLAN-GPE packet type, testpmd should treat the packet as a normal UDP packet
@@ -248,7 +248,7 @@ class TestVxlanGpeSupportInI40e(TestCase):
self.tester.scapy_append(packet)
self.tester.scapy_execute()
out = self.dut.get_session_output(timeout=5)
- print out
+ print(out)
self.pmdout.execute_cmd('quit', '#')
self.verify('L3_IPV4_EXT_UNKNOWN' in out and '%s' % VXLAN_GPE_PORT not in out, 'no detect vxlan-gpe packet')
diff --git a/tests/TestSuite_vxlan_sample.py b/tests/TestSuite_vxlan_sample.py
index d0291e9..7d4be40 100644
--- a/tests/TestSuite_vxlan_sample.py
+++ b/tests/TestSuite_vxlan_sample.py
@@ -202,11 +202,11 @@ class TestVxlanSample(TestCase):
if self.vm_dut is None:
raise Exception("Set up VM ENV failed!")
except Exception as e:
- print utils.RED("Failure for %s" % str(e))
+ print(utils.RED("Failure for %s" % str(e)))
# create another vm
if vm_num == 2:
- print "not implemented now"
+ print("not implemented now")
return True
@@ -303,11 +303,11 @@ class TestVxlanSample(TestCase):
self.verify(ord(payload[i]) == 88, "Check udp data failed")
except:
case_pass = False
- print utils.RED("Failure in checking packet payload")
+ print(utils.RED("Failure in checking packet payload"))
if case_pass:
- print utils.GREEN("Check normal udp packet forward pass on "
- "virtIO port %d" % vf_id)
+ print(utils.GREEN("Check normal udp packet forward pass on "
+ "virtIO port %d" % vf_id))
if pkt_type == "vxlan_udp_decap":
# create vxlan packet pf mac + vni=1000 + inner virtIO port0 mac
@@ -338,11 +338,11 @@ class TestVxlanSample(TestCase):
self.verify(ord(payload[i]) == 88, "Check udp data failed")
except:
case_pass = False
- print utils.RED("Failure in checking packet payload")
+ print(utils.RED("Failure in checking packet payload"))
if case_pass:
- print utils.GREEN("Check vxlan packet decap pass on virtIO port"
- " %d" % vf_id)
+ print(utils.GREEN("Check vxlan packet decap pass on virtIO port"
+ " %d" % vf_id))
if pkt_type == "vxlan_udp":
# create vxlan packet pf mac + vni=1000 + inner virtIO port0 mac
@@ -373,11 +373,11 @@ class TestVxlanSample(TestCase):
self.verify(ord(payload[i]) == 88, "Check udp data failed")
except:
case_pass = False
- print utils.RED("Failure in checking packet payload")
+ print(utils.RED("Failure in checking packet payload"))
if case_pass:
- print utils.GREEN("Check vxlan packet decap and encap pass on "
- "virtIO port %d" % vf_id)
+ print(utils.GREEN("Check vxlan packet decap and encap pass on "
+ "virtIO port %d" % vf_id))
if pkt_type == "vxlan_udp_chksum":
params['inner_l4_type'] = 'UDP'
@@ -396,7 +396,7 @@ class TestVxlanSample(TestCase):
vxlan_pkt = VxlanTestConfig(self, **params)
vxlan_pkt.create_pcap()
chksums_ref = vxlan_pkt.get_chksums()
- print utils.GREEN("Checksum reference: %s" % chksums_ref)
+ print(utils.GREEN("Checksum reference: %s" % chksums_ref))
params['inner_ip_invalid'] = 1
params['inner_l4_invalid'] = 1
@@ -419,14 +419,14 @@ class TestVxlanSample(TestCase):
pk_new.pktgen.assign_pkt(pkts)
pk_new.pktgen.update_pkts()
chksums = vxlan_pkt.get_chksums(pk_new)
- print utils.GREEN("Checksum : %s" % chksums)
+ print(utils.GREEN("Checksum : %s" % chksums))
for key in chksums_ref:
if 'inner' in key: # only check inner packet chksum
self.verify(chksums[key] == chksums_ref[key],
"%s not matched to %s"
% (key, chksums_ref[key]))
- print utils.GREEN("%s checksum pass" % params['inner_l4_type'])
+ print(utils.GREEN("%s checksum pass" % params['inner_l4_type']))
if pkt_type == "vxlan_tcp_tso":
# create vxlan packet pf mac + vni=1000 + inner virtIO port0 mac +
@@ -459,15 +459,15 @@ class TestVxlanSample(TestCase):
del inner.chksum
inner[IP] = inner[IP].__class__(str(inner[IP]))
inner_ip_chksum_ref = inner[IP].chksum
- print utils.GREEN("inner ip checksum reference: %x" % inner_ip_chksum_ref)
- print utils.GREEN("inner ip checksum: %x" % inner_ip_chksum)
+ print(utils.GREEN("inner ip checksum reference: %x" % inner_ip_chksum_ref))
+ print(utils.GREEN("inner ip checksum: %x" % inner_ip_chksum))
self.verify(inner_ip_chksum == inner_ip_chksum_ref, "inner ip checksum error")
inner_l4_chksum = inner[params['inner_l4_type']].chksum
del inner[params['inner_l4_type']].chksum
inner[params['inner_l4_type']] = inner[params['inner_l4_type']].__class__(str(inner[params['inner_l4_type']]))
inner_l4_chksum_ref = inner[params['inner_l4_type']].chksum
- print utils.GREEN("inner l4 checksum reference: %x" % inner_l4_chksum_ref)
- print utils.GREEN("inner l4 checksum: %x" % inner_l4_chksum)
+ print(utils.GREEN("inner l4 checksum reference: %x" % inner_l4_chksum_ref))
+ print(utils.GREEN("inner l4 checksum: %x" % inner_l4_chksum))
self.verify(inner_l4_chksum == inner_l4_chksum_ref, "inner %s checksum error" % params['inner_l4_type'])
length = 0
@@ -481,12 +481,12 @@ class TestVxlanSample(TestCase):
length += len(payload)
except:
case_pass = False
- print utils.RED("Failure in checking tso payload")
+ print(utils.RED("Failure in checking tso payload"))
self.verify(length == 892, "Total tcp payload size not match")
if case_pass:
- print utils.GREEN("Vxlan packet tso pass on virtIO port %d"
- % vf_id)
+ print(utils.GREEN("Vxlan packet tso pass on virtIO port %d"
+ % vf_id))
def test_perf_vxlan_sample(self):
# vxlan payload length for performance test
diff --git a/tests/bonding.py b/tests/bonding.py
index 6c136a3..b5fc45f 100644
--- a/tests/bonding.py
+++ b/tests/bonding.py
@@ -148,8 +148,7 @@ class PmdBonding(object):
def get_pkt_len(self, pkt_type):
''' get packet payload size '''
frame_size = self.default_pkt_size
- headers_size = sum(map(lambda x: HEADER_SIZE[x],
- ['eth', 'ip', pkt_type]))
+ headers_size = sum([HEADER_SIZE[x] for x in ['eth', 'ip', pkt_type]])
pktlen = frame_size - headers_size
return pktlen
@@ -186,7 +185,7 @@ class PmdBonding(object):
pkt_type = pkt_config.get('type')
pkt_layers = pkt_config.get('pkt_layers')
pkt = Packet(pkt_type=pkt_type.upper())
- for layer in pkt_layers.keys():
+ for layer in list(pkt_layers.keys()):
pkt.config_layer(layer, pkt_layers[layer])
pkt.save_pcapfile(filename=savePath)
streams.append(pkt.pktgen.pkt)
@@ -233,7 +232,7 @@ class PmdBonding(object):
pkt_type = values.get('type')
pkt_layers = values.get('pkt_layers')
pkt = Packet(pkt_type=pkt_type.upper())
- for layer in pkt_layers.keys():
+ for layer in list(pkt_layers.keys()):
pkt.config_layer(layer, pkt_layers[layer])
pkt.save_pcapfile(filename=savePath)
streams.append(pkt.pktgen.pkt)
@@ -265,7 +264,7 @@ class PmdBonding(object):
self.tgen_input = []
tgen_input = self.tgen_input
# generate packet contain multi stream
- for pkt in self.packet_types.values():
+ for pkt in list(self.packet_types.values()):
send_pkts.append(pkt.pktgen.pkt)
ixia_pkt = os.sep.join([self.target_source, 'bonding_ixia.pcap'])
wrpcap(ixia_pkt, send_pkts)
@@ -481,7 +480,7 @@ class PmdBonding(object):
"""
get one port statistics of testpmd
"""
- _portid = int(portid) if isinstance(portid, (str, unicode)) else portid
+ _portid = int(portid) if isinstance(portid, str) else portid
info = self.testpmd.get_pmd_stats(_portid)
_kwd = ["-packets", "-errors", "-bytes"]
stats = {}
@@ -490,7 +489,7 @@ class PmdBonding(object):
for item2 in _kwd:
name = item.upper() + item2
stats[name] = int(info[name])
- elif isinstance(flow, (str, unicode)):
+ elif isinstance(flow, str):
for item in _kwd:
name = flow.upper() + item
stats[name] = int(info[name])
@@ -547,7 +546,7 @@ class PmdBonding(object):
"""
Get some values from the given string by the regular expression.
"""
- if isinstance(key_str, (unicode, str)):
+ if isinstance(key_str, str):
pattern = r"(?<=%s)%s" % (key_str, regx_str)
s = re.compile(pattern)
res = s.search(string)
@@ -613,12 +612,12 @@ class PmdBonding(object):
['Min possible number of TXDs per queue: ', "\d+"],]
}
- if info_type in info_set.keys():
+ if info_type in list(info_set.keys()):
return self.get_detail_from_port_info(port_id, info_set[info_type])
else:
msg = os.linesep.join([
"support query items including::",
- os.linesep.join(info_set.keys())])
+ os.linesep.join(list(info_set.keys()))])
self.logger.warning(msg)
return None
#
@@ -664,7 +663,7 @@ class PmdBonding(object):
if isinstance(info_types, (list or tuple)):
query_values = []
for info_type in info_types:
- if info_type in info_set.keys():
+ if info_type in list(info_set.keys()):
find_value = self.get_info_from_bond_config(
config_content, info_set[info_type])
if info_type in ['active_slaves', 'slaves']:
@@ -676,7 +675,7 @@ class PmdBonding(object):
return query_values
else:
info_type = info_types
- if info_type in info_set.keys():
+ if info_type in list(info_set.keys()):
find_value = self.get_info_from_bond_config(
config_content, info_set[info_type])
if info_type in ['active_slaves', 'slaves']:
diff --git a/tests/compress_common.py b/tests/compress_common.py
index 5d681e4..6bde1ce 100644
--- a/tests/compress_common.py
+++ b/tests/compress_common.py
@@ -90,14 +90,14 @@ def bind_qat_device(test_case, driver = "igb_uio"):
def get_opt_str(test_case, default_opts={}, override_opts={}):
case_cfg = conf.load_case_config(test_case._suite_result.test_case)
opts = default_opts.copy()
- for key in default_opts.keys():
+ for key in list(default_opts.keys()):
if key in case_cfg:
opts[key] = case_cfg[key]
opts.update(override_opts)
opt_str = ""
- for key,value in opts.items():
+ for key,value in list(opts.items()):
if value is None:
continue
dash = "-" if len(key) == 1 else "--"
@@ -263,7 +263,7 @@ def format_perf_data(flag, output):
stats_results = parse_perf_output(output)
json_result = []
- for level, values in stats_results.items():
+ for level, values in list(stats_results.items()):
status, delta = "PASS", 0
try:
if 'accepted_tolerance' in conf.suite_cfg:
diff --git a/tests/cryptodev_common.py b/tests/cryptodev_common.py
index 1f2a9ae..a20dd51 100644
--- a/tests/cryptodev_common.py
+++ b/tests/cryptodev_common.py
@@ -154,12 +154,12 @@ def get_opt_str(test_case, default_opts, override_opts={}, add_port=False):
opts = default_opts.copy()
# Update options with test suite/case config file
- for key in opts.keys():
+ for key in list(opts.keys()):
if key in test_case.get_case_cfg():
opts[key] = test_case.get_case_cfg()[key]
pci_list = [port["pci"] for port in test_case.dut.ports_info]
- if 'w' in opts.keys() and opts['w']:
+ if 'w' in list(opts.keys()) and opts['w']:
pci_list.append(opts['w'])
if add_port and pci_list:
opts['w'] = " -w ".join(pci_list)
@@ -169,7 +169,7 @@ def get_opt_str(test_case, default_opts, override_opts={}, add_port=False):
# Generate option string
opt_str = ""
- for key,value in opts.items():
+ for key,value in list(opts.items()):
if value is None:
continue
dash = "-" if len(key) == 1 else "--"
diff --git a/tests/rte_flow_common.py b/tests/rte_flow_common.py
index 568a0e8..7592114 100644
--- a/tests/rte_flow_common.py
+++ b/tests/rte_flow_common.py
@@ -244,19 +244,19 @@ def check_queue(out, pkt_num, check_param, stats=True):
if stats:
if isinstance(queue, int):
verify(all(q == queue for q in res_queue), "fail: queue id not matched, expect queue %s, got %s" % (queue, res_queue))
- print(GREEN("pass: queue id %s matched" % res_queue))
+ print((GREEN("pass: queue id %s matched" % res_queue)))
elif isinstance(queue, list):
verify(all(q in queue for q in res_queue), "fail: queue id not matched, expect queue %s, got %s" % (queue, res_queue))
- print(GREEN("pass: queue id %s matched" % res_queue))
+ print((GREEN("pass: queue id %s matched" % res_queue)))
else:
raise Exception("wrong queue value, expect int or list")
else:
if isinstance(queue, int):
verify(not any(q == queue for q in res_queue), "fail: queue id should not matched, expect queue %s, got %s" % (queue, res_queue))
- print(GREEN("pass: queue id %s not matched" % res_queue))
+ print((GREEN("pass: queue id %s not matched" % res_queue)))
elif isinstance(queue, list):
verify(not any(q in queue for q in res_queue), "fail: each queue in %s should not in queue %s" % (res_queue, queue))
- print(GREEN("pass: queue id %s not matched" % res_queue))
+ print((GREEN("pass: queue id %s not matched" % res_queue)))
else:
raise Exception("wrong action value, expect queue_index or queue_group")
else:
@@ -270,7 +270,7 @@ def check_drop(out, pkt_num, check_param, stats=True):
title_li = ["rx-packets", "rx-dropped", "rx-total"]
pkt_li = p.findall(out)
if pkt_li:
- res = {k: v for k, v in zip(title_li, map(int, list(pkt_li[0])))}
+ res = {k: v for k, v in zip(title_li, list(map(int, list(pkt_li[0]))))}
verify(pkt_num == res["rx-total"], "failed: get wrong amount of packet %d, expected %d" % (res["rx-total"], pkt_num))
if stats:
verify(res["rx-dropped"] == pkt_num, "failed: dropped packets number %s not match" % res["rx-dropped"])
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread