Skip to content

Commit

Permalink
iotests: Add iotests.image_size
Browse files Browse the repository at this point in the history
This retrieves the virtual size of the image out of qemu-img info.

Signed-off-by: Fam Zheng <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Reviewed-by: Jeff Cody <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
Fam Zheng authored and kevmw committed Apr 20, 2016
1 parent 4150ae6 commit 74f6905
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/qemu-iotests/iotests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import qmp
import qtest
import struct
import json


# This will not work if arguments contain spaces but is necessary if we
Expand Down Expand Up @@ -103,6 +104,11 @@ def create_image(name, size):
i = i + 512
file.close()

def image_size(img):
'''Return image's virtual size'''
r = qemu_img_pipe('info', '--output=json', '-f', imgfmt, img)
return json.loads(r)['virtual-size']

test_dir_re = re.compile(r"%s" % test_dir)
def filter_test_dir(msg):
return test_dir_re.sub("TEST_DIR", msg)
Expand Down

0 comments on commit 74f6905

Please sign in to comment.