From: Peter Xu <peterx@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com,
Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 3/3] tests: more strict command batching test
Date: Thu, 22 Mar 2018 11:48:35 +0800 [thread overview]
Message-ID: <20180322034835.GE32362@xz-mi> (raw)
In-Reply-To: <820c6c94-2b95-0d02-a104-3d70ee76ea37@redhat.com>
On Wed, Mar 21, 2018 at 07:55:19AM -0500, Eric Blake wrote:
> On 03/21/2018 01:55 AM, Peter Xu wrote:
> > Add "id" fields to the commands, and check that the command returns are
> > in order.
> >
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> > tests/qmp-test.c | 8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >
>
> > +++ b/tests/qmp-test.c
> > @@ -83,6 +83,7 @@ static void test_qmp_protocol(void)
> > const QListEntry *entry;
> > QString *qstr;
> > int i;
> > + char buf[128];
>
> Eww, we shouldn't need this.
>
> > qts = qtest_init_without_qmp_handshake(common_args);
> > @@ -150,7 +151,10 @@ static void test_qmp_protocol(void)
> > * best-effort test.
> > */
> > for (i = 0; i < 16; i++) {
> > - qtest_async_qmp(qts, "{ 'execute': 'query-version' }");
> > + snprintf(buf, sizeof(buf) - 1, "{ 'execute': 'query-version', "
> > + "'id': %d }", i);
> > + buf[sizeof(buf) - 1] = '\0';
> > + qtest_async_qmp(qts, buf);
>
> snprintf() of JSON strings is prone to failures especially when the JSON
> string is reinterpreted as a printf argument in qtest_async_qmp. Better is
> to let qtest_async_qmp() directly do the formatting, as in:
>
> qtest_async_qmp(qts, "{ 'execute':'query-version', 'id':%d}", i);
>
> And then I was right - you don't need buf.
Ouch. :)
Will fix that. Thanks,
>
> Otherwise the addition is good.
>
> --
> Eric Blake, Principal Software Engineer
> Red Hat, Inc. +1-919-301-3266
> Virtualization: qemu.org | libvirt.org
--
Peter Xu
next prev parent reply other threads:[~2018-03-22 3:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-21 6:55 [Qemu-devel] [PATCH 0/3] tests: trivial enhancements for OOB Peter Xu
2018-03-21 6:55 ` [Qemu-devel] [PATCH 1/3] tests: let qapi-schema tests detect oob Peter Xu
2018-03-21 12:47 ` Eric Blake
2018-03-21 6:55 ` [Qemu-devel] [PATCH 2/3] tests: add oob-test for qapi-schema Peter Xu
2018-03-21 12:52 ` Eric Blake
2018-03-22 3:43 ` Peter Xu
2018-03-21 6:55 ` [Qemu-devel] [PATCH 3/3] tests: more strict command batching test Peter Xu
2018-03-21 12:55 ` Eric Blake
2018-03-22 3:48 ` Peter Xu [this message]
2018-03-21 12:45 ` [Qemu-devel] [PATCH 0/3] tests: trivial enhancements for OOB Eric Blake
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=20180322034835.GE32362@xz-mi \
--to=peterx@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--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).