DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Wilks <thomas.wilks@arm.com>
To: dev@dpdk.org
Cc: Paul Szczepanek <paul.szczepanek@arm.com>,
	Luca Vizzarro <luca.vizzarro@arm.com>,
	Patrick Robb <probb@iol.unh.edu>,
	Thomas Wilks <thomas.wilks@arm.com>
Subject: [PATCH v1 2/2] dts: add verify to match all packets
Date: Thu, 16 Jan 2025 13:16:15 +0000	[thread overview]
Message-ID: <20250116131615.196053-3-thomas.wilks@arm.com> (raw)
In-Reply-To: <20250116131615.196053-1-thomas.wilks@arm.com>

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(-)

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(
-- 
2.43.0


      parent reply	other threads:[~2025-01-16 13:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16 13:16 [PATCH v1 0/2] dts: add promiscuous mode verification test Thomas Wilks
2025-01-16 13:16 ` [PATCH v1 1/2] " Thomas Wilks
2025-01-16 13:16 ` Thomas Wilks [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=20250116131615.196053-3-thomas.wilks@arm.com \
    --to=thomas.wilks@arm.com \
    --cc=dev@dpdk.org \
    --cc=luca.vizzarro@arm.com \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    /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).