From 5bdb653baf24ff73914a2c2d5101ceaa475e2298 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Tue, 14 Jan 2020 19:18:17 +0100 Subject: [PATCH] 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. --- nixos/lib/test-driver/test-driver.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py index 7e575189209..c2cbedc5e3e 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})