mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-18 19:04:38 +00:00
test: Improve handling of sending commands
We expect commands to be echoed and this should happen quite quickly, since U-Boot is sitting at the prompt waiting for a command. Reduce the timeout for this situation. Try to produce a more useful error message when something goes wrong. Also handle the case where the connection has gone away since the last command was issued. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
8308a5eed6
commit
f32951df40
1 changed files with 21 additions and 14 deletions
|
@ -31,6 +31,7 @@ PAT_RE = 1
|
||||||
|
|
||||||
# Timeout before expecting the console to be ready (in milliseconds)
|
# Timeout before expecting the console to be ready (in milliseconds)
|
||||||
TIMEOUT_MS = 30000 # Standard timeout
|
TIMEOUT_MS = 30000 # Standard timeout
|
||||||
|
TIMEOUT_CMD_MS = 10000 # Command-echo timeout
|
||||||
|
|
||||||
# Timeout for board preparation in lab mode. This needs to be enough to build
|
# Timeout for board preparation in lab mode. This needs to be enough to build
|
||||||
# U-Boot, write it to the board and then boot the board. Since this process is
|
# U-Boot, write it to the board and then boot the board. Since this process is
|
||||||
|
@ -300,22 +301,28 @@ class ConsoleBase(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.at_prompt = False
|
self.at_prompt = False
|
||||||
|
if not self.p:
|
||||||
|
raise BootFail(
|
||||||
|
f"Lab failure: Connection lost when sending command '{cmd}'")
|
||||||
|
|
||||||
if send_nl:
|
if send_nl:
|
||||||
cmd += '\n'
|
cmd += '\n'
|
||||||
while cmd:
|
rem = cmd # Remaining to be sent
|
||||||
# Limit max outstanding data, so UART FIFOs don't overflow
|
with self.temporary_timeout(TIMEOUT_CMD_MS):
|
||||||
chunk = cmd[:self.max_fifo_fill]
|
while rem:
|
||||||
cmd = cmd[self.max_fifo_fill:]
|
# Limit max outstanding data, so UART FIFOs don't overflow
|
||||||
self.p.send(chunk)
|
chunk = rem[:self.max_fifo_fill]
|
||||||
if not wait_for_echo:
|
rem = rem[self.max_fifo_fill:]
|
||||||
continue
|
self.p.send(chunk)
|
||||||
chunk = re.escape(chunk)
|
if not wait_for_echo:
|
||||||
chunk = chunk.replace('\\\n', '[\r\n]')
|
continue
|
||||||
m = self.p.expect([chunk] + self.bad_patterns)
|
chunk = re.escape(chunk)
|
||||||
if m != 0:
|
chunk = chunk.replace('\\\n', '[\r\n]')
|
||||||
self.at_prompt = False
|
m = self.p.expect([chunk] + self.bad_patterns)
|
||||||
raise BootFail('Bad pattern found on console: ' +
|
if m != 0:
|
||||||
self.bad_pattern_ids[m - 1])
|
self.at_prompt = False
|
||||||
|
raise BootFail(f"Failed to get echo on console (cmd '{cmd}':rem '{rem}'): " +
|
||||||
|
self.bad_pattern_ids[m - 1])
|
||||||
if not wait_for_prompt:
|
if not wait_for_prompt:
|
||||||
return
|
return
|
||||||
if wait_for_reboot:
|
if wait_for_reboot:
|
||||||
|
|
Loading…
Add table
Reference in a new issue