diff mbox series

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

Message ID 20191001194715.2796-7-mreitz@redhat.com
State New
Headers show
Series iotests: Honor $IMGOPTS in Python tests | expand

Commit Message

Max Reitz Oct. 1, 2019, 7:46 p.m. UTC
Just like we have file_path() as an alternative to FilePath, this is an
alternative fo ImagePath.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/iotests.py | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
diff mbox series

Patch

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