qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 14/24] check-qjson: Test errors from qobject_fro


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 14/24] check-qjson: Test errors from qobject_from_json()
Date: Tue, 28 Feb 2017 20:52:10 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Eric Blake <address@hidden> writes:

> On 02/27/2017 05:20 AM, Markus Armbruster wrote:
>> Pass &error_abort with known-good input.  Else pass &err and check
>> what comes back.  This demonstrates that the parser fails silently for
>> many errors.
>> 
>> Signed-off-by: Markus Armbruster <address@hidden>
>> ---
>>  tests/check-qjson.c | 88 
>> ++++++++++++++++++++++++++++++++++-------------------
>>  1 file changed, 56 insertions(+), 32 deletions(-)
>> 
>
>> @@ -809,7 +811,7 @@ static void utf8_string(void)
>>          utf8_in = test_cases[i].utf8_in ?: test_cases[i].utf8_out;
>>          json_out = test_cases[i].json_out ?: test_cases[i].json_in;
>>  
>> -        obj = qobject_from_json(json_in, NULL);
>> +        obj = qobject_from_json(json_in, utf8_out ? &error_abort : NULL);
>
> This one ignores errors if utf8_out is not specified; intentional?
> Especially when compared to...

            if (utf8_out) {
                str = qobject_to_qstring(obj);
                g_assert(str);
                g_assert_cmpstr(qstring_get_str(str), ==, utf8_out);

If @utf8_out, the conversion is expected to work and produce utf8_out.

            } else {
                g_assert(!obj);

Else, the conversion expected not to work.  These are bugs we've known
for a long time.

            }

>>  static void unterminated_string(void)
>>  {
>> -    QObject *obj = qobject_from_json("\"abc", NULL);
>> +    Error *err = NULL;
>> +    QObject *obj = qobject_from_json("\"abc", &err);
>> +    g_assert(!err);             /* BUG */
>>      g_assert(obj == NULL);
>
> change like these.

These are new bugs: the JSON parser can fail without setting an error.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]