[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 12/20] qemu-iotests: extract wait_until_completed() i
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 12/20] qemu-iotests: extract wait_until_completed() into iotests.py |
Date: |
Fri, 28 Jun 2013 16:25:01 +0200 |
From: Stefan Hajnoczi <address@hidden>
The 'drive-mirror' tests often issue 'block-job-complete' and wait for
the QMP completion event. Other types of block jobs also want to wait
for completion but they may not need to issue 'block-job-complete'.
Extract wait_until_completed() from 041 and put it into iotests.py.
Return the QMP event object so the caller can make additional
assertions, if necessary.
Signed-off-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
tests/qemu-iotests/041 | 14 ++------------
tests/qemu-iotests/iotests.py | 15 +++++++++++++++
2 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
index 1e923e7..6661c03 100755
--- a/tests/qemu-iotests/041
+++ b/tests/qemu-iotests/041
@@ -57,18 +57,8 @@ class ImageMirroringTestCase(iotests.QMPTestCase):
result = self.vm.qmp('block-job-complete', device=drive)
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', 'mirror')
- self.assert_qmp(event, 'data/device', drive)
- self.assert_qmp_absent(event, 'data/error')
- self.assert_qmp(event, 'data/offset', self.image_len)
- self.assert_qmp(event, 'data/len', self.image_len)
- completed = True
-
- self.assert_no_active_block_jobs()
+ event = self.wait_until_completed()
+ self.assert_qmp(event, 'data/type', 'mirror')
class TestSingleDrive(ImageMirroringTestCase):
image_len = 1 * 1024 * 1024 # MB
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 8a8f181..b028a89 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -208,6 +208,21 @@ class QMPTestCase(unittest.TestCase):
self.assert_no_active_block_jobs()
return result
+ def wait_until_completed(self, drive='drive0'):
+ '''Wait for a block job to finish, returning the event'''
+ 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/device', drive)
+ self.assert_qmp_absent(event, 'data/error')
+ self.assert_qmp(event, 'data/offset', self.image_len)
+ self.assert_qmp(event, 'data/len', self.image_len)
+ completed = True
+
+ self.assert_no_active_block_jobs()
+ return event
+
def notrun(reason):
'''Skip this test suite'''
# Each test in qemu-iotests has a number ("seq")
--
1.8.1.4
- [Qemu-devel] [PULL 02/20] notify: add NotiferWithReturn so notifier list can abort, (continued)
- [Qemu-devel] [PULL 02/20] notify: add NotiferWithReturn so notifier list can abort, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 03/20] block: add bdrv_add_before_write_notifier(), Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 06/20] blockdev: use bdrv_getlength() in qmp_drive_mirror(), Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 04/20] block: add basic backup support to block driver, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 05/20] blockdev: drop redundant proto_drv check, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 09/20] blockdev: allow BdrvActionOps->commit() to be NULL, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 07/20] block: add drive-backup QMP command, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 10/20] blockdev: add DriveBackup transaction, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 08/20] blockdev: rename BlkTransactionStates to singular, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 11/20] blockdev: add Abort transaction, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 12/20] qemu-iotests: extract wait_until_completed() into iotests.py,
Kevin Wolf <=
- [Qemu-devel] [PULL 15/20] block/ssh: Set bdrv_has_zero_init according to the file type., Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 13/20] qemu-iotests: add 055 drive-backup test case, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 14/20] block: Make BlockJobTypes const, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 16/20] gluster: Return bdrv_has_zero_init = 0, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 18/20] vpc: Implement .bdrv_has_zero_init, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 19/20] block: change default of .has_zero_init to 0, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 20/20] cmd646: fix build when DEBUG_IDE is enabled., Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 17/20] vmdk: remove wrong calculation of relative path, Kevin Wolf, 2013/06/28