summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Vizzarro <[email protected]>2024-11-13 16:31:26 +0000
committerPatrick Robb <[email protected]>2024-11-13 20:55:32 +0100
commita97f8cc4efef6dd88352c823d98f89a8a8183e58 (patch)
treeae1ea39119028c27a1a6ac8e3a2242175fe87299
parent9f8a257235ac6d7ed5b621428551c88b4408ac26 (diff)
dts: fix adjusting L2/L3 addresses
The _adjust_addresses function has been updated to both modify the original packets and return new updated copies of them. Having a double behavior even if documented is not intuitive and can lead to bugs. This changes the behavior to solely act on copies, leaving the original packet untouched. Fixes: 1a1825962777 ("dts: rework packet addressing") Signed-off-by: Luca Vizzarro <[email protected]> Reviewed-by: Paul Szczepanek <[email protected]> Reviewed-by: Dean Marx <[email protected]> Reviewed-by: Patrick Robb <[email protected]> Tested-by: Patrick Robb <[email protected]>
-rw-r--r--dts/framework/test_suite.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
index fb5d646ce3..5b3e7c205e 100644
--- a/dts/framework/test_suite.py
+++ b/dts/framework/test_suite.py
@@ -324,8 +324,7 @@ class TestSuite(TestProtocol):
def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> list[Packet]:
"""L2 and L3 address additions in both directions.
- Packets in `packets` will be directly modified in this method. The returned list of packets
- however will be copies of the modified packets.
+ Copies of `packets` will be made, modified and returned in this method.
Only missing addresses are added to packets, existing addresses will not be overridden. If
any packet in `packets` has multiple IP layers (using GRE, for example) only the inner-most
@@ -343,7 +342,9 @@ class TestSuite(TestProtocol):
A list containing copies of all packets in `packets` after modification.
"""
ret_packets = []
- for packet in packets:
+ for original_packet in packets:
+ packet = original_packet.copy()
+
# update l2 addresses
# If `expected` is :data:`True`, the packet enters the TG from SUT, otherwise the
# packet leaves the TG towards the SUT.