qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Nir Soffer <nirsof@gmail.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, John Snow <jsnow@redhat.com>,
	Max Reitz <mreitz@redhat.com>, Nir Soffer <nsoffer@redhat.com>
Subject: [PATCH v2 1/5] qemu-iotests: Fix FilePaths cleanup
Date: Fri, 21 Aug 2020 02:54:23 +0300	[thread overview]
Message-ID: <20200820235427.374645-2-nsoffer@redhat.com> (raw)
In-Reply-To: <20200820235427.374645-1-nsoffer@redhat.com>

If os.remove() fails to remove one of the paths, for example if the file
was removed by the test, the cleanup loop would exit silently, without
removing the rest of the files.

Fixes: de263986b5dc
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
---
 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 717b5b652c..16a04df8a3 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -468,11 +468,11 @@ class FilePaths:
         return self.paths
 
     def __exit__(self, exc_type, exc_val, exc_tb):
-        try:
-            for path in self.paths:
+        for path in self.paths:
+            try:
                 os.remove(path)
-        except OSError:
-            pass
+            except OSError:
+                pass
         return False
 
 class FilePath(FilePaths):
-- 
2.26.2



  reply	other threads:[~2020-08-20 23:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-20 23:54 [PATCH v2 0/5] iotest.FilePath fixes and cleanups Nir Soffer
2020-08-20 23:54 ` Nir Soffer [this message]
2020-08-25 10:27   ` [PATCH v2 1/5] qemu-iotests: Fix FilePaths cleanup Max Reitz
2020-08-20 23:54 ` [PATCH v2 2/5] qemu-iotests: Fix FilePaths docstring Nir Soffer
2020-08-25 10:39   ` Max Reitz
2020-08-25 10:48   ` Max Reitz
2020-08-25 11:17     ` Nir Soffer
2020-08-20 23:54 ` [PATCH v2 3/5] qemu-iotests: Support varargs syntax in FilePaths Nir Soffer
2020-08-25 10:48   ` Max Reitz
2020-08-20 23:54 ` [PATCH v2 4/5] qemu-iotests: Merge FilePaths and FilePath Nir Soffer
2020-08-25 10:57   ` Max Reitz
2020-08-20 23:54 ` [PATCH v2 5/5] qemu-iotests: Simplify FilePath __init__ Nir Soffer
2020-08-25 10:58   ` Max Reitz
2020-08-25 11:37 ` [PATCH v2 0/5] iotest.FilePath fixes and cleanups Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200820235427.374645-2-nsoffer@redhat.com \
    --to=nirsof@gmail.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=nsoffer@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).