[Concept,01/16] test: py: Always consume {lab ready} marker in lab mode
Commit Message
From: Simon Glass <sjg@chromium.org>
_wait_for_boot_prompt() loops on either '=>' or on the labgrid
'{lab ready in <t>s: <banner>}' marker, breaking on whichever arrives
first. In lab mode U-Boot prints '=>' before labgrid emits the marker,
so the plain prompt wins the race and the marker stays in the receive
buffer. The marker has the U-Boot banner embedded in it, so the very
next command run in the test scans forward, trips the main_signon
bad-pattern inside the marker and aborts with:
Failed to get echo on console (cmd 'boot':rem ''): main_signon
In lab mode, only wait for the '{lab ready...}' marker (plus the
autoboot prompt so we can interrupt it). Drop the raw '=>' match from
that path so the marker and its embedded banner are always consumed
before the test runs its first command. The non-lab flow is unchanged.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
test/py/console_base.py | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
@@ -331,25 +331,38 @@ class ConsoleBase():
if not self.lab_mode:
self._wait_for_banner(loop_num)
self.u_boot_version_string = self.after
+ # In lab mode the '{lab ready in <t>s: <banner>}' marker is
+ # the authoritative ready signal and must be consumed so
+ # the embedded banner does not trip the signon bad-pattern
+ # when the next command runs. Skip the plain '=>' prompt
+ # match in that case.
+ if self.lab_mode:
+ wait_patterns = [pattern_ready_prompt,
+ pattern_stop_autoboot_prompt]
+ else:
+ wait_patterns = [self.prompt_compiled, pattern_ready_prompt,
+ pattern_stop_autoboot_prompt]
+ ready_idx = wait_patterns.index(pattern_ready_prompt)
+ autoboot_idx = wait_patterns.index(pattern_stop_autoboot_prompt)
+ base = len(wait_patterns)
while True:
- m = self.expect([self.prompt_compiled, pattern_ready_prompt,
- pattern_stop_autoboot_prompt] + self.bad_patterns)
- if m == 0:
+ m = self.expect(wait_patterns + self.bad_patterns)
+ if not self.lab_mode and m == 0:
self.log.info(f'Found ready prompt {m}')
break
- if m == 1:
+ if m == ready_idx:
m = pattern_ready_prompt.search(self.after)
self.u_boot_version_string = m.group(2)
self.log.info('Lab: Board is ready')
self.timeout = self.get_default_timeout()
break
- if m == 2:
+ if m == autoboot_idx:
self.log.info(f'Found autoboot prompt {m}')
self.p.send(' ')
continue
if not self.lab_mode:
raise BootFail('Missing prompt / ready message on console: ' +
- self.bad_pattern_ids[m - 3])
+ self.bad_pattern_ids[m - base])
self.log.info('U-Boot is ready')
finally: