mirror of https://gitee.com/openkylin/qemu.git
qapi: Remove outdated tests related to QMP/branch collisions
Now that branches are in a separate C namespace, we can remove
the restrictions in the parser that claim a branch name would
collide with QMP, and delete the negative tests that are no
longer problematic. A separate patch can then add positive
tests to qapi-schema-test to test that any corner cases will
compile correctly.
This reverts the scripts/qapi.py portion of commit 7b2a5c2
,
now that the assertions that it plugged are no longer possible.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447836791-369-15-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
10565ca92a
commit
61a946611b
|
@ -548,8 +548,7 @@ def check_union(expr, expr_info):
|
||||||
base = expr.get('base')
|
base = expr.get('base')
|
||||||
discriminator = expr.get('discriminator')
|
discriminator = expr.get('discriminator')
|
||||||
members = expr['data']
|
members = expr['data']
|
||||||
values = {'MAX': '(automatic)', 'KIND': '(automatic)',
|
values = {'MAX': '(automatic)'}
|
||||||
'TYPE': '(automatic)'}
|
|
||||||
|
|
||||||
# Two types of unions, determined by discriminator.
|
# Two types of unions, determined by discriminator.
|
||||||
|
|
||||||
|
@ -607,19 +606,13 @@ def check_union(expr, expr_info):
|
||||||
" of branch '%s'" % key)
|
" of branch '%s'" % key)
|
||||||
|
|
||||||
# If the discriminator names an enum type, then all members
|
# If the discriminator names an enum type, then all members
|
||||||
# of 'data' must also be members of the enum type, which in turn
|
# of 'data' must also be members of the enum type.
|
||||||
# must not collide with the discriminator name.
|
|
||||||
if enum_define:
|
if enum_define:
|
||||||
if key not in enum_define['enum_values']:
|
if key not in enum_define['enum_values']:
|
||||||
raise QAPIExprError(expr_info,
|
raise QAPIExprError(expr_info,
|
||||||
"Discriminator value '%s' is not found in "
|
"Discriminator value '%s' is not found in "
|
||||||
"enum '%s'" %
|
"enum '%s'" %
|
||||||
(key, enum_define["enum_name"]))
|
(key, enum_define["enum_name"]))
|
||||||
if discriminator in enum_define['enum_values']:
|
|
||||||
raise QAPIExprError(expr_info,
|
|
||||||
"Discriminator name '%s' collides with "
|
|
||||||
"enum value in '%s'" %
|
|
||||||
(discriminator, enum_define["enum_name"]))
|
|
||||||
|
|
||||||
# Otherwise, check for conflicts in the generated enum
|
# Otherwise, check for conflicts in the generated enum
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -281,9 +281,7 @@ qapi-schema += flat-union-bad-base.json
|
||||||
qapi-schema += flat-union-bad-discriminator.json
|
qapi-schema += flat-union-bad-discriminator.json
|
||||||
qapi-schema += flat-union-base-any.json
|
qapi-schema += flat-union-base-any.json
|
||||||
qapi-schema += flat-union-base-union.json
|
qapi-schema += flat-union-base-union.json
|
||||||
qapi-schema += flat-union-clash-branch.json
|
|
||||||
qapi-schema += flat-union-clash-member.json
|
qapi-schema += flat-union-clash-member.json
|
||||||
qapi-schema += flat-union-clash-type.json
|
|
||||||
qapi-schema += flat-union-empty.json
|
qapi-schema += flat-union-empty.json
|
||||||
qapi-schema += flat-union-inline.json
|
qapi-schema += flat-union-inline.json
|
||||||
qapi-schema += flat-union-int-branch.json
|
qapi-schema += flat-union-int-branch.json
|
||||||
|
@ -345,7 +343,6 @@ qapi-schema += union-bad-branch.json
|
||||||
qapi-schema += union-base-no-discriminator.json
|
qapi-schema += union-base-no-discriminator.json
|
||||||
qapi-schema += union-clash-branches.json
|
qapi-schema += union-clash-branches.json
|
||||||
qapi-schema += union-clash-data.json
|
qapi-schema += union-clash-data.json
|
||||||
qapi-schema += union-clash-type.json
|
|
||||||
qapi-schema += union-empty.json
|
qapi-schema += union-empty.json
|
||||||
qapi-schema += union-invalid-base.json
|
qapi-schema += union-invalid-base.json
|
||||||
qapi-schema += union-max.json
|
qapi-schema += union-max.json
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
0
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Flat union branch name collision
|
|
||||||
# FIXME: this parses, but then fails to compile due to a duplicate 'c_d'
|
|
||||||
# (one from the base member, the other from the branch name). We should
|
|
||||||
# either reject the collision at parse time, or munge the generated branch
|
|
||||||
# name to allow this to compile.
|
|
||||||
{ 'enum': 'TestEnum',
|
|
||||||
'data': [ 'base', 'c-d' ] }
|
|
||||||
{ 'struct': 'Base',
|
|
||||||
'data': { 'enum1': 'TestEnum', '*c_d': 'str' } }
|
|
||||||
{ 'struct': 'Branch1',
|
|
||||||
'data': { 'string': 'str' } }
|
|
||||||
{ 'struct': 'Branch2',
|
|
||||||
'data': { 'value': 'int' } }
|
|
||||||
{ 'union': 'TestUnion',
|
|
||||||
'base': 'Base',
|
|
||||||
'discriminator': 'enum1',
|
|
||||||
'data': { 'base': 'Branch1',
|
|
||||||
'c-d': 'Branch2' } }
|
|
|
@ -1,14 +0,0 @@
|
||||||
object :empty
|
|
||||||
object Base
|
|
||||||
member enum1: TestEnum optional=False
|
|
||||||
member c_d: str optional=True
|
|
||||||
object Branch1
|
|
||||||
member string: str optional=False
|
|
||||||
object Branch2
|
|
||||||
member value: int optional=False
|
|
||||||
enum TestEnum ['base', 'c-d']
|
|
||||||
object TestUnion
|
|
||||||
base Base
|
|
||||||
tag enum1
|
|
||||||
case base: Branch1
|
|
||||||
case c-d: Branch2
|
|
|
@ -1 +0,0 @@
|
||||||
tests/qapi-schema/flat-union-clash-type.json:11: Discriminator name 'type' collides with enum value in 'TestEnum'
|
|
|
@ -1 +0,0 @@
|
||||||
1
|
|
|
@ -1,14 +0,0 @@
|
||||||
# Flat union branch 'type'
|
|
||||||
# Reject this, because we would have a clash in generated C, between the
|
|
||||||
# outer tag 'type' and the branch name 'type' within the union.
|
|
||||||
# TODO: We could munge the generated C branch name to let it compile.
|
|
||||||
{ 'enum': 'TestEnum',
|
|
||||||
'data': [ 'type' ] }
|
|
||||||
{ 'struct': 'Base',
|
|
||||||
'data': { 'type': 'TestEnum' } }
|
|
||||||
{ 'struct': 'Branch1',
|
|
||||||
'data': { 'string': 'str' } }
|
|
||||||
{ 'union': 'TestUnion',
|
|
||||||
'base': 'Base',
|
|
||||||
'discriminator': 'type',
|
|
||||||
'data': { 'type': 'Branch1' } }
|
|
|
@ -1 +0,0 @@
|
||||||
tests/qapi-schema/union-clash-type.json:8: Union 'TestUnion' member 'kind' clashes with '(automatic)'
|
|
|
@ -1 +0,0 @@
|
||||||
1
|
|
|
@ -1,9 +0,0 @@
|
||||||
# Union branch 'type'
|
|
||||||
# Reject this, because we would have a clash in generated C, between the
|
|
||||||
# simple union's implicit tag member 'kind' and the branch name 'kind'
|
|
||||||
# within the union.
|
|
||||||
# TODO: Even when the generated C is switched to use 'type' rather than
|
|
||||||
# 'kind', to match the QMP spelling, the collision should still be detected.
|
|
||||||
# Or, we could munge the branch name to allow compilation.
|
|
||||||
{ 'union': 'TestUnion',
|
|
||||||
'data': { 'kind': 'int', 'type': 'str' } }
|
|
Loading…
Reference in New Issue