[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 3/3] tests: Add a tester for HMP commands
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v2 3/3] tests: Add a tester for HMP commands |
Date: |
Mon, 26 Jun 2017 21:55:04 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 |
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 <address@hidden>
> ---
> +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).
> + 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
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v2 3/3] tests: Add a tester for HMP commands,
Eric Blake <=