diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index eb7bf996d1e13507e09076c56d5aa82fe1403dab..4ab7d62961ccd0c20f400131df3c3222996cdc2a 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -21,6 +21,7 @@ import os import iotests from iotests import qemu_img, qemu_io +import struct backing_img = os.path.join(iotests.test_dir, 'backing.img') mid_img = os.path.join(iotests.test_dir, 'mid.img') @@ -48,11 +49,21 @@ class ImageStreamingTestCase(iotests.QMPTestCase): self.assert_no_active_streams() + def create_image(self, name, size): + file = open(name, 'w') + i = 0 + while i < size: + sector = struct.pack('>l504xl', i / 512, i / 512) + file.write(sector) + i = i + 512 + file.close() + + class TestSingleDrive(ImageStreamingTestCase): image_len = 1 * 1024 * 1024 # MB def setUp(self): - qemu_img('create', backing_img, str(TestSingleDrive.image_len)) + self.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) self.vm = iotests.VM().add_drive(test_img)