From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEA7AC433B4 for ; Sat, 15 May 2021 13:48:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8ACFC613C7 for ; Sat, 15 May 2021 13:48:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8ACFC613C7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhuej-0007ec-GG for qemu-devel@archiver.kernel.org; Sat, 15 May 2021 09:48:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhucH-00049q-Nn; Sat, 15 May 2021 09:46:05 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:38649) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lhucG-0002Jx-6Q; Sat, 15 May 2021 09:46:05 -0400 Received: by mail-wm1-x329.google.com with SMTP id a10-20020a05600c068ab029014dcda1971aso2690764wmn.3; Sat, 15 May 2021 06:46:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G8s61eN0lJK7kTgoNeT21G2dYt+87J3oMV0XWs16zIo=; b=maP1gYzPaJouaW35ycnih8wS0VpxQNalAe0otrRDSgBfcBhXPejntVPtxHFavaZnCJ Ljsn/qlfJZIzspIpcmzKbMDABL9/6J6i0GeTM8H/yNv/yBH+nSR1eMlnZdryYkqVt4GR D+eCgAYiUtZnRcwqDP1Bq4W5znp1bCG5CvIKzQpK9ceGEAvBiNBWn/9kpuQzFWVX390s U43/8Ybgsq7avRzfi/oDPeVQAlpR39jmrjkZR2u748O6sah3z5YuMT/I8R4Tk1YuyrFq GbZrSb8gV0+3etW73T4+tBaqXuRZ5hmGzYxlEgw2eKnB/CZ5HElcYXWA6gf/vdIpMPqR ZtjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=G8s61eN0lJK7kTgoNeT21G2dYt+87J3oMV0XWs16zIo=; b=lqXJ/jwkgPgZS0PHvBtoCO4AyLtzBTC6g/H1hji9TqNBGM/l3NlapWdHHymZgbWHG1 ZtBS9g9PyGAoMfreEp0rH3zIC92lEZR+2sXfnInwD5jnzQjOA3KXxkrWO08Fzi5/iYaS XjcS55xmvsEBGLtOAJSXDNs4ssY0Uo86yh/hc14YRe2PTm6JoArJ9g7gCfRyLhUlcOlf 2Bedtt6Vsv7XaQiodnuca/E4OjyYkby/jz/Ru4cDXzonZevs5E5US1ghnPtdSfNyLvsq tTWendO5ShHJ0mT7+oxPLjWoAU3ee09g+IkKgx6Q7Mm4/TuMz2bLgQr1BqVFz9z6zbIQ 1DPQ== X-Gm-Message-State: AOAM531LchFh804ODtEmqttRrrPj+cjMAFCi4xpE7KlCSJsfJNLNwMs3 lp2gAbWt07vFknE9/cwHsMUBcdixFqhC4w== X-Google-Smtp-Source: ABdhPJzlg2LQMKC8l6u3jq/Fy7ML3z3z5fCpru5Y2lCgRd6lqXG/9AIkZcf35zFMk+8OiW2HNcBobg== X-Received: by 2002:a05:600c:6d6:: with SMTP id b22mr27078112wmn.134.1621086362238; Sat, 15 May 2021 06:46:02 -0700 (PDT) Received: from localhost.localdomain (31.red-83-51-215.dynamicip.rima-tde.net. [83.51.215.31]) by smtp.gmail.com with ESMTPSA id e20sm1300893wme.26.2021.05.15.06.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 May 2021 06:46:01 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/2] tests/acceptance: Ignore binary data sent on serial console Date: Sat, 15 May 2021 15:45:54 +0200 Message-Id: <20210515134555.307404-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210515134555.307404-1-f4bug@amsat.org> References: <20210515134555.307404-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , qemu-ppc@nongnu.org, Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- tests/acceptance/avocado_qemu/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) -- 2.26.3