diff mbox series

[v5,01/20] test: Allow signaling that U-Boot is ready

Message ID 20240828220846.1205813-2-sjg@chromium.org
State Changes Requested
Delegated to: Tom Rini
Headers show
Series labgrid: Provide an integration with Labgrid | expand

Commit Message

Simon Glass Aug. 28, 2024, 10:08 p.m. UTC
When Labgrid is used, it can get U-Boot ready for running tests. It
prints a message when it has done so.

Add logic to detect this message and accept it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 test/py/u_boot_console_base.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Neil Armstrong Aug. 29, 2024, 2:22 p.m. UTC | #1
On 29/08/2024 00:08, Simon Glass wrote:
> When Labgrid is used, it can get U-Boot ready for running tests. It
> prints a message when it has done so.
> 
> Add logic to detect this message and accept it.

So labgrid can boot and wait for `board_type & board_identity` itself right ?

It's cool, but if the boots fails for a reason, what would happen ?
Having the U-Boot pytest to parse the U-Boot boot log makes sure we can identify crash
and report them in the pytest log.

And this adds a labgrid-only string to parse, which could potentially
collide with pre-uboot or whatever log when not using labgrid.

Neil

> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
> (no changes since v1)
> 
>   test/py/u_boot_console_base.py | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
> index 76a550d45a1..882d04cd1e9 100644
> --- a/test/py/u_boot_console_base.py
> +++ b/test/py/u_boot_console_base.py
> @@ -22,6 +22,7 @@ pattern_stop_autoboot_prompt = re.compile('Hit any key to stop autoboot: ')
>   pattern_unknown_command = re.compile('Unknown command \'.*\' - try \'help\'')
>   pattern_error_notification = re.compile('## Error: ')
>   pattern_error_please_reset = re.compile('### ERROR ### Please RESET the board ###')
> +pattern_ready_prompt = re.compile('U-Boot is ready')
>   
>   PAT_ID = 0
>   PAT_RE = 1
> @@ -196,15 +197,15 @@ class ConsoleBase(object):
>                                       self.bad_pattern_ids[m - 1])
>               self.u_boot_version_string = self.p.after
>               while True:
> -                m = self.p.expect([self.prompt_compiled,
> +                m = self.p.expect([self.prompt_compiled, pattern_ready_prompt,
>                       pattern_stop_autoboot_prompt] + self.bad_patterns)
> -                if m == 0:
> +                if m == 0 or m == 1:
>                       break
> -                if m == 1:
> +                if m == 2:
>                       self.p.send(' ')
>                       continue
>                   raise Exception('Bad pattern found on console: ' +
> -                                self.bad_pattern_ids[m - 2])
> +                                self.bad_pattern_ids[m - 3])
>   
>           except Exception as ex:
>               self.log.error(str(ex))
Neil Armstrong Aug. 29, 2024, 2:34 p.m. UTC | #2
On 29/08/2024 16:22, neil.armstrong@linaro.org wrote:
> On 29/08/2024 00:08, Simon Glass wrote:
>> When Labgrid is used, it can get U-Boot ready for running tests. It
>> prints a message when it has done so.
>>
>> Add logic to detect this message and accept it.
> 
> So labgrid can boot and wait for `board_type & board_identity` itself right ?

Sorry bad copy paste, I was meaning `Hit any key to stop autoboot: `

> 
> It's cool, but if the boots fails for a reason, what would happen ?
> Having the U-Boot pytest to parse the U-Boot boot log makes sure we can identify crash
> and report them in the pytest log.
> 
> And this adds a labgrid-only string to parse, which could potentially
> collide with pre-uboot or whatever log when not using labgrid.
> 
> Neil
> 
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>> (no changes since v1)
>>
>>   test/py/u_boot_console_base.py | 9 +++++----
>>   1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
>> index 76a550d45a1..882d04cd1e9 100644
>> --- a/test/py/u_boot_console_base.py
>> +++ b/test/py/u_boot_console_base.py
>> @@ -22,6 +22,7 @@ pattern_stop_autoboot_prompt = re.compile('Hit any key to stop autoboot: ')
>>   pattern_unknown_command = re.compile('Unknown command \'.*\' - try \'help\'')
>>   pattern_error_notification = re.compile('## Error: ')
>>   pattern_error_please_reset = re.compile('### ERROR ### Please RESET the board ###')
>> +pattern_ready_prompt = re.compile('U-Boot is ready')
>>   PAT_ID = 0
>>   PAT_RE = 1
>> @@ -196,15 +197,15 @@ class ConsoleBase(object):
>>                                       self.bad_pattern_ids[m - 1])
>>               self.u_boot_version_string = self.p.after
>>               while True:
>> -                m = self.p.expect([self.prompt_compiled,
>> +                m = self.p.expect([self.prompt_compiled, pattern_ready_prompt,
>>                       pattern_stop_autoboot_prompt] + self.bad_patterns)
>> -                if m == 0:
>> +                if m == 0 or m == 1:
>>                       break
>> -                if m == 1:
>> +                if m == 2:
>>                       self.p.send(' ')
>>                       continue
>>                   raise Exception('Bad pattern found on console: ' +
>> -                                self.bad_pattern_ids[m - 2])
>> +                                self.bad_pattern_ids[m - 3])
>>           except Exception as ex:
>>               self.log.error(str(ex))
>
Simon Glass Aug. 29, 2024, 3:01 p.m. UTC | #3
Hi Neil,

On Thu, 29 Aug 2024 at 08:22, <neil.armstrong@linaro.org> wrote:
>
> On 29/08/2024 00:08, Simon Glass wrote:
> > When Labgrid is used, it can get U-Boot ready for running tests. It
> > prints a message when it has done so.
> >
> > Add logic to detect this message and accept it.
>
> So labgrid can boot and wait for `board_type & board_identity` itself right ?

Well, it just waits for the U-Boot banner. See Labgrid's UBootDriver[1].

>
> It's cool, but if the boots fails for a reason, what would happen ?

Several things:

1. It could timeout, meaning that it gives up waiting. In that case
any output the board did produce is shown
2. It could see invalid output, in which case it will likely complain
and fail (showing the output)

> Having the U-Boot pytest to parse the U-Boot boot log makes sure we can identify crash
> and report them in the pytest log.

It should work the same, or at least it does for me.

>
> And this adds a labgrid-only string to parse, which could potentially
> collide with pre-uboot or whatever log when not using labgrid.

It doesn't seem to. I made sure that {lab mode} is not checked
anywhere else in test.py

Regards,
SImon

>
> Neil
>
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > (no changes since v1)
> >
> >   test/py/u_boot_console_base.py | 9 +++++----
> >   1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
> > index 76a550d45a1..882d04cd1e9 100644
> > --- a/test/py/u_boot_console_base.py
> > +++ b/test/py/u_boot_console_base.py
> > @@ -22,6 +22,7 @@ pattern_stop_autoboot_prompt = re.compile('Hit any key to stop autoboot: ')
> >   pattern_unknown_command = re.compile('Unknown command \'.*\' - try \'help\'')
> >   pattern_error_notification = re.compile('## Error: ')
> >   pattern_error_please_reset = re.compile('### ERROR ### Please RESET the board ###')
> > +pattern_ready_prompt = re.compile('U-Boot is ready')
> >
> >   PAT_ID = 0
> >   PAT_RE = 1
> > @@ -196,15 +197,15 @@ class ConsoleBase(object):
> >                                       self.bad_pattern_ids[m - 1])
> >               self.u_boot_version_string = self.p.after
> >               while True:
> > -                m = self.p.expect([self.prompt_compiled,
> > +                m = self.p.expect([self.prompt_compiled, pattern_ready_prompt,
> >                       pattern_stop_autoboot_prompt] + self.bad_patterns)
> > -                if m == 0:
> > +                if m == 0 or m == 1:
> >                       break
> > -                if m == 1:
> > +                if m == 2:
> >                       self.p.send(' ')
> >                       continue
> >                   raise Exception('Bad pattern found on console: ' +
> > -                                self.bad_pattern_ids[m - 2])
> > +                                self.bad_pattern_ids[m - 3])
> >
> >           except Exception as ex:
> >               self.log.error(str(ex))
>

[1] https://github.com/labgrid-project/labgrid/blob/master/labgrid/driver/ubootdriver.py#L142
diff mbox series

Patch

diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
index 76a550d45a1..882d04cd1e9 100644
--- a/test/py/u_boot_console_base.py
+++ b/test/py/u_boot_console_base.py
@@ -22,6 +22,7 @@  pattern_stop_autoboot_prompt = re.compile('Hit any key to stop autoboot: ')
 pattern_unknown_command = re.compile('Unknown command \'.*\' - try \'help\'')
 pattern_error_notification = re.compile('## Error: ')
 pattern_error_please_reset = re.compile('### ERROR ### Please RESET the board ###')
+pattern_ready_prompt = re.compile('U-Boot is ready')
 
 PAT_ID = 0
 PAT_RE = 1
@@ -196,15 +197,15 @@  class ConsoleBase(object):
                                     self.bad_pattern_ids[m - 1])
             self.u_boot_version_string = self.p.after
             while True:
-                m = self.p.expect([self.prompt_compiled,
+                m = self.p.expect([self.prompt_compiled, pattern_ready_prompt,
                     pattern_stop_autoboot_prompt] + self.bad_patterns)
-                if m == 0:
+                if m == 0 or m == 1:
                     break
-                if m == 1:
+                if m == 2:
                     self.p.send(' ')
                     continue
                 raise Exception('Bad pattern found on console: ' +
-                                self.bad_pattern_ids[m - 2])
+                                self.bad_pattern_ids[m - 3])
 
         except Exception as ex:
             self.log.error(str(ex))