qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: armbru@redhat.com
Subject: Re: [PATCH for-5.2 3/4] qtest: escape device name in device-introspect-test
Date: Wed, 4 Nov 2020 08:44:51 +0100	[thread overview]
Message-ID: <9fc66c84-56c4-ce09-524f-2cf8ffc210a4@redhat.com> (raw)
In-Reply-To: <20201103151452.416784-4-pbonzini@redhat.com>

On 03/11/2020 16.14, Paolo Bonzini wrote:
> device-introspect-test uses HMP, so it should escape the device name
> properly.  Because of this, a few devices that had commas in their
> names were escaping testing.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  tests/qtest/device-introspect-test.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/qtest/device-introspect-test.c b/tests/qtest/device-introspect-test.c
> index 9f22340ee5..f471b0e0dd 100644
> --- a/tests/qtest/device-introspect-test.c
> +++ b/tests/qtest/device-introspect-test.c
> @@ -104,7 +104,9 @@ static QList *device_type_list(QTestState *qts, bool abstract)
>  static void test_one_device(QTestState *qts, const char *type)
>  {
>      QDict *resp;
> -    char *help;
> +    g_autofree char *help;
> +    g_autofree GRegex *comma;
> +    g_autofree char *escaped;
>  
>      g_test_message("Testing device '%s'", type);
>  
> @@ -113,8 +115,9 @@ static void test_one_device(QTestState *qts, const char *type)
>                 type);
>      qobject_unref(resp);
>  
> -    help = qtest_hmp(qts, "device_add \"%s,help\"", type);
> -    g_free(help);
> +    comma = g_regex_new(",", 0, 0, NULL);
> +    escaped = g_regex_replace_literal(comma, type, -1, 0, ",,", 0, NULL);
> +    help = qtest_hmp(qts, "device_add \"%s,help\"", escaped);
>  }

Having "help =" as final statement now, this looks somewhat weird at a first
glance (until you look at the g_autofree at the beginning of the function).
Maybe it's better to drop the help variable completely and just do:
g_free(gtest_hmp(...)) ?

 Thomas



  reply	other threads:[~2020-11-04  7:47 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03 15:14 [PATCH for-5.2 0/4] deprecate short-form boolean options Paolo Bonzini
2020-11-03 15:14 ` [PATCH for-5.2 1/4] ivshmem-test: do not use short-form boolean option Paolo Bonzini
2020-11-04  7:40   ` Thomas Huth
2020-11-04  9:12   ` Markus Armbruster
2020-11-03 15:14 ` [PATCH for-5.2 2/4] qemu-option: move help handling to get_opt_name_value Paolo Bonzini
2020-11-04 12:21   ` Markus Armbruster
2020-11-04 12:49     ` Paolo Bonzini
2020-11-03 15:14 ` [PATCH for-5.2 3/4] qtest: escape device name in device-introspect-test Paolo Bonzini
2020-11-04  7:44   ` Thomas Huth [this message]
2020-11-04  8:10     ` Paolo Bonzini
2020-11-06 13:15   ` Markus Armbruster
2020-11-06 13:23     ` Paolo Bonzini
2020-11-06 15:34       ` Markus Armbruster
2020-11-03 15:14 ` [PATCH for-5.2 4/4] qemu-option: warn for short-form boolean options Paolo Bonzini
2020-11-03 16:08   ` Daniel P. Berrangé
2020-11-03 16:18     ` Paolo Bonzini
2020-11-04 13:43       ` Markus Armbruster
2020-11-03 21:22     ` Igor Mammedov
2020-11-03 21:41       ` Paolo Bonzini
2020-11-04 11:04         ` Igor Mammedov
2020-11-03 15:33 ` [PATCH for-5.2 0/4] deprecate " 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=9fc66c84-56c4-ce09-524f-2cf8ffc210a4@redhat.com \
    --to=thuth@redhat.com \
    --cc=armbru@redhat.com \
    --cc=pbonzini@redhat.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).