1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-31 10:11:17 +00:00

Gem5Device: Improve shell command matching

- Replace ugly while True loop with a simple regex substitution
  achieving the same thing. This is required to match the command in
  the shell output when the command wraps around due to the length of
  the command.
This commit is contained in:
Sascha Bischoff 2015-11-02 11:42:33 +00:00
parent 96a6179355
commit 3bf114cf48

View File

@ -717,26 +717,12 @@ class Gem5Device(AndroidDevice):
while command_index == -1:
if conn.prompt():
output = re.sub(r' \r([^\n])', r'\1', conn.before)
command_index = output.find(command)
# The command was probably too long and wrapped. This bit of
# code is a total hack!
if command_index == -1:
# We need to remove the backspace characters!
output = re.sub(r'[\b]', r'', output)
while True:
first_cr = output.find('\r')
first_lt = output.find('<')
if first_cr == -1 or first_lt == -1:
break
if first_cr < first_lt:
new_output = output[:first_cr]
new_output += output[first_lt + 1:]
output = new_output
# Deal with line wrapping
output = re.sub(r'[\r].+?<', r'', output)
command_index = output.find(command)
else:
break
# If we STILL have -1, then we cannot match the command, but the
# If we have -1, then we cannot match the command, but the
# prompt has returned. Hence, we have a bit of an issue. We
# warn, and return the whole output.
if command_index == -1: