diff options
author | rnhmjoj <rnhmjoj@inventati.org> | 2023-02-02 13:26:18 +0100 |
---|---|---|
committer | rnhmjoj <rnhmjoj@inventati.org> | 2023-02-07 08:47:14 +0100 |
commit | 067d688b1687b731007ddfe58a399f466492efe4 (patch) | |
tree | 6991d1b790fb28d0f312ad406b85decdc80480c0 /nixos/lib | |
parent | f2929eb949dadce3c195fc67f742c0f56710976c (diff) |
nixos/test-driver: handle decoding errors in Machine.execute
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.
Diffstat (limited to 'nixos/lib')
-rw-r--r-- | nixos/lib/test-driver/test_driver/machine.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/nixos/lib/test-driver/test_driver/machine.py b/nixos/lib/test-driver/test_driver/machine.py index 1c77550bd1fd0..0db7930f496b2 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. |