Skip to content

Commit

Permalink
qapi: Add tests of redefined expressions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ebblake authored and Markus Armbruster committed May 5, 2015
1 parent 0545f6b commit cfdd5bc
Show file tree
Hide file tree
Showing 25 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
Empty file.
1 change: 1 addition & 0 deletions tests/qapi-schema/command-int.exit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
3 changes: 3 additions & 0 deletions tests/qapi-schema/command-int.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# FIXME: we should reject collisions between commands and types
{ 'command': 'int', 'data': { 'character': 'str' },
'returns': { 'value': 'int' } }
3 changes: 3 additions & 0 deletions tests/qapi-schema/command-int.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[OrderedDict([('command', 'int'), ('data', OrderedDict([('character', 'str')])), ('returns', OrderedDict([('value', 'int')]))])]
[]
[]
Empty file added tests/qapi-schema/event-max.err
Empty file.
1 change: 1 addition & 0 deletions tests/qapi-schema/event-max.exit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
2 changes: 2 additions & 0 deletions tests/qapi-schema/event-max.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# FIXME: an event named 'MAX' would conflict with implicit C enum
{ 'event': 'MAX' }
3 changes: 3 additions & 0 deletions tests/qapi-schema/event-max.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[OrderedDict([('event', 'MAX')])]
[]
[]
Empty file.
1 change: 1 addition & 0 deletions tests/qapi-schema/redefined-builtin.exit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
2 changes: 2 additions & 0 deletions tests/qapi-schema/redefined-builtin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# FIXME: we should reject types that duplicate builtin names
{ 'type': 'size', 'data': { 'myint': 'size' } }
3 changes: 3 additions & 0 deletions tests/qapi-schema/redefined-builtin.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[OrderedDict([('type', 'size'), ('data', OrderedDict([('myint', 'size')]))])]
[]
[OrderedDict([('type', 'size'), ('data', OrderedDict([('myint', 'size')]))])]
Empty file.
1 change: 1 addition & 0 deletions tests/qapi-schema/redefined-command.exit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
3 changes: 3 additions & 0 deletions tests/qapi-schema/redefined-command.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# FIXME: we should reject commands defined more than once
{ 'command': 'foo', 'data': { 'one': 'str' } }
{ 'command': 'foo', 'data': { '*two': 'str' } }
4 changes: 4 additions & 0 deletions tests/qapi-schema/redefined-command.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[OrderedDict([('command', 'foo'), ('data', OrderedDict([('one', 'str')]))]),
OrderedDict([('command', 'foo'), ('data', OrderedDict([('*two', 'str')]))])]
[]
[]
Empty file.
1 change: 1 addition & 0 deletions tests/qapi-schema/redefined-event.exit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
3 changes: 3 additions & 0 deletions tests/qapi-schema/redefined-event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# FIXME: we should reject duplicate events
{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
4 changes: 4 additions & 0 deletions tests/qapi-schema/redefined-event.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[OrderedDict([('event', 'EVENT_A'), ('data', OrderedDict([('myint', 'int')]))]),
OrderedDict([('event', 'EVENT_A'), ('data', OrderedDict([('myint', 'int')]))])]
[]
[]
Empty file.
1 change: 1 addition & 0 deletions tests/qapi-schema/redefined-type.exit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
3 changes: 3 additions & 0 deletions tests/qapi-schema/redefined-type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# FIXME: we should reject types defined more than once
{ 'type': 'foo', 'data': { 'one': 'str' } }
{ 'enum': 'foo', 'data': [ 'two' ] }
4 changes: 4 additions & 0 deletions tests/qapi-schema/redefined-type.out
Original file line number Diff line number Diff line change
@@ -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')]))])]

0 comments on commit cfdd5bc

Please sign in to comment.