From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SRln3-0001r3-On for qemu-devel@nongnu.org; Tue, 08 May 2012 10:53:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SRlmw-0007h2-7q for qemu-devel@nongnu.org; Tue, 08 May 2012 10:53:25 -0400 Received: from mail-pz0-f47.google.com ([209.85.210.47]:52083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SRlmv-0007Sn-Vb for qemu-devel@nongnu.org; Tue, 08 May 2012 10:53:18 -0400 Received: by mail-pz0-f47.google.com with SMTP id h21so8313251dal.34 for ; Tue, 08 May 2012 07:53:17 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 8 May 2012 16:51:54 +0200 Message-Id: <1336488722-13120-15-git-send-email-pbonzini@redhat.com> In-Reply-To: <1336488722-13120-1-git-send-email-pbonzini@redhat.com> References: <1336488722-13120-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 1.1 14/22] stream: add testcase for partial streaming List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@linux.vnet.ibm.com Signed-off-by: Paolo Bonzini --- tests/qemu-iotests/030 | 27 ++++++++++++++++++++++++++- tests/qemu-iotests/030.out | 4 ++-- 2 file changed, 28 insertions(+), 3 deletion(-) diff --git a/tests/qemu-iotests/030.out b/tests/qemu-iotests/030.out index 0d2f87b..0aa7a0a 100644 --- a/tests/qemu-iotests/030.out +++ b/tests/qemu-iotests/030.out @@ -1,5 +1,5 @@ -..... +...... ---------------------------------------------------------------------- -Ran 5 tests +Ran 6 tests OK diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index 0d2f87b..0aa7a0a 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -23,6 +23,7 @@ import iotests from iotests import qemu_img, qemu_io backing_img = os.path.join(iotests.test_dir, 'backing.img') +mid_img = os.path.join(iotests.test_dir, 'mid.img') test_img = os.path.join(iotests.test_dir, 'test.img') class ImageStreamingTestCase(iotests.QMPTestCase): @@ -52,7 +53,8 @@ class TestSingleDrive(ImageStreamingTestCase): def setUp(self): qemu_img('create', backing_img, str(TestSingleDrive.image_len)) - qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img) + 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) self.vm.launch() @@ -83,6 +85,29 @@ class TestSingleDrive(ImageStreamingTestCase): self.assertFalse('sectors not allocated' in qemu_io('-c', 'map', test_img), 'image file not fully populated after streaming') + def test_stream_partial(self): + self.assert_no_active_streams() + + result = self.vm.qmp('block-stream', device='drive0', base=mid_img) + self.assert_qmp(result, 'return', {}) + + completed = False + while not completed: + for event in self.vm.get_qmp_events(wait=True): + if event['event'] == 'BLOCK_JOB_COMPLETED': + self.assert_qmp(event, 'data/type', 'stream') + self.assert_qmp(event, 'data/device', 'drive0') + self.assert_qmp(event, 'data/offset', self.image_len) + self.assert_qmp(event, 'data/len', self.image_len) + completed = True + + self.assert_no_active_streams() + self.vm.shutdown() + + self.assertEqual(qemu_io('-c', 'map', mid_img), + qemu_io('-c', 'map', test_img), + 'image file map does not match backing file after streaming') + def test_device_not_found(self): result = self.vm.qmp('block-stream', device='nonexistent') self.assert_qmp(result, 'error/class', 'DeviceNotFound') -- 1.7.10.1