qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] tests/acceptance: Ignore binary data sent on serial cons


From: Wainer dos Santos Moschetta
Subject: Re: [PATCH 1/2] tests/acceptance: Ignore binary data sent on serial console
Date: Thu, 27 May 2021 16:50:53 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1


On 5/15/21 10:45 AM, Philippe Mathieu-Daudé wrote:
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


Good catch!



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>
---
  tests/acceptance/avocado_qemu/__init__.py | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)

Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>

Tested-by: Wainer dos Santos Moschetta <wainersm@redhat.com>


diff --git a/tests/acceptance/avocado_qemu/__init__.py 
b/tests/acceptance/avocado_qemu/__init__.py
index 83b1741ec85..b55578e1cca 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -82,14 +82,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)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]