[v1,2/2] dts: add verify to match all packets

Message ID 20250116131615.196053-3-thomas.wilks@arm.com (mailing list archive)
State Accepted
Delegated to: Paul Szczepanek
Headers
Series dts: add promiscuous mode verification test |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS

Commit Message

Thomas Wilks Jan. 16, 2025, 1:16 p.m. UTC
Added verify to match_all_packets function
that if False and there are missing packets
causes the function to return False, if all
packets are present it returns True.

Signed-off-by: Thomas Wilks <thomas.wilks@arm.com>
---
Reviewed-by: Luca Vizzarro <luca.vizzarro@arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
---
 dts/framework/test_suite.py | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
  

Patch

diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
index de9f871b3f..f5d3e3e545 100644
--- a/dts/framework/test_suite.py
+++ b/dts/framework/test_suite.py
@@ -422,8 +422,11 @@  def verify_packets(self, expected_packet: Packet, received_packets: list[Packet]
             self._fail_test_case_verify("An expected packet not found among received packets.")
 
     def match_all_packets(
-        self, expected_packets: list[Packet], received_packets: list[Packet]
-    ) -> None:
+        self,
+        expected_packets: list[Packet],
+        received_packets: list[Packet],
+        verify: bool = True,
+    ) -> bool:
         """Matches all the expected packets against the received ones.
 
         Matching is performed by counting down the occurrences in a dictionary which keys are the
@@ -433,10 +436,14 @@  def match_all_packets(
         Args:
             expected_packets: The packets we are expecting to receive.
             received_packets: All the packets that were received.
+            verify: If :data:`True`, and there are missing packets an exception will be raised.
 
         Raises:
             TestCaseVerifyError: if and not all the `expected_packets` were found in
                 `received_packets`.
+
+        Returns:
+            :data:`True` If there are no missing packets.
         """
         expected_packets_counters = Counter(map(raw, expected_packets))
         received_packets_counters = Counter(map(raw, received_packets))
@@ -450,10 +457,14 @@  def match_all_packets(
         )
 
         if missing_packets_count != 0:
-            self._fail_test_case_verify(
-                f"Not all packets were received, expected {len(expected_packets)} "
-                f"but {missing_packets_count} were missing."
-            )
+            if verify:
+                self._fail_test_case_verify(
+                    f"Not all packets were received, expected {len(expected_packets)} "
+                    f"but {missing_packets_count} were missing."
+                )
+            return False
+
+        return True
 
     def _compare_packets(self, expected_packet: Packet, received_packet: Packet) -> bool:
         self._logger.debug(