diff mbox series

[15/67] iotests/030: Honor $IMGOPTS

Message ID 20191001194715.2796-16-mreitz@redhat.com (mailing list archive)
State New, archived
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/030 | 69 ++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 37 deletions(-)
diff mbox series

Patch

diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
index 01aa96ed16..cddb017496 100755
--- a/tests/qemu-iotests/030
+++ b/tests/qemu-iotests/030
@@ -21,7 +21,7 @@ 
 import time
 import os
 import iotests
-from iotests import qemu_img, qemu_io
+from iotests import create_test_image, remove_test_image, qemu_io
 
 backing_img = os.path.join(iotests.test_dir, 'backing.img')
 mid_img = os.path.join(iotests.test_dir, 'mid.img')
@@ -32,8 +32,8 @@  class TestSingleDrive(iotests.QMPTestCase):
 
     def setUp(self):
         iotests.create_image(backing_img, TestSingleDrive.image_len)
-        qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, mid_img)
-        qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % mid_img, test_img)
+        create_test_image(mid_img, backing_file=backing_img)
+        create_test_image(test_img, backing_file=mid_img)
         qemu_io('-f', 'raw', '-c', 'write -P 0x1 0 512', backing_img)
         qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0x1 524288 512', mid_img)
         self.vm = iotests.VM().add_drive("blkdebug::" + test_img,
@@ -43,8 +43,8 @@  class TestSingleDrive(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(test_img)
-        os.remove(mid_img)
+        remove_test_image(test_img)
+        remove_test_image(mid_img)
         os.remove(backing_img)
 
     def test_stream(self):
@@ -155,9 +155,8 @@  class TestSingleDrive(iotests.QMPTestCase):
 
     def test_read_only(self):
         # Create a new file that we can attach (we need a read-only top)
-        with iotests.FilePath('ro-top.img') as ro_top_path:
-            qemu_img('create', '-f', iotests.imgfmt, ro_top_path,
-                     str(self.image_len))
+        with iotests.ImagePath('ro-top.img') as ro_top_path:
+            create_test_image(ro_top_path, self.image_len)
 
             result = self.vm.qmp('blockdev-add',
                                  node_name='ro-top',
@@ -198,8 +197,7 @@  class TestParallelOps(iotests.QMPTestCase):
         # Create all images
         iotests.create_image(self.imgs[0], self.image_len)
         for i in range(1, self.num_imgs):
-            qemu_img('create', '-f', iotests.imgfmt,
-                     '-o', 'backing_file=%s' % self.imgs[i-1], self.imgs[i])
+            create_test_image(self.imgs[i], backing_file=self.imgs[i - 1])
 
         # Put data into the images we are copying data from
         odd_img_indexes = [x for x in reversed(range(self.num_imgs)) if x % 2 == 1]
@@ -219,7 +217,7 @@  class TestParallelOps(iotests.QMPTestCase):
     def tearDown(self):
         self.vm.shutdown()
         for img in self.imgs:
-            os.remove(img)
+            remove_test_image(img)
 
     # Test that it's possible to run several block-stream operations
     # in parallel in the same snapshot chain
@@ -539,11 +537,10 @@  class TestQuorum(iotests.QMPTestCase):
             backing_img = os.path.join(iotests.test_dir, 'backing-%d.img' % i)
             self.children.append(child_img)
             self.backing.append(backing_img)
-            qemu_img('create', '-f', iotests.imgfmt, backing_img, '1M')
+            create_test_image(backing_img, '1M')
             qemu_io('-f', iotests.imgfmt,
                     '-c', 'write -P 0x55 0 1024', backing_img)
-            qemu_img('create', '-f', iotests.imgfmt,
-                     '-o', 'backing_file=%s' % backing_img, child_img)
+            create_test_image(child_img, backing_file=backing_img)
             opts.append("children.%d.file.filename=%s" % (i, child_img))
             opts.append("children.%d.node-name=node%d" % (i, i))
 
@@ -555,9 +552,9 @@  class TestQuorum(iotests.QMPTestCase):
     def tearDown(self):
         self.vm.shutdown()
         for img in self.children:
-            os.remove(img)
+            remove_test_image(img)
         for img in self.backing:
-            os.remove(img)
+            remove_test_image(img)
 
     def test_stream_quorum(self):
         if not iotests.supports_quorum():
@@ -587,7 +584,7 @@  class TestSmallerBackingFile(iotests.QMPTestCase):
 
     def setUp(self):
         iotests.create_image(backing_img, self.backing_len)
-        qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img, str(self.image_len))
+        create_test_image(test_img, self.image_len, backing_file=backing_img)
         self.vm = iotests.VM().add_drive(test_img)
         self.vm.launch()
 
@@ -638,16 +635,15 @@  class TestEIO(TestErrors):
         self.blkdebug_file = backing_img + ".blkdebug"
         iotests.create_image(backing_img, TestErrors.image_len)
         self.create_blkdebug_file(self.blkdebug_file, "read_aio", 5)
-        qemu_img('create', '-f', iotests.imgfmt,
-                 '-o', 'backing_file=blkdebug:%s:%s,backing_fmt=raw'
-                       % (self.blkdebug_file, backing_img),
-                 test_img)
+        create_test_image(test_img, backing_fmt='raw',
+                          backing_file=('blkdebug:%s:%s' % (self.blkdebug_file,
+                                                            backing_img)))
         self.vm = iotests.VM().add_drive(test_img)
         self.vm.launch()
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(test_img)
+        remove_test_image(test_img)
         os.remove(backing_img)
         os.remove(self.blkdebug_file)
 
@@ -788,16 +784,15 @@  class TestENOSPC(TestErrors):
         self.blkdebug_file = backing_img + ".blkdebug"
         iotests.create_image(backing_img, TestErrors.image_len)
         self.create_blkdebug_file(self.blkdebug_file, "read_aio", 28)
-        qemu_img('create', '-f', iotests.imgfmt,
-                 '-o', 'backing_file=blkdebug:%s:%s,backing_fmt=raw'
-                       % (self.blkdebug_file, backing_img),
-                 test_img)
+        create_test_image(test_img, backing_fmt='raw',
+                          backing_file=('blkdebug:%s:%s' % (self.blkdebug_file,
+                                                            backing_img)))
         self.vm = iotests.VM().add_drive(test_img)
         self.vm.launch()
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(test_img)
+        remove_test_image(test_img)
         os.remove(backing_img)
         os.remove(self.blkdebug_file)
 
@@ -848,17 +843,17 @@  class TestStreamStop(iotests.QMPTestCase):
     image_len = 8 * 1024 * 1024 * 1024 # GB
 
     def setUp(self):
-        qemu_img('create', backing_img, str(TestStreamStop.image_len))
-        qemu_io('-f', 'raw', '-c', 'write -P 0x1 0 32M', backing_img)
-        qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
+        create_test_image(backing_img, TestStreamStop.image_len)
+        qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0x1 0 32M', backing_img)
+        create_test_image(test_img, backing_file=backing_img)
         qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0x1 32M 32M', test_img)
         self.vm = iotests.VM().add_drive("blkdebug::" + test_img)
         self.vm.launch()
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(test_img)
-        os.remove(backing_img)
+        remove_test_image(test_img)
+        remove_test_image(backing_img)
 
     def test_stream_stop(self):
         self.assert_no_active_block_jobs()
@@ -879,17 +874,17 @@  class TestSetSpeed(iotests.QMPTestCase):
     image_len = 80 * 1024 * 1024 # MB
 
     def setUp(self):
-        qemu_img('create', backing_img, str(TestSetSpeed.image_len))
-        qemu_io('-f', 'raw', '-c', 'write -P 0x1 0 32M', backing_img)
-        qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
+        create_test_image(backing_img, TestSetSpeed.image_len)
+        qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0x1 0 32M', backing_img)
+        create_test_image(test_img, backing_file=backing_img)
         qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0x1 32M 32M', test_img)
         self.vm = iotests.VM().add_drive('blkdebug::' + test_img)
         self.vm.launch()
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(test_img)
-        os.remove(backing_img)
+        remove_test_image(test_img)
+        remove_test_image(backing_img)
 
     # This is a short performance test which is not run by default.
     # Invoke "IMGFMT=qed ./030 TestSetSpeed.perf_test_throughput"