test suite reviews and discussions
 help / color / mirror / Atom feed
From: Ke Xu <ke1.xu@intel.com>
To: dts@dpdk.org
Cc: qi.fu@intel.com, weiyuanx.li@intel.com, lijuan.tu@intel.com,
	ke1.xu@intel.com
Subject: [DTS][PATCH V1 5/5] tests/vf_offload: Replace the tcpdump implementation to a packet reading implementation.
Date: Tue, 27 Dec 2022 18:21:37 +0800	[thread overview]
Message-ID: <20221227102131.529684-6-ke1.xu@intel.com> (raw)
In-Reply-To: <20221227102131.529684-1-ke1.xu@intel.com>

Packet reading implementation is more common to use when to verify the
 received packet count and payload size. The tcpdump method is not
 able to recognize some of the tunnel packets, leading to a wrong output
 failing the validation. Newly added tcpdump_analyse_sniff method is
 implemented by sniff packet reading and analysing and can replace
 the lagacy methods number_of_packets and number_of_bytes.

Signed-off-by: Ke Xu <ke1.xu@intel.com>
---
 tests/TestSuite_vf_offload.py | 77 +++++++++--------------------------
 1 file changed, 20 insertions(+), 57 deletions(-)

diff --git a/tests/TestSuite_vf_offload.py b/tests/TestSuite_vf_offload.py
index eb702559..f2356c76 100644
--- a/tests/TestSuite_vf_offload.py
+++ b/tests/TestSuite_vf_offload.py
@@ -627,43 +627,6 @@ class TestVfOffload(TestCase):
         rx_packet_size = [len(p[Raw].load) for p in pkts]
         return rx_packet_count, rx_packet_size
 
