public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] test/py: match prompt only at line boundaries
@ 2016-08-17  1:58 Stephen Warren
  2016-08-17 14:11 ` Tom Rini
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stephen Warren @ 2016-08-17  1:58 UTC (permalink / raw)
  To: u-boot

This prevents capture of command output from terminating early on boards
that use a simple prompt (e.g. "=> ") that appears in the middle of
command output (e.g. crc32's "... ==> 2fa737e0").

Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
---
 test/py/u_boot_console_base.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
index ee9b928756fa..b1f474236e4e 100644
--- a/test/py/u_boot_console_base.py
+++ b/test/py/u_boot_console_base.py
@@ -106,7 +106,7 @@ class ConsoleBase(object):
 
         # Array slice removes leading/trailing quotes
         self.prompt = self.config.buildconfig['config_sys_prompt'][1:-1]
-        self.prompt_escaped = re.escape(self.prompt)
+        self.prompt_compiled = re.compile('^' + re.escape(self.prompt), re.MULTILINE)
         self.p = None
         self.disable_check_count = {pat[PAT_ID]: 0 for pat in bad_pattern_defs}
         self.eval_bad_patterns()
@@ -201,7 +201,7 @@ class ConsoleBase(object):
                                     self.bad_pattern_ids[m - 1])
             if not wait_for_prompt:
                 return
-            m = self.p.expect([self.prompt_escaped] + self.bad_patterns)
+            m = self.p.expect([self.prompt_compiled] + self.bad_patterns)
             if m != 0:
                 self.at_prompt = False
                 raise Exception('Bad pattern found on console: ' +
@@ -354,7 +354,7 @@ 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_escaped,
+                m = self.p.expect([self.prompt_compiled,
                     pattern_stop_autoboot_prompt] + self.bad_patterns)
                 if m == 0:
                     break
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] test/py: match prompt only at line boundaries
  2016-08-17  1:58 [U-Boot] [PATCH] test/py: match prompt only at line boundaries Stephen Warren
@ 2016-08-17 14:11 ` Tom Rini
  2016-08-18  4:23 ` Heiko Schocher
  2016-08-21 15:08 ` [U-Boot] " Tom Rini
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2016-08-17 14:11 UTC (permalink / raw)
  To: u-boot

On Tue, Aug 16, 2016 at 07:58:59PM -0600, Stephen Warren wrote:

> This prevents capture of command output from terminating early on boards
> that use a simple prompt (e.g. "=> ") that appears in the middle of
> command output (e.g. crc32's "... ==> 2fa737e0").
> 
> Reported-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>

Tested-by: Tom Rini <trini@konsulko.com>

Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160817/17252e28/attachment.sig>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] test/py: match prompt only at line boundaries
  2016-08-17  1:58 [U-Boot] [PATCH] test/py: match prompt only at line boundaries Stephen Warren
  2016-08-17 14:11 ` Tom Rini
@ 2016-08-18  4:23 ` Heiko Schocher
  2016-08-21 15:08 ` [U-Boot] " Tom Rini
  2 siblings, 0 replies; 4+ messages in thread
From: Heiko Schocher @ 2016-08-18  4:23 UTC (permalink / raw)
  To: u-boot

Hello Stephen,

Am 17.08.2016 um 03:58 schrieb Stephen Warren:
> This prevents capture of command output from terminating early on boards
> that use a simple prompt (e.g. "=> ") that appears in the middle of
> command output (e.g. crc32's "... ==> 2fa737e0").
>
> Reported-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
> ---
>   test/py/u_boot_console_base.py | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)

Nice solution! For U-Boot prompt this should always work.

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
> index ee9b928756fa..b1f474236e4e 100644
> --- a/test/py/u_boot_console_base.py
> +++ b/test/py/u_boot_console_base.py
> @@ -106,7 +106,7 @@ class ConsoleBase(object):
>
>           # Array slice removes leading/trailing quotes
>           self.prompt = self.config.buildconfig['config_sys_prompt'][1:-1]
> -        self.prompt_escaped = re.escape(self.prompt)
> +        self.prompt_compiled = re.compile('^' + re.escape(self.prompt), re.MULTILINE)
>           self.p = None
>           self.disable_check_count = {pat[PAT_ID]: 0 for pat in bad_pattern_defs}
>           self.eval_bad_patterns()
> @@ -201,7 +201,7 @@ class ConsoleBase(object):
>                                       self.bad_pattern_ids[m - 1])
>               if not wait_for_prompt:
>                   return
> -            m = self.p.expect([self.prompt_escaped] + self.bad_patterns)
> +            m = self.p.expect([self.prompt_compiled] + self.bad_patterns)
>               if m != 0:
>                   self.at_prompt = False
>                   raise Exception('Bad pattern found on console: ' +
> @@ -354,7 +354,7 @@ 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_escaped,
> +                m = self.p.expect([self.prompt_compiled,
>                       pattern_stop_autoboot_prompt] + self.bad_patterns)
>                   if m == 0:
>                       break
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] test/py: match prompt only at line boundaries
  2016-08-17  1:58 [U-Boot] [PATCH] test/py: match prompt only at line boundaries Stephen Warren
  2016-08-17 14:11 ` Tom Rini
  2016-08-18  4:23 ` Heiko Schocher
@ 2016-08-21 15:08 ` Tom Rini
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2016-08-21 15:08 UTC (permalink / raw)
  To: u-boot

On Tue, Aug 16, 2016 at 07:58:59PM -0600, Stephen Warren wrote:

> This prevents capture of command output from terminating early on boards
> that use a simple prompt (e.g. "=> ") that appears in the middle of
> command output (e.g. crc32's "... ==> 2fa737e0").
> 
> Reported-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
> Tested-by: Tom Rini <trini@konsulko.com>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160821/2819294f/attachment.sig>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-21 15:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-17  1:58 [U-Boot] [PATCH] test/py: match prompt only at line boundaries Stephen Warren
2016-08-17 14:11 ` Tom Rini
2016-08-18  4:23 ` Heiko Schocher
2016-08-21 15:08 ` [U-Boot] " Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox