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

Harald Seiler hws at denx.de
Tue Mar 5 06:29:28 UTC 2019


Hello Lukasz,

thank you for your patches!  The first one is perfect, I'll apply it asap.
With the second one I'm not quite happy:  I tried to keep the use of timeouts
to an absolute minimum in tbot to A) make it as fast as possible and B) as
robust as possible.  Timeouts introduce unnecessary delays and can break easily
if they were not set with enough tolerance (which makes things very sloow).

Now I am completely aware of the issue you try to solve here as I have fought
this exact problem myself in the past.  My current best bet for a solution would
be calling `sysctl kernel.printk 1 1 1 1` at the start of each board session to
at least keep the kernel from clobbering the console.

But this is of course not implemented yet (mainly because of portability concerns)
so I am willing to settle with your patch for now.

Thanks again!
-- 
	Harald

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-62  Fax: +49-8142-66989-80   Email: hws at denx.de

On Tue, 2019-03-05 at 00:43 +0100, Lukasz Majewski wrote:
> 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)



More information about the tbot mailing list