From nobody Tue Nov 11 04:57:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1560993464; cv=none; d=zoho.com; s=zohoarc; b=LHXQO/IA/+H4VUUoEvmWTV6+zVgCVo1OanrPxCT3FUvk7l3zss+dVcG3tifmAvWHKZX7aulYcx+V8gsLBfCXGU9Gi4djeA/mj34n2uHmGAQXfS8fhIpzGHnCb9vj4G7BXIrZXKzwjlOWU/aQb2ocK/UKsORMtYPS84xvaPFvToI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560993464; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=IQTdij87I0Aa434jQ9W6bzYHuSHH5A7VwPRGdBUTEQw=; b=nVHBPvqbpguWr9GZm2WwD6oZydIg0Ut4WQnrUKMe3q+WUrB3I5Ts1FR+PMsZY/DCPYl5DEvBbd0bW9TVKzKl7Y8saAy3D2eOegD/PxACLN0TN02tNvZ+g+jtMx2p3AoQ1SAkV9IakqCToiZ/bNY3h4LFk8DFR2lTVvhVAjO17Z0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560993464729679.738928001949; Wed, 19 Jun 2019 18:17:44 -0700 (PDT) Received: from localhost ([::1]:42888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdlhn-0004UI-J3 for importer@patchew.org; Wed, 19 Jun 2019 21:17:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40379) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdle4-0001zb-9m for qemu-devel@nongnu.org; Wed, 19 Jun 2019 21:13:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdlV1-00050V-8K for qemu-devel@nongnu.org; Wed, 19 Jun 2019 21:04:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53408) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hdlUu-0004uB-Jv; Wed, 19 Jun 2019 21:04:16 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id CB57F81F1B; Thu, 20 Jun 2019 01:04:15 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-164.bos.redhat.com [10.18.17.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF4FF1001E67; Thu, 20 Jun 2019 01:04:14 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Wed, 19 Jun 2019 21:03:54 -0400 Message-Id: <20190620010356.19164-11-jsnow@redhat.com> In-Reply-To: <20190620010356.19164-1-jsnow@redhat.com> References: <20190620010356.19164-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 20 Jun 2019 01:04:15 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 10/12] iotests: teach FilePath to produce multiple paths X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , vsementsov@virtuozzo.com, Wen Congyang , Xie Changlong , Markus Armbruster , Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Use "FilePaths" instead of "FilePath" to request multiple files be cleaned up after we leave that object's scope. This is not crucial; but it saves a little typing. Signed-off-by: John Snow Reviewed-by: Max Reitz --- tests/qemu-iotests/iotests.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index c544659ecb..b938fa9719 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -359,7 +359,7 @@ class Timeout: raise Exception(self.errmsg) =20 =20 -class FilePath(object): +class FilePaths(object): '''An auto-generated filename that cleans itself up. =20 Use this context manager to generate filenames and ensure that the file @@ -369,20 +369,29 @@ class FilePath(object): qemu_img('create', img_path, '1G') # migration_sock_path is automatically deleted ''' - def __init__(self, name): - filename =3D '{0}-{1}'.format(os.getpid(), name) - self.path =3D os.path.join(test_dir, filename) + def __init__(self, names): + self.paths =3D [] + for name in names: + filename =3D '{0}-{1}'.format(os.getpid(), name) + self.paths.append(os.path.join(test_dir, filename)) =20 def __enter__(self): - return self.path + return self.paths =20 def __exit__(self, exc_type, exc_val, exc_tb): try: - os.remove(self.path) + for path in self.paths: + os.remove(path) except OSError: pass return False =20 +class FilePath(FilePaths): + def __init__(self, name): + super(FilePath, self).__init__([name]) + + def __enter__(self): + return self.paths[0] =20 def file_path_remover(): for path in reversed(file_path_remover.paths): --=20 2.21.0