[PATCH 1/2] dts: add method for closing ports to testpmd
Patrick Robb
probb at iol.unh.edu
Thu Apr 24 03:44:11 CEST 2025
From: Jeremy Spewock <jspewock at iol.unh.edu>
Closing ports is a standard configuration feature that is available in
testpmd but the framework lacks the ability to access this command
through the testpmd API. This patch adds a method that performs this
action and verifies the results of sending the command to allow
developers to have more control over the state of the ports that
testpmd is aware of.
Signed-off-by: Jeremy Spewock <jspewock at iol.unh.edu>
Signed-off-by: Patrick Robb <probb at iol.unh.edu>
Tested-by: Patrick Robb <probb at iol.unh.edu>
---
dts/framework/remote_session/testpmd_shell.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index 1f291fcb68..c9c95be4b2 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -1723,6 +1723,24 @@ def set_ports_queues(self, number_of: int) -> None:
self.send_command(f"port config all rxq {number_of}")
self.send_command(f"port config all txq {number_of}")
+ @requires_stopped_ports
+ def close_all_ports(self, verify: bool = True) -> None:
+ """Close all ports.
+
+ Args:
+ verify: If :data:`True` the output of the close command will be scanned in an attempt
+ to verify that all ports were stopped successfully. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and at lease one port
+ failed to close.
+ """
+ port_close_output = self.send_command("port close all")
+ if verify:
+ num_ports = len(self.ports)
+ if not all(f"Port {p_id} is closed" in port_close_output for p_id in range(num_ports)):
+ raise InteractiveCommandExecutionError("Ports were not closed successfully.")
+
def show_port_info_all(self) -> list[TestPmdPort]:
"""Returns the information of all the ports.
--
2.48.1
More information about the dev
mailing list