mirror of
https://github.com/qemu/qemu.git
synced 2024-11-26 12:23:36 +08:00
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:
parent
31248b985e
commit
ef91ab0d5f
@ -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
|
||||
|
0
tests/qapi-schema/alternate-branch-if-invalid.err
Normal file
0
tests/qapi-schema/alternate-branch-if-invalid.err
Normal file
1
tests/qapi-schema/alternate-branch-if-invalid.exit
Normal file
1
tests/qapi-schema/alternate-branch-if-invalid.exit
Normal file
@ -0,0 +1 @@
|
||||
0
|
4
tests/qapi-schema/alternate-branch-if-invalid.json
Normal file
4
tests/qapi-schema/alternate-branch-if-invalid.json
Normal file
@ -0,0 +1,4 @@
|
||||
# Cover alternative with invalid 'if'
|
||||
# FIXME not rejected, would generate '#if \n'
|
||||
{ 'alternate': 'Alt',
|
||||
'data': { 'branch': { 'type': 'int', 'if': ' ' } } }
|
16
tests/qapi-schema/alternate-branch-if-invalid.out
Normal file
16
tests/qapi-schema/alternate-branch-if-invalid.out
Normal 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 [' ']
|
0
tests/qapi-schema/features-if-invalid.err
Normal file
0
tests/qapi-schema/features-if-invalid.err
Normal file
1
tests/qapi-schema/features-if-invalid.exit
Normal file
1
tests/qapi-schema/features-if-invalid.exit
Normal file
@ -0,0 +1 @@
|
||||
0
|
5
tests/qapi-schema/features-if-invalid.json
Normal file
5
tests/qapi-schema/features-if-invalid.json
Normal file
@ -0,0 +1,5 @@
|
||||
# Cover feature with invalid 'if'
|
||||
# FIXME not rejected, misinterpreted as unconditional
|
||||
{ 'struct': 'Stru',
|
||||
'data': {},
|
||||
'features': [{'name': 'f', 'if': null }] }
|
14
tests/qapi-schema/features-if-invalid.out
Normal file
14
tests/qapi-schema/features-if-invalid.out
Normal 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
|
0
tests/qapi-schema/struct-member-if-invalid.err
Normal file
0
tests/qapi-schema/struct-member-if-invalid.err
Normal file
1
tests/qapi-schema/struct-member-if-invalid.exit
Normal file
1
tests/qapi-schema/struct-member-if-invalid.exit
Normal file
@ -0,0 +1 @@
|
||||
0
|
4
tests/qapi-schema/struct-member-if-invalid.json
Normal file
4
tests/qapi-schema/struct-member-if-invalid.json
Normal 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 } } }
|
15
tests/qapi-schema/struct-member-if-invalid.out
Normal file
15
tests/qapi-schema/struct-member-if-invalid.out
Normal 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]
|
0
tests/qapi-schema/union-branch-if-invalid.err
Normal file
0
tests/qapi-schema/union-branch-if-invalid.err
Normal file
1
tests/qapi-schema/union-branch-if-invalid.exit
Normal file
1
tests/qapi-schema/union-branch-if-invalid.exit
Normal file
@ -0,0 +1 @@
|
||||
0
|
7
tests/qapi-schema/union-branch-if-invalid.json
Normal file
7
tests/qapi-schema/union-branch-if-invalid.json
Normal 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': [''] } } }
|
23
tests/qapi-schema/union-branch-if-invalid.out
Normal file
23
tests/qapi-schema/union-branch-if-invalid.out
Normal 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 ['']
|
Loading…
Reference in New Issue
Block a user