From patchwork Mon Jan 22 18:26:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Vizzarro X-Patchwork-Id: 136044 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 65E7A4399C; Mon, 22 Jan 2024 19:26:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7EC5942DB2; Mon, 22 Jan 2024 19:26:39 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 4326D40E72 for ; Mon, 22 Jan 2024 19:26: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 F24DDFEC; Mon, 22 Jan 2024 10:27:22 -0800 (PST) Received: from localhost.localdomain (unknown [10.57.90.210]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 351603F762; Mon, 22 Jan 2024 10:26:36 -0800 (PST) From: Luca Vizzarro To: dev@dpdk.org Cc: Luca Vizzarro , =?utf-8?q?Juraj_Linke=C5=A1?= , Paul Szczepanek Subject: [PATCH 4/4] dts: log stderr with failed remote commands Date: Mon, 22 Jan 2024 18:26:11 +0000 Message-Id: <20240122182611.1904974-5-luca.vizzarro@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240122182611.1904974-1-luca.vizzarro@arm.com> References: <20240122182611.1904974-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 Add the executed command stderr to RemoteCommandExecutionError. So that it is logged as an error, instead of just as debug. Reviewed-by: Paul Szczepanek Signed-off-by: Luca Vizzarro --- dts/framework/exception.py | 10 +++++++--- dts/framework/remote_session/remote_session.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dts/framework/exception.py b/dts/framework/exception.py index 658eee2c38..9fc3fa096a 100644 --- a/dts/framework/exception.py +++ b/dts/framework/exception.py @@ -130,20 +130,24 @@ class RemoteCommandExecutionError(DTSError): #: The executed command. command: str _command_return_code: int + _command_stderr: str - def __init__(self, command: str, command_return_code: int): + def __init__(self, command: str, command_return_code: int, command_stderr: str): """Define the meaning of the first two arguments. Args: command: The executed command. command_return_code: The return code of the executed command. + command_stderr: The stderr of the executed command. """ self.command = command self._command_return_code = command_return_code + self._command_stderr = command_stderr def __str__(self) -> str: - """Include both the command and return code in the string representation.""" - return f"Command {self.command} returned a non-zero exit code: {self._command_return_code}" + """Include the command, its return code and stderr in the string representation.""" + return (f"Command '{self.command}' returned a non-zero exit code: " + f"{self._command_return_code}\n{self._command_stderr}") class RemoteDirectoryExistsError(DTSError): diff --git a/dts/framework/remote_session/remote_session.py b/dts/framework/remote_session/remote_session.py index 2059f9a981..345439f2de 100644 --- a/dts/framework/remote_session/remote_session.py +++ b/dts/framework/remote_session/remote_session.py @@ -157,7 +157,7 @@ def send_command( ) self._logger.debug(f"stdout: '{result.stdout}'") self._logger.debug(f"stderr: '{result.stderr}'") - raise RemoteCommandExecutionError(command, result.return_code) + raise RemoteCommandExecutionError(command, result.return_code, result.stderr) self._logger.debug(f"Received from '{command}':\n{result}") self.history.append(result) return result