From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Schocher Date: Thu, 18 Aug 2016 06:23:59 +0200 Subject: [U-Boot] [PATCH] test/py: match prompt only at line boundaries In-Reply-To: <20160817015859.13573-1-swarren@wwwdotorg.org> References: <20160817015859.13573-1-swarren@wwwdotorg.org> Message-ID: <57B5385F.6000509@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 > Signed-off-by: Stephen Warren > --- > 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 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