[v4,2/7] dts: allow passing parameters into interactive apps

Message ID 20231218181221.10057-3-jspewock@iol.unh.edu (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series dts: Port scatter suite over |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Jeremy Spewock Dec. 18, 2023, 6:12 p.m. UTC
  From: Jeremy Spewock <jspewock@iol.unh.edu>

Modified interactive applications to allow for the ability to pass
parameters into the app on start up. Also modified the way EAL
parameters are handled so that the trailing "--" separator is added be
default after all EAL parameters.

Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu>
---
 .../remote_session/remote/testpmd_shell.py       |  2 +-
 dts/framework/testbed_model/sut_node.py          | 16 ++++++++++------
 2 files changed, 11 insertions(+), 7 deletions(-)
  

Comments

Juraj Linkeš Dec. 19, 2023, 4:50 p.m. UTC | #1
We should also update the subject and the body based on our previous
discussion. I don't think they properly describe the change, as we're
also updating the method's behavior of DPDK apps.

On Mon, Dec 18, 2023 at 7:13 PM <jspewock@iol.unh.edu> wrote:
>
> From: Jeremy Spewock <jspewock@iol.unh.edu>
>
> Modified interactive applications to allow for the ability to pass
> parameters into the app on start up. Also modified the way EAL
> parameters are handled so that the trailing "--" separator is added be
> default after all EAL parameters.
>
> Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu>
> ---
>  .../remote_session/remote/testpmd_shell.py       |  2 +-
>  dts/framework/testbed_model/sut_node.py          | 16 ++++++++++------
>  2 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/dts/framework/remote_session/remote/testpmd_shell.py b/dts/framework/remote_session/remote/testpmd_shell.py
> index b5e4cba9b3..369807a33e 100644
> --- a/dts/framework/remote_session/remote/testpmd_shell.py
> +++ b/dts/framework/remote_session/remote/testpmd_shell.py
> @@ -62,7 +62,7 @@ class TestPmdShell(InteractiveShell):
>
>      def _start_application(self, get_privileged_command: Callable[[str], str] | None) -> None:
>          """See "_start_application" in InteractiveShell."""
> -        self._app_args += " -- -i"
> +        self._app_args += " -i"
>          super()._start_application(get_privileged_command)
>
>      def start(self, verify: bool = True) -> None:
> diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py
> index 7f75043bd3..9c92232d9e 100644
> --- a/dts/framework/testbed_model/sut_node.py
> +++ b/dts/framework/testbed_model/sut_node.py
> @@ -361,7 +361,8 @@ def create_interactive_shell(
>          shell_cls: Type[InteractiveShellType],
>          timeout: float = SETTINGS.timeout,
>          privileged: bool = False,
> -        eal_parameters: EalParameters | str | None = None,
> +        eal_parameters: EalParameters | None = None,
> +        app_parameters: str = "",
>      ) -> InteractiveShellType:
>          """Factory method for creating a handler for an interactive session.
>
> @@ -376,19 +377,22 @@ def create_interactive_shell(
>              eal_parameters: List of EAL parameters to use to launch the app. If this
>                  isn't provided or an empty string is passed, it will default to calling
>                  create_eal_parameters().
> +            app_parameters: Additional arguments to pass into the application on the
> +                command-line.
>          Returns:
>              Instance of the desired interactive application.
>          """
> -        if not eal_parameters:
> -            eal_parameters = self.create_eal_parameters()
> -
> -        # We need to append the build directory for DPDK apps
> +        # We need to append the build directory and add EAL parameters for DPDK apps
>          if shell_cls.dpdk_app:
> +            if not eal_parameters:
> +                eal_parameters = self.create_eal_parameters()
> +            app_parameters = f"{eal_parameters} -- {app_parameters}"
> +
>              shell_cls.path = self.main_session.join_remote_path(
>                  self.remote_dpdk_build_dir, shell_cls.path
>              )
>
> -        return super().create_interactive_shell(shell_cls, timeout, privileged, str(eal_parameters))
> +        return super().create_interactive_shell(shell_cls, timeout, privileged, app_parameters)
>
>      def bind_ports_to_driver(self, for_dpdk: bool = True) -> None:
>          """Bind all ports on the SUT to a driver.
> --
> 2.43.0
>
  

Patch

diff --git a/dts/framework/remote_session/remote/testpmd_shell.py b/dts/framework/remote_session/remote/testpmd_shell.py
index b5e4cba9b3..369807a33e 100644
--- a/dts/framework/remote_session/remote/testpmd_shell.py
+++ b/dts/framework/remote_session/remote/testpmd_shell.py
@@ -62,7 +62,7 @@  class TestPmdShell(InteractiveShell):
 
     def _start_application(self, get_privileged_command: Callable[[str], str] | None) -> None:
         """See "_start_application" in InteractiveShell."""
-        self._app_args += " -- -i"
+        self._app_args += " -i"
         super()._start_application(get_privileged_command)
 
     def start(self, verify: bool = True) -> None:
diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py
index 7f75043bd3..9c92232d9e 100644
--- a/dts/framework/testbed_model/sut_node.py
+++ b/dts/framework/testbed_model/sut_node.py
@@ -361,7 +361,8 @@  def create_interactive_shell(
         shell_cls: Type[InteractiveShellType],
         timeout: float = SETTINGS.timeout,
         privileged: bool = False,
-        eal_parameters: EalParameters | str | None = None,
+        eal_parameters: EalParameters | None = None,
+        app_parameters: str = "",
     ) -> InteractiveShellType:
         """Factory method for creating a handler for an interactive session.
 
@@ -376,19 +377,22 @@  def create_interactive_shell(
             eal_parameters: List of EAL parameters to use to launch the app. If this
                 isn't provided or an empty string is passed, it will default to calling
                 create_eal_parameters().
+            app_parameters: Additional arguments to pass into the application on the
+                command-line.
         Returns:
             Instance of the desired interactive application.
         """
-        if not eal_parameters:
-            eal_parameters = self.create_eal_parameters()
-
-        # We need to append the build directory for DPDK apps
+        # We need to append the build directory and add EAL parameters for DPDK apps
         if shell_cls.dpdk_app:
+            if not eal_parameters:
+                eal_parameters = self.create_eal_parameters()
+            app_parameters = f"{eal_parameters} -- {app_parameters}"
+
             shell_cls.path = self.main_session.join_remote_path(
                 self.remote_dpdk_build_dir, shell_cls.path
             )
 
-        return super().create_interactive_shell(shell_cls, timeout, privileged, str(eal_parameters))
+        return super().create_interactive_shell(shell_cls, timeout, privileged, app_parameters)
 
     def bind_ports_to_driver(self, for_dpdk: bool = True) -> None:
         """Bind all ports on the SUT to a driver.