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 D13C0454EF; Tue, 25 Jun 2024 14:38:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4812C42E55; Tue, 25 Jun 2024 14:38:37 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 994DA402D0 for ; Tue, 25 Jun 2024 14:36:48 +0200 (CEST) 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 CDAB7339; Tue, 25 Jun 2024 05:37:12 -0700 (PDT) Received: from localhost.localdomain (unknown [10.57.74.179]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 553B83F766; Tue, 25 Jun 2024 05:36:47 -0700 (PDT) From: Luca Vizzarro To: dev@dpdk.org Cc: Luca Vizzarro , Paul Szczepanek Subject: [PATCH 2/2] dts: add blocklist test suite Date: Tue, 25 Jun 2024 13:36:11 +0100 Message-Id: <20240625123611.1474204-3-luca.vizzarro@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240625123611.1474204-1-luca.vizzarro@arm.com> References: <20240625123611.1474204-1-luca.vizzarro@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 This test suite tests the port blocklisting functionality built in testpmd. Signed-off-by: Luca Vizzarro Reviewed-by: Paul Szczepanek --- dts/framework/config/conf_yaml_schema.json | 3 +- dts/tests/TestSuite_blocklist.py | 68 ++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 dts/tests/TestSuite_blocklist.py diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json index f02a310bb5..e9414ebff1 100644 --- a/dts/framework/config/conf_yaml_schema.json +++ b/dts/framework/config/conf_yaml_schema.json @@ -187,7 +187,8 @@ "enum": [ "hello_world", "os_udp", - "pmd_buffer_scatter" + "pmd_buffer_scatter", + "blocklist" ] }, "test_target": { diff --git a/dts/tests/TestSuite_blocklist.py b/dts/tests/TestSuite_blocklist.py new file mode 100644 index 0000000000..7d7f323e36 --- /dev/null +++ b/dts/tests/TestSuite_blocklist.py @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Arm Limited + +"""The DPDK device blocklisting test suite. + +This testing suite ensures tests the port blocklisting functionality of testpmd. +""" + +from framework.remote_session.testpmd_shell import TestPmdShell +from framework.test_suite import TestSuite +from framework.testbed_model.port import Port + + +class TestBlocklist(TestSuite): + """DPDK device blocklisting test suite. + + For this test suite to work at least 2 ports need to be configured for the SUT node. + """ + + def set_up_suite(self) -> None: + """Verify setup.""" + self.verify(len(self.sut_node.ports) >= 2, "At least two ports are required for this test") + + def verify_blocklisted_ports(self, ports_to_block: list[Port]): + """Runs testpmd with the given ports blocklisted and verifies the ports.""" + testpmd = TestPmdShell(self.sut_node, allowed_ports=[], blocked_ports=ports_to_block) + + allowlisted_ports = {port.device_name for port in testpmd.show_port_info_all()} + blocklisted_ports = {port.pci for port in ports_to_block} + + # sanity check + allowed_len = len(allowlisted_ports - blocklisted_ports) + self.verify(allowed_len > 0, "At least one port should have been allowed") + + blocked = not allowlisted_ports & blocklisted_ports + self.verify(blocked, "At least one port was not blocklisted") + + testpmd.close() + + def test_bl_no_blocklisted(self): + """Run testpmd with no blocklisted device. + + Steps: + Run testpmd without specifying allowed or blocked ports. + Verify: + That no ports were blocked. + """ + self.verify_blocklisted_ports([]) + + def test_bl_one_port_blocklisted(self): + """Run testpmd with one blocklisted port. + + Steps: + Run testpmd with one only one blocklisted port and allowing all the other ones. + Verify: + That the port was successfully blocklisted. + """ + self.verify_blocklisted_ports(self.sut_node.ports[:1]) + + def test_bl_all_but_one_port_blocklisted(self): + """Run testpmd with all but one blocklisted port. + + Steps: + Run testpmd with only one allowed port, blocking all the other ones. + Verify: + That all specified ports were successfully blocklisted. + """ + self.verify_blocklisted_ports(self.sut_node.ports[:-1]) -- 2.34.1