summaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/iotests.py
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2013-05-28 17:11:37 +0200
committerKevin Wolf <kwolf@redhat.com>2013-06-04 12:11:58 +0200
commit2499a096a2427f0a5c71750c9f79cf2d2d2d60f4 (patch)
tree28735b783da2c270b56fbbd48c199b595fbfed91 /tests/qemu-iotests/iotests.py
parent3a3918c396c5caeab35a7f51af905172a13d996a (diff)
downloadqemu-2499a096a2427f0a5c71750c9f79cf2d2d2d60f4.tar.gz
qemu-iotests: make create_image() common
Both 030 and 041 use create_image(). Move it to iotests.py. Also drop ImageStreamingTestCase since the class now has no methods. Suggested-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/iotests.py')
-rw-r--r--tests/qemu-iotests/iotests.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 733b82b42b..8a8f1814bd 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -23,6 +23,7 @@ import string
import unittest
import sys; sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'QMP'))
import qmp
+import struct
__all__ = ['imgfmt', 'imgproto', 'test_dir' 'qemu_img', 'qemu_io',
'VM', 'QMPTestCase', 'notrun', 'main']
@@ -56,6 +57,16 @@ def compare_images(img1, img2):
return qemu_img('compare', '-f', imgfmt,
'-F', imgfmt, img1, img2) == 0
+def create_image(name, size):
+ '''Create a fully-allocated raw image with sector markers'''
+ 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 VM(object):
'''A QEMU VM'''