[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] iotests/236: fix transaction kwarg order
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
Re: [Qemu-devel] [PATCH] iotests/236: fix transaction kwarg order |
Date: |
Thu, 31 Jan 2019 10:17:17 +0000 |
31.01.2019 5:26, John Snow wrote:
> It's not enough to order the kwargs for consistent QMP log output,
> we must also sort any sub-dictionaries in lists that appear as values.
>
> Reported-by: Kevin Wolf <address@hidden>
> Signed-off-by: John Snow <address@hidden>
> ---
> tests/qemu-iotests/236.out | 56 +++++++++++++++++------------------
> tests/qemu-iotests/iotests.py | 21 ++++++-------
> 2 files changed, 39 insertions(+), 38 deletions(-)
>
> diff --git a/tests/qemu-iotests/236.out b/tests/qemu-iotests/236.out
> index 1dad24db0d..bb2d71ea5e 100644
> --- a/tests/qemu-iotests/236.out
> +++ b/tests/qemu-iotests/236.out
> @@ -45,23 +45,23 @@ write -P0xcd 0x3ff0000 64k
> "actions": [
> {
> "data": {
> - "node": "drive0",
> - "name": "bitmapB"
We could notice during review, that things we are trying to order so hard
are just not ordered in result :)))
> + "name": "bitmapB",
> + "node": "drive0"
> },
[..]
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index cbedfaf1df..76ad52b358 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -76,15 +76,16 @@ def qemu_img(*args):
> sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode,
> ' '.join(qemu_img_args + list(args))))
> return exitcode
>
> -def ordered_kwargs(kwargs):
> - # kwargs prior to 3.6 are not ordered, so:
> - od = OrderedDict()
> - for k, v in sorted(kwargs.items()):
> - if isinstance(v, dict):
> - od[k] = ordered_kwargs(v)
> - else:
> - od[k] = v
> - return od
> +def ordered_qmp(qmsg):
> + # Dictionaries are not ordered prior to 3.6, therefore:
> + if isinstance(qmsg, list):
> + return [ordered_qmp(atom) for atom in qmsg]
> + if isinstance(qmsg, dict):
> + od = OrderedDict()
> + for k, v in sorted(qmsg.items()):
> + od[k] = ordered_qmp(v)
> + return od
or if you want:
pairs = ((k, ordered_qmp(v)) for k, v in sorted(qmsg.items()))
return OrderedDict(pairs)
> + return qmsg
>
> def qemu_img_create(*args):
> args = list(args)
> @@ -491,7 +492,7 @@ class VM(qtest.QEMUQtestMachine):
> def qmp_log(self, cmd, filters=[], indent=None, **kwargs):
> full_cmd = OrderedDict((
> ("execute", cmd),
> - ("arguments", ordered_kwargs(kwargs))
> + ("arguments", ordered_qmp(kwargs))
> ))
> log(full_cmd, filters, indent=indent)
> result = self.qmp(cmd, **kwargs)
>
anyway,
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
--
Best regards,
Vladimir