From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org, Jeff Cody <jcody@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
stefanha@redhat.com, pbonzini@redhat.com
Subject: [Qemu-devel] [PATCH v2 3/3] iotests: Add test cases for drive-mirror "detect-zeroes" option
Date: Mon, 8 Jun 2015 18:34:22 +0800 [thread overview]
Message-ID: <1433759662-25139-4-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1433759662-25139-1-git-send-email-famz@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
---
tests/qemu-iotests/132 | 28 +++++++++++++++++++++++++---
tests/qemu-iotests/132.out | 4 ++--
tests/qemu-iotests/iotests.py | 7 +++++++
3 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/tests/qemu-iotests/132 b/tests/qemu-iotests/132
index f53ef6e..a4a4f01 100644
--- a/tests/qemu-iotests/132
+++ b/tests/qemu-iotests/132
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Test mirror with unmap
+# Test mirror with unmap and zero source clusters
#
# Copyright (C) 2015 Red Hat, Inc.
#
@@ -21,7 +21,7 @@
import time
import os
import iotests
-from iotests import qemu_img, qemu_io
+from iotests import qemu_img, qemu_io, qemu_img_map
test_img = os.path.join(iotests.test_dir, 'test.img')
target_img = os.path.join(iotests.test_dir, 'target.img')
@@ -55,5 +55,27 @@ class TestSingleDrive(iotests.QMPTestCase):
self.assertTrue(iotests.compare_images(test_img, target_img),
'target image does not match source after mirroring')
+ def do_detect_zeroes_test(self, detect_zeroes, unmap):
+ self.vm.hmp_qemu_io('drive0', 'write -P 0 0 2M')
+ result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
+ target=target_img, detect_zeroes=detect_zeroes,
+ unmap=unmap)
+ self.assert_qmp(result, 'return', {})
+ self.complete_and_wait('drive0')
+ self.vm.shutdown()
+ return qemu_img_map(target_img)
+
+ def test_detect_zeroes(self):
+ m = self.do_detect_zeroes_test(detect_zeroes=True, unmap=False);
+ self.assertTrue(m[0]["zero"])
+
+ def test_detect_zeroes_unmap(self):
+ m = self.do_detect_zeroes_test(detect_zeroes=True, unmap=True);
+ self.assertTrue(m[0]["zero"])
+
+ def test_no_detect_zeroes(self):
+ m = self.do_detect_zeroes_test(detect_zeroes=False, unmap=False);
+ self.assertFalse(m[0]["zero"])
+
if __name__ == '__main__':
- iotests.main(supported_fmts=['raw', 'qcow2'])
+ iotests.main(supported_fmts=['qcow2'])
diff --git a/tests/qemu-iotests/132.out b/tests/qemu-iotests/132.out
index ae1213e..89968f3 100644
--- a/tests/qemu-iotests/132.out
+++ b/tests/qemu-iotests/132.out
@@ -1,5 +1,5 @@
-.
+....
----------------------------------------------------------------------
-Ran 1 tests
+Ran 4 tests
OK
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 8615b10..2ddc735 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -27,6 +27,7 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'scripts', '
import qmp
import qtest
import struct
+import json
__all__ = ['imgfmt', 'imgproto', 'test_dir' 'qemu_img', 'qemu_io',
'VM', 'QMPTestCase', 'notrun', 'main']
@@ -58,6 +59,12 @@ def qemu_img_pipe(*args):
'''Run qemu-img and return its output'''
return subprocess.Popen(qemu_img_args + list(args), stdout=subprocess.PIPE).communicate()[0]
+def qemu_img_map(*args):
+ '''Run qemu-img map and return the result parsed from the json formated
+ output '''
+ output = qemu_img_pipe(*(['map', '--output=json'] + list(args)))
+ return json.loads(output)
+
def qemu_io(*args):
'''Run qemu-io and return the stdout data'''
args = qemu_io_args + list(args)
--
2.4.2
prev parent reply other threads:[~2015-06-08 10:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-08 10:34 [Qemu-devel] [PATCH v2 0/3] mirror: Allow detection of zeroes on source sectors Fam Zheng
2015-06-08 10:34 ` [Qemu-devel] [PATCH v2 1/3] block: Extrace bdrv_parse_detect_zeroes_flags Fam Zheng
2015-06-08 14:17 ` Eric Blake
2015-06-08 14:53 ` Paolo Bonzini
2015-06-10 9:11 ` Fam Zheng
2015-06-10 9:24 ` Fam Zheng
2015-06-08 10:34 ` [Qemu-devel] [PATCH v2 2/3] qapi: Add "detect-zeroes" option to drive-mirror Fam Zheng
2015-06-08 10:47 ` Paolo Bonzini
2015-06-08 14:21 ` Eric Blake
2015-06-08 10:34 ` Fam Zheng [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1433759662-25139-4-git-send-email-famz@redhat.com \
--to=famz@redhat.com \
--cc=armbru@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).