<div dir="ltr">Applied to next-dts, thanks.</div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Jun 26, 2025 at 3:56 PM Dean Marx <<a href="mailto:dmarx@iol.unh.edu">dmarx@iol.unh.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Add a method for validating flow rules to the testpmd shell class.<br>
Implement test case skipping for flow rules that do not pass<br>
validation.<br>
<br>
Signed-off-by: Dean Marx <<a href="mailto:dmarx@iol.unh.edu" target="_blank">dmarx@iol.unh.edu</a>><br>
Reviewed-by: Patrick Robb <<a href="mailto:probb@iol.unh.edu" target="_blank">probb@iol.unh.edu</a>><br>
---<br>
dts/framework/remote_session/testpmd_shell.py | 15 +++++++++++++<br>
dts/framework/test_run.py | 3 +++<br>
dts/framework/test_suite.py | 21 ++++++++++++++++++-<br>
3 files changed, 38 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py<br>
index 0b9bb4070a..299887dd80 100644<br>
--- a/dts/framework/remote_session/testpmd_shell.py<br>
+++ b/dts/framework/remote_session/testpmd_shell.py<br>
@@ -1984,6 +1984,21 @@ def flow_create(self, flow_rule: FlowRule, port_id: int) -> int:<br>
self._logger.debug(f"Failed to create flow rule:\n{flow_output}")<br>
raise InteractiveCommandExecutionError(f"Failed to create flow rule:\n{flow_output}")<br>
<br>
+ def flow_validate(self, flow_rule: FlowRule, port_id: int) -> bool:<br>
+ """Validates a flow rule in the testpmd session.<br>
+<br>
+ Args:<br>
+ flow_rule: :class:`FlowRule` object used for validating testpmd flow rule.<br>
+ port_id: Integer representing the port to use.<br>
+<br>
+ Returns:<br>
+ Boolean representing whether rule is valid or not.<br>
+ """<br>
+ flow_output = self.send_command(f"flow validate {port_id} {flow_rule}")<br>
+ if "Flow rule validated" in flow_output:<br>
+ return True<br>
+ return False<br>
+<br>
def flow_delete(self, flow_id: int, port_id: int, verify: bool = True) -> None:<br>
"""Deletes the specified flow rule from the testpmd session.<br>
<br>
diff --git a/dts/framework/test_run.py b/dts/framework/test_run.py<br>
index 10a5e1a6b8..fd49a7dc74 100644<br>
--- a/dts/framework/test_run.py<br>
+++ b/dts/framework/test_run.py<br>
@@ -655,6 +655,9 @@ def next(self) -> State | None:<br>
return self<br>
<br>
self.result.update(Result.FAIL, e)<br>
+ except SkippedTestException as e:<br>
+ <a href="http://self.logger.info" rel="noreferrer" target="_blank">self.logger.info</a>(f"{self.description.capitalize()} SKIPPED: {e}")<br>
+ self.result.update(Result.SKIP, e)<br>
else:<br>
self.result.update(Result.PASS)<br>
<a href="http://self.logger.info" rel="noreferrer" target="_blank">self.logger.info</a>(f"{self.description.capitalize()} PASSED.")<br>
diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py<br>
index e5fbadd1a1..145b79496f 100644<br>
--- a/dts/framework/test_suite.py<br>
+++ b/dts/framework/test_suite.py<br>
@@ -39,7 +39,7 @@<br>
PacketFilteringConfig,<br>
)<br>
<br>
-from .exception import ConfigurationError, InternalError, TestCaseVerifyError<br>
+from .exception import ConfigurationError, InternalError, SkippedTestException, TestCaseVerifyError<br>
from .logger import DTSLogger, get_dts_logger<br>
from .utils import get_packet_summaries, to_pascal_case<br>
<br>
@@ -411,6 +411,25 @@ def _fail_test_case_verify(self, failure_description: str) -> None:<br>
self._logger.debug(command_res.command)<br>
raise TestCaseVerifyError(failure_description)<br>
<br>
+ def verify_else_skip(self, condition: bool, skip_reason: str) -> None:<br>
+ """Verify `condition` and handle skips.<br>
+<br>
+ When `condition` is :data:`False`, raise a skip exception.<br>
+<br>
+ Args:<br>
+ condition: The condition to check.<br>
+ skip_reason: Description of the reason for skipping.<br>
+<br>
+ Raises:<br>
+ SkippedTestException: `condition` is :data:`False`.<br>
+ """<br>
+ if not condition:<br>
+ self._skip_test_case_verify(skip_reason)<br>
+<br>
+ def _skip_test_case_verify(self, skip_description: str) -> None:<br>
+ self._logger.debug(f"Test case skipped: {skip_description}")<br>
+ raise SkippedTestException(skip_description)<br>
+<br>
def verify_packets(self, expected_packet: Packet, received_packets: list[Packet]) -> None:<br>
"""Verify that `expected_packet` has been received.<br>
<br>
-- <br>
2.49.0<br>
<br>
</blockquote></div>