From: Fabiano Rosas <farosas@suse.de>
To: qemu-devel@nongnu.org
Cc: "Markus Armbruster" <armbru@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>
Subject: [PATCH v2 02/11] tests/unit/test-qemu-opts: Validate help=foo options
Date: Wed, 30 Sep 2026 19:10:56 -0300 [thread overview]
Message-ID: <20260930221105.2262063-3-farosas@suse.de> (raw)
In-Reply-To: <20260930221105.2262063-1-farosas@suse.de>
The test_has_help_option currently tests two functions:
has_help_option() and qemu_opt_has_help_opt(). The former is only used
by qemu-img and has a significant difference from the latter, which is
used by QOM and qdev:
- has_help_option() REJECTS help=on and all variants that provide a
value, including invalid ones such as help=foo.
- qemu_opt_has_help_opt() ACCEPTS help=on and all variants that
provide a value, including invalid ones such as help=foo.
Add a new test that validates these cases separately.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
tests/unit/test-qemu-opts.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/tests/unit/test-qemu-opts.c b/tests/unit/test-qemu-opts.c
index 8d03a69f7c..4ccb79d406 100644
--- a/tests/unit/test-qemu-opts.c
+++ b/tests/unit/test-qemu-opts.c
@@ -750,6 +750,31 @@ static void test_has_help_option(void)
}
}
+static void test_has_help_option_with_value(void)
+{
+ static const struct {
+ const char *params;
+ } test[] = {
+ { "help=on" },
+ { "help=off" },
+ { "help=foo" },
+ { "help=" },
+ };
+ int i;
+ QemuOpts *opts;
+
+ for (i = 0; i < ARRAY_SIZE(test); i++) {
+ /* reject all */
+ g_assert_cmpint(has_help_option(test[i].params), ==, false);
+
+ /* accept all */
+ opts = qemu_opts_parse(&opts_list_03, test[i].params, false,
+ &error_abort);
+ g_assert_cmpint(qemu_opt_has_help_opt(opts), ==, true);
+ qemu_opts_del(opts);
+ }
+}
+
static void append_verify_list_01(QemuOptDesc *desc, bool with_overlapping)
{
int i = 0;
@@ -1012,6 +1037,8 @@ int main(int argc, char *argv[])
g_test_add_func("/qemu-opts/opts_parse/number", test_opts_parse_number);
g_test_add_func("/qemu-opts/opts_parse/size", test_opts_parse_size);
g_test_add_func("/qemu-opts/has_help_option", test_has_help_option);
+ g_test_add_func("/qemu-opts/has_help_option_with_value",
+ test_has_help_option_with_value);
g_test_add_func("/qemu-opts/append_to_null", test_opts_append_to_null);
g_test_add_func("/qemu-opts/append", test_opts_append);
g_test_add_func("/qemu-opts/to_qdict/basic", test_opts_to_qdict_basic);
--
2.53.0
next prev parent reply other threads:[~2026-09-30 22:12 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 22:10 [PATCH v2 00/11] qemu-options: Spring cleanup Fabiano Rosas
2026-09-30 22:10 ` [PATCH v2 01/11] qemu-option: Use g_autofree when calling get_opt_name_value() Fabiano Rosas
2026-10-01 9:42 ` marcandre.lureau
2026-09-30 22:10 ` Fabiano Rosas [this message]
2026-10-01 9:42 ` [PATCH v2 02/11] tests/unit/test-qemu-opts: Validate help=foo options marcandre.lureau
2026-09-30 22:10 ` [PATCH v2 03/11] qemu-option: Remove short form options support Fabiano Rosas
2026-10-01 9:42 ` marcandre.lureau
2026-10-07 7:08 ` Markus Armbruster
2026-10-07 12:43 ` Fabiano Rosas
2026-10-08 4:42 ` Markus Armbruster
2026-10-10 0:04 ` Fabiano Rosas
2026-10-07 8:16 ` Markus Armbruster
2026-09-30 22:10 ` [PATCH v2 04/11] qemu-option: Fix 'help' parameter parsing Fabiano Rosas
2026-10-01 9:42 ` marcandre.lureau
2026-10-01 15:43 ` Fabiano Rosas
2026-09-30 22:10 ` [PATCH v2 05/11] qemu-option: Add qemu_opts_parse_list Fabiano Rosas
2026-10-01 9:42 ` marcandre.lureau
2026-09-30 22:11 ` [PATCH v2 06/11] qemu-option: Change qemu_parse_opts() to take the group name Fabiano Rosas
2026-10-01 9:42 ` marcandre.lureau
2026-09-30 22:11 ` [PATCH v2 07/11] qemu-option: Add qemu_opts_parse_list_noisily Fabiano Rosas
2026-10-01 9:42 ` marcandre.lureau
2026-10-07 12:54 ` Eric Blake
2026-09-30 22:11 ` [PATCH v2 08/11] qemu-option: Use qemu_opts_parse_list_noisily where appropriate Fabiano Rosas
2026-10-01 9:42 ` marcandre.lureau
2026-09-30 22:11 ` [PATCH v2 09/11] qemu-option: Change qemu_opts_parse_noisily() to take the group Fabiano Rosas
2026-10-01 9:42 ` marcandre.lureau
2026-10-07 12:54 ` Eric Blake
2026-09-30 22:11 ` [PATCH v2 10/11] qemu-option: Check for NULL list at qemu_opts_parse() Fabiano Rosas
2026-10-01 9:42 ` marcandre.lureau
2026-09-30 22:11 ` [PATCH v2 11/11] qemu-option: Remove a few instances of noisily parsing Fabiano Rosas
2026-10-01 9:42 ` marcandre.lureau
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=20260930221105.2262063-3-farosas@suse.de \
--to=farosas@suse.de \
--cc=armbru@redhat.com \
--cc=berrange@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 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.