test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts][PATCH V1] tests/tso: improve checksum verify code
@ 2022-11-10  8:10 Ke Xu
  2022-11-18  8:10 ` lijuan.tu
  0 siblings, 1 reply; 2+ messages in thread
From: Ke Xu @ 2022-11-10  8:10 UTC (permalink / raw)
  To: dts; +Cc: lijuan.tu, ke1.xu

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [dts][PATCH V1] tests/tso: improve checksum verify code
  2022-11-10  8:10 [dts][PATCH V1] tests/tso: improve checksum verify code Ke Xu
@ 2022-11-18  8:10 ` lijuan.tu
  0 siblings, 0 replies; 2+ messages in thread
From: lijuan.tu @ 2022-11-18  8:10 UTC (permalink / raw)
  To: dts, Ke Xu; +Cc: lijuan.tu, ke1.xu

On Thu, 10 Nov 2022 16:10:50 +0800, Ke Xu <ke1.xu@intel.com> wrote:
> 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>

Reviewed-by: Lijuan Tu <lijuan.tu@intel.com>
Applied, thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-18  8:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10  8:10 [dts][PATCH V1] tests/tso: improve checksum verify code Ke Xu
2022-11-18  8:10 ` lijuan.tu

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).