From: Luca Vizzarro <luca.vizzarro@arm.com>
To: dev@dpdk.org
Cc: Luca Vizzarro <luca.vizzarro@arm.com>,
Paul Szczepanek <paul.szczepanek@arm.com>,
Patrick Robb <probb@iol.unh.edu>
Subject: [PATCH v2 5/7] dts: make shells path dynamic
Date: Fri, 14 Mar 2025 15:18:55 +0200 [thread overview]
Message-ID: <20250314131857.1298247-6-luca.vizzarro@arm.com> (raw)
In-Reply-To: <20250314131857.1298247-1-luca.vizzarro@arm.com>
Turn the `path` attribute of InteractiveShell into a method property.
This allows path to both be defined statically by the class
implementation and also to be defined dynamically as part of the class
construction.
Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
---
dts/framework/remote_session/dpdk_app.py | 9 +++++++-
dts/framework/remote_session/dpdk_shell.py | 18 ++++++++-------
.../remote_session/interactive_shell.py | 22 ++++++++-----------
dts/framework/remote_session/python_shell.py | 6 +++--
dts/framework/remote_session/testpmd_shell.py | 8 ++++---
5 files changed, 36 insertions(+), 27 deletions(-)
diff --git a/dts/framework/remote_session/dpdk_app.py b/dts/framework/remote_session/dpdk_app.py
index c5aae05e02..dc4b817bdd 100644
--- a/dts/framework/remote_session/dpdk_app.py
+++ b/dts/framework/remote_session/dpdk_app.py
@@ -54,7 +54,14 @@ def __init__(
eal_params.append_str(app_params)
app_params = eal_params
- super().__init__(name, privileged, path, app_params)
+ self._path = path
+
+ super().__init__(name, privileged, app_params)
+
+ @property
+ def path(self) -> PurePath:
+ """The path of the DPDK app relative to the DPDK build folder."""
+ return self._path
def wait_until_ready(self, end_token: str) -> None:
"""Start app and wait until ready.
diff --git a/dts/framework/remote_session/dpdk_shell.py b/dts/framework/remote_session/dpdk_shell.py
index 24a39482ce..2d4f91052d 100644
--- a/dts/framework/remote_session/dpdk_shell.py
+++ b/dts/framework/remote_session/dpdk_shell.py
@@ -6,7 +6,7 @@
Provides a base class to create interactive shells based on DPDK.
"""
-from abc import ABC
+from abc import ABC, abstractmethod
from pathlib import PurePath
from framework.context import get_ctx
@@ -65,20 +65,22 @@ def __init__(
self,
name: str | None = None,
privileged: bool = True,
- path: PurePath | None = None,
app_params: EalParams = EalParams(),
) -> None:
"""Extends :meth:`~.interactive_shell.InteractiveShell.__init__`."""
app_params = compute_eal_params(app_params)
node = get_ctx().sut_node
- super().__init__(node, name, privileged, path, app_params)
+ super().__init__(node, name, privileged, app_params)
- def _update_real_path(self, path: PurePath) -> None:
- """Extends :meth:`~.interactive_shell.InteractiveShell._update_real_path`.
+ @property
+ @abstractmethod
+ def path(self) -> PurePath:
+ """Relative path to the shell executable from the build folder."""
+
+ def _make_real_path(self):
+ """Overrides :meth:`~.interactive_shell.InteractiveShell._make_real_path`.
Adds the remote DPDK build directory to the path.
"""
- super()._update_real_path(
- PurePath(get_ctx().dpdk_build.remote_dpdk_build_dir).joinpath(path)
- )
+ return get_ctx().dpdk_build.remote_dpdk_build_dir.joinpath(self.path)
diff --git a/dts/framework/remote_session/interactive_shell.py b/dts/framework/remote_session/interactive_shell.py
index 62f9984d3b..6b7ca0b6af 100644
--- a/dts/framework/remote_session/interactive_shell.py
+++ b/dts/framework/remote_session/interactive_shell.py
@@ -21,7 +21,7 @@
environment variable configure the timeout of getting the output from command execution.
"""
-from abc import ABC
+from abc import ABC, abstractmethod
from pathlib import PurePath
from typing import ClassVar
@@ -66,7 +66,6 @@ class InteractiveShell(MultiInheritanceBaseClass, ABC):
_timeout: float
_app_params: Params
_privileged: bool
- _real_path: PurePath
#: The number of times to try starting the application before considering it a failure.
_init_attempts: ClassVar[int] = 5
@@ -83,9 +82,6 @@ class InteractiveShell(MultiInheritanceBaseClass, ABC):
#: the expected prompt.
_command_extra_chars: ClassVar[str] = ""
- #: Path to the executable to start the interactive application.
- path: ClassVar[PurePath]
-
is_alive: bool = False
def __init__(
@@ -93,7 +89,6 @@ def __init__(
node: Node,
name: str | None = None,
privileged: bool = False,
- path: PurePath | None = None,
app_params: Params = Params(),
**kwargs,
) -> None:
@@ -107,7 +102,6 @@ def __init__(
name: Name for the interactive shell to use for logging. This name will be appended to
the name of the underlying node which it is running on.
privileged: Enables the shell to run as superuser.
- path: Path to the executable. If :data:`None`, then the class' path attribute is used.
app_params: The command line parameters to be passed to the application on startup.
**kwargs: Any additional arguments if any.
"""
@@ -118,8 +112,6 @@ def __init__(
self._app_params = app_params
self._privileged = privileged
self._timeout = SETTINGS.timeout
- # Ensure path is properly formatted for the host
- self._update_real_path(path or self.path)
super().__init__(**kwargs)
def _setup_ssh_channel(self):
@@ -131,7 +123,7 @@ def _setup_ssh_channel(self):
def _make_start_command(self) -> str:
"""Makes the command that starts the interactive shell."""
- start_command = f"{self._real_path} {self._app_params or ''}"
+ start_command = f"{self._make_real_path()} {self._app_params or ''}"
if self._privileged:
start_command = self._node.main_session._get_privileged_command(start_command)
return start_command
@@ -250,9 +242,13 @@ def close(self) -> None:
raise InteractiveSSHTimeoutError("Application 'exit' command") from e
self._ssh_channel.close()
- def _update_real_path(self, path: PurePath) -> None:
- """Updates the interactive shell's real path used at command line."""
- self._real_path = self._node.main_session.join_remote_path(path)
+ @property
+ @abstractmethod
+ def path(self) -> PurePath:
+ """Path to the shell executable."""
+
+ def _make_real_path(self) -> PurePath:
+ return self._node.main_session.join_remote_path(self.path)
def __enter__(self) -> Self:
"""Enter the context block.
diff --git a/dts/framework/remote_session/python_shell.py b/dts/framework/remote_session/python_shell.py
index 17e6c2559d..6331d047c4 100644
--- a/dts/framework/remote_session/python_shell.py
+++ b/dts/framework/remote_session/python_shell.py
@@ -27,8 +27,10 @@ class PythonShell(InteractiveShell):
#: This forces the prompt to appear after sending a command.
_command_extra_chars: ClassVar[str] = "\n"
- #: The Python executable.
- path: ClassVar[PurePath] = PurePath("python3")
+ @property
+ def path(self) -> PurePath:
+ """Path to the Python3 executable."""
+ return PurePath("python3")
def close(self):
"""Close Python shell."""
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index b83b0c82a0..19437b6233 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -1520,9 +1520,6 @@ class TestPmdShell(DPDKShell):
_app_params: TestPmdParams
_ports: list[TestPmdPort] | None
- #: The path to the testpmd executable.
- path: ClassVar[PurePath] = PurePath("app", "dpdk-testpmd")
-
#: The testpmd's prompt.
_default_prompt: ClassVar[str] = "testpmd>"
@@ -1544,6 +1541,11 @@ def __init__(
self.ports_started = not self._app_params.disable_device_start
self._ports = None
+ @property
+ def path(self) -> PurePath:
+ """The path to the testpmd executable."""
+ return PurePath("app/dpdk-testpmd")
+
@property
def ports(self) -> list[TestPmdPort]:
"""The ports of the instance.
--
2.43.0
next prev parent reply other threads:[~2025-03-14 13:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-20 17:23 [RFC PATCH 0/2] dts: add basic scope to improve shell handling Luca Vizzarro
2024-12-20 17:24 ` [RFC PATCH 1/2] dts: add scoping and shell registration to Node Luca Vizzarro
2024-12-20 17:24 ` [RFC PATCH 2/2] dts: revert back shell split Luca Vizzarro
2025-03-14 13:18 ` [PATCH v2 0/7] dts: shell improvements Luca Vizzarro
2025-03-14 13:18 ` [PATCH v2 1/7] dts: escape single quotes Luca Vizzarro
2025-03-14 13:18 ` [PATCH v2 2/7] dts: add blocking dpdk app class Luca Vizzarro
2025-03-14 13:18 ` [PATCH v2 3/7] dts: add shells pool Luca Vizzarro
2025-03-14 13:18 ` [PATCH v2 4/7] dts: revert back to a single InteractiveShell Luca Vizzarro
2025-03-14 13:18 ` Luca Vizzarro [this message]
2025-03-14 13:18 ` [PATCH v2 6/7] dts: remove multi-inheritance classes Luca Vizzarro
2025-03-14 13:18 ` [PATCH v2 7/7] dts: enable shell pooling Luca Vizzarro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250314131857.1298247-6-luca.vizzarro@arm.com \
--to=luca.vizzarro@arm.com \
--cc=dev@dpdk.org \
--cc=paul.szczepanek@arm.com \
--cc=probb@iol.unh.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).