mirror of
https://git.yoctoproject.org/poky
synced 2026-04-27 03:32:12 +02:00
oeqa/utils/qemurunner: support ignoring vt100 escape sequences
If we talk to terminals that like colors, we need to ignore the vt100 escape sequences when matching strings. An unprocessed barebox console prompt would e.g. look like: ESC[1;32mbarebox@ESC[1;36mARM QEMU virt64:/ESC[0m where we cannot match for something like "barebox@ARM QEMU virt64:/". The same applies to colored Linux terminal output of course. The "\x1b\[" from the regex catches the standard start of ANSI escape sequence while the rest catches the actual command code executed. (From OE-Core rev: 33bbe4cb040f890121681865fbcf28bc8213a170) Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
776c12c5c8
commit
6b90b53c7a
@@ -30,6 +30,8 @@ control_range = list(range(0,32))+list(range(127,160))
|
||||
control_chars = [chr(x) for x in control_range
|
||||
if chr(x) not in string.printable]
|
||||
re_control_char = re.compile('[%s]' % re.escape("".join(control_chars)))
|
||||
# Regex to remove the ANSI (color) control codes from console strings in order to match the text only
|
||||
re_vt100 = re.compile(r'(\x1b\[|\x9b)[^@-_a-z]*[@-_a-z]|\x1b[@-_a-z]')
|
||||
|
||||
def getOutput(o):
|
||||
import fcntl
|
||||
@@ -681,7 +683,7 @@ class QemuRunner:
|
||||
time.sleep(0.1)
|
||||
answer = self.server_socket.recv(1024)
|
||||
if answer:
|
||||
data += answer.decode('utf-8')
|
||||
data += re_vt100.sub("", answer.decode('utf-8'))
|
||||
# Search the prompt to stop
|
||||
if re.search(self.boot_patterns['search_cmd_finished'], data):
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user