qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 06/67] iotests.py: Add image_path()


From: Max Reitz
Subject: [PATCH 06/67] iotests.py: Add image_path()
Date: Tue, 1 Oct 2019 21:46:14 +0200

Just like we have file_path() as an alternative to FilePath, this is an
alternative fo ImagePath.

Signed-off-by: Max Reitz <address@hidden>
---
 tests/qemu-iotests/iotests.py | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 5be6ca674c..280e6c2ec2 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -505,8 +505,12 @@ def file_path_remover():
         except OSError:
             pass
 
+def image_path_remover():
+    for path in reversed(image_path_remover.paths):
+        remove_test_image(path)
 
-def file_path(*names):
+
+def file_path(*names, remover=file_path_remover):
     ''' Another way to get auto-generated filename that cleans itself up.
 
     Use is as simple as:
@@ -515,19 +519,22 @@ def file_path(*names):
     sock = file_path('socket')
     '''
 
-    if not hasattr(file_path_remover, 'paths'):
-        file_path_remover.paths = []
-        atexit.register(file_path_remover)
+    if not hasattr(remover, 'paths'):
+        remover.paths = []
+        atexit.register(remover)
 
     paths = []
     for name in names:
         filename = file_pattern(name)
         path = os.path.join(test_dir, filename)
-        file_path_remover.paths.append(path)
+        remover.paths.append(path)
         paths.append(path)
 
     return paths[0] if len(paths) == 1 else paths
 
+def image_path(*names):
+    return file_path(*names, remover=image_path_remover)
+
 def remote_filename(path):
     if imgproto == 'file':
         return path
-- 
2.21.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]