Browse Source

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>
pull/23/head
Eric Blake 11 years ago
committed by Markus Armbruster
parent
commit
cfdd5bcad5
  1. 2
      tests/Makefile
  2. 0
      tests/qapi-schema/command-int.err
  3. 1
      tests/qapi-schema/command-int.exit
  4. 3
      tests/qapi-schema/command-int.json
  5. 3
      tests/qapi-schema/command-int.out
  6. 0
      tests/qapi-schema/event-max.err
  7. 1
      tests/qapi-schema/event-max.exit
  8. 2
      tests/qapi-schema/event-max.json
  9. 3
      tests/qapi-schema/event-max.out
  10. 0
      tests/qapi-schema/redefined-builtin.err
  11. 1
      tests/qapi-schema/redefined-builtin.exit
  12. 2
      tests/qapi-schema/redefined-builtin.json
  13. 3
      tests/qapi-schema/redefined-builtin.out
  14. 0
      tests/qapi-schema/redefined-command.err
  15. 1
      tests/qapi-schema/redefined-command.exit
  16. 3
      tests/qapi-schema/redefined-command.json
  17. 4
      tests/qapi-schema/redefined-command.out
  18. 0
      tests/qapi-schema/redefined-event.err
  19. 1
      tests/qapi-schema/redefined-event.exit
  20. 3
      tests/qapi-schema/redefined-event.json
  21. 4
      tests/qapi-schema/redefined-event.out
  22. 0
      tests/qapi-schema/redefined-type.err
  23. 1
      tests/qapi-schema/redefined-type.exit
  24. 3
      tests/qapi-schema/redefined-type.json
  25. 4
      tests/qapi-schema/redefined-type.out

2
tests/Makefile

@ -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
tests/qapi-schema/command-int.err

1
tests/qapi-schema/command-int.exit

@ -0,0 +1 @@
0

3
tests/qapi-schema/command-int.json

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

3
tests/qapi-schema/command-int.out

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

0
tests/qapi-schema/event-max.err

1
tests/qapi-schema/event-max.exit

@ -0,0 +1 @@
0

2
tests/qapi-schema/event-max.json

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

3
tests/qapi-schema/event-max.out

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

0
tests/qapi-schema/redefined-builtin.err

1
tests/qapi-schema/redefined-builtin.exit

@ -0,0 +1 @@
0

2
tests/qapi-schema/redefined-builtin.json

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

3
tests/qapi-schema/redefined-builtin.out

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

0
tests/qapi-schema/redefined-command.err

1
tests/qapi-schema/redefined-command.exit

@ -0,0 +1 @@
0

3
tests/qapi-schema/redefined-command.json

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

4
tests/qapi-schema/redefined-command.out

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

0
tests/qapi-schema/redefined-event.err

1
tests/qapi-schema/redefined-event.exit

@ -0,0 +1 @@
0

3
tests/qapi-schema/redefined-event.json

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

4
tests/qapi-schema/redefined-event.out

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

0
tests/qapi-schema/redefined-type.err

1
tests/qapi-schema/redefined-type.exit

@ -0,0 +1 @@
0

3
tests/qapi-schema/redefined-type.json

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

4
tests/qapi-schema/redefined-type.out

@ -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')]))])]
Loading…
Cancel
Save