aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2019-07-29 16:35:53 -0400
committerJohn Snow <jsnow@redhat.com>2019-08-16 16:28:02 -0400
commitd443b74b3d752640e57a0f7e8efcc09d33504e63 (patch)
treeaeac260d150d77357778abcde33829c3aeaec70a /tests
parent456a2d5ac7641c7e75c76328a561b528a8607a8e (diff)
downloadqemu-d443b74b3d752640e57a0f7e8efcc09d33504e63.zip
qemu-d443b74b3d752640e57a0f7e8efcc09d33504e63.tar.gz
qemu-d443b74b3d752640e57a0f7e8efcc09d33504e63.tar.bz2
iotests: teach run_job to cancel pending jobs
run_job can cancel pending jobs to simulate failure. This lets us use the pending callback to issue test commands while the job is open, but then still have the job fail in the end. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 20190709232550.10724-15-jsnow@redhat.com [Maintainer edit: Merge conflict resolution in run_job] Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qemu-iotests/iotests.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 7fc062c..81ae7b9 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -541,7 +541,23 @@ 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, use_log=True, wait=60.0):
+ pre_finalize=None, cancel=False, use_log=True, wait=60.0):
+ """
+ run_job moves a job from creation through to dismissal.
+
+ :param job: String. ID of recently-launched job
+ :param auto_finalize: Bool. True if the job was launched with
+ auto_finalize. Defaults to True.
+ :param auto_dismiss: Bool. True if the job was launched with
+ auto_dismiss=True. Defaults to False.
+ :param pre_finalize: Callback. A callable that takes no arguments to be
+ invoked prior to issuing job-finalize, if any.
+ :param cancel: Bool. When true, cancels the job after the pre_finalize
+ callback.
+ :param use_log: Bool. When false, does not log QMP messages.
+ :param wait: Float. Timeout value specifying how long to wait for any
+ event, in seconds. Defaults to 60.0.
+ """
match_device = {'data': {'device': job}}
match_id = {'data': {'id': job}}
events = [
@@ -570,7 +586,11 @@ class VM(qtest.QEMUQtestMachine):
elif status == 'pending' and not auto_finalize:
if pre_finalize:
pre_finalize()
- if use_log:
+ if cancel and use_log:
+ self.qmp_log('job-cancel', id=job)
+ elif cancel:
+ self.qmp('job-cancel', id=job)
+ elif use_log:
self.qmp_log('job-finalize', id=job)
else:
self.qmp('job-finalize', id=job)