From patchwork Thu Oct 27 14:09:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Juraj_Linke=C5=A1?= X-Patchwork-Id: 119236 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 B01DAA00C5; Thu, 27 Oct 2022 16:09:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B5BC42670; Thu, 27 Oct 2022 16:09:49 +0200 (CEST) Received: from lb.pantheon.sk (lb.pantheon.sk [46.229.239.20]) by mails.dpdk.org (Postfix) with ESMTP id B557341153 for ; Thu, 27 Oct 2022 16:09:47 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by lb.pantheon.sk (Postfix) with ESMTP id 623F51B6ECF; Thu, 27 Oct 2022 16:09:47 +0200 (CEST) X-Virus-Scanned: amavisd-new at siecit.sk Received: from lb.pantheon.sk ([127.0.0.1]) by localhost (lb.pantheon.sk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WZ8_LarVrPEY; Thu, 27 Oct 2022 16:09:46 +0200 (CEST) Received: from entguard.lab.pantheon.local (unknown [46.229.239.141]) by lb.pantheon.sk (Postfix) with ESMTP id 27DC71B6ECA; Thu, 27 Oct 2022 16:09:46 +0200 (CEST) From: =?utf-8?q?Juraj_Linke=C5=A1?= To: Cc: dev@dpdk.org, =?utf-8?q?Juraj_Linke=C5=A1?= Subject: [PATCH v1] dts: fix ssh timeout and output Date: Thu, 27 Oct 2022 14:09:45 +0000 Message-Id: <20221027140945.18249-1-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.25.1 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 We were always waiting the full timeout because we always waited for the MAGIC_PROMPT, which is only usable for cleaning the session of previous data. That also meant that the actual prompt was appended to the output, resulting in output being '[PEXPECT]#' when the executed command produced empty output. Both are fixed by using the MAGIC_PROMPT only in self._clean_session. Fixes: e81a070a1c7d ("dts: add ssh session module") Signed-off-by: Juraj Linkeš --- dts/framework/remote_session/ssh_session.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dts/framework/remote_session/ssh_session.py b/dts/framework/remote_session/ssh_session.py index f71acfb1ca..dc37e9772b 100644 --- a/dts/framework/remote_session/ssh_session.py +++ b/dts/framework/remote_session/ssh_session.py @@ -116,7 +116,9 @@ def send_expect_base(self, command: str, prompt: str, timeout: float) -> str: return before def _clean_session(self) -> None: + self.session.PROMPT = self.magic_prompt self.get_output(timeout=0.01) + self.session.PROMPT = self.session.UNIQUE_PROMPT def _send_line(self, command: str) -> None: if not self.is_alive(): @@ -134,7 +136,6 @@ def get_output(self, timeout: float = 15) -> str: """ Get all output before timeout """ - self.session.PROMPT = self.magic_prompt try: self.session.prompt(timeout) except Exception: @@ -143,7 +144,6 @@ def get_output(self, timeout: float = 15) -> str: before = self._get_output() self._flush() - self.logger.debug(before) return before def _get_output(self) -> str: