summaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/iotests.py
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2013-05-28 17:11:36 +0200
committerKevin Wolf <kwolf@redhat.com>2013-06-04 12:11:58 +0200
commit3a3918c396c5caeab35a7f51af905172a13d996a (patch)
tree4faa0b5a8e4f5be73e9c530f92c2359b859385ac /tests/qemu-iotests/iotests.py
parent2575fe16d257a1fb5f452391b868b3c3263a9aca (diff)
downloadqemu-3a3918c396c5caeab35a7f51af905172a13d996a.tar.gz
qemu-iotests: make compare_images() common
The iotests.compare_images() function returns True if two image files have the identical data. Previously this was implemented by converting images to raw and then comparing their contents using Python. Since "qemu-img compare" is now available and is more efficient, switch to it. This function will be reused by the 'drive-backup' test case. 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.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index bc9c71b979..733b82b42b 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -51,6 +51,11 @@ def qemu_io(*args):
args = qemu_io_args + list(args)
return subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0]
+def compare_images(img1, img2):
+ '''Return True if two image files are identical'''
+ return qemu_img('compare', '-f', imgfmt,
+ '-F', imgfmt, img1, img2) == 0
+
class VM(object):
'''A QEMU VM'''