[v1] dts: fix ssh timeout and output
Checks
Commit Message
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(-)
@@ -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: