test-qemu-opts: Cover qemu_opts_parse() of "no"
authorMarkus Armbruster <armbru@redhat.com>
Tue, 28 Feb 2017 21:26:47 +0000 (22:26 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 7 Mar 2017 15:07:46 +0000 (16:07 +0100)
qemu_opts_parse() interprets "no" as negated empty key.  Consistent
with its acceptance of empty keys elsewhere, whatever that's worth.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <1488317230-26248-2-git-send-email-armbru@redhat.com>

tests/test-qemu-opts.c

index c46ef3165896f99df1a5d0d3c5f4c1dfba42c65b..f6310b34f13d1b2724c3cdff4aaf9b511ef815c0 100644 (file)
@@ -532,6 +532,11 @@ static void test_opts_parse(void)
     g_assert_cmpstr(qemu_opt_get(opts, "aus"), ==, "off");
     g_assert_cmpstr(qemu_opt_get(opts, "noaus"), ==, "");
 
+    /* Implied value, negated empty key */
+    opts = qemu_opts_parse(&opts_list_03, "no", false, &error_abort);
+    g_assert_cmpuint(opts_count(opts), ==, 1);
+    g_assert_cmpstr(qemu_opt_get(opts, ""), ==, "off");
+
     /* Implied key */
     opts = qemu_opts_parse(&opts_list_03, "an,noaus,noaus=", true,
                            &error_abort);