Unverified Commit 067d688b authored by rnhmjoj's avatar rnhmjoj
Browse files

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.
parent f2929eb9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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.