qapi: Add some enum tests

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>
This commit is contained in:
Eric Blake
2015-05-05 18:39:00 +02:00
committed by Markus Armbruster
parent fe2a9303c9
commit ad11dbb937
37 changed files with 66 additions and 1 deletions
+5 -1
View File
@@ -207,7 +207,11 @@ $(foreach target,$(SYSEMU_TARGET_LIST), \
$(eval check-qtest-$(target)-y += tests/qom-test$(EXESUF))))
check-qapi-schema-y := $(addprefix tests/qapi-schema/, \
comments.json empty.json funny-char.json indented-expr.json \
comments.json empty.json enum-empty.json enum-missing-data.json \
enum-wrong-data.json enum-int-member.json enum-dict-member.json \
enum-clash-member.json enum-max-member.json enum-union-clash.json \
enum-bad-name.json \
funny-char.json indented-expr.json \
missing-colon.json missing-comma-list.json \
missing-comma-object.json non-objects.json \
qapi-schema-test.json quoted-structural-chars.json \
View File
+1
View File
@@ -0,0 +1 @@
0
+2
View File
@@ -0,0 +1,2 @@
# FIXME: we should ensure all enum names can map to C
{ 'enum': 'MyEnum', 'data': [ 'not^possible' ] }
+3
View File
@@ -0,0 +1,3 @@
[OrderedDict([('enum', 'MyEnum'), ('data', ['not^possible'])])]
[{'enum_name': 'MyEnum', 'enum_values': ['not^possible']}]
[]
+1
View File
@@ -0,0 +1 @@
0
+2
View File
@@ -0,0 +1,2 @@
# FIXME: we should reject enums where members will clash when mapped to C enum
{ 'enum': 'MyEnum', 'data': [ 'one', 'ONE' ] }
+3
View File
@@ -0,0 +1,3 @@
[OrderedDict([('enum', 'MyEnum'), ('data', ['one', 'ONE'])])]
[{'enum_name': 'MyEnum', 'enum_values': ['one', 'ONE']}]
[]
+1
View File
@@ -0,0 +1 @@
0
+2
View File
@@ -0,0 +1,2 @@
# FIXME: we should reject any enum member that is not a string
{ 'enum': 'MyEnum', 'data': [ { 'value': 'str' } ] }
+3
View File
@@ -0,0 +1,3 @@
[OrderedDict([('enum', 'MyEnum'), ('data', [OrderedDict([('value', 'str')])])])]
[{'enum_name': 'MyEnum', 'enum_values': [OrderedDict([('value', 'str')])]}]
[]
View File
+1
View File
@@ -0,0 +1 @@
0
+2
View File
@@ -0,0 +1,2 @@
# An empty enum, although unusual, is currently acceptable
{ 'enum': 'MyEnum', 'data': [ ] }
+3
View File
@@ -0,0 +1,3 @@
[OrderedDict([('enum', 'MyEnum'), ('data', [])])]
[{'enum_name': 'MyEnum', 'enum_values': []}]
[]
+1
View File
@@ -0,0 +1 @@
tests/qapi-schema/enum-int-member.json:3:31: Stray "1"
+1
View File
@@ -0,0 +1 @@
1
+3
View File
@@ -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 ] }

Some files were not shown because too many files have changed in this diff Show More