aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/iotests.py
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2015-04-28 16:55:03 +0100
committerPeter Maydell <peter.maydell@linaro.org>2015-04-28 16:55:03 +0100
commita9392bc93c8615ad1983047e9f91ee3fa8aae75f (patch)
tree0ff3fbb6401aa0addbbda6900ce4b984b0c1d2a3 /tests/qemu-iotests/iotests.py
parent84cbd63f87c1d246f51ec8eee5367a5588f367fd (diff)
parent61007b316cd71ee7333ff7a0a749a8949527575f (diff)
downloadqemu-a9392bc93c8615ad1983047e9f91ee3fa8aae75f.zip
qemu-a9392bc93c8615ad1983047e9f91ee3fa8aae75f.tar.gz
qemu-a9392bc93c8615ad1983047e9f91ee3fa8aae75f.tar.bz2
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block patches # gpg: Signature made Tue Apr 28 15:35:05 2015 BST using RSA key ID C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" * remotes/kevin/tags/for-upstream: (76 commits) block: move I/O request processing to block/io.c block: extract bdrv_setup_io_funcs() block: add bdrv_set_dirty()/bdrv_reset_dirty() to block_int.h block: replace bdrv_states iteration with bdrv_next() vmdk: Widen before shifting 32 bit header field block/dmg: make it modular block/mirror: Always call block_job_sleep_ns() iotests: add incremental backup granularity tests iotests: add incremental backup failure recovery test iotests: add simple incremental backup case iotests: add QMP event waiting queue iotests: add invalid input incremental backup tests hbitmap: truncate tests block: Resize bitmaps on bdrv_truncate block: Ensure consistent bitmap function prototypes block: add BdrvDirtyBitmap documentation qmp: Add dirty bitmap status field in query-block qmp: add block-dirty-bitmap-clear qmp: Add support of "dirty-bitmap" sync mode for drive-backup block: Add bitmap successors ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/qemu-iotests/iotests.py')
-rw-r--r--tests/qemu-iotests/iotests.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 1402854..e93e623 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -78,6 +78,23 @@ def create_image(name, size):
i = i + 512
file.close()
+# Test if 'match' is a recursive subset of 'event'
+def event_match(event, match=None):
+ if match is None:
+ return True
+
+ for key in match:
+ if key in event:
+ if isinstance(event[key], dict):
+ if not event_match(event[key], match[key]):
+ return False
+ elif event[key] != match[key]:
+ return False
+ else:
+ return False
+
+ return True
+
class VM(object):
'''A QEMU VM'''
@@ -92,6 +109,7 @@ class VM(object):
'-machine', 'accel=qtest',
'-display', 'none', '-vga', 'none']
self._num_drives = 0
+ self._events = []
# This can be used to add an unused monitor instance.
def add_monitor_telnet(self, ip, port):
@@ -202,14 +220,34 @@ class VM(object):
def get_qmp_event(self, wait=False):
'''Poll for one queued QMP events and return it'''
+ if len(self._events) > 0:
+ return self._events.pop(0)
return self._qmp.pull_event(wait=wait)
def get_qmp_events(self, wait=False):
'''Poll for queued QMP events and return a list of dicts'''
events = self._qmp.get_events(wait=wait)
+ events.extend(self._events)
+ del self._events[:]
self._qmp.clear_events()
return events
+ def event_wait(self, name='BLOCK_JOB_COMPLETED', timeout=60.0, match=None):
+ # Search cached events
+ for event in self._events:
+ if (event['event'] == name) and event_match(event, match):
+ self._events.remove(event)
+ return event
+
+ # Poll for new events
+ while True:
+ event = self._qmp.pull_event(wait=timeout)
+ if (event['event'] == name) and event_match(event, match):
+ return event
+ self._events.append(event)
+
+ return None
+
index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
class QMPTestCase(unittest.TestCase):