提交 cfdd5bca 编写于 作者: E Eric Blake 提交者: Markus Armbruster

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: NEric Blake <eblake@redhat.com>
Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
上级 0545f6b8
......@@ -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 \
......
0
# FIXME: we should reject collisions between commands and types
{ 'command': 'int', 'data': { 'character': 'str' },
'returns': { 'value': 'int' } }
[OrderedDict([('command', 'int'), ('data', OrderedDict([('character', 'str')])), ('returns', OrderedDict([('value', 'int')]))])]
[]
[]
0
# FIXME: an event named 'MAX' would conflict with implicit C enum
{ 'event': 'MAX' }
[OrderedDict([('event', 'MAX')])]
[]
[]
0
# FIXME: we should reject types that duplicate builtin names
{ 'type': 'size', 'data': { 'myint': 'size' } }
[OrderedDict([('type', 'size'), ('data', OrderedDict([('myint', 'size')]))])]
[]
[OrderedDict([('type', 'size'), ('data', OrderedDict([('myint', 'size')]))])]
0
# FIXME: we should reject commands defined more than once
{ 'command': 'foo', 'data': { 'one': 'str' } }
{ 'command': 'foo', 'data': { '*two': 'str' } }
[OrderedDict([('command', 'foo'), ('data', OrderedDict([('one', 'str')]))]),
OrderedDict([('command', 'foo'), ('data', OrderedDict([('*two', 'str')]))])]
[]
[]
0
# FIXME: we should reject duplicate events
{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
[OrderedDict([('event', 'EVENT_A'), ('data', OrderedDict([('myint', 'int')]))]),
OrderedDict([('event', 'EVENT_A'), ('data', OrderedDict([('myint', 'int')]))])]
[]
[]
0
# FIXME: we should reject types defined more than once
{ 'type': 'foo', 'data': { 'one': 'str' } }
{ 'enum': 'foo', 'data': [ 'two' ] }
[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')]))])]
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部