[v1] dts: fix ssh timeout and output

Message ID 20221027140945.18249-1-juraj.linkes@pantheon.tech (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v1] dts: fix ssh timeout and output |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation warning apply issues
ci/iol-testing warning apply patch failure

Commit Message

Juraj Linkeš Oct. 27, 2022, 2:09 p.m. UTC
  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š <juraj.linkes@pantheon.tech>
---
 dts/framework/remote_session/ssh_session.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Patch

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: