mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-16 09:54:35 +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_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
|
||||
# U-Boot, write it to the board and then boot the board. Since this process is
|
||||
|
@ -300,22 +301,28 @@ class ConsoleBase(object):
|
|||
|
||||
try:
|
||||
self.at_prompt = False
|
||||
if not self.p:
|
||||
raise BootFail(
|
||||
f"Lab failure: Connection lost when sending command '{cmd}'")
|
||||
|
||||
if send_nl:
|
||||
cmd += '\n'
|
||||
while cmd:
|
||||
# Limit max outstanding data, so UART FIFOs don't overflow
|
||||
chunk = cmd[:self.max_fifo_fill]
|
||||
cmd = cmd[self.max_fifo_fill:]
|
||||
self.p.send(chunk)
|
||||
if not wait_for_echo:
|
||||
continue
|
||||
chunk = re.escape(chunk)
|
||||
chunk = chunk.replace('\\\n', '[\r\n]')
|
||||
m = self.p.expect([chunk] + self.bad_patterns)
|
||||
if m != 0:
|
||||
self.at_prompt = False
|
||||
raise BootFail('Bad pattern found on console: ' +
|
||||
self.bad_pattern_ids[m - 1])
|
||||
rem = cmd # Remaining to be sent
|
||||
with self.temporary_timeout(TIMEOUT_CMD_MS):
|
||||
while rem:
|
||||
# Limit max outstanding data, so UART FIFOs don't overflow
|
||||
chunk = rem[:self.max_fifo_fill]
|
||||
rem = rem[self.max_fifo_fill:]
|
||||
self.p.send(chunk)
|
||||
if not wait_for_echo:
|
||||
continue
|
||||
chunk = re.escape(chunk)
|
||||
chunk = chunk.replace('\\\n', '[\r\n]')
|
||||
m = self.p.expect([chunk] + self.bad_patterns)
|
||||
if m != 0:
|
||||
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:
|
||||
return
|
||||
if wait_for_reboot:
|
||||
|
|
Loading…
Add table
Reference in a new issue