[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH 14/24] check-qjson: Test errors fro
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-block] [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.
- [Qemu-block] [PATCH 22/24] qapi: New parse_qapi_name(), (continued)
- [Qemu-block] [PATCH 22/24] qapi: New parse_qapi_name(), Markus Armbruster, 2017/02/27
- [Qemu-block] [PATCH 07/24] qapi: Factor out common qobject_input_get_keyval(), Markus Armbruster, 2017/02/27
- [Qemu-block] [PATCH 15/24] test-visitor-serialization: Pass &error_abort to qobject_from_json(), Markus Armbruster, 2017/02/27
- [Qemu-block] [PATCH 14/24] check-qjson: Test errors from qobject_from_json(), Markus Armbruster, 2017/02/27
- [Qemu-block] [PATCH 23/24] keyval: Restrict key components to valid QAPI names, Markus Armbruster, 2017/02/27
- [Qemu-block] [PATCH 21/24] test-qapi-util: New, covering qapi/qapi-util.c, Markus Armbruster, 2017/02/27
- [Qemu-block] [PATCH 16/24] monitor: Assert qmp_schema_json[] is sane, Markus Armbruster, 2017/02/27
- [Qemu-block] [PATCH 10/24] qjson: Abort earlier on qobject_from_jsonf() misuse, Markus Armbruster, 2017/02/27
- [Qemu-block] [PATCH 09/24] libqtest: Fix qmp() & friends to abort on JSON parse errors, Markus Armbruster, 2017/02/27