Applied to next-dts, thanks.

On Thu, Jun 26, 2025 at 3:56 PM Dean Marx <dm...@iol.unh.edu> wrote:

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

Reply via email to