aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2019-05-23 13:06:40 -0400
committerMax Reitz <mreitz@redhat.com>2019-06-14 14:16:57 +0200
commit8b6f5f8b9f3bec5cbeebefab34bae0102a2581b3 (patch)
tree6fbb073754e619cac48cbb434216a81cc980d86c /tests
parentd81e1efbea7d19c2f142d300df56538c73800590 (diff)
downloadqemu-8b6f5f8b9f3bec5cbeebefab34bae0102a2581b3.zip
qemu-8b6f5f8b9f3bec5cbeebefab34bae0102a2581b3.tar.gz
qemu-8b6f5f8b9f3bec5cbeebefab34bae0102a2581b3.tar.bz2
iotests.py: do not use infinite waits
Cap waits to 60 seconds so that iotests can fail gracefully if something goes wrong. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20190523170643.20794-3-jsnow@redhat.com Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qemu-iotests/iotests.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index f11482f..6a3703e 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -524,7 +524,7 @@ class VM(qtest.QEMUQtestMachine):
output_list += [key + '=' + obj[key]]
return ','.join(output_list)
- def get_qmp_events_filtered(self, wait=True):
+ def get_qmp_events_filtered(self, wait=60.0):
result = []
for ev in self.get_qmp_events(wait=wait):
result.append(filter_qmp_event(ev))
@@ -542,10 +542,10 @@ class VM(qtest.QEMUQtestMachine):
# Returns None on success, and an error string on failure
def run_job(self, job, auto_finalize=True, auto_dismiss=False,
- pre_finalize=None):
+ pre_finalize=None, wait=60.0):
error = None
while True:
- for ev in self.get_qmp_events_filtered(wait=True):
+ for ev in self.get_qmp_events_filtered(wait=wait):
if ev['event'] == 'JOB_STATUS_CHANGE':
status = ev['data']['status']
if status == 'aborting':
@@ -650,7 +650,7 @@ class QMPTestCase(unittest.TestCase):
self.assertEqual(self.vm.flatten_qmp_object(json.loads(json_filename[5:])),
self.vm.flatten_qmp_object(reference))
- def cancel_and_wait(self, drive='drive0', force=False, resume=False):
+ def cancel_and_wait(self, drive='drive0', force=False, resume=False, wait=60.0):
'''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', {})
@@ -661,7 +661,7 @@ class QMPTestCase(unittest.TestCase):
cancelled = False
result = None
while not cancelled:
- for event in self.vm.get_qmp_events(wait=True):
+ for event in self.vm.get_qmp_events(wait=wait):
if event['event'] == 'BLOCK_JOB_COMPLETED' or \
event['event'] == 'BLOCK_JOB_CANCELLED':
self.assert_qmp(event, 'data/device', drive)
@@ -674,10 +674,10 @@ class QMPTestCase(unittest.TestCase):
self.assert_no_active_block_jobs()
return result
- def wait_until_completed(self, drive='drive0', check_offset=True):
+ def wait_until_completed(self, drive='drive0', check_offset=True, wait=60.0):
'''Wait for a block job to finish, returning the event'''
while True:
- for event in self.vm.get_qmp_events(wait=True):
+ for event in self.vm.get_qmp_events(wait=wait):
if event['event'] == 'BLOCK_JOB_COMPLETED':
self.assert_qmp(event, 'data/device', drive)
self.assert_qmp_absent(event, 'data/error')