[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 06/28] tests/qapi-schema: Tweak to demonstrate buggy member n
From: |
Markus Armbruster |
Subject: |
Re: [PATCH 06/28] tests/qapi-schema: Tweak to demonstrate buggy member name check |
Date: |
Tue, 23 Mar 2021 21:42:08 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
John Snow <jsnow@redhat.com> writes:
> On 3/23/21 11:44 AM, Markus Armbruster wrote:
>> John Snow <jsnow@redhat.com> writes:
>>
>>> On 3/23/21 5:40 AM, Markus Armbruster wrote:
>>>> Member name 'u' and names starting with 'has-' or 'has_' are reserved
>>>> for the generator. check_type() enforces this, covered by tests
>>>> reserved-member-u and reserved-member-has.
>>>> These tests neglect to cover optional members, where the name starts
>>>> with '*'. Tweak reserved-member-u to fix that.
>>>> This demonstrates the reserved member name check is broken for
>>>> optional members. The next commit will fix it.
>>>>
>>>
>>> The test without an optional member goes away. Do we lose coverage?
>>> (Do we care?)
>> Up to a point :) We do try to cover all failure modes, just not in
>> all
>> contexts.
>> The test is about this error:
>> if c_name(key, False) == 'u' or c_name(key,
>> False).startswith('has_'):
>> raise QAPISemError(info, "%s uses reserved name" % key_source)
>> Full matrix: (is "u", starts with "has_") x (optional, not
>> optional).
>> Instead of covering all four cases, we cover two: non-optional "u"
>> (reserved-member-u) and non-optional "has-" (reserved-member-has).
>> The patch flips the former to optional. The latter still covers
>> non-optional.
>> Good enough, I think.
>>
>
> Relies a tiny bit on knowing these two reserved name checks are
> implemented in the same place. Doubt it'll matter
> practically. Coverage has increased overall.
>
>> Do you feel I should point to reserved-member-has in the commit message?
>>
>
> It'd be for my benefit, but you also already just explained it to me.
Amending the second paragraph:
These tests neglect to cover optional members, where the name starts
with '*'. Tweak reserved-member-u to fix that. Test
reserved-member-has still covers non-optional members.
> Reviewed-by: John Snow <jsnow@redhat.com>
Thanks!
- Re: [PATCH 09/28] qapi: Lift enum-specific code out of check_name_str(), (continued)
[PATCH 05/28] tests/qapi-schema: Drop TODO comment on simple unions, Markus Armbruster, 2021/03/23
[PATCH 04/28] tests/qapi-schema: Belatedly update comment on alternate clash, Markus Armbruster, 2021/03/23
[PATCH 24/28] qapi: Enforce command naming rules, Markus Armbruster, 2021/03/23
[PATCH 25/28] tests/qapi-schema: Switch member name clash test to struct, Markus Armbruster, 2021/03/23
[PATCH 16/28] qapi: Factor out QAPISchemaParser._check_pragma_list_of_str(), Markus Armbruster, 2021/03/23