[v3,1/2] dts: allow expected packets to come from the TG

Message ID 20250109134421.160262-2-thomas.wilks@arm.com (mailing list archive)
State Accepted
Delegated to: Paul Szczepanek
Headers
Series dts: add softnic test |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Wilks Jan. 9, 2025, 1:44 p.m. UTC
From: Paul Szczepanek <paul.szczepanek@arm.com>

Add sent_from_tg variable to get_expected_packets
for when packets are sent from the TG.

Signed-off-by: Thomas Wilks <thomas.wilks@arm.com>
Signed-off-by: Paul Szczepanek <paul.szczepanek@arm.com>
---
 dts/framework/test_suite.py | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
  

Comments

Luca Vizzarro Jan. 10, 2025, 11:30 a.m. UTC | #1
Reviewed-by: Luca Vizzarro  <luca.vizzarro@arm.com>
  

Patch

diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
index 16012bfc79..144fc78e07 100644
--- a/dts/framework/test_suite.py
+++ b/dts/framework/test_suite.py
@@ -274,31 +274,41 @@  def send_packets(
         packets = self._adjust_addresses(packets)
         self.tg_node.send_packets(packets, self._tg_port_egress)
 
-    def get_expected_packets(self, packets: list[Packet]) -> list[Packet]:
+    def get_expected_packets(
+        self,
+        packets: list[Packet],
+        sent_from_tg: bool = False,
+    ) -> list[Packet]:
         """Inject the proper L2/L3 addresses into `packets`.
 
         Inject the L2/L3 addresses expected at the receiving end of the traffic generator.
 
         Args:
             packets: The packets to modify.
+            sent_from_tg: If :data:`True` packet was sent from the TG.
 
         Returns:
             `packets` with injected L2/L3 addresses.
         """
-        return self._adjust_addresses(packets, expected=True)
+        return self._adjust_addresses(packets, not sent_from_tg)
 
-    def get_expected_packet(self, packet: Packet) -> Packet:
+    def get_expected_packet(
+        self,
+        packet: Packet,
+        sent_from_tg: bool = False,
+    ) -> Packet:
         """Inject the proper L2/L3 addresses into `packet`.
 
         Inject the L2/L3 addresses expected at the receiving end of the traffic generator.
 
         Args:
             packet: The packet to modify.
+            sent_from_tg: If :data:`True` packet was sent from the TG.
 
         Returns:
             `packet` with injected L2/L3 addresses.
         """
-        return self.get_expected_packets([packet])[0]
+        return self.get_expected_packets([packet], sent_from_tg)[0]
 
     def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> list[Packet]:
         """L2 and L3 address additions in both directions.