From patchwork Tue Jun 24 12:26:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 363422 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4121F1400AB for ; Tue, 24 Jun 2014 22:28:55 +1000 (EST) Received: from localhost ([::1]:59281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzPqH-0007BH-F2 for incoming@patchwork.ozlabs.org; Tue, 24 Jun 2014 08:28:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzPo8-0003xK-8e for qemu-devel@nongnu.org; Tue, 24 Jun 2014 08:26:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzPo2-0002ra-1Y for qemu-devel@nongnu.org; Tue, 24 Jun 2014 08:26:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22936) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzPo1-0002rI-PS for qemu-devel@nongnu.org; Tue, 24 Jun 2014 08:26:33 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5OCQWAM019400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jun 2014 08:26:33 -0400 Received: from T430.redhat.com (vpn1-114-78.nay.redhat.com [10.66.114.78]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5OCQJFj006540; Tue, 24 Jun 2014 08:26:30 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 24 Jun 2014 20:26:37 +0800 Message-Id: <1403612798-25167-4-git-send-email-famz@redhat.com> In-Reply-To: <1403612798-25167-1-git-send-email-famz@redhat.com> References: <1403612798-25167-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , stefanha@redhat.com Subject: [Qemu-devel] [PATCH v3 3/4] qemu-iotests: Test BLOCK_JOB_READY event for 0Kb image active commit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org There should be a BLOCK_JOB_READY event with active commit, regardless of image length. Let's test the 0 length image case, and make sure it goes through the ready->complete process. Signed-off-by: Fam Zheng Reviewed-by: Eric Blake --- tests/qemu-iotests/040 | 12 +++++++++--- tests/qemu-iotests/040.out | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index 734b6a6..d166810 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -35,12 +35,13 @@ test_img = os.path.join(iotests.test_dir, 'test.img') class ImageCommitTestCase(iotests.QMPTestCase): '''Abstract base class for image commit test cases''' - def run_commit_test(self, top, base): + def run_commit_test(self, top, base, need_ready=False): self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top=top, base=base) self.assert_qmp(result, 'return', {}) completed = False + ready = False while not completed: for event in self.vm.get_qmp_events(wait=True): if event['event'] == 'BLOCK_JOB_COMPLETED': @@ -48,8 +49,11 @@ class ImageCommitTestCase(iotests.QMPTestCase): 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) + if need_ready: + self.assertTrue(ready, "Expecting BLOCK_JOB_COMPLETED event") completed = True elif event['event'] == 'BLOCK_JOB_READY': + ready = True self.assert_qmp(event, 'data/type', 'commit') self.assert_qmp(event, 'data/device', 'drive0') self.assert_qmp(event, 'data/len', self.image_len) @@ -63,7 +67,7 @@ class TestSingleDrive(ImageCommitTestCase): test_len = 1 * 1024 * 256 def setUp(self): - iotests.create_image(backing_img, TestSingleDrive.image_len) + iotests.create_image(backing_img, self.image_len) 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) qemu_io('-c', 'write -P 0xab 0 524288', backing_img) @@ -105,7 +109,7 @@ class TestSingleDrive(ImageCommitTestCase): self.assert_qmp(result, 'error/desc', 'Base \'badfile\' not found') def test_top_is_active(self): - self.run_commit_test(test_img, backing_img) + self.run_commit_test(test_img, backing_img, need_ready=True) self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', backing_img).find("verification failed")) self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed")) @@ -238,6 +242,8 @@ class TestSetSpeed(ImageCommitTestCase): self.cancel_and_wait(resume=True) +class TestActiveZeroLengthImage(TestSingleDrive): + image_len = 0 if __name__ == '__main__': iotests.main(supported_fmts=['qcow2', 'qed']) diff --git a/tests/qemu-iotests/040.out b/tests/qemu-iotests/040.out index b6f2576..42314e9 100644 --- a/tests/qemu-iotests/040.out +++ b/tests/qemu-iotests/040.out @@ -1,5 +1,5 @@ -................ +........................ ---------------------------------------------------------------------- -Ran 16 tests +Ran 24 tests OK