qapi: Add tests of redefined expressions

Demonstrate that the qapi generator doesn't deal very well with
redefined expressions.  At the parse level, they are silently
accepted; and while the testsuite just stops at parsing, I've
further tested that many of them cause generator crashes or
invalid C code if they were appended to qapi-schema-test.json.
A later patch will tighten things up and adjust the testsuite
to match.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
master
Eric Blake 2015-05-04 09:05:16 -06:00 committed by Markus Armbruster
parent 0545f6b887
commit cfdd5bcad5
25 changed files with 45 additions and 0 deletions

View File

@ -214,6 +214,8 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, \
missing-type.json bad-ident.json ident-with-escape.json \
double-type.json bad-base.json bad-type-bool.json bad-type-int.json \
bad-type-dict.json double-data.json unknown-expr-key.json \
redefined-type.json redefined-command.json redefined-builtin.json \
redefined-event.json command-int.json event-max.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

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,3 @@
# FIXME: we should reject collisions between commands and types
{ 'command': 'int', 'data': { 'character': 'str' },
'returns': { 'value': 'int' } }

View File

@ -0,0 +1,3 @@
[OrderedDict([('command', 'int'), ('data', OrderedDict([('character', 'str')])), ('returns', OrderedDict([('value', 'int')]))])]
[]
[]

View File

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,2 @@
# FIXME: an event named 'MAX' would conflict with implicit C enum
{ 'event': 'MAX' }

View File

@ -0,0 +1,3 @@
[OrderedDict([('event', 'MAX')])]
[]
[]

View File

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,2 @@
# FIXME: we should reject types that duplicate builtin names
{ 'type': 'size', 'data': { 'myint': 'size' } }

View File

@ -0,0 +1,3 @@
[OrderedDict([('type', 'size'), ('data', OrderedDict([('myint', 'size')]))])]
[]
[OrderedDict([('type', 'size'), ('data', OrderedDict([('myint', 'size')]))])]

View File

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,3 @@
# FIXME: we should reject commands defined more than once
{ 'command': 'foo', 'data': { 'one': 'str' } }
{ 'command': 'foo', 'data': { '*two': 'str' } }

View File

@ -0,0 +1,4 @@
[OrderedDict([('command', 'foo'), ('data', OrderedDict([('one', 'str')]))]),
OrderedDict([('command', 'foo'), ('data', OrderedDict([('*two', 'str')]))])]
[]
[]

View File

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,3 @@
# FIXME: we should reject duplicate events
{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } }

View File

@ -0,0 +1,4 @@
[OrderedDict([('event', 'EVENT_A'), ('data', OrderedDict([('myint', 'int')]))]),
OrderedDict([('event', 'EVENT_A'), ('data', OrderedDict([('myint', 'int')]))])]
[]
[]

View File

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,3 @@
# FIXME: we should reject types defined more than once
{ 'type': 'foo', 'data': { 'one': 'str' } }
{ 'enum': 'foo', 'data': [ 'two' ] }

View File

@ -0,0 +1,4 @@
[OrderedDict([('type', 'foo'), ('data', OrderedDict([('one', 'str')]))]),
OrderedDict([('enum', 'foo'), ('data', ['two'])])]
[{'enum_name': 'foo', 'enum_values': ['two']}]
[OrderedDict([('type', 'foo'), ('data', OrderedDict([('one', 'str')]))])]