qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: John Snow <jsnow@redhat.com>,
	"qemu-block@nongnu.org" <qemu-block@nongnu.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: Markus Armbruster <armbru@redhat.com>,
	"eblake@redhat.com" <eblake@redhat.com>,
	Max Reitz <mreitz@redhat.com>, Kevin Wolf <kwolf@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 6/7] iotests: allow pretty-print for qmp_log
Date: Mon, 17 Dec 2018 14:26:50 +0000	[thread overview]
Message-ID: <0780ebaa-3e11-c197-85f9-9133dc227d65@virtuozzo.com> (raw)
In-Reply-To: <20181214231512.5295-7-jsnow@redhat.com>

15.12.2018 2:15, 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.
> 
> Note that this changes the sort order for "command" and "arguments",
> so I restrict this reordering to occur only when the indent is specified.
> ---
>   tests/qemu-iotests/iotests.py | 17 +++++++++++++----
>   1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index 9595429fea..ab5823c011 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -447,12 +447,21 @@ class VM(qtest.QEMUQtestMachine):
>               result.append(filter_qmp_event(ev))
>           return result
>   
> -    def qmp_log(self, cmd, filters=[filter_testfiles], **kwargs):
> -        logmsg = '{"execute": "%s", "arguments": %s}' % \
> -            (cmd, json.dumps(kwargs, sort_keys=True))
> +    def qmp_log(self, cmd, indent=None, filters=[filter_testfiles], **kwargs):
> +        # Python < 3.4 needs to know not to add whitespace when pretty-printing:
> +        separators = (',', ': ') if indent is not None else (',', ': ')
> +        if indent is not None:
> +            fullcmd = { "execute": cmd,
> +                        "arguments": kwargs }
> +            logmsg = json.dumps(fullcmd, indent=indent, separators=separators,
> +                                sort_keys=True)
> +        else:
> +            logmsg = '{"execute": "%s", "arguments": %s}' % \
> +                (cmd, json.dumps(kwargs, sort_keys=True))

definitely overlogic on None/is not None, but anyway, ',' separator leads to less
beautiful output. So, I think it is better to do just "re.sub(r'\s+\n', '\n', longmsg)"
on final message, here or in log(), or in both.

>           log(logmsg, filters)
>           result = self.qmp(cmd, **kwargs)
> -        log(json.dumps(result, sort_keys=True), filters)
> +        log(json.dumps(result, indent=indent, separators=separators,
> +                       sort_keys=True), filters)
>           return result
>   
>       def run_job(self, job, auto_finalize=True, auto_dismiss=False):
> 


-- 
Best regards,
Vladimir

  reply	other threads:[~2018-12-17 14:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-14 23:15 [Qemu-devel] [PATCH v3 0/7] bitmaps: remove x- prefix from QMP api John Snow
2018-12-14 23:15 ` [Qemu-devel] [PATCH v3 1/7] blockdev: abort transactions in reverse order John Snow
2018-12-14 23:15 ` [Qemu-devel] [PATCH v3 2/7] blockdev: n-ary bitmap merge John Snow
2018-12-14 23:15 ` [Qemu-devel] [PATCH v3 3/7] block: remove 'x' prefix from experimental bitmap APIs John Snow
2018-12-14 23:15 ` [Qemu-devel] [PATCH v3 4/7] iotests.py: don't abort if IMGKEYSECRET is undefined John Snow
2018-12-14 23:15 ` [Qemu-devel] [PATCH v3 6/7] iotests: allow pretty-print for qmp_log John Snow
2018-12-17 14:26   ` Vladimir Sementsov-Ogievskiy [this message]
2018-12-17 16:37     ` Vladimir Sementsov-Ogievskiy
2018-12-17 19:21       ` John Snow
2018-12-18  8:37         ` Vladimir Sementsov-Ogievskiy
2018-12-14 23:15 ` [Qemu-devel] [PATCH v3 7/7] iotests: add iotest 236 for testing bitmap merge John Snow
2018-12-17 15:48   ` Vladimir Sementsov-Ogievskiy
2018-12-17 21:32     ` John Snow
2018-12-18  8:45       ` Vladimir Sementsov-Ogievskiy
2018-12-18  9:20   ` Vladimir Sementsov-Ogievskiy
2018-12-14 23:32 ` [Qemu-devel] [PATCH v3 5/7 RESEND] iotests: add filter_generated_node_ids John Snow
     [not found] ` <20181214231512.5295-6-jsnow@redhat.com>
2018-12-17 14:37   ` [Qemu-devel] [PATCH v3 5/7] " Vladimir Sementsov-Ogievskiy
2018-12-17 21:14 ` [Qemu-devel] [PATCH v3 0/7] bitmaps: remove x- prefix from QMP api John Snow
2018-12-20  1:24   ` John Snow
2018-12-23 14:28 ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0780ebaa-3e11-c197-85f9-9133dc227d65@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).