[PATCH 25/42] test: Allow connecting to a running board

Simon Glass sjg at chromium.org
Tue Jun 25 14:31:19 CEST 2024


Hi Andrejs,

On Tue, 25 Jun 2024 at 00:56, Andrejs Cainikovs
<andrejs.cainikovs at toradex.com> wrote:
>
> On Tue, Jun 11, 2024 at 02:01:39PM -0600, Simon Glass wrote:
> > Sometimes we know that the board is already running the right software,
> > so provide an option to allow running of tests directly, without first
> > resetting the board.
> >
> > This saves time when re-running a test where only the Python code is
> > changing.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > ---
> >
> >  test/py/conftest.py                   |  3 +++
> >  test/py/u_boot_console_base.py        | 14 ++++++++++----
> >  test/py/u_boot_console_exec_attach.py | 21 ++++++++++++---------
> >  3 files changed, 25 insertions(+), 13 deletions(-)
> >
> > diff --git a/test/py/conftest.py b/test/py/conftest.py
> > index fc9dd3a83f8..ca66b9d9e61 100644
> > --- a/test/py/conftest.py
> > +++ b/test/py/conftest.py
> > @@ -79,6 +79,8 @@ def pytest_addoption(parser):
> >      parser.addoption('--gdbserver', default=None,
> >          help='Run sandbox under gdbserver. The argument is the channel '+
> >          'over which gdbserver should communicate, e.g. localhost:1234')
> > +    parser.addoption('--no-prompt-wait', default=False, action='store_true',
> > +        help="Assume that U-Boot is ready and don't wait for a prompt")
> >
> >  def run_build(config, source_dir, build_dir, board_type, log):
> >      """run_build: Build U-Boot
> > @@ -238,6 +240,7 @@ def pytest_configure(config):
> >      ubconfig.board_type = board_type
> >      ubconfig.board_identity = board_identity
> >      ubconfig.gdbserver = gdbserver
> > +    ubconfig.no_prompt_wait = config.getoption('no_prompt_wait')
> >      ubconfig.dtb = build_dir + '/arch/sandbox/dts/test.dtb'
> >
> >      env_vars = (
> > diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
> > index e4f86f6af5b..a61eec31148 100644
> > --- a/test/py/u_boot_console_base.py
> > +++ b/test/py/u_boot_console_base.py
> > @@ -413,11 +413,17 @@ class ConsoleBase(object):
> >              if not self.config.gdbserver:
> >                  self.p.timeout = TIMEOUT_MS
> >              self.p.logfile_read = self.logstream
> > -            if expect_reset:
> > -                loop_num = 2
> > +            if self.config.no_prompt_wait:
> > +                # Send an empty command to set up the 'expect' logic. This has
> > +                # the side effect of ensuring that there was no partial command
> > +                # line entered
> > +                self.run_command(' ')
> >              else:
> > -                loop_num = 1
> > -            self.wait_for_boot_prompt(loop_num = loop_num)
> > +                if expect_reset:
> > +                    loop_num = 2
> > +                else:
> > +                    loop_num = 1
> > +                self.wait_for_boot_prompt(loop_num = loop_num)
>
> Hi Simon,
>
> I had a very bad day, so here you go:
>
> == ?

What does this mean? I hope you have a good day today.

>
> /Andrejs
>
> >              self.at_prompt = True
> >              self.at_prompt_logevt = self.logstream.logfile.cur_evt
> >          except Exception as ex:
> > diff --git a/test/py/u_boot_console_exec_attach.py b/test/py/u_boot_console_exec_attach.py
> > index 5f4916b7da2..42fc15197b9 100644
> > --- a/test/py/u_boot_console_exec_attach.py
> > +++ b/test/py/u_boot_console_exec_attach.py
> > @@ -59,15 +59,18 @@ class ConsoleExecAttach(ConsoleBase):
> >          args = [self.config.board_type, self.config.board_identity]
> >          s = Spawn(['u-boot-test-console'] + args)
> >
> > -        try:
> > -            self.log.action('Resetting board')
> > -            cmd = ['u-boot-test-reset'] + args
> > -            runner = self.log.get_runner(cmd[0], sys.stdout)
> > -            runner.run(cmd)
> > -            runner.close()
> > -        except:
> > -            s.close()
> > -            raise
> > +        if self.config.no_prompt_wait:
> > +            self.log.action('Connecting to board without reset')
> > +        else:
> > +            try:
> > +                self.log.action('Resetting board')
> > +                cmd = ['u-boot-test-reset'] + args
> > +                runner = self.log.get_runner(cmd[0], sys.stdout)
> > +                runner.run(cmd)
> > +                runner.close()
> > +            except:
> > +                s.close()
> > +                raise
> >
> >          return s
> >
> > --
> > 2.34.1
> >
>

Regards,
Simon


More information about the U-Boot mailing list