about summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authorErik Arvstedt <erik.arvstedt@gmail.com>2020-01-14 19:18:17 +0100
committerJon <jonringer@users.noreply.github.com>2020-01-14 15:52:44 -0800
commit5bdb653baf24ff73914a2c2d5101ceaa475e2298 (patch)
tree9f9067b7724a63748aaf01c3d841e1552268dde5 /nixos/lib
parentcaa435fd1d164cc5d1059897f18970ad290b56db (diff)
test-driver.py: fix decoding of VM output
The codec format 'unicode_escape' was introduced in 52ee102 to handle
undecodable bytes in boot menus.

This made the problem worse as unicode chars outside of iso-8859-1
produce garbled output and valid utf-8 strings (such as "\x" ) trigger
decoding errors.

Fix this by using the default 'utf-8' codec and by explicitly ignoring
decoding errors.
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/test-driver/test-driver.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py
index 7e575189209ae..c2cbedc5e3e20 100644
--- a/nixos/lib/test-driver/test-driver.py
+++ b/nixos/lib/test-driver/test-driver.py
@@ -704,7 +704,8 @@ class Machine:
 
         def process_serial_output() -> None:
             for _line in self.process.stdout:
-                line = _line.decode("unicode_escape").replace("\r", "").rstrip()
+                # Ignore undecodable bytes that may occur in boot menus
+                line = _line.decode(errors="ignore").replace("\r", "").rstrip()
                 eprint("{} # {}".format(self.name, line))
                 self.logger.enqueue({"msg": line, "machine": self.name})