[2/2] dts: add blocklist test suite

Message ID 20240625123611.1474204-3-luca.vizzarro@arm.com (mailing list archive)
State Superseded, archived
Delegated to: Paul Szczepanek
Headers
Series dts: add blocklist test suite |

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/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Luca Vizzarro June 25, 2024, 12:36 p.m. UTC
This test suite tests the port blocklisting functionality built in
testpmd.

Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
---
 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
  

Comments

Dean Marx Sept. 9, 2024, 7:16 p.m. UTC | #1
On Tue, Jun 25, 2024 at 8:38 AM Luca Vizzarro <luca.vizzarro@arm.com> wrote:

> This test suite tests the port blocklisting functionality built in
> testpmd.
>
> Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
> Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
>

Reviewed-by: Dean Marx <dmarx@iol.unh.edu>
  
Patrick Robb Sept. 11, 2024, 12:12 a.m. UTC | #2
Barring a couple updates needed due to framework changes, this looks
good and runs on a Broadcom 975908 25G NIC I used for testing.

It runs fine after switching to invoking the testpmd shell via the
context manager, and removing the use of "testpmd.close()." Once a new
version is submitted with these changes, in my opinion it makes sense
to move this series to next-dts. Thanks!

Reviewed-by: Patrick Robb <probb@iol.unh.edu>
Tested-by: Patrick Robb <probb@iol.unh.edu>
  

Patch

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