From patchwork Tue Mar 26 19:04:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Vizzarro X-Patchwork-Id: 138831 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D004A43D5B; Tue, 26 Mar 2024 20:05:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 30195427DA; Tue, 26 Mar 2024 20:04:42 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id EEF334161A for ; Tue, 26 Mar 2024 20:04:37 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2546B2F4; Tue, 26 Mar 2024 12:05:11 -0700 (PDT) Received: from localhost.localdomain (unknown [10.57.16.115]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7EAC23F64C; Tue, 26 Mar 2024 12:04:36 -0700 (PDT) From: Luca Vizzarro To: dev@dpdk.org Cc: =?utf-8?q?Juraj_Linke=C5=A1?= , Luca Vizzarro , Jack Bond-Preston , Honnappa Nagarahalli Subject: [PATCH 5/6] dts: add statefulness to InteractiveShell Date: Tue, 26 Mar 2024 19:04:21 +0000 Message-Id: <20240326190422.577028-6-luca.vizzarro@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240326190422.577028-1-luca.vizzarro@arm.com> References: <20240326190422.577028-1-luca.vizzarro@arm.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The InteractiveShell class can be started in privileged mode, but this is not saved for reference to the tests developer. Moreover, originally a command timeout could only be set at initialisation, this can now be amended and reset back as needed. Signed-off-by: Luca Vizzarro Reviewed-by: Jack Bond-Preston Reviewed-by: Honnappa Nagarahalli --- .../remote_session/interactive_shell.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dts/framework/remote_session/interactive_shell.py b/dts/framework/remote_session/interactive_shell.py index a2c7b30d9f..5d80061e8d 100644 --- a/dts/framework/remote_session/interactive_shell.py +++ b/dts/framework/remote_session/interactive_shell.py @@ -41,8 +41,10 @@ class InteractiveShell(ABC): _stdout: channel.ChannelFile _ssh_channel: Channel _logger: DTSLogger + __default_timeout: float _timeout: float _app_args: Params | None + _is_privileged: bool = False #: Prompt to expect at the end of output when sending a command. #: This is often overridden by subclasses. @@ -88,7 +90,7 @@ def __init__( self._ssh_channel.settimeout(timeout) self._ssh_channel.set_combine_stderr(True) # combines stdout and stderr streams self._logger = logger - self._timeout = timeout + self._timeout = self.__default_timeout = timeout self._app_args = app_args self._start_application(get_privileged_command) @@ -105,6 +107,7 @@ def _start_application(self, get_privileged_command: Callable[[str], str] | None start_command = f"{self.path} {self._app_args or ''}" if get_privileged_command is not None: start_command = get_privileged_command(start_command) + self._is_privileged = True self.send_command(start_command) def send_command(self, command: str, prompt: str | None = None) -> str: @@ -150,3 +153,16 @@ def close(self) -> None: def __del__(self) -> None: """Make sure the session is properly closed before deleting the object.""" self.close() + + @property + def is_privileged(self) -> bool: + """Property specifying if the interactive shell is running in privileged mode.""" + return self._is_privileged + + def set_timeout(self, timeout: float): + """Set the timeout to use with the next commands.""" + self._timeout = timeout + + def reset_timeout(self): + """Reset the timeout to the default setting.""" + self._timeout = self.__default_timeout