From: xinfengx <xinfengx.zhao@intel.com>
To: dts@dpdk.org
Cc: xinfengx <xinfengx.zhao@intel.com>
Subject: [dts] [next][PATCH V1 2/5] tests: modify test suites to support python3
Date: Mon, 13 Jan 2020 06:18:28 +0800 [thread overview]
Message-ID: <20200112221831.12192-3-xinfengx.zhao@intel.com> (raw)
In-Reply-To: <20200112221831.12192-1-xinfengx.zhao@intel.com>
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
next prev parent reply other threads:[~2020-01-13 7:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-12 22:18 [dts] [next][PATCH V1 0/5] dts: modify dts " xinfengx
2020-01-12 22:18 ` [dts] [next][PATCH V1 1/5] framework: modify dts framework " xinfengx
2020-01-12 22:18 ` xinfengx [this message]
2020-01-12 22:18 ` [dts] [next][PATCH V1 3/5] dep: modify dts dep " xinfengx
2020-01-12 22:18 ` [dts] [next][PATCH V1 4/5] nics: modify dts nics " xinfengx
2020-01-12 22:18 ` [dts] [next][PATCH V1 5/5] tools: modify dts tools " xinfengx
2020-01-16 5:47 ` [dts] [next][PATCH V1 0/5] dts: modify dts " Tu, Lijuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200112221831.12192-3-xinfengx.zhao@intel.com \
--to=xinfengx.zhao@intel.com \
--cc=dts@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).