diff options
author | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2021-05-15 15:45:54 +0200 |
---|---|---|
committer | Cleber Rosa <crosa@redhat.com> | 2021-07-13 13:18:50 -0400 |
commit | 9f5193413026ed65f9651108b6656054b40e43a0 (patch) | |
tree | 2262533e4dd331007ad619d77aa71c16c4987b53 /tests/acceptance/avocado_qemu | |
parent | d5adf9d52b36d63347b2f658b8c67567ff6bd525 (diff) |
tests/acceptance: Ignore binary data sent on serial console
If a guest sends binary data on the serial console, we get:
File "tests/acceptance/avocado_qemu/__init__.py", line 92,
in _console_interaction msg = console.readline().strip()
File "/usr/lib64/python3.8/codecs.py", line 322,
in decode (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9 in position 2: invalid start byte
Since we use the console with readline(), fix it the easiest
way possible: ignore binary data (all current tests compare
text string anyway).
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210515134555.307404-2-f4bug@amsat.org>
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Tested-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
Diffstat (limited to 'tests/acceptance/avocado_qemu')
-rw-r--r-- | tests/acceptance/avocado_qemu/__init__.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index 1f1728ab83..c3163af3b7 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -86,14 +86,17 @@ def _console_interaction(test, success_message, failure_message, assert not keep_sending or send_string if vm is None: vm = test.vm - console = vm.console_socket.makefile() + console = vm.console_socket.makefile(mode='rb', encoding='utf-8') console_logger = logging.getLogger('console') while True: if send_string: vm.console_socket.sendall(send_string.encode()) if not keep_sending: send_string = None # send only once - msg = console.readline().strip() + try: + msg = console.readline().decode().strip() + except UnicodeDecodeError: + msg = None if not msg: continue console_logger.debug(msg) |