[tbot] [PATCH] tbot: Provide login_delay parameter for Linux board

Lukasz Majewski lukma at denx.de
Mon Mar 4 23:43:00 UTC 2019


From: lukma <lukma at denx.de>

This code improves the robustness on board, which by SW design
floods the console excessively during boot up time.

However, after some time - specified by login_delay parameter -
there is no flooding, so the prodecure for logging in can be
reliably performed (_boot_to_shell)

Signed-off-by: Lukasz Majewski <lukma at denx.de>
---
 tbot/machine/board/linux.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tbot/machine/board/linux.py b/tbot/machine/board/linux.py
index 246e262..56f717a 100644
--- a/tbot/machine/board/linux.py
+++ b/tbot/machine/board/linux.py
@@ -30,6 +30,9 @@ class LinuxMachine(linux.LinuxMachine, board.BoardMachine[B]):
     login_prompt = "login:"
     """Prompt that indicates tbot should send the username."""
 
+    login_delay = 0
+    """The delay between first occurence of login_prompt and actual login."""
+
     @property
     @abc.abstractmethod
     def shell(self) -> typing.Type[linux.shell.Shell]:
@@ -82,6 +85,17 @@ class LinuxMachine(linux.LinuxMachine, board.BoardMachine[B]):
             self.login_prompt, stream=stream, must_end=False
         )
 
+        # On purpose do not login immediately as we may get some
+        # console flooding from upper SW layers (and tbot's console setup
+        # may get broken)
+        if self.password is None and self.login_delay != 0:
+            try:
+                output += chan.read_until_prompt(
+                    '', stream=stream, timeout=self.login_delay)
+            except TimeoutError:
+                pass
+            chan.send("\n")
+
         chan.send(self.username + "\n")
         if self.password is not None:
             chan.read_until_prompt("word: ", stream=stream, must_end=False)
-- 
2.20.1



More information about the tbot mailing list