-    def tcpdump_command(self, command):
-        """
-        Send a tcpdump related command and return an integer from the output.
-        """
-
-        result = self.tester.send_expect(command, "#")
-        print(result)
-        return int(result.strip())
-
-    def number_of_packets(self, iface):
-        """
-        By reading the file generated by tcpdump it counts how many packets are
-        forwarded by the sample app and received in the self.tester. The sample app
-        will add a known MAC address for the test to look for.
-        """
-
-        command = (
-            "tcpdump -A -nn -e -v -r tcpdump_{iface}.pcap 2>/dev/null | "
-            + 'grep -c "seq"'
-        )
-        return self.tcpdump_command(command.format(**locals()))
-
-    def tcpdump_scanner(self, scanner):
-        """
-        Execute scanner to return results
-        """
-        scanner_result = self.tester.send_expect(scanner, "#")
-        finally_result = re.findall(r"length( \d+)", scanner_result)
-        return list(finally_result)
-
-    def number_of_bytes(self, iface):
-        """
-        Get the length of loading_sizes
-        """
-        scanner = 'tcpdump  -n -vv -r tcpdump_{iface}.pcap 2>/dev/null | grep "seq"  | grep "length"'
-        return self.tcpdump_scanner(scanner.format(**locals()))
-
     def test_tso(self):
         """
         TSO IPv4 TCP, IPv6 TCP testing.
@@ -761,27 +724,26 @@ class TestVfOffload(TestCase):
             out = self.vm0_testpmd.execute_cmd("show port stats all")
             print(out)
             self.tcpdump_stop_sniff()
-            rx_stats = self.number_of_packets(rx_interface)
-            tx_stats = self.number_of_packets(tx_interface)
-            tx_outlist = self.number_of_bytes(rx_interface)
-            tx_outlist.sort(reverse=True)
-            self.logger.info(tx_outlist)
+            rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface)
+            tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface)
+            payload_size_list.sort(reverse=True)
+            self.logger.info(payload_size_list)
             if loading_size <= 800:
                 self.verify(
-                    rx_stats == tx_stats and int(tx_outlist[0]) == loading_size,
+                    rx_stats == tx_stats and int(payload_size_list[0]) == loading_size,
                     "IPV4 RX or TX packet number not correct",
                 )
             else:
                 num = loading_size // 800
                 for i in range(num):
                     self.verify(
-                        int(tx_outlist[i]) == 800,
-                        "the packet segmentation incorrect, %s" % tx_outlist,
+                        int(payload_size_list[i]) == 800,
+                        "the packet segmentation incorrect, %s" % payload_size_list,
                     )
                 if loading_size % 800 != 0:
                     self.verify(
-                        int(tx_outlist[num]) == loading_size % 800,
-                        "the packet segmentation incorrect, %s" % tx_outlist,
+                        int(payload_size_list[num]) == loading_size % 800,
+                        "the packet segmentation incorrect, %s" % payload_size_list,
                     )
 
         for loading_size in self.loading_sizes:
@@ -796,27 +758,26 @@ class TestVfOffload(TestCase):
             out = self.vm0_testpmd.execute_cmd("show port stats all")
             print(out)
             self.tcpdump_stop_sniff()
-            rx_stats = self.number_of_packets(rx_interface)
-            tx_stats = self.number_of_packets(tx_interface)
-            tx_outlist = self.number_of_bytes(rx_interface)
-            tx_outlist.sort(reverse=True)
-            self.logger.info(tx_outlist)
+            rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface)
+            tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface)
+            payload_size_list.sort(reverse=True)
+            self.logger.info(payload_size_list)
             if loading_size <= 800:
                 self.verify(
-                    rx_stats == tx_stats and int(tx_outlist[0]) == loading_size,
+                    rx_stats == tx_stats and int(payload_size_list[0]) == loading_size,
                     "IPV6 RX or TX packet number not correct",
                 )
             else:
                 num = loading_size // 800
                 for i in range(num):
                     self.verify(
-                        int(tx_outlist[i]) == 800,
-                        "the packet segmentation incorrect, %s" % tx_outlist,
+                        int(payload_size_list[i]) == 800,
+                        "the packet segmentation incorrect, %s" % payload_size_list,
                     )
                 if loading_size % 800 != 0:
                     self.verify(
-                        int(tx_outlist[num]) == loading_size % 800,
-                        "the packet segmentation incorrect, %s" % tx_outlist,
+                        int(payload_size_list[num]) == loading_size % 800,
+                        "the packet segmentation incorrect, %s" % payload_size_list,
                     )
 
     @check_supported_nic(
@@ -915,6 +876,7 @@ class TestVfOffload(TestCase):
                 self.tcpdump_stop_sniff()
                 rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface)
                 tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface)
+                payload_size_list.sort(reverse=True)
                 self.logger.info(payload_size_list)
                 if loading_size <= 800:
                     self.verify(
@@ -958,6 +920,7 @@ class TestVfOffload(TestCase):
                 self.tcpdump_stop_sniff()
                 rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface)
                 tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface)
+                payload_size_list.sort(reverse=True)
                 self.logger.info(payload_size_list)
                 if loading_size <= 800:
                     self.verify(
-- 
2.25.1


      parent reply	other threads:[~2022-12-27 10:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-27 10:21 [DTS][PATCH V1 0/5] Improve checksum validate and tso packet counting Ke Xu
2022-12-27 10:21 ` [DTS][PATCH V1 1/5] tests/vf_offload: Improve checksum_validate method Ke Xu
2022-12-27 10:21 ` [DTS][PATCH V1 2/5] tests/vf_offload: Remove redundant variable used Ke Xu
2022-12-27 10:21 ` [DTS][PATCH V1 3/5] tests/vf_offload: Use modified checksum_validate to replace checksum_validate_tunnel Ke Xu
2022-12-27 10:21 ` [DTS][PATCH V1 4/5] tests/vf_offload: Improve tcpdump_analyse_sniff method Ke Xu
2022-12-27 10:21 ` Ke Xu [this message]

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=20221227102131.529684-6-ke1.xu@intel.com \
    --to=ke1.xu@intel.com \
    --cc=dts@dpdk.org \
    --cc=lijuan.tu@intel.com \
    --cc=qi.fu@intel.com \
    --cc=weiyuanx.li@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).