]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
qemu-iotests: Fix FilePaths cleanup
authorNir Soffer <nirsof@gmail.com>
Fri, 28 Aug 2020 23:21:48 +0000 (02:21 +0300)
committerMax Reitz <mreitz@redhat.com>
Tue, 15 Sep 2020 09:05:12 +0000 (11:05 +0200)
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>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200828232152.205833-2-nsoffer@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
tests/qemu-iotests/iotests.py

index 64ccaf906145030c1a1bb53ffe325b14c9304950..36814daf84e58d3f9d9771bd7dda762f02ba5fd5 100644 (file)
@@ -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):