From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645483234878636.6328908903927; Mon, 21 Feb 2022 14:40:34 -0800 (PST) Received: from localhost ([::1]:33476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHM9-0008NI-LV for importer@patchew.org; Mon, 21 Feb 2022 17:40:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGE-0007of-SU for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23445) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGB-000870-9Z for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:25 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-665-VPlYizuMOe6GIBpSCj7JWg-1; Mon, 21 Feb 2022 17:34:19 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72A22801B0C; Mon, 21 Feb 2022 22:34:18 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65CBD1038AAF; Mon, 21 Feb 2022 22:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Est3gT7fKJzLxS65tT1wupOiKJEw+eV9Ot8heZ+DqM=; b=Erfpb4GDCbDBIHPSFKU6FBhZrcWpDOo7CIu3zh9+UEScNo875ByGGUr0fK7n5zYHeIpCuC AISVTIyS9n6/HAApbHM9Tq+7Px5gPZCTCYNHx0drdlWYEPo2sPHQhUrOeuuyZoM0258/uw 1LuplJ4rYvcsHBb6EffLaZFYXbSI0m0= X-MC-Unique: VPlYizuMOe6GIBpSCj7JWg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 01/18] python/utils: add enboxify() text decoration utility Date: Mon, 21 Feb 2022 17:33:56 -0500 Message-Id: <20220221223413.2123003-2-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483235505100001 >>> print(enboxify(msg, width=3D72, name=3D"commit message")) =E2=94=8F=E2=94=81 commit message =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=93 =E2=94=83 enboxify() takes a chunk of text and wraps it in a text art box t= hat =E2=94=83 =E2=94=83 adheres to a specified width. An optional title label may be giv= en, =E2=94=83 =E2=94=83 and any of the individual glyphs used to draw the box may be = =E2=94=83 =E2=94=83 replaced or specified as well. = =E2=94=83 =E2=94=97=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=9B Signed-off-by: John Snow --- python/qemu/utils/__init__.py | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/python/qemu/utils/__init__.py b/python/qemu/utils/__init__.py index 7f1a5138c4b..f785316f230 100644 --- a/python/qemu/utils/__init__.py +++ b/python/qemu/utils/__init__.py @@ -15,7 +15,10 @@ # the COPYING file in the top-level directory. # =20 +import os import re +import shutil +import textwrap from typing import Optional =20 # pylint: disable=3Dimport-error @@ -23,6 +26,7 @@ =20 =20 __all__ =3D ( + 'enboxify', 'get_info_usernet_hostfwd_port', 'kvm_available', 'list_accel', @@ -43,3 +47,57 @@ def get_info_usernet_hostfwd_port(info_usernet_output: s= tr) -> Optional[int]: if match is not None: return int(match[1]) return None + + +# pylint: disable=3Dtoo-many-arguments +def enboxify( + content: str =3D '', + width: Optional[int] =3D None, + name: Optional[str] =3D None, + padding: int =3D 1, + upper_left: str =3D '=E2=94=8F', + upper_right: str =3D '=E2=94=93', + lower_left: str =3D '=E2=94=97', + lower_right: str =3D '=E2=94=9B', + horizontal: str =3D '=E2=94=81', + vertical: str =3D '=E2=94=83', +) -> str: + """ + Wrap some text into a text art box of a given width. + + :param content: The text to wrap into a box. + :param width: The number of columns (including the box itself). + :param name: A label to apply to the upper-left of the box. + :param padding: How many columns of padding to apply inside. + """ + if width is None: + width =3D shutil.get_terminal_size()[0] + prefix =3D vertical + (' ' * padding) + suffix =3D (' ' * padding) + vertical + lwidth =3D width - len(suffix) + + def _bar(name: Optional[str], top: bool =3D True) -> str: + ret =3D upper_left if top else lower_left + right =3D upper_right if top else lower_right + if name is not None: + ret +=3D f"{horizontal} {name} " + + assert width is not None + filler_len =3D width - len(ret) - len(right) + ret +=3D f"{horizontal * filler_len}{right}" + return ret + + def _wrap(line: str) -> str: + return os.linesep.join([ + wrapped_line.ljust(lwidth) + suffix + for wrapped_line in textwrap.wrap( + line, width=3Dlwidth, initial_indent=3Dprefix, + subsequent_indent=3Dprefix, replace_whitespace=3DFalse, + drop_whitespace=3DFalse, break_on_hyphens=3DFalse) + ]) + + return os.linesep.join(( + _bar(name, top=3DTrue), + os.linesep.join(_wrap(line) for line in content.splitlines()), + _bar(None, top=3DFalse), + )) --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645483001439913.3343427871741; Mon, 21 Feb 2022 14:36:41 -0800 (PST) Received: from localhost ([::1]:52868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHIP-0002NI-I7 for importer@patchew.org; Mon, 21 Feb 2022 17:36:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGE-0007r0-Co for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:22300) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGC-00087M-GT for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:26 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-607-KrS1-54iNhq9VflqZ_X8UA-1; Mon, 21 Feb 2022 17:34:20 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D60E91006AA0; Mon, 21 Feb 2022 22:34:19 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C0281038AAF; Mon, 21 Feb 2022 22:34:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482864; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WKYH+17zmQCu6cX2SgtNBAAeNes0Kdl9fsB+zzGNkGY=; b=jNwijpnE1nx2r2xDvs4dY36kCh0hTmLpN/3YIxugqHpfLfY0EgnHPfat8oBR5h/gXa1PMc zOuNz8dTs60lsOADTOGW6nOIspQPeeTxWy8tjzBfTun6g/hlSRxHicAxyeVKgqcheqysiz PkciK4KBjzfpr8jGqCRGQjlED+5lbfs= X-MC-Unique: KrS1-54iNhq9VflqZ_X8UA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 02/18] iotests: add VerboseProcessError Date: Mon, 21 Feb 2022 17:33:57 -0500 Message-Id: <20220221223413.2123003-3-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483003722100001 Content-Type: text/plain; charset="utf-8" This adds an Exception that extends the Python built-in subprocess.CalledProcessError. When this exception is raised, it will still be caught when selecting for the stdlib variant. The difference is that the str() method of this Exception also adds the stdout/stderr logs. In effect, if this exception goes unhandled, Python will print the output in a nice, highlighted box to the terminal so that it's easy to spot. This should save some headache from having to re-run test suites with debugging enabled by augmenting the exceptions to print more information in the default case. Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 6ba65eb1ffe..5617f991da7 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -30,6 +30,7 @@ import struct import subprocess import sys +import textwrap import time from typing import (Any, Callable, Dict, Iterable, Iterator, List, Optional, Sequence, TextIO, Tuple, Type, TypeVar) @@ -39,6 +40,7 @@ =20 from qemu.machine import qtest from qemu.qmp import QMPMessage +from qemu.utils import enboxify =20 # Use this logger for logging messages directly from the iotests module logger =3D logging.getLogger('qemu.iotests') @@ -117,6 +119,38 @@ sample_img_dir =3D os.environ['SAMPLE_IMG_DIR'] =20 =20 +class VerboseProcessError(subprocess.CalledProcessError): + """ + The same as CalledProcessError, but more verbose. + + This is useful for debugging failed calls during test executions. + The return code, signal (if any), and terminal output will be displayed + on unhandled exceptions. + """ + def summary(self) -> str: + return super().__str__() + + def __str__(self) -> str: + lmargin =3D ' ' + width =3D shutil.get_terminal_size()[0] - len(lmargin) + sections =3D [] + + name =3D 'output' if self.stderr is None else 'stdout' + if self.stdout: + sections.append(enboxify(self.stdout, width, name)) + else: + sections.append(f"{name}: N/A") + + if self.stderr: + sections.append(enboxify(self.stderr, width, 'stderr')) + elif self.stderr is not None: + sections.append("stderr: N/A") + + return os.linesep.join(( + self.summary(), + textwrap.indent(os.linesep.join(sections), prefix=3Dlmargin), + )) + @contextmanager def change_log_level( logger_name: str, level: int =3D logging.CRITICAL) -> Iterator[Non= e]: --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164548341808548.410346022771705; Mon, 21 Feb 2022 14:43:38 -0800 (PST) Received: from localhost ([::1]:39996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHP8-0004Pm-J2 for importer@patchew.org; Mon, 21 Feb 2022 17:43:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGF-0007uk-Q2 for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27284) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGD-00087h-Kc for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:27 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-629-_l0q8Lx2PrCzdIlmwJAisA-1; Mon, 21 Feb 2022 17:34:22 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 17860801ADB; Mon, 21 Feb 2022 22:34:21 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B58C1038AAF; Mon, 21 Feb 2022 22:34:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482865; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xYFNuilb7ExN2VNrIj/55ZXK+t5YaYCISJqfKtnc1nM=; b=a7V/kG2sx1Mj8plv9snyJvHhSm0mYTIsMbq78d7JyGu7VW4oMKGvNkNY1dGH/TQWUOThAE 7/+VYawuMN7HwRONcS7u8EorbaisMZQlCP6E0vecrraAnxVViJzYrcWLRZATVGhshwnSD9 ZOfgw0KbXf6HDHAjvRVAcdtId+gKhdA= X-MC-Unique: _l0q8Lx2PrCzdIlmwJAisA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 03/18] iotests: Remove explicit checks for qemu_img() == 0 Date: Mon, 21 Feb 2022 17:33:58 -0500 Message-Id: <20220221223413.2123003-4-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483434629100001 Content-Type: text/plain; charset="utf-8" qemu_img() returning zero ought to be the rule, not the exception. Remove all explicit checks against the condition in preparation for making non-zero returns an Exception. Signed-off-by: John Snow Reviewed-by: Eric Blake --- tests/qemu-iotests/163 | 9 +++------ tests/qemu-iotests/216 | 6 +++--- tests/qemu-iotests/218 | 2 +- tests/qemu-iotests/224 | 11 +++++------ tests/qemu-iotests/228 | 12 ++++++------ tests/qemu-iotests/257 | 3 +-- tests/qemu-iotests/258 | 4 ++-- tests/qemu-iotests/310 | 14 +++++++------- tests/qemu-iotests/tests/block-status-cache | 3 +-- tests/qemu-iotests/tests/image-fleecing | 4 ++-- tests/qemu-iotests/tests/mirror-ready-cancel-error | 6 ++---- tests/qemu-iotests/tests/mirror-top-perms | 3 +-- .../qemu-iotests/tests/remove-bitmap-from-backing | 8 ++++---- tests/qemu-iotests/tests/stream-error-on-reset | 4 ++-- 14 files changed, 40 insertions(+), 49 deletions(-) diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163 index b8bfc95358e..e4cd4b230f3 100755 --- a/tests/qemu-iotests/163 +++ b/tests/qemu-iotests/163 @@ -107,8 +107,7 @@ class ShrinkBaseClass(iotests.QMPTestCase): =20 if iotests.imgfmt =3D=3D 'raw': return - self.assertEqual(qemu_img('check', test_img), 0, - "Verifying image corruption") + qemu_img('check', test_img) =20 def test_empty_image(self): qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img, @@ -130,8 +129,7 @@ class ShrinkBaseClass(iotests.QMPTestCase): qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img, self.shrink_size) =20 - self.assertEqual(qemu_img("compare", test_img, check_img), 0, - "Verifying image content") + qemu_img("compare", test_img, check_img) =20 self.image_verify() =20 @@ -146,8 +144,7 @@ class ShrinkBaseClass(iotests.QMPTestCase): qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img, self.shrink_size) =20 - self.assertEqual(qemu_img("compare", test_img, check_img), 0, - "Verifying image content") + qemu_img("compare", test_img, check_img) =20 self.image_verify() =20 diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216 index c02f8d2880f..88b385afa30 100755 --- a/tests/qemu-iotests/216 +++ b/tests/qemu-iotests/216 @@ -51,10 +51,10 @@ with iotests.FilePath('base.img') as base_img_path, \ log('--- Setting up images ---') log('') =20 - assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') = =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') =3D=3D 0 - assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, - '-F', iotests.imgfmt, top_img_path) =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, + '-F', iotests.imgfmt, top_img_path) assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') =3D=3D 0 =20 log('Done') diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218 index 4922b4d3b6f..853ed52b349 100755 --- a/tests/qemu-iotests/218 +++ b/tests/qemu-iotests/218 @@ -145,7 +145,7 @@ log('') with iotests.VM() as vm, \ iotests.FilePath('src.img') as src_img_path: =20 - assert qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M') = =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M') assert qemu_io_silent('-f', iotests.imgfmt, src_img_path, '-c', 'write -P 42 0M 64M') =3D=3D 0 =20 diff --git a/tests/qemu-iotests/224 b/tests/qemu-iotests/224 index 38dd1536254..c31c55b49d2 100755 --- a/tests/qemu-iotests/224 +++ b/tests/qemu-iotests/224 @@ -47,12 +47,11 @@ for filter_node_name in False, True: iotests.FilePath('top.img') as top_img_path, \ iotests.VM() as vm: =20 - assert qemu_img('create', '-f', iotests.imgfmt, - base_img_path, '64M') =3D=3D 0 - assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_pat= h, - '-F', iotests.imgfmt, mid_img_path) =3D=3D 0 - assert qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path, - '-F', iotests.imgfmt, top_img_path) =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') + qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, + '-F', iotests.imgfmt, mid_img_path) + qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path, + '-F', iotests.imgfmt, top_img_path) =20 # Something to commit assert qemu_io_silent(mid_img_path, '-c', 'write -P 1 0 1M') =3D= =3D 0 diff --git a/tests/qemu-iotests/228 b/tests/qemu-iotests/228 index a5eda2e149b..f79bae02677 100755 --- a/tests/qemu-iotests/228 +++ b/tests/qemu-iotests/228 @@ -54,11 +54,11 @@ with iotests.FilePath('base.img') as base_img_path, \ iotests.FilePath('top.img') as top_img_path, \ iotests.VM() as vm: =20 - assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') = =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') # Choose a funny way to describe the backing filename - assert qemu_img('create', '-f', iotests.imgfmt, '-b', - 'file:' + base_img_path, '-F', iotests.imgfmt, - top_img_path) =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, '-b', + 'file:' + base_img_path, '-F', iotests.imgfmt, + top_img_path) =20 vm.launch() =20 @@ -172,8 +172,8 @@ with iotests.FilePath('base.img') as base_img_path, \ # (because qemu cannot "canonicalize"/"resolve" the backing # filename unless the backing file is opened implicitly with the # overlay) - assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, - '-F', iotests.imgfmt, top_img_path) =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, + '-F', iotests.imgfmt, top_img_path) =20 # You can only reliably override backing options by using a node # reference (or by specifying file.filename, but, well...) diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257 index c72c82a171b..fb5359c581e 100755 --- a/tests/qemu-iotests/257 +++ b/tests/qemu-iotests/257 @@ -240,8 +240,7 @@ def compare_images(image, reference, baseimg=3DNone, ex= pected_match=3DTrue): """ expected_ret =3D 0 if expected_match else 1 if baseimg: - assert qemu_img("rebase", "-u", "-b", baseimg, '-F', iotests.imgfm= t, - image) =3D=3D 0 + qemu_img("rebase", "-u", "-b", baseimg, '-F', iotests.imgfmt, imag= e) ret =3D qemu_img("compare", image, reference) log('qemu_img compare "{:s}" "{:s}" =3D=3D> {:s}, {:s}'.format( image, reference, diff --git a/tests/qemu-iotests/258 b/tests/qemu-iotests/258 index a6618208a89..7798a04d7d3 100755 --- a/tests/qemu-iotests/258 +++ b/tests/qemu-iotests/258 @@ -75,13 +75,13 @@ def test_concurrent_finish(write_to_stream_node): =20 # It is important to use raw for the base layer (so that # permissions are just handed through to the protocol layer) - assert qemu_img('create', '-f', 'raw', node0_path, '64M') =3D=3D 0 + qemu_img('create', '-f', 'raw', node0_path, '64M') =20 stream_throttle=3DNone commit_throttle=3DNone =20 for path in [node1_path, node2_path, node3_path, node4_path]: - assert qemu_img('create', '-f', iotests.imgfmt, path, '64M') = =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, path, '64M') =20 if write_to_stream_node: # This is what (most of the time) makes commit finish diff --git a/tests/qemu-iotests/310 b/tests/qemu-iotests/310 index 33c34118694..4e6d70e5ac6 100755 --- a/tests/qemu-iotests/310 +++ b/tests/qemu-iotests/310 @@ -43,15 +43,15 @@ with iotests.FilePath('base.img') as base_img_path, \ log('--- Setting up images ---') log('') =20 - assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') = =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') =3D=3D 0 assert qemu_io_silent(base_img_path, '-c', 'write -P 1 3M 1M') =3D=3D 0 - assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, - '-F', iotests.imgfmt, mid_img_path) =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, + '-F', iotests.imgfmt, mid_img_path) assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 2M 1M') =3D=3D 0 assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 4M 1M') =3D=3D 0 - assert qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path, - '-F', iotests.imgfmt, top_img_path) =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path, + '-F', iotests.imgfmt, top_img_path) assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') =3D=3D 0 =20 # 0 1 2 3 4 @@ -105,8 +105,8 @@ with iotests.FilePath('base.img') as base_img_path, \ log('') =20 # Detach backing to check that we can read the data from the top level= now - assert qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt, - top_img_path) =3D=3D 0 + qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt, + top_img_path) =20 assert qemu_io_silent(top_img_path, '-c', 'read -P 0 0 1M') =3D=3D 0 assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') =3D=3D 0 diff --git a/tests/qemu-iotests/tests/block-status-cache b/tests/qemu-iotes= ts/tests/block-status-cache index 6fa10bb8f8a..40e648e251a 100755 --- a/tests/qemu-iotests/tests/block-status-cache +++ b/tests/qemu-iotests/tests/block-status-cache @@ -35,8 +35,7 @@ nbd_sock =3D os.path.join(iotests.sock_dir, 'nbd.sock') class TestBscWithNbd(iotests.QMPTestCase): def setUp(self) -> None: """Just create an empty image with a read-only NBD server on it""" - assert qemu_img_create('-f', iotests.imgfmt, test_img, - str(image_size)) =3D=3D 0 + qemu_img_create('-f', iotests.imgfmt, test_img, str(image_size)) =20 # Pass --allocation-depth to enable the qemu:allocation-depth cont= ext, # which we are going to query to provoke a block-status inquiry wi= th diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/t= ests/image-fleecing index a58b5a17816..ac8f19e5062 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -53,8 +53,8 @@ def do_test(use_cbw, base_img_path, fleece_img_path, nbd_= sock_path, vm): log('--- Setting up images ---') log('') =20 - assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') = =3D=3D 0 - assert qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') =3D= =3D 0 + qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') + qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') =20 for p in patterns: qemu_io('-f', iotests.imgfmt, diff --git a/tests/qemu-iotests/tests/mirror-ready-cancel-error b/tests/qem= u-iotests/tests/mirror-ready-cancel-error index 770ffca3793..1d0e333b5ef 100755 --- a/tests/qemu-iotests/tests/mirror-ready-cancel-error +++ b/tests/qemu-iotests/tests/mirror-ready-cancel-error @@ -31,10 +31,8 @@ target =3D os.path.join(iotests.test_dir, 'target.img') =20 class TestMirrorReadyCancelError(iotests.QMPTestCase): def setUp(self) -> None: - assert iotests.qemu_img_create('-f', iotests.imgfmt, source, - str(image_size)) =3D=3D 0 - assert iotests.qemu_img_create('-f', iotests.imgfmt, target, - str(image_size)) =3D=3D 0 + iotests.qemu_img_create('-f', iotests.imgfmt, source, str(image_si= ze)) + iotests.qemu_img_create('-f', iotests.imgfmt, target, str(image_si= ze)) =20 # Ensure that mirror will copy something before READY so the # target format layer will forward the pre-READY flush to its diff --git a/tests/qemu-iotests/tests/mirror-top-perms b/tests/qemu-iotests= /tests/mirror-top-perms index b5849978c41..6ac8d5efccb 100755 --- a/tests/qemu-iotests/tests/mirror-top-perms +++ b/tests/qemu-iotests/tests/mirror-top-perms @@ -34,8 +34,7 @@ source =3D os.path.join(iotests.test_dir, 'source.img') =20 class TestMirrorTopPerms(iotests.QMPTestCase): def setUp(self): - assert qemu_img('create', '-f', iotests.imgfmt, source, - str(image_size)) =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, source, str(image_size)) self.vm =3D iotests.VM() self.vm.add_drive(source) self.vm.add_blockdev(f'null-co,node-name=3Dnull,size=3D{image_size= }') diff --git a/tests/qemu-iotests/tests/remove-bitmap-from-backing b/tests/qe= mu-iotests/tests/remove-bitmap-from-backing index 3c397b08ea4..fee31413400 100755 --- a/tests/qemu-iotests/tests/remove-bitmap-from-backing +++ b/tests/qemu-iotests/tests/remove-bitmap-from-backing @@ -27,11 +27,11 @@ iotests.script_initialize(supported_fmts=3D['qcow2'], top, base =3D iotests.file_path('top', 'base') size =3D '1M' =20 -assert qemu_img_create('-f', iotests.imgfmt, base, size) =3D=3D 0 -assert qemu_img_create('-f', iotests.imgfmt, '-b', base, - '-F', iotests.imgfmt, top, size) =3D=3D 0 +qemu_img_create('-f', iotests.imgfmt, base, size) +qemu_img_create('-f', iotests.imgfmt, '-b', base, + '-F', iotests.imgfmt, top, size) =20 -assert qemu_img('bitmap', '--add', base, 'bitmap0') =3D=3D 0 +qemu_img('bitmap', '--add', base, 'bitmap0') # Just assert that our method of checking bitmaps in the image works. assert 'bitmaps' in qemu_img_pipe('info', base) =20 diff --git a/tests/qemu-iotests/tests/stream-error-on-reset b/tests/qemu-io= tests/tests/stream-error-on-reset index 7eaedb24d7b..389ae822b8b 100755 --- a/tests/qemu-iotests/tests/stream-error-on-reset +++ b/tests/qemu-iotests/tests/stream-error-on-reset @@ -54,9 +54,9 @@ class TestStreamErrorOnReset(QMPTestCase): to it will result in an error - top image is attached to a virtio-scsi device """ - assert qemu_img_create('-f', imgfmt, base, str(image_size)) =3D=3D= 0 + qemu_img_create('-f', imgfmt, base, str(image_size)) assert qemu_io_silent('-c', f'write 0 {data_size}', base) =3D=3D 0 - assert qemu_img_create('-f', imgfmt, top, str(image_size)) =3D=3D 0 + qemu_img_create('-f', imgfmt, top, str(image_size)) =20 self.vm =3D iotests.VM() self.vm.add_args('-accel', 'tcg') # Make throttling work properly --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645483419483986.7837531307568; Mon, 21 Feb 2022 14:43:39 -0800 (PST) Received: from localhost ([::1]:40000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHP8-0004Pv-Fv for importer@patchew.org; Mon, 21 Feb 2022 17:43:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGI-00084C-KB for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24430) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGG-000891-Ex for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:30 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-453-nnwWZHlEMVqkejCRyiyb0A-1; Mon, 21 Feb 2022 17:34:23 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 506522F4C; Mon, 21 Feb 2022 22:34:22 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41A6A1038AAF; Mon, 21 Feb 2022 22:34:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gBbYUbNWW5IZZx1rnuvbPVZ5RwTIhLfYN+YIIxffZ9A=; b=ZLPY7+lb1/wgeFLk08z80f/jMnvPS/+MgrOh+rEieDODUWhPeNdjO8Oigqf4TeISeyFRqv K9YH5A/5dsr1AG5Y0qGweS3lJq1dMHI68sKIUA1GaUQ/rWE7NeC4nvap4gPiy2S/jYAMkd piuWRy5i/U57NrUCfesNf2AKf4lvsxo= X-MC-Unique: nnwWZHlEMVqkejCRyiyb0A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 04/18] iotests: make qemu_img raise on non-zero rc by default Date: Mon, 21 Feb 2022 17:33:59 -0500 Message-Id: <20220221223413.2123003-5-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483420566100001 Content-Type: text/plain; charset="utf-8" re-write qemu_img() as a function that will by default raise a VerboseProcessException (extended from CalledProcessException) on non-zero return codes. This will produce a stack trace that will show the command line arguments and return code from the failed process run. Users that want something more flexible (there appears to be only one) can use check=3DFalse and manage the return themselves. However, when the return code is negative, the Exception will be raised no matter what. This is done under the belief that there's no legitimate reason, even in negative tests, to see a crash from a tool. Signed-off-by: John Snow --- tests/qemu-iotests/257 | 8 ++++-- tests/qemu-iotests/iotests.py | 53 +++++++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257 index fb5359c581e..e7e7a2317e3 100755 --- a/tests/qemu-iotests/257 +++ b/tests/qemu-iotests/257 @@ -241,11 +241,13 @@ def compare_images(image, reference, baseimg=3DNone, = expected_match=3DTrue): expected_ret =3D 0 if expected_match else 1 if baseimg: qemu_img("rebase", "-u", "-b", baseimg, '-F', iotests.imgfmt, imag= e) - ret =3D qemu_img("compare", image, reference) + + sub =3D qemu_img("compare", image, reference, check=3DFalse) + log('qemu_img compare "{:s}" "{:s}" =3D=3D> {:s}, {:s}'.format( image, reference, - "Identical" if ret =3D=3D 0 else "Mismatch", - "OK!" if ret =3D=3D expected_ret else "ERROR!"), + "Identical" if sub.returncode =3D=3D 0 else "Mismatch", + "OK!" if sub.returncode =3D=3D expected_ret else "ERROR!"), filters=3D[iotests.filter_testfiles]) =20 def test_bitmap_sync(bsync_mode, msync_mode=3D'bitmap', failure=3DNone): diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 5617f991da7..546e5cb671b 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -249,9 +249,49 @@ def qemu_img_pipe_and_status(*args: str) -> Tuple[str,= int]: return qemu_tool_pipe_and_status('qemu-img', full_args, drop_successful_output=3Dis_create) =20 -def qemu_img(*args: str) -> int: - '''Run qemu-img and return the exit code''' - return qemu_img_pipe_and_status(*args)[1] +def qemu_img(*args: str, check: bool =3D True, combine_stdio: bool =3D True + ) -> subprocess.CompletedProcess[str]: + """ + Run qemu_img and return the status code and console output. + + This function always prepends QEMU_IMG_OPTIONS and may further alter + the args for 'create' commands. + + :param args: command-line arguments to qemu-img. + :param check: Enforce a return code of zero. + :param combine_stdio: set to False to keep stdout/stderr separated. + + :raise VerboseProcessError: + When the return code is negative, or on any non-zero exit code + when 'check=3DTrue' was provided (the default). This exception has + 'stdout', 'stderr', and 'returncode' properties that may be + inspected to show greater detail. If this exception is not + handled, the command-line, return code, and all console output + will be included at the bottom of the stack trace. + + :return: a CompletedProcess. This object has args, returncode, and + stdout properties. If streams are not combined, it will also + have a stderr property. + """ + full_args =3D qemu_img_args + qemu_img_create_prepare_args(list(args)) + + subp =3D subprocess.run( + full_args, + stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.STDOUT if combine_stdio else subprocess.PIPE, + universal_newlines=3DTrue, + check=3DFalse + ) + + if check and subp.returncode or (subp.returncode < 0): + raise VerboseProcessError( + subp.returncode, full_args, + output=3Dsubp.stdout, + stderr=3Dsubp.stderr, + ) + + return subp + =20 def ordered_qmp(qmsg, conv_keys=3DTrue): # Dictionaries are not ordered prior to 3.6, therefore: @@ -266,7 +306,7 @@ def ordered_qmp(qmsg, conv_keys=3DTrue): return od return qmsg =20 -def qemu_img_create(*args): +def qemu_img_create(*args: str) -> subprocess.CompletedProcess[str]: return qemu_img('create', *args) =20 def qemu_img_measure(*args): @@ -469,8 +509,9 @@ def qemu_nbd_popen(*args): =20 def compare_images(img1, img2, fmt1=3Dimgfmt, fmt2=3Dimgfmt): '''Return True if two image files are identical''' - return qemu_img('compare', '-f', fmt1, - '-F', fmt2, img1, img2) =3D=3D 0 + res =3D qemu_img('compare', '-f', fmt1, + '-F', fmt2, img1, img2, check=3DFalse) + return res.returncode =3D=3D 0 =20 def create_image(name, size): '''Create a fully-allocated raw image with sector markers''' --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645483235887657.6930837863946; Mon, 21 Feb 2022 14:40:35 -0800 (PST) Received: from localhost ([::1]:33516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHMA-0008OX-Jp for importer@patchew.org; Mon, 21 Feb 2022 17:40:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGG-0007wY-EU for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:50946) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGE-00088B-Ik for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:28 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-457-uVzO3uUdOCeyNr11qOG1Jw-1; Mon, 21 Feb 2022 17:34:24 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 80783814246; Mon, 21 Feb 2022 22:34:23 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 767481038AAF; Mon, 21 Feb 2022 22:34:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482866; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DfPoBDBQIxQ64A+CX9kGUZoFtNLHvl7l7IlzedOfndY=; b=fyaydCK8f3eqj+jmFcMtKnrmgHqZQQHGTicsTw2JtRfyGC/kiAPgMhP6PvgJZcVJlCi/so 2ESUHz5RALoRtxxB6OeWT/SKL8ZBd55XiI6hts85hcJof3f/SDVjcKQA40UpHO7yx/A4a+ AvQvpfLsHWKHvRe955yeF9/nQUUoOlY= X-MC-Unique: uVzO3uUdOCeyNr11qOG1Jw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 05/18] iotests: fortify compare_images() against crashes Date: Mon, 21 Feb 2022 17:34:00 -0500 Message-Id: <20220221223413.2123003-6-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483237445100003 Content-Type: text/plain; charset="utf-8" Make this helper function a little stricter about what it allows by default. If qemu_img returns some exit code that implies it didn't actually perform the comparison, treat that as an exceptional circumstance and force the caller to be aware of the peril. Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 546e5cb671b..24765de2e27 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -507,11 +507,22 @@ def qemu_nbd_popen(*args): p.kill() p.wait() =20 -def compare_images(img1, img2, fmt1=3Dimgfmt, fmt2=3Dimgfmt): - '''Return True if two image files are identical''' - res =3D qemu_img('compare', '-f', fmt1, - '-F', fmt2, img1, img2, check=3DFalse) - return res.returncode =3D=3D 0 +def compare_images(img1: str, img2: str, + fmt1: str =3D imgfmt, fmt2: str =3D imgfmt) -> bool: + """ + Compare two images with QEMU_IMG; return True if they are identical. + + :raise CalledProcessError: + when qemu-img crashes or returns a status code of anything other + than 0 (identical) or 1 (different). + """ + try: + qemu_img('compare', '-f', fmt1, '-F', fmt2, img1, img2) + return True + except subprocess.CalledProcessError as exc: + if exc.returncode =3D=3D 1: + return False + raise =20 def create_image(name, size): '''Create a fully-allocated raw image with sector markers''' --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645483145525335.07767829662816; Mon, 21 Feb 2022 14:39:05 -0800 (PST) Received: from localhost ([::1]:56208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHKk-0004he-5A for importer@patchew.org; Mon, 21 Feb 2022 17:39:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGH-00081A-QJ for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45305) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGF-00088W-OC for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:29 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-272-PK4RKkOKPPq4iyQ10zhW1A-1; Mon, 21 Feb 2022 17:34:25 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B4F891006AA0; Mon, 21 Feb 2022 22:34:24 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id A80801038AAF; Mon, 21 Feb 2022 22:34:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482866; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dxwUROcozBuy9pQwmJ/gNNr5A1jRd8gT5aI4WeCLmO0=; b=PZtTkKTRVPSyYCPtKz7U9ykGAaiHbRBbSR8X9Z4oSyU9J/8r9llC1wAMQ8V5kcnPWFD1W6 4q3dpf1Bfi0vHmiC2IScyudoDPq8pc/Oid/r1+6QNFaAeKBDMJTmoZo/lcnRFIaPEXKGmz rfTo5AD8wEN0Rjnxjg6EZ0eZGKqrpsM= X-MC-Unique: PK4RKkOKPPq4iyQ10zhW1A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 06/18] iotests: add qemu_img_json() Date: Mon, 21 Feb 2022 17:34:01 -0500 Message-Id: <20220221223413.2123003-7-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483163662100001 Content-Type: text/plain; charset="utf-8" A little helper built on top of qemu_img() that tries to pull a valid JSON document out of the stdout stream. In the event that the return code is negative (the program crashed), or the code is greater than zero and did not produce valid JSON output, the VerboseProcessError raised by qemu_img is re-raised instead. In the event that the return code is zero but we can't parse valid JSON, allow the JSON deserialization error to be raised. Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 24765de2e27..1e6947b893b 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -309,6 +309,41 @@ def ordered_qmp(qmsg, conv_keys=3DTrue): def qemu_img_create(*args: str) -> subprocess.CompletedProcess[str]: return qemu_img('create', *args) =20 +def qemu_img_json(*args: str) -> Any: + """ + Run qemu-img and return its output as deserialized JSON. + + :raise CalledProcessError: + When qemu-img crashes, or returns a non-zero exit code without + producing a valid JSON document to stdout. + :raise JSONDecoderError: + When qemu-img returns 0, but failed to produce a valid JSON docume= nt. + """ + json_data =3D ... # json.loads can legitimately return 'None'. + + try: + res =3D qemu_img(*args, combine_stdio=3DFalse) + except subprocess.CalledProcessError as exc: + # Terminated due to signal. Don't bother. + if exc.returncode < 0: + raise + + # Commands like 'check' can return failure (exit codes 2 and 3) + # to indicate command completion, but with errors found. For + # multi-command flexibility, ignore the exact error codes and + # *try* to load JSON. + try: + json_data =3D json.loads(exc.stdout) + except json.JSONDecodeError: + pass # Nope. This thing is toast. + + if json_data is ...: + raise + + if json_data is ...: + json_data =3D json.loads(res.stdout) + return json_data + def qemu_img_measure(*args): return json.loads(qemu_img_pipe("measure", "--output", "json", *args)) =20 --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645483395822999.980377181233; Mon, 21 Feb 2022 14:43:15 -0800 (PST) Received: from localhost ([::1]:38248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHOj-0003Ef-G6 for importer@patchew.org; Mon, 21 Feb 2022 17:43:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGK-0008C0-DS for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:49827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGI-00089b-Mk for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:32 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-193-kALe-HRCMOWamuyyrLA1yw-1; Mon, 21 Feb 2022 17:34:27 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EAA2E801ADB; Mon, 21 Feb 2022 22:34:25 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC2051038AAF; Mon, 21 Feb 2022 22:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482870; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wLfz01wC3qkv7LcbmuJF6x6zBmJu3obwnjhJSdnK5+M=; b=ec4sRwK2vDNvL8rOD3TBoYQxmSsGC+no9h7qerCwZZXfZleQ81MDKcyBeDmnQYsh1hL7pQ 88Lvielv39uDUGqg9svUi4EK/h7fozwRSMvR0qzjp6UpOjS/ZHLDARyLjt8y/BJzAJDWjx /7x2DZ1KvWcn+gCwz8kXl43aapVe3kk= X-MC-Unique: kALe-HRCMOWamuyyrLA1yw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 07/18] iotests: use qemu_img_json() when applicable Date: Mon, 21 Feb 2022 17:34:02 -0500 Message-Id: <20220221223413.2123003-8-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483396624100001 Content-Type: text/plain; charset="utf-8" These functions should now give better crash information when something unexpected happens. Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 1e6947b893b..fc0d054e129 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -344,11 +344,11 @@ def qemu_img_json(*args: str) -> Any: json_data =3D json.loads(res.stdout) return json_data =20 -def qemu_img_measure(*args): - return json.loads(qemu_img_pipe("measure", "--output", "json", *args)) +def qemu_img_measure(*args: str) -> Any: + return qemu_img_json("measure", "--output", "json", *args) =20 -def qemu_img_check(*args): - return json.loads(qemu_img_pipe("check", "--output", "json", *args)) +def qemu_img_check(*args: str) -> Any: + return qemu_img_json("check", "--output", "json", *args) =20 def qemu_img_pipe(*args: str) -> str: '''Run qemu-img and return its output''' --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645483559540525.3539972890302; Mon, 21 Feb 2022 14:45:59 -0800 (PST) Received: from localhost ([::1]:46478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHRQ-0000Im-4G for importer@patchew.org; Mon, 21 Feb 2022 17:46:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGK-0008Ay-59 for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:22883) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGI-00089V-HD for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:31 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-139-9RD5TMQmOGq0qT14QSl6eg-1; Mon, 21 Feb 2022 17:34:28 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B5681801ADB; Mon, 21 Feb 2022 22:34:27 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FDB01038AAF; Mon, 21 Feb 2022 22:34:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482870; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eRGWTtM642m0e5QACba7X8RwQo5OUweIs6wRdmIsKA8=; b=TY5A9riP0Nt/7cZiBd8CnpI+Ie3jkts+LpZtlJqNZCbWElsI40hHGU8gwZXr5O7pq138vJ SHlnzQCX+GfQNamVubl80M3tz3RsoV5xCJ1SXqUebdivaF4DVR6bQUCSYnCUbj0fnLdI90 EbAtU1A1B38yRu0T/XNaVHejNmMFW90= X-MC-Unique: 9RD5TMQmOGq0qT14QSl6eg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 08/18] iotests: add qemu_img_info() Date: Mon, 21 Feb 2022 17:34:03 -0500 Message-Id: <20220221223413.2123003-9-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483584969100001 Content-Type: text/plain; charset="utf-8" Add qemu_img_info() by analogy with qemu_img_{measure,check}. Modify image_size() to use this function instead. Signed-off-by: John Snow --- tests/qemu-iotests/065 | 5 ++--- tests/qemu-iotests/242 | 5 ++--- tests/qemu-iotests/iotests.py | 12 ++++++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065 index f7c1b68dadb..9466ce7df4d 100755 --- a/tests/qemu-iotests/065 +++ b/tests/qemu-iotests/065 @@ -24,7 +24,7 @@ import os import re import json import iotests -from iotests import qemu_img, qemu_img_pipe +from iotests import qemu_img, qemu_img_info, qemu_img_pipe import unittest =20 test_img =3D os.path.join(iotests.test_dir, 'test.img') @@ -49,8 +49,7 @@ class TestQemuImgInfo(TestImageInfoSpecific): human_compare =3D None =20 def test_json(self): - data =3D json.loads(qemu_img_pipe('info', '--output=3Djson', test_= img)) - data =3D data['format-specific'] + data =3D qemu_img_info(test_img)['format-specific'] self.assertEqual(data['type'], iotests.imgfmt) self.assertEqual(data['data'], self.json_compare) =20 diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242 index 96a30152b04..547bf382e39 100755 --- a/tests/qemu-iotests/242 +++ b/tests/qemu-iotests/242 @@ -22,7 +22,7 @@ import iotests import json import struct -from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \ +from iotests import qemu_img_create, qemu_io, qemu_img_info, \ file_path, img_info_log, log, filter_qemu_io =20 iotests.script_initialize(supported_fmts=3D['qcow2'], @@ -39,8 +39,7 @@ flag_offset =3D 0x5000f def print_bitmap(extra_args): log('qemu-img info dump:\n') img_info_log(disk, extra_args=3Dextra_args) - result =3D json.loads(qemu_img_pipe('info', '--force-share', - '--output=3Djson', disk)) + result =3D qemu_img_info('--force-share', disk) if 'bitmaps' in result['format-specific']['data']: bitmaps =3D result['format-specific']['data']['bitmaps'] log('The same bitmaps in JSON format:') diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index fc0d054e129..df143ecec73 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -350,6 +350,9 @@ def qemu_img_measure(*args: str) -> Any: def qemu_img_check(*args: str) -> Any: return qemu_img_json("check", "--output", "json", *args) =20 +def qemu_img_info(*args: str) -> Any: + return qemu_img_json('info', "--output", "json", *args) + def qemu_img_pipe(*args: str) -> str: '''Run qemu-img and return its output''' return qemu_img_pipe_and_status(*args)[0] @@ -568,10 +571,11 @@ def create_image(name, size): file.write(sector) i =3D i + 512 =20 -def image_size(img): - '''Return image's virtual size''' - r =3D qemu_img_pipe('info', '--output=3Djson', '-f', imgfmt, img) - return json.loads(r)['virtual-size'] +def image_size(img: str) -> int: + """Return image's virtual size""" + value =3D qemu_img_info('-f', imgfmt, img)['virtual-size'] + assert isinstance(value, int) + return value =20 def is_str(val): return isinstance(val, str) --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164548373710188.69396125019; Mon, 21 Feb 2022 14:48:57 -0800 (PST) Received: from localhost ([::1]:53088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHUF-0004pd-UK for importer@patchew.org; Mon, 21 Feb 2022 17:48:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGV-0000Ue-PS for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44760) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGU-0008C9-8Z for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:43 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-258-hGM_aLvUOyiTLdSm7X938w-1; Mon, 21 Feb 2022 17:34:38 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 92060814243; Mon, 21 Feb 2022 22:34:37 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDD3C1038AAF; Mon, 21 Feb 2022 22:34:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s6OJFVxOFWitfwLFi3aEol6Hg7IpcKBFDxQTcNUfTfw=; b=JhiId9fa/bSQWDV9jI2jpR7rIqiO7DW6jPccFyAAMrhdtkBrQrc3cYV077V9fbAHvtMt3w /hLL+J4R2Lqi5mUJxkEiD5U7jAisVEMWN9U7xP/P04xJ3mN6Ddo0uXF6RhuUy1cKH7WmmE O79wpxD74HSkfXbOVSfL2S0EAgh0Km8= X-MC-Unique: hGM_aLvUOyiTLdSm7X938w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 09/18] iotests: remove-bitmap-from-backing: use qemu_img_info() Date: Mon, 21 Feb 2022 17:34:04 -0500 Message-Id: <20220221223413.2123003-10-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483738459100003 Content-Type: text/plain; charset="utf-8" Remove two more usages of qemu_img_pipe(). Signed-off-by: John Snow --- tests/qemu-iotests/tests/remove-bitmap-from-backing | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/tests/remove-bitmap-from-backing b/tests/qe= mu-iotests/tests/remove-bitmap-from-backing index fee31413400..15be32dcb96 100755 --- a/tests/qemu-iotests/tests/remove-bitmap-from-backing +++ b/tests/qemu-iotests/tests/remove-bitmap-from-backing @@ -19,7 +19,7 @@ # =20 import iotests -from iotests import log, qemu_img_create, qemu_img, qemu_img_pipe +from iotests import log, qemu_img_create, qemu_img, qemu_img_info =20 iotests.script_initialize(supported_fmts=3D['qcow2'], unsupported_imgopts=3D['compat']) @@ -33,7 +33,7 @@ qemu_img_create('-f', iotests.imgfmt, '-b', base, =20 qemu_img('bitmap', '--add', base, 'bitmap0') # Just assert that our method of checking bitmaps in the image works. -assert 'bitmaps' in qemu_img_pipe('info', base) +assert 'bitmaps' in qemu_img_info(base)['format-specific']['data'] =20 vm =3D iotests.VM().add_drive(top, 'backing.node-name=3Dbase') vm.launch() @@ -68,5 +68,5 @@ if result !=3D {'return': {}}: =20 vm.shutdown() =20 -if 'bitmaps' in qemu_img_pipe('info', base): +if 'bitmaps' in qemu_img_info(base)['format-specific']['data']: log('ERROR: Bitmap is still in the base image') --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645483559836543.4128822290272; Mon, 21 Feb 2022 14:45:59 -0800 (PST) Received: from localhost ([::1]:46508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHRQ-0000Kc-F4 for importer@patchew.org; Mon, 21 Feb 2022 17:46:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGX-0000bE-Lr for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59494) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGV-0008CO-Jn for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:45 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-304-mLw2FuJxOOyzXMtFWes4QA-1; Mon, 21 Feb 2022 17:34:39 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6D241091DA2; Mon, 21 Feb 2022 22:34:38 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA7F81038AAF; Mon, 21 Feb 2022 22:34:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482883; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4Bj0jFVZIGJVu40H0YiuDQMLocLIVPRCRpQjAqO6pJU=; b=JwqplEg1AEPtB4EBjJ03QFLRdQ1HxVwAgrG+tLhMRwuH0LLUe/CWFC3wzrfyj8u393QQ5N //jdYx1klny0b3RJoVsuLD33rBApM17Y/5W5/82b66EF2z5nk71aPPQ+iFXMZa2/mWVE2w XDZBzb8XynpbsLLcC9hFNSbpXc7o/jg= X-MC-Unique: mLw2FuJxOOyzXMtFWes4QA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 10/18] iotests: add qemu_img_map() function Date: Mon, 21 Feb 2022 17:34:05 -0500 Message-Id: <20220221223413.2123003-11-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483584977100002 Content-Type: text/plain; charset="utf-8" By analogy with qemu_img_{measure, check, info}. Replace calls to qemu_img_pipe('map', '--output=3Djson', ...) with the new function. Signed-off-by: John Snow --- tests/qemu-iotests/041 | 5 ++--- tests/qemu-iotests/211 | 6 +++--- tests/qemu-iotests/iotests.py | 3 +++ tests/qemu-iotests/tests/block-status-cache | 11 ++++------- tests/qemu-iotests/tests/parallels-read-bitmap | 6 ++---- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index db9f5dc540e..3e16acee567 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -24,7 +24,7 @@ import os import re import json import iotests -from iotests import qemu_img, qemu_img_pipe, qemu_io +from iotests import qemu_img, qemu_img_map, qemu_io =20 backing_img =3D os.path.join(iotests.test_dir, 'backing.img') target_backing_img =3D os.path.join(iotests.test_dir, 'target-backing.img') @@ -1360,8 +1360,7 @@ class TestFilters(iotests.QMPTestCase): =20 self.vm.qmp('blockdev-del', node_name=3D'target') =20 - target_map =3D qemu_img_pipe('map', '--output=3Djson', target_img) - target_map =3D json.loads(target_map) + target_map =3D qemu_img_map(target_img) =20 assert target_map[0]['start'] =3D=3D 0 assert target_map[0]['length'] =3D=3D 512 * 1024 diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211 index f52cadade12..1a3b4596c80 100755 --- a/tests/qemu-iotests/211 +++ b/tests/qemu-iotests/211 @@ -59,7 +59,7 @@ with iotests.FilePath('t.vdi') as disk_path, \ vm.shutdown() =20 iotests.img_info_log(disk_path) - iotests.log(iotests.qemu_img_pipe('map', '--output=3Djson', disk_path)) + iotests.log(iotests.qemu_img_map(disk_path)) =20 # # Successful image creation (explicit defaults) @@ -83,7 +83,7 @@ with iotests.FilePath('t.vdi') as disk_path, \ vm.shutdown() =20 iotests.img_info_log(disk_path) - iotests.log(iotests.qemu_img_pipe('map', '--output=3Djson', disk_path)) + iotests.log(iotests.qemu_img_map(disk_path)) =20 # # Successful image creation (with non-default options) @@ -107,7 +107,7 @@ with iotests.FilePath('t.vdi') as disk_path, \ vm.shutdown() =20 iotests.img_info_log(disk_path) - iotests.log(iotests.qemu_img_pipe('map', '--output=3Djson', disk_path)) + iotests.log(iotests.qemu_img_map(disk_path)) =20 # # Invalid BlockdevRef diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index df143ecec73..cbb3af71523 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -353,6 +353,9 @@ def qemu_img_check(*args: str) -> Any: def qemu_img_info(*args: str) -> Any: return qemu_img_json('info', "--output", "json", *args) =20 +def qemu_img_map(*args: str) -> Any: + return qemu_img_json('map', "--output", "json", *args) + def qemu_img_pipe(*args: str) -> str: '''Run qemu-img and return its output''' return qemu_img_pipe_and_status(*args)[0] diff --git a/tests/qemu-iotests/tests/block-status-cache b/tests/qemu-iotes= ts/tests/block-status-cache index 40e648e251a..5a7bc2c1493 100755 --- a/tests/qemu-iotests/tests/block-status-cache +++ b/tests/qemu-iotests/tests/block-status-cache @@ -22,7 +22,7 @@ import os import signal import iotests -from iotests import qemu_img_create, qemu_img_pipe, qemu_nbd +from iotests import qemu_img_create, qemu_img_map, qemu_nbd =20 =20 image_size =3D 1 * 1024 * 1024 @@ -76,8 +76,7 @@ class TestBscWithNbd(iotests.QMPTestCase): # to allocate the first sector to facilitate alignment probing), a= nd # then the rest to be zero. The BSC will thus contain (if anythin= g) # one range covering the first sector. - map_pre =3D qemu_img_pipe('map', '--output=3Djson', '--image-opts', - nbd_img_opts) + map_pre =3D qemu_img_map('--image-opts', nbd_img_opts) =20 # qemu:allocation-depth maps for want_zero=3Dfalse. # want_zero=3Dfalse should (with the file driver, which the server= is @@ -111,14 +110,12 @@ class TestBscWithNbd(iotests.QMPTestCase): # never loop too many times here. for _ in range(2): # (Ignore the result, this is just to contaminate the cache) - qemu_img_pipe('map', '--output=3Djson', '--image-opts', - nbd_img_opts_alloc_depth) + qemu_img_map('--image-opts', nbd_img_opts_alloc_depth) =20 # Now let's see whether the cache reports everything as data, or # whether we get correct information (i.e. the same as we got on o= ur # first attempt). - map_post =3D qemu_img_pipe('map', '--output=3Djson', '--image-opts= ', - nbd_img_opts) + map_post =3D qemu_img_map('--image-opts', nbd_img_opts) =20 if map_pre !=3D map_post: print('ERROR: Map information differs before and after queryin= g ' + diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap b/tests/qemu-io= tests/tests/parallels-read-bitmap index af6b9c5db3e..38ab5fa5b28 100755 --- a/tests/qemu-iotests/tests/parallels-read-bitmap +++ b/tests/qemu-iotests/tests/parallels-read-bitmap @@ -18,9 +18,8 @@ # along with this program. If not, see . # =20 -import json import iotests -from iotests import qemu_nbd_popen, qemu_img_pipe, log, file_path +from iotests import qemu_nbd_popen, qemu_img_map, log, file_path =20 iotests.script_initialize(supported_fmts=3D['parallels']) =20 @@ -36,8 +35,7 @@ iotests.unarchive_sample_image('parallels-with-bitmap', d= isk) =20 with qemu_nbd_popen('--read-only', f'--socket=3D{nbd_sock}', f'--bitmap=3D{bitmap}', '-f', iotests.imgfmt, disk): - out =3D qemu_img_pipe('map', '--output=3Djson', '--image-opts', nbd_op= ts) - chunks =3D json.loads(out) + chunks =3D qemu_img_map('--image-opts', nbd_opts) cluster =3D 64 * 1024 =20 log('dirty clusters (cluster size is 64K):') --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645483559277273.50985478272764; Mon, 21 Feb 2022 14:45:59 -0800 (PST) Received: from localhost ([::1]:46350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHRO-0000Dm-5E for importer@patchew.org; Mon, 21 Feb 2022 17:45:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGZ-0000i2-82 for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37111) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGW-0008Co-JW for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:46 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-418-jTozLkwxNGOJ9uB-abYJ5w-1; Mon, 21 Feb 2022 17:34:41 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0753E814243; Mon, 21 Feb 2022 22:34:40 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE7461038AAF; Mon, 21 Feb 2022 22:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L7i/fRy92bqqFDBLPwmXaVoukAs5FDkkysp3wBfMYyo=; b=fz+164AEKTAwtj/FrKU6hSEG6iOoauijzWShUXQa5J+kVggoSGopubEnMUxJDBo3nYhU95 NX5kyiIHbZQzZ8pAinxneRGFBNlVy5lvpOhzZRkk5xjKNe2X05HQweAR6X8/e82gK1I3ZB fztw9CA3gQcCSCfk6qHnmZlcwEFEynM= X-MC-Unique: jTozLkwxNGOJ9uB-abYJ5w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 11/18] iotests: change supports_quorum to use qemu_img Date: Mon, 21 Feb 2022 17:34:06 -0500 Message-Id: <20220221223413.2123003-12-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483561287100001 Content-Type: text/plain; charset="utf-8" Similar to other recent changes: use the qemu_img invocation that supports throwing loud, nasty exceptions when it fails for surprising reasons. (Why would "--help" ever fail? I don't know, but consistency is like a well-manicured bonsai.) Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index cbb3af71523..882d3e0214a 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1428,8 +1428,8 @@ def _verify_imgopts(unsupported: Sequence[str] =3D ()= ) -> None: notrun(f'not suitable for this imgopts: {imgopts}') =20 =20 -def supports_quorum(): - return 'quorum' in qemu_img_pipe('--help') +def supports_quorum() -> bool: + return 'quorum' in qemu_img('--help').stdout =20 def verify_quorum(): '''Skip test suite if quorum support is not available''' --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164548373362434.169500295447165; Mon, 21 Feb 2022 14:48:53 -0800 (PST) Received: from localhost ([::1]:52924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHUC-0004jH-3s for importer@patchew.org; Mon, 21 Feb 2022 17:48:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGa-0000lQ-AS for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40953) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGX-0008DE-VX for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:47 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-207-m4EqkMIGNmamXJNdL6pazA-1; Mon, 21 Feb 2022 17:34:42 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C0E9814246; Mon, 21 Feb 2022 22:34:41 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EB981038AAF; Mon, 21 Feb 2022 22:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l+Gz6KY16YcGc4ARd3IXASz1KLMf4BRroWoEehnAAkc=; b=DYdk3jWLW18CrFLMFKCQNcrwA0mGxhP0gdhoNxOJIoCdP3p4FwlsCjPw37KtwBfXs6pQZ5 128MXTWLOAT08pue+AxiDRU+0/+7arL56GmWqEBGZ9roJ7UBsIKFbPzHy8RZQ1VDdd83bQ uH7sfqXt6cqlABBaxP1rFvDPA0llaxo= X-MC-Unique: m4EqkMIGNmamXJNdL6pazA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 12/18] iotests: replace unchecked calls to qemu_img_pipe() Date: Mon, 21 Feb 2022 17:34:07 -0500 Message-Id: <20220221223413.2123003-13-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483734918100001 Content-Type: text/plain; charset="utf-8" qemu_img_pipe() discards the return code in favor of returning just the output. Some tests using this function don't save, log, or check the output either, though. Replace those calls to a checked version as appropriate. Tests affected are 194, 202, 203, 234, 262, and 303. Signed-off-by: John Snow --- tests/qemu-iotests/194 | 4 ++-- tests/qemu-iotests/202 | 4 ++-- tests/qemu-iotests/203 | 4 ++-- tests/qemu-iotests/234 | 4 ++-- tests/qemu-iotests/262 | 2 +- tests/qemu-iotests/303 | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/qemu-iotests/194 b/tests/qemu-iotests/194 index e44b8df7280..68894371f51 100755 --- a/tests/qemu-iotests/194 +++ b/tests/qemu-iotests/194 @@ -33,8 +33,8 @@ with iotests.FilePath('source.img') as source_img_path, \ iotests.VM('dest') as dest_vm: =20 img_size =3D '1G' - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, source_img_path,= img_size) - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, dest_img_path, i= mg_size) + iotests.qemu_img_create('-f', iotests.imgfmt, source_img_path, img_siz= e) + iotests.qemu_img_create('-f', iotests.imgfmt, dest_img_path, img_size) =20 iotests.log('Launching VMs...') (source_vm.add_drive(source_img_path) diff --git a/tests/qemu-iotests/202 b/tests/qemu-iotests/202 index 8eb5f32d153..b784dcd791a 100755 --- a/tests/qemu-iotests/202 +++ b/tests/qemu-iotests/202 @@ -35,8 +35,8 @@ with iotests.FilePath('disk0.img') as disk0_img_path, \ iotests.VM() as vm: =20 img_size =3D '10M' - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk0_img_path, = img_size) - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk1_img_path, = img_size) + iotests.qemu_img_create('-f', iotests.imgfmt, disk0_img_path, img_size) + iotests.qemu_img_create('-f', iotests.imgfmt, disk1_img_path, img_size) =20 iotests.log('Launching VM...') vm.launch() diff --git a/tests/qemu-iotests/203 b/tests/qemu-iotests/203 index ea30e504976..ab80fd0e44a 100755 --- a/tests/qemu-iotests/203 +++ b/tests/qemu-iotests/203 @@ -33,8 +33,8 @@ with iotests.FilePath('disk0.img') as disk0_img_path, \ iotests.VM() as vm: =20 img_size =3D '10M' - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk0_img_path, = img_size) - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk1_img_path, = img_size) + iotests.qemu_img_create('-f', iotests.imgfmt, disk0_img_path, img_size) + iotests.qemu_img_create('-f', iotests.imgfmt, disk1_img_path, img_size) =20 iotests.log('Launching VM...') (vm.add_object('iothread,id=3Diothread0') diff --git a/tests/qemu-iotests/234 b/tests/qemu-iotests/234 index cb5f1753e08..a9f764bb2c6 100755 --- a/tests/qemu-iotests/234 +++ b/tests/qemu-iotests/234 @@ -34,8 +34,8 @@ with iotests.FilePath('img') as img_path, \ iotests.VM(path_suffix=3D'a') as vm_a, \ iotests.VM(path_suffix=3D'b') as vm_b: =20 - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, backing_path, '6= 4M') - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, img_path, '64M') + iotests.qemu_img_create('-f', iotests.imgfmt, backing_path, '64M') + iotests.qemu_img_create('-f', iotests.imgfmt, img_path, '64M') =20 os.mkfifo(fifo_a) os.mkfifo(fifo_b) diff --git a/tests/qemu-iotests/262 b/tests/qemu-iotests/262 index 32d69988ef7..2294fd5ecbd 100755 --- a/tests/qemu-iotests/262 +++ b/tests/qemu-iotests/262 @@ -51,7 +51,7 @@ with iotests.FilePath('img') as img_path, \ =20 vm.add_device('virtio-blk,drive=3D%s,iothread=3Diothread0' % root) =20 - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, img_path, '64M') + iotests.qemu_img_create('-f', iotests.imgfmt, img_path, '64M') =20 os.mkfifo(fifo) =20 diff --git a/tests/qemu-iotests/303 b/tests/qemu-iotests/303 index 16c2e108276..93aa5ce9b7d 100755 --- a/tests/qemu-iotests/303 +++ b/tests/qemu-iotests/303 @@ -38,7 +38,7 @@ def create_bitmap(bitmap_number, disabled): if disabled: args.append('--disable') =20 - iotests.qemu_img_pipe(*args) + iotests.qemu_img(*args) =20 =20 def write_to_disk(offset, size): --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645483140182909.9362343440415; Mon, 21 Feb 2022 14:39:00 -0800 (PST) Received: from localhost ([::1]:55948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHKc-0004WX-Uy for importer@patchew.org; Mon, 21 Feb 2022 17:38:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGa-0000m6-FH for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32119) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGY-0008DL-8I for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:48 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-544-TdGKhqzLNdeexwD6Yt76ng-1; Mon, 21 Feb 2022 17:34:43 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 715851091DA0; Mon, 21 Feb 2022 22:34:42 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 655D71038AAF; Mon, 21 Feb 2022 22:34:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WOQshHnPziXRN3DHEqr1VVyp8s3YdH2g/JeqiwGLYk4=; b=NAEK1LAMy30bcRNryMQ0+9UXF3NntMgSBkORQaRtxQe3Cyzo+8nWxZx61xs93c2YxTxAdQ cWOt/RSWxHghRrbkUfIvNerO7IQj+qnqKJewnEUlh8bxIBMfmpfC2CbetWFLq2O8jdoQOI JkvTz05CtKvX0XTDbKi6cCV916FCULw= X-MC-Unique: TdGKhqzLNdeexwD6Yt76ng-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 13/18] iotests: remove external calls to qemu_img_pipe() Date: Mon, 21 Feb 2022 17:34:08 -0500 Message-Id: <20220221223413.2123003-14-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483140992100001 Content-Type: text/plain; charset="utf-8" Several cases here rely on the knowledge that qemu_img_pipe() suppresses *all* output on a successful case when the command being issued is 'create'. 065: This call's output is inspected, but it appears as if it's expected to succeed. Replace this call with the checked qemu_img() variant instead to get better diagnostics if/when qemu-img itself fails. 149: If the check_cipher_support check activates, we'll skip the test. Otherwise, we re-raise the Exception and assert that the image creation works. 237: We are only testing blanks against the output. Remove them and use a simpler checked variant. 296: One create and one amend call. The create call is expected to always succeed, but it needs a print statement to keep the output file looking nice. The amend call is an intentional negative test; use check=3DFalse and log the output. After this patch, the only uses of qemu_img_pipe are internal to iotests.py and will be removed in subsequent patches. Signed-off-by: John Snow --- tests/qemu-iotests/065 | 4 ++-- tests/qemu-iotests/149 | 8 ++++++-- tests/qemu-iotests/237 | 3 +-- tests/qemu-iotests/237.out | 3 --- tests/qemu-iotests/296 | 13 +++++++------ 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065 index 9466ce7df4d..ba94e19349b 100755 --- a/tests/qemu-iotests/065 +++ b/tests/qemu-iotests/065 @@ -24,7 +24,7 @@ import os import re import json import iotests -from iotests import qemu_img, qemu_img_info, qemu_img_pipe +from iotests import qemu_img, qemu_img_info import unittest =20 test_img =3D os.path.join(iotests.test_dir, 'test.img') @@ -54,7 +54,7 @@ class TestQemuImgInfo(TestImageInfoSpecific): self.assertEqual(data['data'], self.json_compare) =20 def test_human(self): - data =3D qemu_img_pipe('info', '--output=3Dhuman', test_img).split= ('\n') + data =3D qemu_img('info', '--output=3Dhuman', test_img).stdout.spl= it('\n') data =3D data[(data.index('Format specific information:') + 1) :data.index('')] for field in data: diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149 index d49646ca60b..8b7dfb4e368 100755 --- a/tests/qemu-iotests/149 +++ b/tests/qemu-iotests/149 @@ -265,8 +265,12 @@ def qemu_img_create(config, size_mb): "%dM" % size_mb] =20 iotests.log("qemu-img " + " ".join(args), filters=3D[iotests.filter_te= st_dir]) - iotests.log(check_cipher_support(config, iotests.qemu_img_pipe(*args)), - filters=3D[iotests.filter_test_dir]) + try: + iotests.qemu_img(*args) + except subprocess.CalledProcessError as exc: + iotests.log(check_cipher_support(config, exc.output), + filters=3D[iotests.filter_test_dir]) + raise =20 def qemu_io_image_args(config, dev=3DFalse): """Get the args for access an image or device with qemu-io""" diff --git a/tests/qemu-iotests/237 b/tests/qemu-iotests/237 index 43dfd3bd40a..5ea13eb01fc 100755 --- a/tests/qemu-iotests/237 +++ b/tests/qemu-iotests/237 @@ -165,8 +165,7 @@ with iotests.FilePath('t.vmdk') as disk_path, \ iotests.log("") =20 for path in [ extent1_path, extent2_path, extent3_path ]: - msg =3D iotests.qemu_img_pipe('create', '-f', imgfmt, path, '0') - iotests.log(msg, [iotests.filter_testfiles]) + iotests.qemu_img_create('-f', imgfmt, path, '0') =20 vm.add_blockdev('driver=3Dfile,filename=3D%s,node-name=3Dext1' % (exte= nt1_path)) vm.add_blockdev('driver=3Dfile,filename=3D%s,node-name=3Dext2' % (exte= nt2_path)) diff --git a/tests/qemu-iotests/237.out b/tests/qemu-iotests/237.out index aeb97244928..62b88656778 100644 --- a/tests/qemu-iotests/237.out +++ b/tests/qemu-iotests/237.out @@ -129,9 +129,6 @@ Job failed: Cannot find device=3D'this doesn't exist' n= or node-name=3D'this doesn't =20 =3D=3D=3D Other subformats =3D=3D=3D =20 - - - =3D=3D Missing extent =3D=3D =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "vmdk", "file": "node0", "size": 33554432, "subformat": "monolit= hicFlat"}}} diff --git a/tests/qemu-iotests/296 b/tests/qemu-iotests/296 index 099a3eeaa52..f32ef037a58 100755 --- a/tests/qemu-iotests/296 +++ b/tests/qemu-iotests/296 @@ -76,7 +76,7 @@ class EncryptionSetupTestCase(iotests.QMPTestCase): # create the encrypted block device using qemu-img def createImg(self, file, secret): =20 - output =3D iotests.qemu_img_pipe( + iotests.qemu_img( 'create', '--object', *secret.to_cmdline_object(), '-f', iotests.imgfmt, @@ -85,7 +85,7 @@ class EncryptionSetupTestCase(iotests.QMPTestCase): file, '1M') =20 - iotests.log(output, filters=3D[iotests.filter_test_dir]) + print('') # Keeps 296.out prettier. =20 # attempts to add a key using qemu-img def addKey(self, file, secret, new_secret): @@ -99,7 +99,7 @@ class EncryptionSetupTestCase(iotests.QMPTestCase): } } =20 - output =3D iotests.qemu_img_pipe( + ret =3D iotests.qemu_img( 'amend', '--object', *secret.to_cmdline_object(), '--object', *new_secret.to_cmdline_object(), @@ -108,10 +108,11 @@ class EncryptionSetupTestCase(iotests.QMPTestCase): '-o', 'new-secret=3D' + new_secret.id(), '-o', 'iter-time=3D10', =20 - "json:" + json.dumps(image_options) - ) + "json:" + json.dumps(image_options), + check=3DFalse # Expected to fail, output is logged. + ) =20 - iotests.log(output, filters=3D[iotests.filter_test_dir]) + iotests.log(ret.stdout, filters=3D[iotests.filter_test_dir]) =20 ######################################################################= ##### # open an encrypted block device --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645483872716163.7670513129209; Mon, 21 Feb 2022 14:51:12 -0800 (PST) Received: from localhost ([::1]:60048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHWQ-00017Z-Ul for importer@patchew.org; Mon, 21 Feb 2022 17:51:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGc-0000sa-5f for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37252) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGa-0008E5-MG for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:49 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-472-tb_CEF9wMCK_qedKXNj11w-1; Mon, 21 Feb 2022 17:34:45 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 07E2E1091DA1; Mon, 21 Feb 2022 22:34:44 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id D655E1038AAF; Mon, 21 Feb 2022 22:34:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CKXx9B9XibhZVZIdHJUuZ1uhLEI+0o/fmcLq2uQiJCI=; b=EM+F3cl35JtZYqJbwk0sU4IjTwZifzcT0Bt3r4VxmX/4gBCI8d6I2Kezk6ZjtuEN8wqWIF /Yg2FX+q5Gj1jBR9AenyeXP+K6Ycp734QurzkDi7gI4P28UnbKc+TRYs2+YgagkN4PHW5U PNhJCHnxEuyex8qrn163w5d4CFFkBeo= X-MC-Unique: tb_CEF9wMCK_qedKXNj11w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 14/18] iotests: move has_working_luks onto qemu_img() Date: Mon, 21 Feb 2022 17:34:09 -0500 Message-Id: <20220221223413.2123003-15-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483873317100001 Content-Type: text/plain; charset="utf-8" Admittedly a mostly lateral move; the diagnostics are slightly better on program crash. Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 882d3e0214a..16bac5df969 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1445,20 +1445,20 @@ def has_working_luks() -> Tuple[bool, str]: """ =20 img_file =3D f'{test_dir}/luks-test.luks' - (output, status) =3D \ - qemu_img_pipe_and_status('create', '-f', 'luks', - '--object', luks_default_secret_object, - '-o', luks_default_key_secret_opt, - '-o', 'iter-time=3D10', - img_file, '1G') + res =3D qemu_img('create', '-f', 'luks', + '--object', luks_default_secret_object, + '-o', luks_default_key_secret_opt, + '-o', 'iter-time=3D10', + img_file, '1G', + check=3DFalse) try: os.remove(img_file) except OSError: pass =20 - if status !=3D 0: - reason =3D output - for line in output.splitlines(): + if res.returncode: + reason =3D res.stdout + for line in res.stdout.splitlines(): if img_file + ':' in line: reason =3D line.split(img_file + ':', 1)[1].strip() break --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645483881704388.7536142826725; Mon, 21 Feb 2022 14:51:21 -0800 (PST) Received: from localhost ([::1]:60192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHWa-0001D9-0h for importer@patchew.org; Mon, 21 Feb 2022 17:51:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGd-0000zZ-Ux for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58433) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGc-0008Em-0o for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:51 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-460-4REDl7DlMyC-RQw2rGlKug-1; Mon, 21 Feb 2022 17:34:46 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E524801B04; Mon, 21 Feb 2022 22:34:45 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 319DF1038AB6; Mon, 21 Feb 2022 22:34:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482889; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WMFwZBMAWGu7/ATBP97aW98pHpt3+LlIg4jxC2XFWOE=; b=fnSL8ioJ723cHKmgzqbYapNZOlyz18jf7M1oJr5RVnyt7GKoZ99X0LH7bfKTlHazWdqqwK MvgaD/b9Zwwejsx/gvumTpIDWJKQsXYK0+60qp/T1HJt9gtEPKAXuRIxc7pZ4D1DBtsxCg USQjuwPDS2fcyEe/EZr2fYsXW+rduzY= X-MC-Unique: 4REDl7DlMyC-RQw2rGlKug-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 15/18] iotests: remove qemu_img_log('create', ...) calls Date: Mon, 21 Feb 2022 17:34:10 -0500 Message-Id: <20220221223413.2123003-16-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483883460100001 Content-Type: text/plain; charset="utf-8" qemu_img_log() calls into qemu_img_pipe(), which always removes output for 'create' commands on success anyway. Replace all of these calls to the simpler qemu_img_create(...) which doesn't log, but raises a detailed exception object on failure instead. Blank lines are removed from output files where appropriate. Signed-off-by: John Snow --- tests/qemu-iotests/255 | 8 ++++---- tests/qemu-iotests/255.out | 4 ---- tests/qemu-iotests/274 | 17 ++++++++--------- tests/qemu-iotests/274.out | 29 ----------------------------- tests/qemu-iotests/280 | 2 +- tests/qemu-iotests/280.out | 1 - 6 files changed, 13 insertions(+), 48 deletions(-) diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255 index 3d6d0e80cb5..f86fa851b62 100755 --- a/tests/qemu-iotests/255 +++ b/tests/qemu-iotests/255 @@ -42,8 +42,8 @@ with iotests.FilePath('t.qcow2') as disk_path, \ size_str =3D str(size) =20 iotests.create_image(base_path, size) - iotests.qemu_img_log('create', '-f', iotests.imgfmt, mid_path, size_st= r) - iotests.qemu_img_log('create', '-f', iotests.imgfmt, disk_path, size_s= tr) + iotests.qemu_img_create('-f', iotests.imgfmt, mid_path, size_str) + iotests.qemu_img_create('-f', iotests.imgfmt, disk_path, size_str) =20 # Create a backing chain like this: # base <- [throttled: bps-read=3D4096] <- mid <- overlay @@ -92,8 +92,8 @@ with iotests.FilePath('src.qcow2') as src_path, \ size =3D 128 * 1024 * 1024 size_str =3D str(size) =20 - iotests.qemu_img_log('create', '-f', iotests.imgfmt, src_path, size_st= r) - iotests.qemu_img_log('create', '-f', iotests.imgfmt, dst_path, size_st= r) + iotests.qemu_img_create('-f', iotests.imgfmt, src_path, size_str) + iotests.qemu_img_create('-f', iotests.imgfmt, dst_path, size_str) =20 iotests.log(iotests.qemu_io('-f', iotests.imgfmt, '-c', 'write 0 1M', src_path), diff --git a/tests/qemu-iotests/255.out b/tests/qemu-iotests/255.out index 11a05a5213e..2e837cbb5f3 100644 --- a/tests/qemu-iotests/255.out +++ b/tests/qemu-iotests/255.out @@ -3,8 +3,6 @@ Finishing a commit job with background reads =20 =3D=3D=3D Create backing chain and start VM =3D=3D=3D =20 - - =3D=3D=3D Start background read requests =3D=3D=3D =20 =3D=3D=3D Run a commit job =3D=3D=3D @@ -21,8 +19,6 @@ Closing the VM while a job is being cancelled =20 =3D=3D=3D Create images and start VM =3D=3D=3D =20 - - wrote 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 diff --git a/tests/qemu-iotests/274 b/tests/qemu-iotests/274 index 080a90f10f7..2495e051a22 100755 --- a/tests/qemu-iotests/274 +++ b/tests/qemu-iotests/274 @@ -31,12 +31,11 @@ size_long =3D 2 * 1024 * 1024 size_diff =3D size_long - size_short =20 def create_chain() -> None: - iotests.qemu_img_log('create', '-f', iotests.imgfmt, base, - str(size_long)) - iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', base, - '-F', iotests.imgfmt, mid, str(size_short)) - iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', mid, - '-F', iotests.imgfmt, top, str(size_long)) + iotests.qemu_img_create('-f', iotests.imgfmt, base, str(size_long)) + iotests.qemu_img_create('-f', iotests.imgfmt, '-b', base, + '-F', iotests.imgfmt, mid, str(size_short)) + iotests.qemu_img_create('-f', iotests.imgfmt, '-b', mid, + '-F', iotests.imgfmt, top, str(size_long)) =20 iotests.qemu_io_log('-c', 'write -P 1 0 %d' % size_long, base) =20 @@ -160,9 +159,9 @@ with iotests.FilePath('base') as base, \ ('off', '512k', '256k', '500k', '436k')]: =20 iotests.log('=3D=3D=3D preallocation=3D%s =3D=3D=3D' % prealloc) - iotests.qemu_img_log('create', '-f', iotests.imgfmt, base, base_si= ze) - iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', base, - '-F', iotests.imgfmt, top, top_size_old) + iotests.qemu_img_create('-f', iotests.imgfmt, base, base_size) + iotests.qemu_img_create('-f', iotests.imgfmt, '-b', base, + '-F', iotests.imgfmt, top, top_size_old) iotests.qemu_io_log('-c', 'write -P 1 %s 64k' % off, base) =20 # After this, top_size_old to base_size should be allocated/zeroed. diff --git a/tests/qemu-iotests/274.out b/tests/qemu-iotests/274.out index 1ce40d839a4..acd8b166a65 100644 --- a/tests/qemu-iotests/274.out +++ b/tests/qemu-iotests/274.out @@ -1,7 +1,4 @@ =3D=3D Commit tests =3D=3D - - - wrote 2097152/2097152 bytes at offset 0 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -63,9 +60,6 @@ read 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 =3D=3D=3D Testing HMP commit (top -> mid) =3D=3D=3D - - - wrote 2097152/2097152 bytes at offset 0 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -92,9 +86,6 @@ read 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 =3D=3D=3D Testing QMP active commit (top -> mid) =3D=3D=3D - - - wrote 2097152/2097152 bytes at offset 0 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -127,9 +118,6 @@ read 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 =3D=3D=3D Testing qemu-img commit (top -> base) =3D=3D=3D - - - wrote 2097152/2097152 bytes at offset 0 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -154,9 +142,6 @@ read 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 =3D=3D=3D Testing QMP active commit (top -> base) =3D=3D=3D - - - wrote 2097152/2097152 bytes at offset 0 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -190,8 +175,6 @@ read 1048576/1048576 bytes at offset 1048576 =20 =3D=3D Resize tests =3D=3D =3D=3D=3D preallocation=3Doff =3D=3D=3D - - wrote 65536/65536 bytes at offset 5368709120 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -207,8 +190,6 @@ read 65536/65536 bytes at offset 5368709120 { "start": 1073741824, "length": 7516192768, "depth": 0, "present": true, = "zero": true, "data": false}] =20 =3D=3D=3D preallocation=3Dmetadata =3D=3D=3D - - wrote 65536/65536 bytes at offset 33285996544 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -229,8 +210,6 @@ read 65536/65536 bytes at offset 33285996544 { "start": 34896609280, "length": 536870912, "depth": 0, "present": true, = "zero": true, "data": false, "offset": 2685075456}] =20 =3D=3D=3D preallocation=3Dfalloc =3D=3D=3D - - wrote 65536/65536 bytes at offset 9437184 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -246,8 +225,6 @@ read 65536/65536 bytes at offset 9437184 { "start": 5242880, "length": 10485760, "depth": 0, "present": true, "zero= ": false, "data": true, "offset": 327680}] =20 =3D=3D=3D preallocation=3Dfull =3D=3D=3D - - wrote 65536/65536 bytes at offset 11534336 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -263,8 +240,6 @@ read 65536/65536 bytes at offset 11534336 { "start": 8388608, "length": 4194304, "depth": 0, "present": true, "zero"= : false, "data": true, "offset": 327680}] =20 =3D=3D=3D preallocation=3Doff =3D=3D=3D - - wrote 65536/65536 bytes at offset 259072 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -281,8 +256,6 @@ read 65536/65536 bytes at offset 259072 { "start": 262144, "length": 262144, "depth": 0, "present": true, "zero": = true, "data": false}] =20 =3D=3D=3D preallocation=3Doff =3D=3D=3D - - wrote 65536/65536 bytes at offset 344064 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -298,8 +271,6 @@ read 65536/65536 bytes at offset 344064 { "start": 262144, "length": 262144, "depth": 0, "present": true, "zero": = true, "data": false}] =20 =3D=3D=3D preallocation=3Doff =3D=3D=3D - - wrote 65536/65536 bytes at offset 446464 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 diff --git a/tests/qemu-iotests/280 b/tests/qemu-iotests/280 index 628f3c33cac..5f50500fdb8 100755 --- a/tests/qemu-iotests/280 +++ b/tests/qemu-iotests/280 @@ -33,7 +33,7 @@ with iotests.FilePath('base') as base_path , \ iotests.FilePath('top') as top_path, \ iotests.VM() as vm: =20 - iotests.qemu_img_log('create', '-f', iotests.imgfmt, base_path, '64M') + iotests.qemu_img_create('-f', iotests.imgfmt, base_path, '64M') =20 iotests.log('=3D=3D=3D Launch VM =3D=3D=3D') vm.add_object('iothread,id=3Diothread0') diff --git a/tests/qemu-iotests/280.out b/tests/qemu-iotests/280.out index e39164c579f..c75f437c00e 100644 --- a/tests/qemu-iotests/280.out +++ b/tests/qemu-iotests/280.out @@ -1,4 +1,3 @@ - =3D=3D=3D Launch VM =3D=3D=3D Enabling migration QMP events on VM... {"return": {}} --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645483741996287.7596471411723; Mon, 21 Feb 2022 14:49:01 -0800 (PST) Received: from localhost ([::1]:53578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHUK-0005AG-RM for importer@patchew.org; Mon, 21 Feb 2022 17:49:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGd-0000xw-Gs for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30456) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGb-0008ET-Gi for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:51 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-466-xvstMlXuNHeyMW8f5MWiow-1; Mon, 21 Feb 2022 17:34:47 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A0DB9104; Mon, 21 Feb 2022 22:34:46 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 741811038AAF; Mon, 21 Feb 2022 22:34:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P+lm6rn9H/TN3qWnRxVPO6qqVdAE2mCA0B2AE+Mbv/A=; b=KVjca69pYMUsmZzjrGamiQqWT11o9Lld/IrXBz0Xg99vyevI4MoJnlVp72hbuKaH9NgnA0 s/ayuia+SgMgAbyzNaAwyatqb9glnZ+MdGTmYaCpsBX774+vtlJPxIzw6qLOk7f24uzJFN SjgDPdjeoAloF58FfIUBaLaJWHlZ1Mk= X-MC-Unique: xvstMlXuNHeyMW8f5MWiow-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 16/18] iotests: remove qemu_img_pipe() Date: Mon, 21 Feb 2022 17:34:11 -0500 Message-Id: <20220221223413.2123003-17-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645483742425100001 Content-Type: text/plain; charset="utf-8" With the exceptional 'create' calls removed in the prior commit, change qemu_img_log() and img_info_log() to call qemu_img() directly instead. In keeping with the spirit of diff-based tests, allow these calls to qemu_img() to return an unchecked non-zero status code -- because any error we'd see from the output is going into the log anyway. Every last call to qemu-img is now either checked for a return code of zero or has its output logged. It should be very hard to accidentally ignore the return code *or* output from qemu-img now; intentional malice remains unhandled. Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 16bac5df969..6da6890596c 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -240,15 +240,6 @@ def qemu_img_create_prepare_args(args: List[str]) -> L= ist[str]: =20 return result =20 -def qemu_img_pipe_and_status(*args: str) -> Tuple[str, int]: - """ - Run qemu-img and return both its output and its exit code - """ - is_create =3D bool(args and args[0] =3D=3D 'create') - full_args =3D qemu_img_args + qemu_img_create_prepare_args(list(args)) - return qemu_tool_pipe_and_status('qemu-img', full_args, - drop_successful_output=3Dis_create) - def qemu_img(*args: str, check: bool =3D True, combine_stdio: bool =3D True ) -> subprocess.CompletedProcess[str]: """ @@ -356,17 +347,14 @@ def qemu_img_info(*args: str) -> Any: def qemu_img_map(*args: str) -> Any: return qemu_img_json('map', "--output", "json", *args) =20 -def qemu_img_pipe(*args: str) -> str: - '''Run qemu-img and return its output''' - return qemu_img_pipe_and_status(*args)[0] - -def qemu_img_log(*args): - result =3D qemu_img_pipe(*args) - log(result, filters=3D[filter_testfiles]) +def qemu_img_log(*args: str) -> subprocess.CompletedProcess[str]: + result =3D qemu_img(*args, check=3DFalse) + log(result.stdout, filters=3D[filter_testfiles]) return result =20 -def img_info_log(filename, filter_path=3DNone, use_image_opts=3DFalse, - extra_args=3D()): +def img_info_log(filename: str, filter_path: Optional[str] =3D None, + use_image_opts: bool =3D False, extra_args: Sequence[str]= =3D (), + ) -> None: args =3D ['info'] if use_image_opts: args.append('--image-opts') @@ -375,7 +363,7 @@ def img_info_log(filename, filter_path=3DNone, use_imag= e_opts=3DFalse, args +=3D extra_args args.append(filename) =20 - output =3D qemu_img_pipe(*args) + output =3D qemu_img(*args, check=3DFalse).stdout if not filter_path: filter_path =3D filename log(filter_img_info(output, filter_path)) --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164548417114672.13397791361763; Mon, 21 Feb 2022 14:56:11 -0800 (PST) Received: from localhost ([::1]:42516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHbF-0008VU-SE for importer@patchew.org; Mon, 21 Feb 2022 17:56:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGn-0001Ci-Mf for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:35:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56315) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGl-0008FS-L1 for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:35:01 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-519-9ZPLgEZVOpKFuYTsfBHXzg-1; Mon, 21 Feb 2022 17:34:48 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B66C11E10; Mon, 21 Feb 2022 22:34:47 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7EC51038AAF; Mon, 21 Feb 2022 22:34:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482892; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X1mM3CYvKVw8MvI6SwLl612hl5JXG/ZjVwkIWrbkYTE=; b=T6mfgVjbmBwKyKmbFxsQQ562F0QcgdgXIyWWdTG7no2U2KEIEc3reOsV5pkEuLYGOX+yGx eSvfEdIX5c9OunpfToFZA+tnPh2w1VPbBp97L8ZHsUTKkIEcwLBaR5SAb1++MvI6f2S1t/ 2PLbgO/rnhU8ZJBW5yy4KZ74kBvcH/w= X-MC-Unique: 9ZPLgEZVOpKFuYTsfBHXzg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 17/18] iotests: make qemu_img_log() check log level Date: Mon, 21 Feb 2022 17:34:12 -0500 Message-Id: <20220221223413.2123003-18-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645484173480100001 Content-Type: text/plain; charset="utf-8" Improve qemu_img_log() to actually check if logging is turned on. If it isn't, revert to the behavior of qemu_img(). This is done so that there really is no way to avoid scrutinizing qemu-ing subprocess calls by accident. You're gonna have to work for it. Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 6da6890596c..0519b2a8019 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -348,7 +348,13 @@ def qemu_img_map(*args: str) -> Any: return qemu_img_json('map', "--output", "json", *args) =20 def qemu_img_log(*args: str) -> subprocess.CompletedProcess[str]: - result =3D qemu_img(*args, check=3DFalse) + """ + Logged, unchecked variant of qemu_img() that allows non-zero exit code= s. + + If logging is perceived to be disabled, this function will behave + like qemu_img() and prohibit non-zero return codes. + """ + result =3D qemu_img(*args, check=3Dnot logging_enabled()) log(result.stdout, filters=3D[filter_testfiles]) return result =20 @@ -1635,6 +1641,11 @@ def activate_logging(): test_logger.setLevel(logging.INFO) test_logger.propagate =3D False =20 +def logging_enabled() -> bool: + """Return True if iotest logging is active.""" + return (test_logger.hasHandlers() + and test_logger.getEffectiveLevel() >=3D logging.INFO) + # This is called from script-style iotests without a single point of entry def script_initialize(*args, **kwargs): """Initialize script-style tests without running any tests.""" --=20 2.34.1 From nobody Tue May 14 07:30:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645484037753748.2410540853524; Mon, 21 Feb 2022 14:53:57 -0800 (PST) Received: from localhost ([::1]:37736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMHZ6-0005Dz-5O for importer@patchew.org; Mon, 21 Feb 2022 17:53:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGm-00016K-2o for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:35:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36489) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMHGd-0008F8-NJ for qemu-devel@nongnu.org; Mon, 21 Feb 2022 17:34:53 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-290-0HihfAz5OpeT9haWgX7U8A-1; Mon, 21 Feb 2022 17:34:50 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F05D9180CBFE; Mon, 21 Feb 2022 22:34:48 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEF061038AAF; Mon, 21 Feb 2022 22:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645482891; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LiD4YEi7R+Kp81+XXVy12vrabiJJ9ekRqulYi65vols=; b=ghKUjbDWGyxMqg6xG+pZs+W7VswTnduWO67tdhS7jA359Di94SAvGNScrCR7aFkCCe34RZ lPY1HW4KWSSwwAqV8oJLsSsNSNxVdfxDQVsVp5zV2ZQcayQRAifCBjns4jzQF6XEoaxvOc 0g54P6zvGiA8PEE/5pgRjy69HJmvNdU= X-MC-Unique: 0HihfAz5OpeT9haWgX7U8A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 18/18] iotests: reimplement img_info_log in terms of qemu_img_log Date: Mon, 21 Feb 2022 17:34:13 -0500 Message-Id: <20220221223413.2123003-19-jsnow@redhat.com> In-Reply-To: <20220221223413.2123003-1-jsnow@redhat.com> References: <20220221223413.2123003-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Kevin Wolf , Thomas Huth , Beraldo Leal , qemu-block@nongnu.org, Eric Blake , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645484038361100001 Content-Type: text/plain; charset="utf-8" Now every last call to qemu_img is certifiably either checked or logged. Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 0519b2a8019..473173324d6 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -347,15 +347,20 @@ def qemu_img_info(*args: str) -> Any: def qemu_img_map(*args: str) -> Any: return qemu_img_json('map', "--output", "json", *args) =20 -def qemu_img_log(*args: str) -> subprocess.CompletedProcess[str]: +def qemu_img_log( + *args: str, + filters: Iterable[Callable[[str], str]] =3D (), +) -> subprocess.CompletedProcess[str]: """ Logged, unchecked variant of qemu_img() that allows non-zero exit code= s. =20 If logging is perceived to be disabled, this function will behave like qemu_img() and prohibit non-zero return codes. + + By default, output will be filtered through filter_testfiles(). """ result =3D qemu_img(*args, check=3Dnot logging_enabled()) - log(result.stdout, filters=3D[filter_testfiles]) + log(result.stdout, filters=3Dfilters or [filter_testfiles]) return result =20 def img_info_log(filename: str, filter_path: Optional[str] =3D None, @@ -369,10 +374,11 @@ def img_info_log(filename: str, filter_path: Optional= [str] =3D None, args +=3D extra_args args.append(filename) =20 - output =3D qemu_img(*args, check=3DFalse).stdout if not filter_path: filter_path =3D filename - log(filter_img_info(output, filter_path)) + qemu_img_log( + *args, + filters=3D[lambda output: filter_img_info(output, filter_path)]) =20 def qemu_io_wrap_args(args: Sequence[str]) -> List[str]: if '-f' in args or '--image-opts' in args: --=20 2.34.1