All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-trivial@nongnu.org, tao3.xu@intel.com, qemu-devel@nongnu.org
Subject: Re: [PATCH 2/2] test-keyval: Tighten test of trailing crap after size
Date: Mon, 25 Nov 2019 16:31:14 +0100	[thread overview]
Message-ID: <87fticdlbx.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <b06f7807-b201-5a52-5a62-b50f52cc4d44@redhat.com> (Eric Blake's message of "Mon, 25 Nov 2019 08:29:54 -0600")

Eric Blake <eblake@redhat.com> writes:

> On 11/25/19 7:38 AM, Markus Armbruster wrote:
>> test_keyval_visit_size() should test for trailing crap after size with
>> and without suffix.  It does test the latter: "sz2=16Gi" has size
>> "16G" followed by crap "i".  It fails to test the former "sz1=16E" is
>> a syntactically valid size that overflows uint64_t.  Replace by
>> "sz1=0Z".
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>   tests/test-keyval.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tests/test-keyval.c b/tests/test-keyval.c
>> index 09b0ae3c68..e331a84149 100644
>> --- a/tests/test-keyval.c
>> +++ b/tests/test-keyval.c
>> @@ -478,7 +478,7 @@ static void test_keyval_visit_size(void)
>>       visit_free(v);
>>         /* Trailing crap */
>> -    qdict = keyval_parse("sz1=16E,sz2=16Gi", NULL, &error_abort);
>> +    qdict = keyval_parse("sz1=0Z,sz2=16Gi", NULL, &error_abort);
>
> Does this actually test both failure cases, or does it abort the parse
> after the first failure (sz1=0Z) without ever hitting the second half
> of the parse (sz2=16Gi)?

Fair question!  Short answer: yes, we check both.

Long answer follows.

       /* Trailing crap */
       qdict = keyval_parse("time1=89ks,time2=ns", NULL, &error_abort);

keyval_parse() must succeed: it takes &error_abort.

        v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
        qobject_unref(qdict);

Can't fail.

        visit_start_struct(v, NULL, NULL, 0, &error_abort);

Must succeed.

        visit_type_size(v, "sz1", &sz, &err);
        error_free_or_abort(&err);

This is where we parse "0Z".  Must fail.  We continue.

        visit_type_size(v, "sz2", &sz, &err);
        error_free_or_abort(&err);

This is where we parse "16Gi".  Must fail.  We continue.

        visit_end_struct(v, NULL);
        visit_free(v);
    }

Clear now?



  reply	other threads:[~2019-11-25 15:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-25 13:38 [PATCH 0/2] Minor integer parsing improvements Markus Armbruster
2019-11-25 13:38 ` [PATCH 1/2] util/cutils: Turn FIXME comment into QEMU_BUILD_BUG_ON() Markus Armbruster
2019-11-25 14:17   ` Philippe Mathieu-Daudé
2019-11-25 13:38 ` [PATCH 2/2] test-keyval: Tighten test of trailing crap after size Markus Armbruster
2019-11-25 14:29   ` Eric Blake
2019-11-25 15:31     ` Markus Armbruster [this message]
2019-11-25 16:25       ` Eric Blake
2019-12-18 11:29   ` Laurent Vivier
2019-11-25 21:33 ` [PATCH 0/2] Minor integer parsing improvements 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=87fticdlbx.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=tao3.xu@intel.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.