From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D73C94609E; Thu, 16 Jan 2025 14:16:37 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0FB94406BB; Thu, 16 Jan 2025 14:16:28 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 3F9A44068E for ; Thu, 16 Jan 2025 14:16:26 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DB06F106F; Thu, 16 Jan 2025 05:16:53 -0800 (PST) Received: from e132991.cambridge.arm.com (unknown [10.1.195.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9E49F3F673; Thu, 16 Jan 2025 05:16:24 -0800 (PST) From: Thomas Wilks To: dev@dpdk.org Cc: Paul Szczepanek , Luca Vizzarro , Patrick Robb , Thomas Wilks Subject: [PATCH v1 2/2] dts: add verify to match all packets Date: Thu, 16 Jan 2025 13:16:15 +0000 Message-ID: <20250116131615.196053-3-thomas.wilks@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250116131615.196053-1-thomas.wilks@arm.com> References: <20250116131615.196053-1-thomas.wilks@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- Reviewed-by: Luca Vizzarro Reviewed-by: Paul Szczepanek --- 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