From patchwork Mon May 6 21:38:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 1096055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44ybhw6PdFz9s3l for ; Tue, 7 May 2019 07:38:53 +1000 (AEST) Received: from localhost ([127.0.0.1]:34301 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNlJx-0003DG-S6 for incoming@patchwork.ozlabs.org; Mon, 06 May 2019 17:38:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNlJY-0003D3-5Z for qemu-devel@nongnu.org; Mon, 06 May 2019 17:38:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNlJX-0007GO-8o for qemu-devel@nongnu.org; Mon, 06 May 2019 17:38:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32878) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hNlJX-0007Fm-3b for qemu-devel@nongnu.org; Mon, 06 May 2019 17:38:23 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BEA30308792D; Mon, 6 May 2019 21:38:21 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20E891A4D9; Mon, 6 May 2019 21:38:18 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Mon, 6 May 2019 18:38:17 -0300 Message-Id: <20190506213817.14344-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 06 May 2019 21:38:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] tests: Force Python I/O encoding for check-qapi-schema X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Michael Roth , Markus Armbruster , Cleber Rosa , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" test-qapi.py doesn't force a specific encoding for stderr or stdout, but the reference files used by check-qapi-schema are in UTF-8. This breaks check-qapi-schema under certain circumstances (e.g. if using the C locale and Python < 3.7). We need to make sure test-qapi.py always generate UTF-8 output somehow. On Python 3.7+ we can do it using `sys.stdout.reconfigure(...)`, but we need a solution that works with older Python versions. Instead of trying a hack like reopening sys.stdout and sys.stderr, we can just tell Python to use UTF-8 for I/O encoding when running test-qapi.py. Do it by setting PYTHONIOENCODING. Reported-by: Thomas Huth Tested-by: Thomas Huth Signed-off-by: Eduardo Habkost Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Tested-by: Alex Bennée --- tests/Makefile.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 7c8b9c84b2..af88ab6f8b 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -1103,7 +1103,7 @@ check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF) .PHONY: $(patsubst %, check-%, $(check-qapi-schema-y)) $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json $(call quiet-command, PYTHONPATH=$(SRC_PATH)/scripts \ - $(PYTHON) $(SRC_PATH)/tests/qapi-schema/test-qapi.py \ + PYTHONIOENCODING=utf-8 $(PYTHON) $(SRC_PATH)/tests/qapi-schema/test-qapi.py \ $^ >$*.test.out 2>$*.test.err; \ echo $$? >$*.test.exit, \ "TEST","$*.out")