diff mbox

[U-Boot,V2,2/2] test/py: capture the entire U-Boot version at boot

Message ID 1454720683-9557-2-git-send-email-swarren@wwwdotorg.org
State Accepted
Commit c82ce04a3f38bb91465da6b2fd9d8dcb0e81f94b
Delegated to: Simon Glass
Headers show

Commit Message

Stephen Warren Feb. 6, 2016, 1:04 a.m. UTC
From: Stephen Warren <swarren@nvidia.com>

The existing regex simply ensures that the captured version string doesn't
go past the end of a line. We really want to grab as much as possible. Do
this by explicitly including a ) character at the end of the regex to
match the last character of the version test.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v2: Also remove some now-redundant code. The signon regex now never
matches the text ", Build: ...", so there's no need for explicit code to
chop it out.
---
 test/py/u_boot_console_base.py | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Simon Glass Feb. 6, 2016, 8:30 p.m. UTC | #1
On 5 February 2016 at 18:04, Stephen Warren <swarren@wwwdotorg.org> wrote:
> From: Stephen Warren <swarren@nvidia.com>
>
> The existing regex simply ensures that the captured version string doesn't
> go past the end of a line. We really want to grab as much as possible. Do
> this by explicitly including a ) character at the end of the regex to
> match the last character of the version test.
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
> v2: Also remove some now-redundant code. The signon regex now never
> matches the text ", Build: ...", so there's no need for explicit code to
> chop it out.
> ---
>  test/py/u_boot_console_base.py | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>
Tested on sandbox:
Tested-by: Simon Glass <sjg@chromium.org>
Simon Glass Feb. 6, 2016, 8:45 p.m. UTC | #2
On 6 February 2016 at 13:30, Simon Glass <sjg@chromium.org> wrote:
> On 5 February 2016 at 18:04, Stephen Warren <swarren@wwwdotorg.org> wrote:
>> From: Stephen Warren <swarren@nvidia.com>
>>
>> The existing regex simply ensures that the captured version string doesn't
>> go past the end of a line. We really want to grab as much as possible. Do
>> this by explicitly including a ) character at the end of the regex to
>> match the last character of the version test.
>>
>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>> ---
>> v2: Also remove some now-redundant code. The signon regex now never
>> matches the text ", Build: ...", so there's no need for explicit code to
>> chop it out.
>> ---
>>  test/py/u_boot_console_base.py | 11 +++--------
>>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> Acked-by: Simon Glass <sjg@chromium.org>
> Tested on sandbox:
> Tested-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm, thanks!
diff mbox

Patch

diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
index cc5427335177..7e1e9d430ffa 100644
--- a/test/py/u_boot_console_base.py
+++ b/test/py/u_boot_console_base.py
@@ -17,8 +17,8 @@  import sys
 import u_boot_spawn
 
 # Regexes for text we expect U-Boot to send to the console.
-pattern_u_boot_spl_signon = re.compile('(U-Boot SPL \\d{4}\\.\\d{2}-[^\r\n]*)')
-pattern_u_boot_main_signon = re.compile('(U-Boot \\d{4}\\.\\d{2}-[^\r\n]*)')
+pattern_u_boot_spl_signon = re.compile('(U-Boot SPL \\d{4}\\.\\d{2}[^\r\n]*\\))')
+pattern_u_boot_main_signon = re.compile('(U-Boot \\d{4}\\.\\d{2}[^\r\n]*\\))')
 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: ')
@@ -312,12 +312,7 @@  class ConsoleBase(object):
             if m != 0:
                 raise Exception('Bad pattern found on console: ' +
                                 self.bad_pattern_ids[m - 1])
-            signon = self.p.after
-            build_idx = signon.find(', Build:')
-            if build_idx == -1:
-                self.u_boot_version_string = signon
-            else:
-                self.u_boot_version_string = signon[:build_idx]
+            self.u_boot_version_string = self.p.after
             while True:
                 m = self.p.expect([self.prompt_escaped,
                     pattern_stop_autoboot_prompt] + self.bad_patterns)