diff mbox series

oeqa qemurunner.py: switch utf8 error handling from ignore to replace

Message ID 20231002141656.1548714-1-mikko.rapeli@linaro.org
State New
Headers show
Series oeqa qemurunner.py: switch utf8 error handling from ignore to replace | expand

Commit Message

Mikko Rapeli Oct. 2, 2023, 2:16 p.m. UTC
It seems like "ignore" is stopping decoding and failing to detect
login prompts. Maybe "replace" works more reliably when reads from
serial console are incomplete and we're trying to detect the login
prompt. See logs like:

https://autobuilder.yoctoproject.org/typhoon/#/builders/86/builds/5833/steps/14/logs/stdio
https://autobuilder.yocto.io/pub/failed-builds-data/6.5%20kernel/log.do_testimage.3051530
https://autobuilder.yocto.io/pub/failed-builds-data/6.5%20kernel/qemu_boot_log.20231001114436

Python documentation is not clear on how "ignore" and "replace" differ
and both should continue processing if there are errors in the stream:

https://docs.python.org/3/library/codecs.html#error-handlers

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
---
 meta/lib/oeqa/utils/qemurunner.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index b24091e212..5c18ccbd3e 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -109,7 +109,7 @@  class QemuRunner:
 
     def decode_qemulog(self, todecode):
         # Sanitize the data received from qemu as it may contain control characters
-        msg = todecode.decode("utf-8", errors='ignore')
+        msg = todecode.decode("utf-8", errors='replace')
         msg = re_control_char.sub('', msg)
         return msg
 
@@ -474,7 +474,7 @@  class QemuRunner:
                         self.logger.error('Invalid file type: %s\n%s' % (file))
                         read = b''
 
-                    self.logger.debug2('Partial boot log:\n%s' % (read.decode('utf-8', errors='ignore')))
+                    self.logger.debug2('Partial boot log:\n%s' % (read.decode('utf-8', errors='replace')))
                     data = data + read
                     if data:
                         bootlog += data