diff options
author | Markus Armbruster <armbru@redhat.com> | 2021-03-23 10:40:03 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2021-03-23 22:29:19 +0100 |
commit | 73c40b07c6fffcb2725f4c9d3f361967e39aef97 (patch) | |
tree | 020e488a0289b526abf55cd66526fe341c22e290 /tests | |
parent | 1444989a3a4e8399e366ceecf4ed5bbd2d83c727 (diff) | |
download | qemu-73c40b07c6fffcb2725f4c9d3f361967e39aef97.zip qemu-73c40b07c6fffcb2725f4c9d3f361967e39aef97.tar.gz qemu-73c40b07c6fffcb2725f4c9d3f361967e39aef97.tar.bz2 |
tests/qapi-schema: Tweak to demonstrate buggy member name check
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. Test
reserved-member-has still covers non-optional members.
This demonstrates the reserved member name check is broken for
optional members. The next commit will fix it.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-7-armbru@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
[Commit message improved slightly]
Diffstat (limited to 'tests')
-rw-r--r-- | tests/qapi-schema/reserved-member-u.err | 2 | ||||
-rw-r--r-- | tests/qapi-schema/reserved-member-u.json | 3 | ||||
-rw-r--r-- | tests/qapi-schema/reserved-member-u.out | 14 |
3 files changed, 16 insertions, 3 deletions
diff --git a/tests/qapi-schema/reserved-member-u.err b/tests/qapi-schema/reserved-member-u.err index 231d552..e69de29 100644 --- a/tests/qapi-schema/reserved-member-u.err +++ b/tests/qapi-schema/reserved-member-u.err @@ -1,2 +0,0 @@ -reserved-member-u.json: In struct 'Oops': -reserved-member-u.json:7: 'data' member 'u' uses reserved name diff --git a/tests/qapi-schema/reserved-member-u.json b/tests/qapi-schema/reserved-member-u.json index 1eaf0f3..15005ab 100644 --- a/tests/qapi-schema/reserved-member-u.json +++ b/tests/qapi-schema/reserved-member-u.json @@ -4,4 +4,5 @@ # This is true even for non-unions, because it is possible to convert a # struct to flat union while remaining backwards compatible in QMP. # TODO - we could munge the member name to 'q_u' to avoid the collision -{ 'struct': 'Oops', 'data': { 'u': 'str' } } +# BUG: not rejected +{ 'struct': 'Oops', 'data': { '*u': 'str' } } diff --git a/tests/qapi-schema/reserved-member-u.out b/tests/qapi-schema/reserved-member-u.out index e69de29..6a37055 100644 --- a/tests/qapi-schema/reserved-member-u.out +++ b/tests/qapi-schema/reserved-member-u.out @@ -0,0 +1,14 @@ +module ./builtin +object q_empty +enum QType + prefix QTYPE + member none + member qnull + member qnum + member qstring + member qdict + member qlist + member qbool +module reserved-member-u.json +object Oops + member u: str optional=True |