From patchwork Thu Oct 31 02:18:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 287378 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C3BA32C03B2 for ; Thu, 31 Oct 2013 13:18:44 +1100 (EST) Received: from localhost ([::1]:55268 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbhqL-0002er-Db for incoming@patchwork.ozlabs.org; Wed, 30 Oct 2013 22:18:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vbhpz-0002dj-Vj for qemu-devel@nongnu.org; Wed, 30 Oct 2013 22:18:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vbhpu-0004TW-KS for qemu-devel@nongnu.org; Wed, 30 Oct 2013 22:18:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34244) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vbhpu-0004Sy-CL for qemu-devel@nongnu.org; Wed, 30 Oct 2013 22:18:14 -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 r9V2ICrE025123 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 30 Oct 2013 22:18:13 -0400 Received: from T430s.nay.redhat.com ([10.66.4.130]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9V2I9OG020076; Wed, 30 Oct 2013 22:18:11 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 31 Oct 2013 10:18:08 +0800 Message-Id: <1383185888-8131-1-git-send-email-famz@redhat.com> In-Reply-To: <1383126148-1664-1-git-send-email-famz@redhat.com> References: <1383126148-1664-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: kwolf@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: [Qemu-devel] [PATCH v3] qemu-iotests: use blkdebug to make test deterministic 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 This patch suspends the test image IO before starting block stream job so that it doesn't complete before we could check the status. Signed-off-by: Fam Zheng --- tests/qemu-iotests/030 | 10 ++++++---- tests/qemu-iotests/iotests.py | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index d0f96ea..bc66e6f 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -391,7 +391,7 @@ class TestStreamStop(iotests.QMPTestCase): qemu_io('-c', 'write -P 0x1 0 32M', backing_img) qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img) qemu_io('-c', 'write -P 0x1 32M 32M', test_img) - self.vm = iotests.VM().add_drive(test_img) + self.vm = iotests.VM().add_drive("blkdebug::" + test_img) self.vm.launch() def tearDown(self): @@ -402,6 +402,7 @@ class TestStreamStop(iotests.QMPTestCase): def test_stream_stop(self): self.assert_no_active_block_jobs() + self.vm.qmp('human-monitor-command', command_line='qemu-io drive0 "break write_aio a"') result = self.vm.qmp('block-stream', device='drive0') self.assert_qmp(result, 'return', {}) @@ -409,7 +410,7 @@ class TestStreamStop(iotests.QMPTestCase): events = self.vm.get_qmp_events(wait=False) self.assertEqual(events, [], 'unexpected QMP event: %s' % events) - self.cancel_and_wait() + self.cancel_and_wait(resume='a') class TestSetSpeed(iotests.QMPTestCase): image_len = 80 * 1024 * 1024 # MB @@ -419,7 +420,7 @@ class TestSetSpeed(iotests.QMPTestCase): qemu_io('-c', 'write -P 0x1 0 32M', backing_img) qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img) qemu_io('-c', 'write -P 0x1 32M 32M', test_img) - self.vm = iotests.VM().add_drive(test_img) + self.vm = iotests.VM().add_drive('blkdebug::' + test_img) self.vm.launch() def tearDown(self): @@ -453,6 +454,7 @@ class TestSetSpeed(iotests.QMPTestCase): def test_set_speed(self): self.assert_no_active_block_jobs() + self.vm.qmp('human-monitor-command', command_line='qemu-io drive0 "break write_aio a"') result = self.vm.qmp('block-stream', device='drive0') self.assert_qmp(result, 'return', {}) @@ -469,7 +471,7 @@ class TestSetSpeed(iotests.QMPTestCase): self.assert_qmp(result, 'return[0]/device', 'drive0') self.assert_qmp(result, 'return[0]/speed', 8 * 1024 * 1024) - self.cancel_and_wait() + self.cancel_and_wait(resume='a') # Check setting speed in block-stream works result = self.vm.qmp('block-stream', device='drive0', speed=4 * 1024 * 1024) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index fb10ff4..de45079 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -222,11 +222,14 @@ class QMPTestCase(unittest.TestCase): result = self.vm.qmp('query-block-jobs') self.assert_qmp(result, 'return', []) - def cancel_and_wait(self, drive='drive0', force=False): + def cancel_and_wait(self, drive='drive0', force=False, resume=""): '''Cancel a block job and wait for it to finish, returning the event''' result = self.vm.qmp('block-job-cancel', device=drive, force=force) self.assert_qmp(result, 'return', {}) + if resume: + self.vm.qmp('human-monitor-command', command_line='qemu-io %s "resume %s"' % (drive, resume)) + cancelled = False result = None while not cancelled: