diff mbox series

[26/67] iotests/124: Honor $IMGOPTS

Message ID 20191001194715.2796-27-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
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/124 | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/tests/qemu-iotests/124 b/tests/qemu-iotests/124
index d3e851e1ae..145dccb2b0 100755
--- a/tests/qemu-iotests/124
+++ b/tests/qemu-iotests/124
@@ -22,6 +22,7 @@ 
 
 import os
 import iotests
+from iotests import create_test_image, remove_test_image
 
 
 def io_write_patterns(img, patterns):
@@ -29,13 +30,6 @@  def io_write_patterns(img, patterns):
         iotests.qemu_io('-c', 'write -P%s %s %s' % pattern, img)
 
 
-def try_remove(img):
-    try:
-        os.remove(img)
-    except OSError:
-        pass
-
-
 def transaction_action(action, **kwargs):
     return {
         'type': action,
@@ -82,13 +76,13 @@  class Bitmap:
 
     def del_target(self):
         for image in self.backups.pop():
-            try_remove(image)
+            remove_test_image(image)
         self.num -= 1
 
     def cleanup(self):
         for backup in self.backups:
             for image in backup:
-                try_remove(image)
+                remove_test_image(image)
 
 
 class TestIncrementalBackupBase(iotests.QMPTestCase):
@@ -133,15 +127,14 @@  class TestIncrementalBackupBase(iotests.QMPTestCase):
 
     def img_create(self, img, fmt=iotests.imgfmt, size='64M',
                    parent=None, parentFormat=None, **kwargs):
-        optargs = []
-        for k,v in kwargs.items():
-            optargs = optargs + ['-o', '%s=%s' % (k,v)]
-        args = ['create', '-f', fmt] + optargs + [img, size]
+        opts = []
+        for k, v in kwargs.items():
+            opts.append('%s=%s' % (k, v))
         if parent:
             if parentFormat is None:
                 parentFormat = fmt
-            args = args + ['-b', parent, '-F', parentFormat]
-        iotests.qemu_img(*args)
+        create_test_image(img, size, fmt=fmt, backing_file=parent,
+                          backing_fmt=parentFormat, opts=opts)
         self.files.append(img)
 
 
@@ -287,7 +280,7 @@  class TestIncrementalBackupBase(iotests.QMPTestCase):
         for bitmap in self.bitmaps:
             bitmap.cleanup()
         for filename in self.files:
-            try_remove(filename)
+            remove_test_image(filename)
 
 
 
@@ -414,6 +407,8 @@  class TestIncrementalBackup(TestIncrementalBackupBase):
         self.check_backups()
 
 
+    # blkdebug does not work with an external data file
+    @iotests.skip_for_imgopts(['data_file'])
     def do_transaction_failure_test(self, race=False):
         # Create a second drive, with pattern:
         drive1 = self.add_node('drive1')
@@ -608,6 +603,8 @@  class TestIncrementalBackup(TestIncrementalBackupBase):
 class TestIncrementalBackupBlkdebug(TestIncrementalBackupBase):
     '''Incremental backup tests that utilize a BlkDebug filter on drive0.'''
 
+    # blkdebug does not work with an external data file
+    @iotests.skip_for_imgopts(['data_file'])
     def setUp(self):
         drive0 = self.add_node('drive0')
         self.img_create(drive0['file'], drive0['fmt'])