All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>,
	qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 3/3] tests: Add a tester for HMP commands
Date: Thu, 29 Jun 2017 12:48:32 +0100	[thread overview]
Message-ID: <20170629114832.GF2894@work-vm> (raw)
In-Reply-To: <5d9cb505-1f1f-8d34-d4bb-dc38f2f1dff7@redhat.com>

* Eric Blake (eblake@redhat.com) wrote:
> On 03/30/2017 02:50 AM, Thomas Huth wrote:
> > HMP commands do not get any automatic testing yet, so on certain
> > QEMU machines, some HMP commands were causing crashes in the past.
> > Thus we should test HMP commands in our test suite, too, to avoid
> > that such problems creep in again in the future.
> > 
> > Signed-off-by: Thomas Huth <thuth@redhat.com>
> > ---
> 
> > +static const char *hmp_cmds[] = {
> > +    "boot_set ndc",
> 
> > +/* Run through the list of pre-defined commands */
> > +static void test_commands(void)
> > +{
> > +    char *response;
> > +    int i;
> > +
> > +    for (i = 0; hmp_cmds[i] != NULL; i++) {
> > +        if (verbose) {
> > +            fprintf(stderr, "\t%s\n", hmp_cmds[i]);
> > +        }
> > +        response = hmp(hmp_cmds[i]);
> 
> I failed to notice this sooner, but hmp() is passing its first arg as a
> format string through a printf family.  If hmp_cmds[i] ever gets
> modified to include something with a %, it will misbehave.  Better is to
> use hmp("%s", variable).
> 
> I've patched it locally as part of rebasing my work on avoiding dynamic
> JSON format strings, if no one beats me to a fix (my series also adds
> the gcc format attribute tag, so that the compiler catches any further
> mismatches in hmp() format vs. arguments).

Ah yes, good spot.  Please include that fix.

Dave

> > +    while (*info) {
> > +        /* Extract the info command, ignore parameters and description */
> > +        g_assert(strncmp(info, "info ", 5) == 0);
> > +        endp = strchr(&info[5], ' ');
> > +        g_assert(endp != NULL);
> > +        *endp = '\0';
> > +        /* Now run the info command */
> > +        if (verbose) {
> > +            fprintf(stderr, "\t%s\n", info);
> > +        }
> > +        resp = hmp(info);
> 
> Another instance.
> 
> -- 
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3266
> Virtualization:  qemu.org | libvirt.org
> 



--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

      reply	other threads:[~2017-06-29 11:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-30  7:50 [Qemu-devel] [PATCH v2 0/3] Add a tester for HMP commands Thomas Huth
2017-03-30  7:50 ` [Qemu-devel] [PATCH v2 1/3] libqtest: Ignore QMP events when parsing the response " Thomas Huth
2017-04-03 19:09   ` John Snow
2017-04-04  7:31     ` Thomas Huth
2017-04-04 14:33       ` John Snow
2017-04-07 17:58         ` Dr. David Alan Gilbert
2017-04-11  9:12         ` Markus Armbruster
2017-04-24 11:31           ` Dr. David Alan Gilbert
2017-04-24 12:23             ` Markus Armbruster
2017-03-30  7:50 ` [Qemu-devel] [PATCH v2 2/3] libqtest: Add a generic function to run a callback function for every machine Thomas Huth
2017-04-03 19:14   ` Philippe Mathieu-Daudé
2017-03-30  7:50 ` [Qemu-devel] [PATCH v2 3/3] tests: Add a tester for HMP commands Thomas Huth
2017-04-24 11:23   ` Dr. David Alan Gilbert
2017-04-28  1:56   ` Eric Blake
2017-06-27  2:55   ` Eric Blake
2017-06-29 11:48     ` Dr. David Alan Gilbert [this message]

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=20170629114832.GF2894@work-vm \
    --to=dgilbert@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.