Browse Source
Demonstrate that the qapi generator doesn't deal well with enums that aren't up to par. Later patches will update the expected results as the generator is made stricter. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>pull/23/head
committed by
Markus Armbruster
37 changed files with 66 additions and 1 deletions
@ -0,0 +1 @@ |
|||
0 |
|||
@ -0,0 +1,2 @@ |
|||
# FIXME: we should ensure all enum names can map to C |
|||
{ 'enum': 'MyEnum', 'data': [ 'not^possible' ] } |
|||
@ -0,0 +1,3 @@ |
|||
[OrderedDict([('enum', 'MyEnum'), ('data', ['not^possible'])])] |
|||
[{'enum_name': 'MyEnum', 'enum_values': ['not^possible']}] |
|||
[] |
|||
@ -0,0 +1 @@ |
|||
0 |
|||
@ -0,0 +1,2 @@ |
|||
# FIXME: we should reject enums where members will clash when mapped to C enum |
|||
{ 'enum': 'MyEnum', 'data': [ 'one', 'ONE' ] } |
|||
@ -0,0 +1,3 @@ |
|||
[OrderedDict([('enum', 'MyEnum'), ('data', ['one', 'ONE'])])] |
|||
[{'enum_name': 'MyEnum', 'enum_values': ['one', 'ONE']}] |
|||
[] |
|||
@ -0,0 +1 @@ |
|||
0 |
|||
@ -0,0 +1,2 @@ |
|||
# FIXME: we should reject any enum member that is not a string |
|||
{ 'enum': 'MyEnum', 'data': [ { 'value': 'str' } ] } |
|||
@ -0,0 +1,3 @@ |
|||
[OrderedDict([('enum', 'MyEnum'), ('data', [OrderedDict([('value', 'str')])])])] |
|||
[{'enum_name': 'MyEnum', 'enum_values': [OrderedDict([('value', 'str')])]}] |
|||
[] |
|||
@ -0,0 +1 @@ |
|||
0 |
|||
@ -0,0 +1,2 @@ |
|||
# An empty enum, although unusual, is currently acceptable |
|||
{ 'enum': 'MyEnum', 'data': [ ] } |
|||
@ -0,0 +1,3 @@ |
|||
[OrderedDict([('enum', 'MyEnum'), ('data', [])])] |
|||
[{'enum_name': 'MyEnum', 'enum_values': []}] |
|||
[] |
|||
@ -0,0 +1 @@ |
|||
tests/qapi-schema/enum-int-member.json:3:31: Stray "1" |
|||
@ -0,0 +1 @@ |
|||
1 |
|||
@ -0,0 +1,3 @@ |
|||
# we reject any enum member that is not a string |
|||
# FIXME: once the parser understands integer inputs, improve the error message |
|||
{ 'enum': 'MyEnum', 'data': [ 1 ] } |
|||
@ -0,0 +1 @@ |
|||
0 |
|||
@ -0,0 +1,3 @@ |
|||
# FIXME: we should reject user-supplied 'max' for clashing with implicit enum end |
|||
# TODO: should we instead munge the implicit value to avoid the clash? |
|||
{ 'enum': 'MyEnum', 'data': [ 'max' ] } |
|||
@ -0,0 +1,3 @@ |
|||
[OrderedDict([('enum', 'MyEnum'), ('data', ['max'])])] |
|||
[{'enum_name': 'MyEnum', 'enum_values': ['max']}] |
|||
[] |
|||
@ -0,0 +1,6 @@ |
|||
Traceback (most recent call last): |
|||
File "tests/qapi-schema/test-qapi.py", line 19, in <module> |
|||
exprs = parse_schema(sys.argv[1]) |
|||
File "scripts/qapi.py", line 334, in parse_schema |
|||
add_enum(expr['enum'], expr['data']) |
|||
KeyError: 'data' |
|||
@ -0,0 +1 @@ |
|||
1 |
|||
@ -0,0 +1,2 @@ |
|||
# FIXME: we should require that all QAPI enums have a data array |
|||
{ 'enum': 'MyEnum' } |
|||
@ -0,0 +1 @@ |
|||
0 |
|||
@ -0,0 +1,4 @@ |
|||
# FIXME: we should reject types that would conflict with implicit union enum |
|||
{ 'enum': 'UnionKind', 'data': [ 'oops' ] } |
|||
{ 'union': 'Union', |
|||
'data': { 'a': 'int' } } |
|||
@ -0,0 +1,5 @@ |
|||
[OrderedDict([('enum', 'UnionKind'), ('data', ['oops'])]), |
|||
OrderedDict([('union', 'Union'), ('data', OrderedDict([('a', 'int')]))])] |
|||
[{'enum_name': 'UnionKind', 'enum_values': ['oops']}, |
|||
{'enum_name': 'UnionKind', 'enum_values': None}] |
|||
[] |
|||
@ -0,0 +1 @@ |
|||
0 |
|||
@ -0,0 +1,2 @@ |
|||
# FIXME: we should require that all qapi enums have an array for data |
|||
{ 'enum': 'MyEnum', 'data': { 'value': 'str' } } |
|||
@ -0,0 +1,3 @@ |
|||
[OrderedDict([('enum', 'MyEnum'), ('data', OrderedDict([('value', 'str')]))])] |
|||
[{'enum_name': 'MyEnum', 'enum_values': OrderedDict([('value', 'str')])}] |
|||
[] |
|||
Loading…
Reference in new issue