From: Ke Xu <ke1.xu@intel.com>
To: dts@dpdk.org
Cc: lijuan.tu@intel.com, ke1.xu@intel.com
Subject: [dts][PATCH V1] tests/tso: improve checksum verify code
Date: Thu, 10 Nov 2022 16:10:50 +0800 [thread overview]
Message-ID: <20221110081050.76753-1-ke1.xu@intel.com> (raw)
Reimplemented the checksum calculation with a non-file method.
Replaced property pks with a local variable pkts.
Renamed local variable pks to pkt as it stands for a single packet.
Use the name of layers as the index of packet to check if it is in a packet rather than check if it is in the dumped string of a packet.
Renamed checksum_list and checksum_list1 to chksum_list_rx and checksum_list_good.
Signed-off-by: Ke Xu <ke1.xu@intel.com>
---
tests/TestSuite_tso.py | 51 +++++++++++++++++-------------------------
1 file changed, 20 insertions(+), 31 deletions(-)
diff --git a/tests/TestSuite_tso.py b/tests/TestSuite_tso.py
index 9f4e27a3..e95f68cf 100644
--- a/tests/TestSuite_tso.py
+++ b/tests/TestSuite_tso.py
@@ -138,41 +138,30 @@ class TestTSO(TestCase):
scanner = 'tcpdump -vv -r /tmp/tcpdump_{iface}.pcap 2>/dev/null | grep "seq" | grep "length"'
return self.tcpdump_scanner(scanner.format(**locals()))
- def get_chksum_value_and_verify(self, dump_pcap, save_file, Nic_list):
+ def get_chksum_value_and_verify(self, dump_pcap, Nic_list):
packet = Packet()
- self.pks = packet.read_pcapfile(dump_pcap, self.tester)
- for i in range(len(self.pks)):
- pks = self.pks[i]
- out = repr(pks)
- chksum_list = re.findall(r"chksum=(0x\w+)", out)
- pks["IP"].chksum = None
- if "VXLAN" in out:
- pks["UDP"].chksum = None
- pks["VXLAN"]["IP"].chksum = None
- pks["VXLAN"]["TCP"].chksum = None
- elif "GRE" in out:
- pks["GRE"]["IP"].chksum = None
- pks["GRE"]["TCP"].chksum = None
- packet.save_pcapfile(self.tester, filename=save_file)
- self.pks = Packet().read_pcapfile(dump_pcap, self.tester)
- self.pks1 = Packet().read_pcapfile(save_file, self.tester)
- self.tester.send_expect("rm -rf %s" % save_file, "#")
- for i in range(len(self.pks1)):
- pks = self.pks[i]
- out = repr(pks)
- chksum_list = re.findall(r"chksum=(0x\w+)", out)
- out1 = repr(self.pks1[i])
- chksum_list1 = re.findall(r"chksum=(0x\w+)", out1)
- if self.nic in Nic_list and "VXLAN" in out:
+ pkts = packet.read_pcapfile(dump_pcap, self.tester)
+ for pkt in pkts:
+ chksum_list_rx = re.findall(r"chksum\s*=\s*(0x\w+)", pkt.show(dump=True))
+ pkt["IP"].chksum = None
+ if "VXLAN" in pkt:
+ pkt["UDP"].chksum = None
+ pkt["VXLAN"]["IP"].chksum = None
+ pkt["VXLAN"]["TCP"].chksum = None
+ elif "GRE" in pkt:
+ pkt["GRE"]["IP"].chksum = None
+ pkt["GRE"]["TCP"].chksum = None
+ chksum_list_good = re.findall(r"chksum\s*=\s*(0x\w+)", pkt.show2(dump=True))
+ if self.nic in Nic_list and "VXLAN" in pkt:
self.verify(
- chksum_list[0] == chksum_list1[0]
- and chksum_list[2] == chksum_list1[2]
- and chksum_list[3] == chksum_list1[3],
+ chksum_list_rx[0] == chksum_list_good[0]
+ and chksum_list_rx[2] == chksum_list_good[2]
+ and chksum_list_rx[3] == chksum_list_good[3],
"The obtained chksum value is incorrect.",
)
else:
self.verify(
- chksum_list == chksum_list1,
+ chksum_list_rx == chksum_list_good,
"The obtained chksum value is incorrect.",
)
@@ -439,7 +428,7 @@ class TestTSO(TestCase):
int(tx_outlist[num]) == loading_size % 800,
"the packet segmentation incorrect, %s" % tx_outlist,
)
- self.get_chksum_value_and_verify(dump_pcap, save_file, Nic_list)
+ self.get_chksum_value_and_verify(dump_pcap, Nic_list)
for loading_size in self.loading_sizes:
# Nvgre test
@@ -474,7 +463,7 @@ class TestTSO(TestCase):
int(tx_outlist[num]) == loading_size % 800,
"the packet segmentation incorrect, %s" % tx_outlist,
)
- self.get_chksum_value_and_verify(dump_pcap, save_file, Nic_list)
+ self.get_chksum_value_and_verify(dump_pcap, Nic_list)
def test_perf_TSO_2ports(self):
"""
--
2.25.1
next reply other threads:[~2022-11-10 8:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 8:10 Ke Xu [this message]
2022-11-18 8:10 ` lijuan.tu
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=20221110081050.76753-1-ke1.xu@intel.com \
--to=ke1.xu@intel.com \
--cc=dts@dpdk.org \
--cc=lijuan.tu@intel.com \
/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).