From: Wainer dos Santos Moschetta <wainersm@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>, qemu-devel@nongnu.org
Cc: "Thomas Huth" <huth@tuxfamily.org>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
qemu-ppc@nongnu.org, "Cleber Rosa" <crosa@redhat.com>
Subject: Re: [PATCH 1/2] tests/acceptance: Ignore binary data sent on serial console
Date: Thu, 27 May 2021 16:50:53 -0300 [thread overview]
Message-ID: <069856a3-96ce-6bdf-5d9b-bef6d93c46a5@redhat.com> (raw)
In-Reply-To: <20210515134555.307404-2-f4bug@amsat.org>
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)
next prev parent reply other threads:[~2021-05-27 19:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-15 13:45 [PATCH 0/2] tests/acceptance: Add tests for the Pegasos2 machine Philippe Mathieu-Daudé
2021-05-15 13:45 ` [PATCH 1/2] tests/acceptance: Ignore binary data sent on serial console Philippe Mathieu-Daudé
2021-05-27 19:50 ` Wainer dos Santos Moschetta [this message]
2021-05-15 13:45 ` [PATCH 2/2] tests/acceptance: Add tests for the Pegasos2 machine Philippe Mathieu-Daudé
2021-05-15 14:33 ` BALATON Zoltan
2021-05-27 20:46 ` Wainer dos Santos Moschetta
2021-07-12 22:05 ` Cleber Rosa
2021-07-13 9:50 ` Philippe Mathieu-Daudé
2021-05-25 7:52 ` [PATCH 0/2] " Philippe Mathieu-Daudé
2021-07-12 20:20 ` BALATON Zoltan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=069856a3-96ce-6bdf-5d9b-bef6d93c46a5@redhat.com \
--to=wainersm@redhat.com \
--cc=crosa@redhat.com \
--cc=f4bug@amsat.org \
--cc=huth@tuxfamily.org \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).