diff options
| author | Enrico Jorns <ejo@pengutronix.de> | 2024-10-11 14:01:14 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-10-11 15:57:44 +0100 |
| commit | 6b90b53c7a103b0658702c06169f64f09b43bde7 (patch) | |
| tree | fa21e88b105a6a0bce639f04dcbbc1887e3c37a8 /meta/lib | |
| parent | 776c12c5c860bd0be4e2399724b7fbe04107a838 (diff) | |
| download | poky-6b90b53c7a103b0658702c06169f64f09b43bde7.tar.gz | |
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>
Diffstat (limited to 'meta/lib')
| -rw-r--r-- | meta/lib/oeqa/utils/qemurunner.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index cda43aad8c..63fc6f6b53 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py | |||
| @@ -30,6 +30,8 @@ control_range = list(range(0,32))+list(range(127,160)) | |||
| 30 | control_chars = [chr(x) for x in control_range | 30 | control_chars = [chr(x) for x in control_range |
| 31 | if chr(x) not in string.printable] | 31 | if chr(x) not in string.printable] |
| 32 | re_control_char = re.compile('[%s]' % re.escape("".join(control_chars))) | 32 | re_control_char = re.compile('[%s]' % re.escape("".join(control_chars))) |
| 33 | # Regex to remove the ANSI (color) control codes from console strings in order to match the text only | ||
| 34 | re_vt100 = re.compile(r'(\x1b\[|\x9b)[^@-_a-z]*[@-_a-z]|\x1b[@-_a-z]') | ||
| 33 | 35 | ||
| 34 | def getOutput(o): | 36 | def getOutput(o): |
| 35 | import fcntl | 37 | import fcntl |
| @@ -681,7 +683,7 @@ class QemuRunner: | |||
| 681 | time.sleep(0.1) | 683 | time.sleep(0.1) |
| 682 | answer = self.server_socket.recv(1024) | 684 | answer = self.server_socket.recv(1024) |
| 683 | if answer: | 685 | if answer: |
| 684 | data += answer.decode('utf-8') | 686 | data += re_vt100.sub("", answer.decode('utf-8')) |
| 685 | # Search the prompt to stop | 687 | # Search the prompt to stop |
| 686 | if re.search(self.boot_patterns['search_cmd_finished'], data): | 688 | if re.search(self.boot_patterns['search_cmd_finished'], data): |
| 687 | break | 689 | break |
