[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 22/24] iotests.py: Let assert_qmp() accept an array
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 22/24] iotests.py: Let assert_qmp() accept an array |
Date: |
Mon, 20 May 2019 18:14:51 +0200 |
From: Max Reitz <address@hidden>
Sometimes we cannot tell which error message qemu will emit, and we do
not care. With this change, we can then just pass an array of all
possible messages to assert_qmp() and it will choose the right one.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
tests/qemu-iotests/iotests.py | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index f811f69135..d96ba1f63c 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -596,9 +596,23 @@ class QMPTestCase(unittest.TestCase):
self.fail('path "%s" has value "%s"' % (path, str(result)))
def assert_qmp(self, d, path, value):
- '''Assert that the value for a specific path in a QMP dict matches'''
+ '''Assert that the value for a specific path in a QMP dict
+ matches. When given a list of values, assert that any of
+ them matches.'''
+
result = self.dictpath(d, path)
- self.assertEqual(result, value, 'values not equal "%s" and "%s"' %
(str(result), str(value)))
+
+ # [] makes no sense as a list of valid values, so treat it as
+ # an actual single value.
+ if isinstance(value, list) and value != []:
+ for v in value:
+ if result == v:
+ return
+ self.fail('no match for "%s" in %s' % (str(result), str(value)))
+ else:
+ self.assertEqual(result, value,
+ 'values not equal "%s" and "%s"'
+ % (str(result), str(value)))
def assert_no_active_block_jobs(self):
result = self.vm.qmp('query-block-jobs')
--
2.20.1
- [Qemu-devel] [PULL 02/24] qcow2: Define and use QCOW2_COMPRESSED_SECTOR_SIZE, (continued)
- [Qemu-devel] [PULL 02/24] qcow2: Define and use QCOW2_COMPRESSED_SECTOR_SIZE, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 10/24] block: Propagate AioContext change to parents, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 08/24] block: Make bdrv_attach/detach_aio_context() static, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 16/24] test-block-iothread: Test AioContext propagation for block jobs, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 15/24] blockjob: Remove AioContext notifiers, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 14/24] blockjob: Propagate AioContext change to all job nodes, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 17/24] block/file-posix: Unaligned O_DIRECT block-status, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 21/24] block: Improve "Block node is read-only" message, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 20/24] qemu-img.texi: Describe human-readable info output, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 23/24] iotests.py: Fix VM.run_job, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 22/24] iotests.py: Let assert_qmp() accept an array,
Kevin Wolf <=
- [Qemu-devel] [PULL 19/24] qemu-img.texi: Be specific about JSON object types, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 18/24] iotests: Test unaligned raw images with O_DIRECT, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 24/24] iotests: Make 245 faster and more reliable, Kevin Wolf, 2019/05/20
- Re: [Qemu-devel] [PULL 00/24] Block layer patches, Peter Maydell, 2019/05/20