DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dean Marx <dmarx@iol.unh.edu>
To: Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech,
	probb@iol.unh.edu, paul.szczepanek@arm.com,
	yoan.picchi@foss.arm.com, jspewock@iol.unh.edu,
	bruce.richardson@intel.com, luca.vizzarro@arm.com
Cc: dev@dpdk.org, Dean Marx <dmarx@iol.unh.edu>
Subject: [PATCH v4 1/3] dts: refactored VLAN test suite
Date: Tue, 18 Jun 2024 11:20:51 -0400	[thread overview]
Message-ID: <20240618152053.30723-1-dmarx@iol.unh.edu> (raw)
In-Reply-To: <20240614150238.26374-1-dmarx@iol.unh.edu>

Tweaked logic on sending and verifying packets for 
more concise code, added verbose and promisc 
function calls from pmd shell module.

Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
 dts/tests/TestSuite_vlan.py | 59 +++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 32 deletions(-)

diff --git a/dts/tests/TestSuite_vlan.py b/dts/tests/TestSuite_vlan.py
index 8b6827ec4b..b9b2a98588 100644
--- a/dts/tests/TestSuite_vlan.py
+++ b/dts/tests/TestSuite_vlan.py
@@ -48,29 +48,26 @@ def send_vlan_packet_and_verify(
             strip: indicates whether stripping is on or off,
             and when the vlan tag is checked for a match
         """
-        data = "P" * 10
-        packet = Ether() / Dot1Q(vlan=vlan_id) / Raw(load=data)
+        packet = Ether() / Dot1Q(vlan=vlan_id) / Raw(load='xxxxx')
         received_packets = self.send_packet_and_capture(packet)
-        received_packets = [
-            packets
-            for packets in received_packets
-            if hasattr(packets, "load") and data in str((packets.load))
-        ]
+        test_packet = None
+        for packet in received_packets:
+            if packet.haslayer(Raw) and packet[Raw].load == b'xxxxx':
+                test_packet = packet
+                break
         if should_receive:
             self.verify(
-                len(received_packets) == 1, "Packet was dropped when it should have been received"
+                test_packet is not None, "Packet was dropped when it should have been received"
             )
-            received = received_packets[0]
             if strip:
-                self.verify(Dot1Q not in received, "Vlan tag was not stripped successfully")
+                self.verify(Dot1Q not in test_packet, "Vlan tag was not stripped successfully")
             else:
-                if len(received_packets) == 1:
                     self.verify(
-                        received.vlan == vlan_id, "The received tag did not match the expected tag"
+                        test_packet.vlan == vlan_id, "The received tag did not match the expected tag"
                     )
         else:
             self.verify(
-                not len(received_packets) == 1,
+                test_packet is None,
                 "Packet was received when it should have been dropped",
             )
 
@@ -81,20 +78,18 @@ def send_packet_and_verify_insertion(self, expected_id: int = -1) -> None:
             expected_id: the vlan id that is being inserted through tx_offload configuration
             should_receive: indicate whether the packet should be successfully received
         """
-        data = "P" * 10
-        packet = Ether() / Raw(load=data)
+        packet = Ether() / Raw(load='xxxxx')
         received_packets = self.send_packet_and_capture(packet)
-        received_packets = [
-            packets
-            for packets in received_packets
-            if hasattr(packets, "load") and data in str((packets.load))
-        ]
+        test_packet = None
+        for packet in received_packets:
+            if packet.haslayer(Raw) and packet[Raw].load == b'xxxxx':
+                test_packet = packet
+                break
         self.verify(
-            len(received_packets) == 1, "Packet was dropped when it should have been received"
+            test_packet is not None, "Packet was dropped when it should have been received"
         )
-        received = received_packets[0]
-        self.verify(Dot1Q in received, "The received packet did not have a vlan tag")
-        self.verify(received.vlan == expected_id, "The received tag did not match the expected tag")
+        self.verify(Dot1Q in test_packet, "The received packet did not have a vlan tag")
+        self.verify(test_packet.vlan == expected_id, "The received tag did not match the expected tag")
 
     def test_vlan_receipt_no_stripping(self) -> None:
         """Ensure vlan packet is dropped when receipts are enabled and header stripping is disabled.
@@ -104,8 +99,8 @@ def test_vlan_receipt_no_stripping(self) -> None:
         """
         testpmd = self.sut_node.create_interactive_shell(TestPmdShell, privileged=True)
         testpmd.set_forward_mode(TestPmdForwardingModes.mac)
-        testpmd.send_command("set verbose 1", "testpmd>")
-        testpmd.send_command("set promisc 0 off", "testpmd>")
+        testpmd.set_verbose(1)
+        testpmd.set_promisc(0, False)
         testpmd.vlan_filter_set_on(0)
         testpmd.rx_vlan_add(1, 0)
         testpmd.start()
@@ -122,8 +117,8 @@ def test_vlan_receipt_stripping(self) -> None:
         """
         testpmd = self.sut_node.create_interactive_shell(TestPmdShell, privileged=True)
         testpmd.set_forward_mode(TestPmdForwardingModes.mac)
-        testpmd.send_command("set verbose 1", "testpmd>")
-        testpmd.send_command("set promisc 0 off", "testpmd>")
+        testpmd.set_verbose(1)
+        testpmd.set_promisc(0, False)
         testpmd.vlan_filter_set_on(0)
         testpmd.rx_vlan_add(1, 0)
         testpmd.vlan_strip_set_on(0)
@@ -140,8 +135,8 @@ def test_vlan_no_receipt(self) -> None:
         """
         testpmd = self.sut_node.create_interactive_shell(TestPmdShell, privileged=True)
         testpmd.set_forward_mode(TestPmdForwardingModes.mac)
-        testpmd.send_command("set verbose 1", "testpmd>")
-        testpmd.send_command("set promisc 0 off", "testpmd>")
+        testpmd.set_verbose(1)
+        testpmd.set_promisc(0, False)
         testpmd.vlan_filter_set_on(0)
         testpmd.rx_vlan_add(1, 0)
         testpmd.start()
@@ -158,8 +153,8 @@ def test_vlan_header_insertion(self) -> None:
         """
         testpmd = self.sut_node.create_interactive_shell(TestPmdShell, privileged=True)
         testpmd.set_forward_mode(TestPmdForwardingModes.mac)
-        testpmd.send_command("set verbose 1", "testpmd>")
-        testpmd.send_command("set promisc 0 off", "testpmd>")
+        testpmd.set_verbose(1)
+        testpmd.set_promisc(0, False)
         testpmd.port_stop_all()
         testpmd.tx_vlan_set(1, 51)
         testpmd.port_start_all()
-- 
2.44.0


  parent reply	other threads:[~2024-06-18 15:21 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-11 16:15 [PATCH v2 0/2] " Dean Marx
2024-06-11 16:15 ` [PATCH v2 1/2] Initial implementation for " Dean Marx
2024-06-11 16:15 ` [PATCH v2 2/2] conf schema Dean Marx
2024-06-14 15:02 ` [PATCH v3 0/3] VLAN Test Suite Dean Marx
2024-06-14 15:02   ` [PATCH v3 1/3] Added VLAN commands to testpmd_shell class Dean Marx
2024-06-14 15:59     ` Patrick Robb
2024-06-14 20:29       ` Jeremy Spewock
2024-06-14 21:24         ` Patrick Robb
2024-06-17 14:37     ` Jeremy Spewock
2024-06-14 15:02   ` [PATCH v3 2/3] Initial implementation for VLAN test suite Dean Marx
2024-06-14 16:19     ` Patrick Robb
2024-06-17 14:56     ` Jeremy Spewock
2024-06-14 15:02   ` [PATCH v3 3/3] Config schema Dean Marx
2024-06-17 14:59     ` Jeremy Spewock
2024-06-17 14:35   ` [PATCH v3 0/3] VLAN Test Suite Jeremy Spewock
2024-06-17 17:50   ` Patrick Robb
2024-06-18 15:20   ` Dean Marx [this message]
2024-06-18 15:20     ` [PATCH v4 2/3] dts: updated testpmd shell class Dean Marx
2024-06-18 15:20     ` [PATCH v4 3/3] dts: config schema Dean Marx
2024-06-18 16:29   ` [PATCH v5 1/3] dts: updated testpmd shell class Dean Marx
2024-06-18 16:29     ` [PATCH v5 2/3] dts: refactored VLAN test suite Dean Marx
2024-06-21 20:53       ` Jeremy Spewock
2024-06-18 16:29     ` [PATCH v5 3/3] dts: config schema Dean Marx
2024-06-21 20:53       ` Jeremy Spewock
2024-06-21 20:50     ` [PATCH v5 1/3] dts: updated testpmd shell class Jeremy Spewock
2024-06-24 18:17   ` [PATCH v6 " Dean Marx
2024-06-24 18:17     ` [PATCH v6 2/3] dts: refactored VLAN test suite Dean Marx
2024-06-24 18:17     ` [PATCH v6 3/3] dts: config schema Dean Marx
2024-06-25 15:33   ` [PATCH v7 1/3] dts: VLAN test suite implementation Dean Marx
2024-06-25 15:33     ` [PATCH v7 2/3] dts: add VLAN methods to testpmd shell Dean Marx
2024-06-26 18:22       ` Jeremy Spewock
2024-06-25 15:33     ` [PATCH v7 3/3] dts: config schema Dean Marx
2024-06-26 18:23       ` Jeremy Spewock
2024-06-26 18:21     ` [PATCH v7 1/3] dts: VLAN test suite implementation Jeremy Spewock
2024-06-28 14:00   ` [PATCH v8 1/3] dts: add VLAN methods to testpmd shell Dean Marx
2024-06-28 14:00     ` [PATCH v8 2/3] dts: VLAN test suite implementation Dean Marx
2024-06-28 14:00     ` [PATCH v8 3/3] dts: config schema Dean Marx

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=20240618152053.30723-1-dmarx@iol.unh.edu \
    --to=dmarx@iol.unh.edu \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=jspewock@iol.unh.edu \
    --cc=juraj.linkes@pantheon.tech \
    --cc=luca.vizzarro@arm.com \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    --cc=yoan.picchi@foss.arm.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).