tests/qapi-schema: Demonstrate insufficient 'if' checking

Cover invalid 'if' in struct members, features, union and alternate
branches.  Four out of four are broken.  Mark FIXME.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-6-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Comment typo fixed]
This commit is contained in:
Markus Armbruster 2019-09-14 17:34:52 +02:00
parent 31248b985e
commit ef91ab0d5f
17 changed files with 96 additions and 0 deletions

View File

@ -294,6 +294,7 @@ check-qtest-generic-y += tests/test-hmp$(EXESUF)
qapi-schema += alternate-any.json
qapi-schema += alternate-array.json
qapi-schema += alternate-base.json
qapi-schema += alternate-branch-if-invalid.json
qapi-schema += alternate-clash.json
qapi-schema += alternate-conflict-dict.json
qapi-schema += alternate-conflict-enum-bool.json
@ -378,6 +379,7 @@ qapi-schema += event-member-invalid-dict.json
qapi-schema += event-nest-struct.json
qapi-schema += features-bad-type.json
qapi-schema += features-duplicate-name.json
qapi-schema += features-if-invalid.json
qapi-schema += features-missing-name.json
qapi-schema += features-name-bad-type.json
qapi-schema += features-no-list.json
@ -452,6 +454,7 @@ qapi-schema += string-code-point-127.json
qapi-schema += struct-base-clash-deep.json
qapi-schema += struct-base-clash.json
qapi-schema += struct-data-invalid.json
qapi-schema += struct-member-if-invalid.json
qapi-schema += struct-member-invalid-dict.json
qapi-schema += struct-member-invalid.json
qapi-schema += trailing-comma-list.json
@ -463,6 +466,7 @@ qapi-schema += unclosed-string.json
qapi-schema += union-base-empty.json
qapi-schema += union-base-no-discriminator.json
qapi-schema += union-branch-case.json
qapi-schema += union-branch-if-invalid.json
qapi-schema += union-branch-invalid-dict.json
qapi-schema += union-clash-branches.json
qapi-schema += union-empty.json

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,4 @@
# Cover alternative with invalid 'if'
# FIXME not rejected, would generate '#if \n'
{ 'alternate': 'Alt',
'data': { 'branch': { 'type': 'int', 'if': ' ' } } }

View File

@ -0,0 +1,16 @@
module None
object q_empty
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool
module alternate-branch-if-invalid.json
alternate Alt
tag type
case branch: int
if [' ']

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,5 @@
# Cover feature with invalid 'if'
# FIXME not rejected, misinterpreted as unconditional
{ 'struct': 'Stru',
'data': {},
'features': [{'name': 'f', 'if': null }] }

View File

@ -0,0 +1,14 @@
module None
object q_empty
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool
module features-if-invalid.json
object Stru
feature f

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,4 @@
# Cover member with invalid 'if'
# FIXME not rejected, would generate '#if True\n'
{ 'struct': 'Stru',
'data': { 'member': { 'type': 'int', 'if': true } } }

View File

@ -0,0 +1,15 @@
module None
object q_empty
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool
module struct-member-if-invalid.json
object Stru
member member: int optional=False
if [True]

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,7 @@
# Cover branch with invalid 'if'
# FIXME not rejected, would generate '#if \n'
{ 'enum': 'Branches', 'data': ['branch1'] }
{ 'struct': 'Stru', 'data': { 'member': 'str' } }
{ 'union': 'Uni',
'base': { 'tag': 'Branches' }, 'discriminator': 'tag',
'data': { 'branch1': { 'type': 'Stru', 'if': [''] } } }

View File

@ -0,0 +1,23 @@
module None
object q_empty
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool
module union-branch-if-invalid.json
enum Branches
member branch1
object Stru
member member: str optional=False
object q_obj_Uni-base
member tag: Branches optional=False
object Uni
base q_obj_Uni-base
tag tag
case branch1: Stru
if ['']