[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 6/7] iotests: allow pretty-print for qmp_log
From: |
John Snow |
Subject: |
Re: [Qemu-devel] [PATCH v2 6/7] iotests: allow pretty-print for qmp_log |
Date: |
Thu, 13 Dec 2018 13:26:27 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 |
On 12/12/18 9:20 PM, Eric Blake wrote:
> On 12/12/18 7:50 PM, John Snow wrote:
>> If iotests have lines exceeding >998 characters long, git doesn't
>> want to send it plaintext to the list. We can solve this by allowing
>> the iotests to use pretty printed QMP output that we can match against
>> instead.
>>
>> As a bonus, it's much nicer for human eyes, too.
>>
>> Signed-off-by: John Snow <address@hidden>
>> ---
>> tests/qemu-iotests/iotests.py | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tests/qemu-iotests/iotests.py
>> b/tests/qemu-iotests/iotests.py
>> index 9595429fea..dbbef4bad3 100644
>> --- a/tests/qemu-iotests/iotests.py
>> +++ b/tests/qemu-iotests/iotests.py
>> @@ -447,12 +447,12 @@ class VM(qtest.QEMUQtestMachine):
>> result.append(filter_qmp_event(ev))
>> return result
>> - def qmp_log(self, cmd, filters=[filter_testfiles], **kwargs):
>> + def qmp_log(self, cmd, indent=None, filters=[filter_testfiles],
>> **kwargs):
>
> Why None instead of False?
>
>> logmsg = '{"execute": "%s", "arguments": %s}' % \
>> (cmd, json.dumps(kwargs, sort_keys=True))
>> log(logmsg, filters)
>> result = self.qmp(cmd, **kwargs)
>> - log(json.dumps(result, sort_keys=True), filters)
>> + log(json.dumps(result, indent=indent, sort_keys=True), filters)
>
> But I'd actually have to read the contract to json.dumps() to learn what
> is expected.
>
> /me goes and does that...
> https://docs.python.org/2/library/json.html
>
> If indent is a non-negative integer, then JSON array elements and object
> members will be pretty-printed with that indent level. An indent level
> of 0, or negative, will only insert newlines. None (the default) selects
> the most compact representation.
>
> Okay, makes sense.
> Reviewed-by: Eric Blake <address@hidden>
>
Yeah, it's a bubbling up of API in this case and a little messy, but it
was the quickest route to making the output look pretty.
- [Qemu-devel] [PATCH v2 0/7] bitmaps: remove x- prefix from QMP api, John Snow, 2018/12/12
- [Qemu-devel] [PATCH v2 1/7] blockdev: abort transactions in reverse order, John Snow, 2018/12/12
- [Qemu-devel] [PATCH v2 2/7] blockdev: n-ary bitmap merge, John Snow, 2018/12/12
- [Qemu-devel] [PATCH v2 3/7] block: remove 'x' prefix from experimental bitmap APIs, John Snow, 2018/12/12
- [Qemu-devel] [PATCH v2 5/7] iotests: add filter_generated_node_ids, John Snow, 2018/12/12