From 067d688b1687b731007ddfe58a399f466492efe4 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Thu, 2 Feb 2023 13:26:18 +0100 Subject: [PATCH] nixos/test-driver: handle decoding errors in Machine.execute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The output of a command is not guaranteed to be valid UTF-8, so the decoding can fail raising UnicodeDecodeError. If this happens during a `succeeds` the check will be erroneously marked failed. This changes the error handling to the "replace" mode, where invalid codepoints are replaced with � (REPLACEMENT CHARACTER U+FFFD) and the decoding can go on. --- nixos/lib/test-driver/test_driver/machine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/lib/test-driver/test_driver/machine.py b/nixos/lib/test-driver/test_driver/machine.py index 1c77550bd1fd..0db7930f496b 100644 --- a/nixos/lib/test-driver/test_driver/machine.py +++ b/nixos/lib/test-driver/test_driver/machine.py @@ -545,7 +545,7 @@ class Machine: self.shell.send("echo ${PIPESTATUS[0]}\n".encode()) rc = int(self._next_newline_closed_block_from_shell().strip()) - return (rc, output.decode()) + return (rc, output.decode(errors="replace")) def shell_interact(self, address: Optional[str] = None) -> None: """Allows you to interact with the guest shell for debugging purposes.