aboutsummaryrefslogtreecommitdiff
path: root/tests/qapi-schema
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2015-05-04 09:05:17 -0600
committerMarkus Armbruster <armbru@redhat.com>2015-05-05 18:39:01 +0200
commit4dc2e6906e1084fdd37bf67385c5dcd2c72ae22b (patch)
tree38dbff47247cefd2448c56813de8bed894096c92 /tests/qapi-schema
parentcfdd5bcad515a8371af59dba9625e31a6f6f733e (diff)
qapi: Better error messages for duplicated expressions
The previous commit demonstrated that the generator overlooked duplicate expressions: - a complex type or command reusing a built-in type name - redeclaration of a type name, whether by the same or different metatype - redeclaration of a command or event - collision of a type with implicit 'Kind' enum for a union - collision with an implicit MAX enum constant Since the c_type() function in the generator treats all names as being in the same namespace, this patch adds a global array to track all known names and their source, to prevent collisions before it can cause further problems. While valid .json files won't trigger any of these cases, we might as well be nicer to developers that make a typo while trying to add new QAPI code. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'tests/qapi-schema')
-rw-r--r--tests/qapi-schema/command-int.err1
-rw-r--r--tests/qapi-schema/command-int.exit2
-rw-r--r--tests/qapi-schema/command-int.json2
-rw-r--r--tests/qapi-schema/command-int.out3
-rw-r--r--tests/qapi-schema/enum-union-clash.err1
-rw-r--r--tests/qapi-schema/enum-union-clash.exit2
-rw-r--r--tests/qapi-schema/enum-union-clash.json2
-rw-r--r--tests/qapi-schema/enum-union-clash.out5
-rw-r--r--tests/qapi-schema/event-max.err1
-rw-r--r--tests/qapi-schema/event-max.exit2
-rw-r--r--tests/qapi-schema/event-max.json2
-rw-r--r--tests/qapi-schema/event-max.out3
-rw-r--r--tests/qapi-schema/redefined-builtin.err1
-rw-r--r--tests/qapi-schema/redefined-builtin.exit2
-rw-r--r--tests/qapi-schema/redefined-builtin.json2
-rw-r--r--tests/qapi-schema/redefined-builtin.out3
-rw-r--r--tests/qapi-schema/redefined-command.err1
-rw-r--r--tests/qapi-schema/redefined-command.exit2
-rw-r--r--tests/qapi-schema/redefined-command.json2
-rw-r--r--tests/qapi-schema/redefined-command.out4
-rw-r--r--tests/qapi-schema/redefined-event.err1
-rw-r--r--tests/qapi-schema/redefined-event.exit2
-rw-r--r--tests/qapi-schema/redefined-event.json2
-rw-r--r--tests/qapi-schema/redefined-event.out4
-rw-r--r--tests/qapi-schema/redefined-type.err1
-rw-r--r--tests/qapi-schema/redefined-type.exit2
-rw-r--r--tests/qapi-schema/redefined-type.json2
-rw-r--r--tests/qapi-schema/redefined-type.out4
28 files changed, 21 insertions, 40 deletions
diff --git a/tests/qapi-schema/command-int.err b/tests/qapi-schema/command-int.err
index e69de29bb2..0f9300679b 100644
--- a/tests/qapi-schema/command-int.err
+++ b/tests/qapi-schema/command-int.err
@@ -0,0 +1 @@
+tests/qapi-schema/command-int.json:2: built-in 'int' is already defined
diff --git a/tests/qapi-schema/command-int.exit b/tests/qapi-schema/command-int.exit
index 573541ac97..d00491fd7e 100644
--- a/tests/qapi-schema/command-int.exit
+++ b/tests/qapi-schema/command-int.exit
@@ -1 +1 @@
-0
+1
diff --git a/tests/qapi-schema/command-int.json b/tests/qapi-schema/command-int.json
index fcbb643c44..c90d408abe 100644
--- a/tests/qapi-schema/command-int.json
+++ b/tests/qapi-schema/command-int.json
@@ -1,3 +1,3 @@
-# FIXME: we should reject collisions between commands and types
+# we reject collisions between commands and types
{ 'command': 'int', 'data': { 'character': 'str' },
'returns': { 'value': 'int' } }
diff --git a/tests/qapi-schema/command-int.out b/tests/qapi-schema/command-int.out
index d8e1854a04..e69de29bb2 100644
--- a/tests/qapi-schema/command-int.out
+++ b/tests/qapi-schema/command-int.out
@@ -1,3 +0,0 @@
-[OrderedDict([('command', 'int'), ('data', OrderedDict([('character', 'str')])), ('returns', OrderedDict([('value', 'int')]))])]
-[]
-[]
diff --git a/tests/qapi-schema/enum-union-clash.err b/tests/qapi-schema/enum-union-clash.err
index e69de29bb2..c04e1a8064 100644
--- a/tests/qapi-schema/enum-union-clash.err
+++ b/tests/qapi-schema/enum-union-clash.err
@@ -0,0 +1 @@
+tests/qapi-schema/enum-union-clash.json:2: enum 'UnionKind' should not end in 'Kind'
diff --git a/tests/qapi-schema/enum-union-clash.exit b/tests/qapi-schema/enum-union-clash.exit
index 573541ac97..d00491fd7e 100644
--- a/tests/qapi-schema/enum-union-clash.exit
+++ b/tests/qapi-schema/enum-union-clash.exit
@@ -1 +1 @@
-0
+1
diff --git a/tests/qapi-schema/enum-union-clash.json b/tests/qapi-schema/enum-union-clash.json
index 714ff6d556..593282b6cf 100644
--- a/tests/qapi-schema/enum-union-clash.json
+++ b/tests/qapi-schema/enum-union-clash.json
@@ -1,4 +1,4 @@
-# FIXME: we should reject types that would conflict with implicit union enum
+# we reject types that would conflict with implicit union enum
{ 'enum': 'UnionKind', 'data': [ 'oops' ] }
{ 'union': 'Union',
'data': { 'a': 'int' } }
diff --git a/tests/qapi-schema/enum-union-clash.out b/tests/qapi-schema/enum-union-clash.out
index d45f5e8a69..e69de29bb2 100644
--- a/tests/qapi-schema/enum-union-clash.out
+++ b/tests/qapi-schema/enum-union-clash.out
@@ -1,5 +0,0 @@
-[OrderedDict([('enum', 'UnionKind'), ('data', ['oops'])]),
- OrderedDict([('union', 'Union'), ('data', OrderedDict([('a', 'int')]))])]
-[{'enum_name': 'UnionKind', 'enum_values': ['oops']},
- {'enum_name': 'UnionKind', 'enum_values': None}]
-[]
diff --git a/tests/qapi-schema/event-max.err b/tests/qapi-schema/event-max.err
index e69de29bb2..c856534379 100644
--- a/tests/qapi-schema/event-max.err
+++ b/tests/qapi-schema/event-max.err
@@ -0,0 +1 @@
+tests/qapi-schema/event-max.json:2: Event name 'MAX' cannot be created
diff --git a/tests/qapi-schema/event-max.exit b/tests/qapi-schema/event-max.exit
index 573541ac97..d00491fd7e 100644
--- a/tests/qapi-schema/event-max.exit
+++ b/tests/qapi-schema/event-max.exit
@@ -1 +1 @@
-0
+1
diff --git a/tests/qapi-schema/event-max.json b/tests/qapi-schema/event-max.json
index 997c61c511..f3d7de2a30 100644
--- a/tests/qapi-schema/event-max.json
+++ b/tests/qapi-schema/event-max.json
@@ -1,2 +1,2 @@
-# FIXME: an event named 'MAX' would conflict with implicit C enum
+# an event named 'MAX' would conflict with implicit C enum
{ 'event': 'MAX' }
diff --git a/tests/qapi-schema/event-max.out b/tests/qapi-schema/event-max.out
index 010c42b3a9..e69de29bb2 100644
--- a/tests/qapi-schema/event-max.out
+++ b/tests/qapi-schema/event-max.out
@@ -1,3 +0,0 @@
-[OrderedDict([('event', 'MAX')])]
-[]
-[]
diff --git a/tests/qapi-schema/redefined-builtin.err b/tests/qapi-schema/redefined-builtin.err
index e69de29bb2..b2757225c4 100644
--- a/tests/qapi-schema/redefined-builtin.err
+++ b/tests/qapi-schema/redefined-builtin.err
@@ -0,0 +1 @@
+tests/qapi-schema/redefined-builtin.json:2: built-in 'size' is already defined
diff --git a/tests/qapi-schema/redefined-builtin.exit b/tests/qapi-schema/redefined-builtin.exit
index 573541ac97..d00491fd7e 100644
--- a/tests/qapi-schema/redefined-builtin.exit
+++ b/tests/qapi-schema/redefined-builtin.exit
@@ -1 +1 @@
-0
+1
diff --git a/tests/qapi-schema/redefined-builtin.json b/tests/qapi-schema/redefined-builtin.json
index a10050dc73..df328ccc66 100644
--- a/tests/qapi-schema/redefined-builtin.json
+++ b/tests/qapi-schema/redefined-builtin.json
@@ -1,2 +1,2 @@
-# FIXME: we should reject types that duplicate builtin names
+# we reject types that duplicate builtin names
{ 'type': 'size', 'data': { 'myint': 'size' } }
diff --git a/tests/qapi-schema/redefined-builtin.out b/tests/qapi-schema/redefined-builtin.out
index b0a9aea548..e69de29bb2 100644
--- a/tests/qapi-schema/redefined-builtin.out
+++ b/tests/qapi-schema/redefined-builtin.out
@@ -1,3 +0,0 @@
-[OrderedDict([('type', 'size'), ('data', OrderedDict([('myint', 'size')]))])]
-[]
-[OrderedDict([('type', 'size'), ('data', OrderedDict([('myint', 'size')]))])]
diff --git a/tests/qapi-schema/redefined-command.err b/tests/qapi-schema/redefined-command.err
index e69de29bb2..82ae256e63 100644
--- a/tests/qapi-schema/redefined-command.err
+++ b/tests/qapi-schema/redefined-command.err
@@ -0,0 +1 @@
+tests/qapi-schema/redefined-command.json:3: command 'foo' is already defined
diff --git a/tests/qapi-schema/redefined-command.exit b/tests/qapi-schema/redefined-command.exit
index 573541ac97..d00491fd7e 100644
--- a/tests/qapi-schema/redefined-command.exit
+++ b/tests/qapi-schema/redefined-command.exit
@@ -1 +1 @@
-0
+1
diff --git a/tests/qapi-schema/redefined-command.json b/tests/qapi-schema/redefined-command.json
index d8c9975e1c..247e401948 100644
--- a/tests/qapi-schema/redefined-command.json
+++ b/tests/qapi-schema/redefined-command.json
@@ -1,3 +1,3 @@
-# FIXME: we should reject commands defined more than once
+# we reject commands defined more than once
{ 'command': 'foo', 'data': { 'one': 'str' } }
{ 'command': 'foo', 'data': { '*two': 'str' } }
diff --git a/tests/qapi-schema/redefined-command.out b/tests/qapi-schema/redefined-command.out
index 44ddba60d5..e69de29bb2 100644
--- a/tests/qapi-schema/redefined-command.out
+++ b/tests/qapi-schema/redefined-command.out
@@ -1,4 +0,0 @@
-[OrderedDict([('command', 'foo'), ('data', OrderedDict([('one', 'str')]))]),
- OrderedDict([('command', 'foo'), ('data', OrderedDict([('*two', 'str')]))])]
-[]
-[]
diff --git a/tests/qapi-schema/redefined-event.err b/tests/qapi-schema/redefined-event.err
index e69de29bb2..35429cb481 100644
--- a/tests/qapi-schema/redefined-event.err
+++ b/tests/qapi-schema/redefined-event.err
@@ -0,0 +1 @@
+tests/qapi-schema/redefined-event.json:3: event 'EVENT_A' is already defined
diff --git a/tests/qapi-schema/redefined-event.exit b/tests/qapi-schema/redefined-event.exit
index 573541ac97..d00491fd7e 100644
--- a/tests/qapi-schema/redefined-event.exit
+++ b/tests/qapi-schema/redefined-event.exit
@@ -1 +1 @@
-0
+1
diff --git a/tests/qapi-schema/redefined-event.json b/tests/qapi-schema/redefined-event.json
index 152cce720f..7717e91c18 100644
--- a/tests/qapi-schema/redefined-event.json
+++ b/tests/qapi-schema/redefined-event.json
@@ -1,3 +1,3 @@
-# FIXME: we should reject duplicate events
+# we reject duplicate events
{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
diff --git a/tests/qapi-schema/redefined-event.out b/tests/qapi-schema/redefined-event.out
index 261b183fc9..e69de29bb2 100644
--- a/tests/qapi-schema/redefined-event.out
+++ b/tests/qapi-schema/redefined-event.out
@@ -1,4 +0,0 @@
-[OrderedDict([('event', 'EVENT_A'), ('data', OrderedDict([('myint', 'int')]))]),
- OrderedDict([('event', 'EVENT_A'), ('data', OrderedDict([('myint', 'int')]))])]
-[]
-[]
diff --git a/tests/qapi-schema/redefined-type.err b/tests/qapi-schema/redefined-type.err
index e69de29bb2..06ea78c478 100644
--- a/tests/qapi-schema/redefined-type.err
+++ b/tests/qapi-schema/redefined-type.err
@@ -0,0 +1 @@
+tests/qapi-schema/redefined-type.json:3: struct 'foo' is already defined
diff --git a/tests/qapi-schema/redefined-type.exit b/tests/qapi-schema/redefined-type.exit
index 573541ac97..d00491fd7e 100644
--- a/tests/qapi-schema/redefined-type.exit
+++ b/tests/qapi-schema/redefined-type.exit
@@ -1 +1 @@
-0
+1
diff --git a/tests/qapi-schema/redefined-type.json b/tests/qapi-schema/redefined-type.json
index 7972194824..e6a5f24ca9 100644
--- a/tests/qapi-schema/redefined-type.json
+++ b/tests/qapi-schema/redefined-type.json
@@ -1,3 +1,3 @@
-# FIXME: we should reject types defined more than once
+# we reject types defined more than once
{ 'type': 'foo', 'data': { 'one': 'str' } }
{ 'enum': 'foo', 'data': [ 'two' ] }
diff --git a/tests/qapi-schema/redefined-type.out b/tests/qapi-schema/redefined-type.out
index b509e5776c..e69de29bb2 100644
--- a/tests/qapi-schema/redefined-type.out
+++ b/tests/qapi-schema/redefined-type.out
@@ -1,4 +0,0 @@
-[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')]))])]