diff options
author | Eric Blake <eblake@redhat.com> | 2015-05-04 09:05:21 -0600 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2015-05-05 18:39:01 +0200 |
commit | dd883c6f0547f02ae805d02852ff3691f6d08f85 (patch) | |
tree | cd92a7393c8dcf3ef4a02266e2a6db581b774858 /tests/qapi-schema | |
parent | 0d8b9fb5f296a96723d98a45a6a00bfd4e45e1b9 (diff) |
qapi: More rigourous checking of types
Now that we know every expression is valid with regards to
its keys, we can add further tests that those keys refer to
valid types. With this patch, all uses of a type (the 'data':
of command, type, union, alternate, and event; the 'returns':
of command; the 'base': of type and union) must resolve to an
appropriate subset of metatypes declared by the current qapi
parse; this includes recursing into each member of a data
dictionary. Dealing with '**' and nested anonymous structs
will be done in later patches.
Update the testsuite to match improved output.
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')
51 files changed, 39 insertions, 68 deletions
diff --git a/tests/qapi-schema/alternate-array.err b/tests/qapi-schema/alternate-array.err index e2a5fc29bf..7b930c64ab 100644 --- a/tests/qapi-schema/alternate-array.err +++ b/tests/qapi-schema/alternate-array.err @@ -1 +1 @@ -tests/qapi-schema/alternate-array.json:5: Alternate 'Alt' member 'two' must not be array type +tests/qapi-schema/alternate-array.json:5: Member 'two' of alternate 'Alt' cannot be an array diff --git a/tests/qapi-schema/alternate-nested.err b/tests/qapi-schema/alternate-nested.err index 00b05c601e..4d1187e60e 100644 --- a/tests/qapi-schema/alternate-nested.err +++ b/tests/qapi-schema/alternate-nested.err @@ -1 +1 @@ -tests/qapi-schema/alternate-nested.json:4: Alternate 'Alt2' member 'nested' has invalid type 'Alt1' +tests/qapi-schema/alternate-nested.json:4: Member 'nested' of alternate 'Alt2' cannot use alternate type 'Alt1' diff --git a/tests/qapi-schema/alternate-unknown.err b/tests/qapi-schema/alternate-unknown.err index 7af1b4c569..dea45dc730 100644 --- a/tests/qapi-schema/alternate-unknown.err +++ b/tests/qapi-schema/alternate-unknown.err @@ -1 +1 @@ -tests/qapi-schema/alternate-unknown.json:2: Alternate 'Alt' member 'unknown' has invalid type 'MissingType' +tests/qapi-schema/alternate-unknown.json:2: Member 'unknown' of alternate 'Alt' uses unknown type 'MissingType' diff --git a/tests/qapi-schema/bad-base.err b/tests/qapi-schema/bad-base.err index e69de29bb2..f398bbb7d3 100644 --- a/tests/qapi-schema/bad-base.err +++ b/tests/qapi-schema/bad-base.err @@ -0,0 +1 @@ +tests/qapi-schema/bad-base.json:3: 'base' for type 'MyType' cannot use union type 'Union' diff --git a/tests/qapi-schema/bad-base.exit b/tests/qapi-schema/bad-base.exit index 573541ac97..d00491fd7e 100644 --- a/tests/qapi-schema/bad-base.exit +++ b/tests/qapi-schema/bad-base.exit @@ -1 +1 @@ -0 +1 diff --git a/tests/qapi-schema/bad-base.json b/tests/qapi-schema/bad-base.json index de964a0e80..a6904706ad 100644 --- a/tests/qapi-schema/bad-base.json +++ b/tests/qapi-schema/bad-base.json @@ -1,3 +1,3 @@ -# FIXME: we should reject a base that is not a struct +# we reject a base that is not a struct { 'union': 'Union', 'data': { 'a': 'int', 'b': 'str' } } { 'type': 'MyType', 'base': 'Union', 'data': { 'c': 'int' } } diff --git a/tests/qapi-schema/bad-base.out b/tests/qapi-schema/bad-base.out index 91d12fcf6d..e69de29bb2 100644 --- a/tests/qapi-schema/bad-base.out +++ b/tests/qapi-schema/bad-base.out @@ -1,4 +0,0 @@ -[OrderedDict([('union', 'Union'), ('data', OrderedDict([('a', 'int'), ('b', 'str')]))]), - OrderedDict([('type', 'MyType'), ('base', 'Union'), ('data', OrderedDict([('c', 'int')]))])] -[{'enum_name': 'UnionKind', 'enum_values': None}] -[OrderedDict([('type', 'MyType'), ('base', 'Union'), ('data', OrderedDict([('c', 'int')]))])] diff --git a/tests/qapi-schema/bad-data.err b/tests/qapi-schema/bad-data.err index e69de29bb2..8523ac4f46 100644 --- a/tests/qapi-schema/bad-data.err +++ b/tests/qapi-schema/bad-data.err @@ -0,0 +1 @@ +tests/qapi-schema/bad-data.json:2: 'data' for command 'oops' cannot be an array diff --git a/tests/qapi-schema/bad-data.exit b/tests/qapi-schema/bad-data.exit index 573541ac97..d00491fd7e 100644 --- a/tests/qapi-schema/bad-data.exit +++ b/tests/qapi-schema/bad-data.exit @@ -1 +1 @@ -0 +1 diff --git a/tests/qapi-schema/bad-data.json b/tests/qapi-schema/bad-data.json index ff1616dd96..832eeb76f4 100644 --- a/tests/qapi-schema/bad-data.json +++ b/tests/qapi-schema/bad-data.json @@ -1,2 +1,2 @@ -# FIXME: we should ensure 'data' is a dictionary for all but enums +# we ensure 'data' is a dictionary for all but enums { 'command': 'oops', 'data': [ ] } diff --git a/tests/qapi-schema/bad-data.out b/tests/qapi-schema/bad-data.out index 67802be93c..e69de29bb2 100644 --- a/tests/qapi-schema/bad-data.out +++ b/tests/qapi-schema/bad-data.out @@ -1,3 +0,0 @@ -[OrderedDict([('command', 'oops'), ('data', [])])] -[] -[] diff --git a/tests/qapi-schema/data-array-empty.err b/tests/qapi-schema/data-array-empty.err index e69de29bb2..f713f14893 100644 --- a/tests/qapi-schema/data-array-empty.err +++ b/tests/qapi-schema/data-array-empty.err @@ -0,0 +1 @@ +tests/qapi-schema/data-array-empty.json:2: Member 'empty' of 'data' for command 'oops': array type must contain single type name diff --git a/tests/qapi-schema/data-array-empty.exit b/tests/qapi-schema/data-array-empty.exit index 573541ac97..d00491fd7e 100644 --- a/tests/qapi-schema/data-array-empty.exit +++ b/tests/qapi-schema/data-array-empty.exit @@ -1 +1 @@ -0 +1 diff --git a/tests/qapi-schema/data-array-empty.json b/tests/qapi-schema/data-array-empty.json index edb543a75d..652dcfb24a 100644 --- a/tests/qapi-schema/data-array-empty.json +++ b/tests/qapi-schema/data-array-empty.json @@ -1,2 +1,2 @@ -# FIXME: we should reject an array for data if it does not contain a known type +# we reject an array for data if it does not contain a known type { 'command': 'oops', 'data': { 'empty': [ ] } } diff --git a/tests/qapi-schema/data-array-empty.out b/tests/qapi-schema/data-array-empty.out index 6f25c9e18a..e69de29bb2 100644 --- a/tests/qapi-schema/data-array-empty.out +++ b/tests/qapi-schema/data-array-empty.out @@ -1,3 +0,0 @@ -[OrderedDict([('command', 'oops'), ('data', OrderedDict([('empty', [])]))])] -[] -[] diff --git a/tests/qapi-schema/data-array-unknown.err b/tests/qapi-schema/data-array-unknown.err index e69de29bb2..8b731bbcc8 100644 --- a/tests/qapi-schema/data-array-unknown.err +++ b/tests/qapi-schema/data-array-unknown.err @@ -0,0 +1 @@ +tests/qapi-schema/data-array-unknown.json:2: Member 'array' of 'data' for command 'oops' uses unknown type 'array of NoSuchType' diff --git a/tests/qapi-schema/data-array-unknown.exit b/tests/qapi-schema/data-array-unknown.exit index 573541ac97..d00491fd7e 100644 --- a/tests/qapi-schema/data-array-unknown.exit +++ b/tests/qapi-schema/data-array-unknown.exit @@ -1 +1 @@ -0 +1 diff --git a/tests/qapi-schema/data-array-unknown.json b/tests/qapi-schema/data-array-unknown.json index 20cd3c0c30..6f3e883315 100644 --- a/tests/qapi-schema/data-array-unknown.json +++ b/tests/qapi-schema/data-array-unknown.json @@ -1,2 +1,2 @@ -# FIXME: we should reject an array for data if it does not contain a known type +# we reject an array for data if it does not contain a known type { 'command': 'oops', 'data': { 'array': [ 'NoSuchType' ] } } diff --git a/tests/qapi-schema/data-array-unknown.out b/tests/qapi-schema/data-array-unknown.out index 4314ab5dfa..e69de29bb2 100644 --- a/tests/qapi-schema/data-array-unknown.out +++ b/tests/qapi-schema/data-array-unknown.out @@ -1,3 +0,0 @@ -[OrderedDict([('command', 'oops'), ('data', OrderedDict([('array', ['NoSuchType'])]))])] -[] -[] diff --git a/tests/qapi-schema/data-int.err b/tests/qapi-schema/data-int.err index e69de29bb2..1a9b077c06 100644 --- a/tests/qapi-schema/data-int.err +++ b/tests/qapi-schema/data-int.err @@ -0,0 +1 @@ +tests/qapi-schema/data-int.json:2: 'data' for command 'oops' cannot use built-in type 'int' diff --git a/tests/qapi-schema/data-int.exit b/tests/qapi-schema/data-int.exit index 573541ac97..d00491fd7e 100644 --- a/tests/qapi-schema/data-int.exit +++ b/tests/qapi-schema/data-int.exit @@ -1 +1 @@ -0 +1 diff --git a/tests/qapi-schema/data-int.json b/tests/qapi-schema/data-int.json index 37916e09a9..a334d92e8c 100644 --- a/tests/qapi-schema/data-int.json +++ b/tests/qapi-schema/data-int.json @@ -1,2 +1,2 @@ -# FIXME: we should reject commands where data is not an array or complex type +# we reject commands where data is not an array or complex type { 'command': 'oops', 'data': 'int' } diff --git a/tests/qapi-schema/data-int.out b/tests/qapi-schema/data-int.out index e589a4ff92..e69de29bb2 100644 --- a/tests/qapi-schema/data-int.out +++ b/tests/qapi-schema/data-int.out @@ -1,3 +0,0 @@ -[OrderedDict([('command', 'oops'), ('data', 'int')])] -[] -[] diff --git a/tests/qapi-schema/data-member-array-bad.err b/tests/qapi-schema/data-member-array-bad.err index e69de29bb2..2c072d5986 100644 --- a/tests/qapi-schema/data-member-array-bad.err +++ b/tests/qapi-schema/data-member-array-bad.err @@ -0,0 +1 @@ +tests/qapi-schema/data-member-array-bad.json:2: Member 'member' of 'data' for command 'oops': array type must contain single type name diff --git a/tests/qapi-schema/data-member-array-bad.exit b/tests/qapi-schema/data-member-array-bad.exit index 573541ac97..d00491fd7e 100644 --- a/tests/qapi-schema/data-member-array-bad.exit +++ b/tests/qapi-schema/data-member-array-bad.exit @@ -1 +1 @@ -0 +1 diff --git a/tests/qapi-schema/data-member-array-bad.json b/tests/qapi-schema/data-member-array-bad.json index c954af13ee..b2ff144ec6 100644 --- a/tests/qapi-schema/data-member-array-bad.json +++ b/tests/qapi-schema/data-member-array-bad.json @@ -1,2 +1,2 @@ -# FIXME: we should reject data if it does not contain a valid array type +# we reject data if it does not contain a valid array type { 'command': 'oops', 'data': { 'member': [ { 'nested': 'str' } ] } } diff --git a/tests/qapi-schema/data-member-array-bad.out b/tests/qapi-schema/data-member-array-bad.out index 0e00c4171c..e69de29bb2 100644 --- a/tests/qapi-schema/data-member-array-bad.out +++ b/tests/qapi-schema/data-member-array-bad.out @@ -1,3 +0,0 @@ -[OrderedDict([('command', 'oops'), ('data', OrderedDict([('member', [OrderedDict([('nested', 'str')])])]))])] -[] -[] diff --git a/tests/qapi-schema/data-member-unknown.err b/tests/qapi-schema/data-member-unknown.err index e69de29bb2..ab905db802 100644 --- a/tests/qapi-schema/data-member-unknown.err +++ b/tests/qapi-schema/data-member-unknown.err @@ -0,0 +1 @@ +tests/qapi-schema/data-member-unknown.json:2: Member 'member' of 'data' for command 'oops' uses unknown type 'NoSuchType' diff --git a/tests/qapi-schema/data-member-unknown.exit b/tests/qapi-schema/data-member-unknown.exit index 573541ac97..d00491fd7e 100644 --- a/tests/qapi-schema/data-member-unknown.exit +++ b/tests/qapi-schema/data-member-unknown.exit @@ -1 +1 @@ -0 +1 diff --git a/tests/qapi-schema/data-member-unknown.json b/tests/qapi-schema/data-member-unknown.json index 40e6252c1d..342a41ec90 100644 --- a/tests/qapi-schema/data-member-unknown.json +++ b/tests/qapi-schema/data-member-unknown.json @@ -1,2 +1,2 @@ -# FIXME: we should reject data if it does not contain a known type +# we reject data if it does not contain a known type { 'command': 'oops', 'data': { 'member': 'NoSuchType' } } diff --git a/tests/qapi-schema/data-member-unknown.out b/tests/qapi-schema/data-member-unknown.out index 36252a5f73..e69de29bb2 100644 --- a/tests/qapi-schema/data-member-unknown.out +++ b/tests/qapi-schema/data-member-unknown.out @@ -1,3 +0,0 @@ -[OrderedDict([('command', 'oops'), ('data', OrderedDict([('member', 'NoSuchType')]))])] -[] -[] diff --git a/tests/qapi-schema/data-unknown.err b/tests/qapi-schema/data-unknown.err index e69de29bb2..5b07277a95 100644 --- a/tests/qapi-schema/data-unknown.err +++ b/tests/qapi-schema/data-unknown.err @@ -0,0 +1 @@ +tests/qapi-schema/data-unknown.json:2: 'data' for command 'oops' uses unknown type 'NoSuchType' diff --git a/tests/qapi-schema/data-unknown.exit b/tests/qapi-schema/data-unknown.exit index 573541ac97..d00491fd7e 100644 --- a/tests/qapi-schema/data-unknown.exit +++ b/tests/qapi-schema/data-unknown.exit @@ -1 +1 @@ -0 +1 diff --git a/tests/qapi-schema/data-unknown.json b/tests/qapi-schema/data-unknown.json index 776bd342e5..32aba43b3f 100644 --- a/tests/qapi-schema/data-unknown.json +++ b/tests/qapi-schema/data-unknown.json @@ -1,2 +1,2 @@ -# FIXME: we should reject data if it does not contain a known type +# we reject data if it does not contain a known type { 'command': 'oops', 'data': 'NoSuchType' } diff --git a/tests/qapi-schema/data-unknown.out b/tests/qapi-schema/data-unknown.out index 2c60726881..e69de29bb2 100644 --- a/tests/qapi-schema/data-unknown.out +++ b/tests/qapi-schema/data-unknown.out @@ -1,3 +0,0 @@ -[OrderedDict([('command', 'oops'), ('data', 'NoSuchType')])] -[] -[] diff --git a/tests/qapi-schema/flat-union-int-branch.err b/tests/qapi-schema/flat-union-int-branch.err index e69de29bb2..faf01573b7 100644 --- a/tests/qapi-schema/flat-union-int-branch.err +++ b/tests/qapi-schema/flat-union-int-branch.err @@ -0,0 +1 @@ +tests/qapi-schema/flat-union-int-branch.json:8: Member 'value1' of union 'TestUnion' cannot use built-in type 'int' diff --git a/tests/qapi-schema/flat-union-int-branch.exit b/tests/qapi-schema/flat-union-int-branch.exit index 573541ac97..d00491fd7e 100644 --- a/tests/qapi-schema/flat-union-int-branch.exit +++ b/tests/qapi-schema/flat-union-int-branch.exit @@ -1 +1 @@ -0 +1 diff --git a/tests/qapi-schema/flat-union-int-branch.json b/tests/qapi-schema/flat-union-int-branch.json index 3543215436..d373131653 100644 --- a/tests/qapi-schema/flat-union-int-branch.json +++ b/tests/qapi-schema/flat-union-int-branch.json @@ -1,4 +1,4 @@ -# FIXME: we should require flat union branches to be a complex type +# we require flat union branches to be a complex type { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } { 'type': 'Base', diff --git a/tests/qapi-schema/flat-union-int-branch.out b/tests/qapi-schema/flat-union-int-branch.out index cd40e6c198..e69de29bb2 100644 --- a/tests/qapi-schema/flat-union-int-branch.out +++ b/tests/qapi-schema/flat-union-int-branch.out @@ -1,7 +0,0 @@ -[OrderedDict([('enum', 'TestEnum'), ('data', ['value1', 'value2'])]), - OrderedDict([('type', 'Base'), ('data', OrderedDict([('enum1', 'TestEnum')]))]), - OrderedDict([('type', 'TestTypeB'), ('data', OrderedDict([('integer', 'int')]))]), - OrderedDict([('union', 'TestUnion'), ('base', 'Base'), ('discriminator', 'enum1'), ('data', OrderedDict([('value1', 'int'), ('value2', 'TestTypeB')]))])] -[{'enum_name': 'TestEnum', 'enum_values': ['value1', 'value2']}] -[OrderedDict([('type', 'Base'), ('data', OrderedDict([('enum1', 'TestEnum')]))]), - OrderedDict([('type', 'TestTypeB'), ('data', OrderedDict([('integer', 'int')]))])] diff --git a/tests/qapi-schema/returns-array-bad.err b/tests/qapi-schema/returns-array-bad.err index e69de29bb2..138095ccde 100644 --- a/tests/qapi-schema/returns-array-bad.err +++ b/tests/qapi-schema/returns-array-bad.err @@ -0,0 +1 @@ +tests/qapi-schema/returns-array-bad.json:2: 'returns' for command 'oops': array type must contain single type name diff --git a/tests/qapi-schema/returns-array-bad.exit b/tests/qapi-schema/returns-array-bad.exit index 573541ac97..d00491fd7e 100644 --- a/tests/qapi-schema/returns-array-bad.exit +++ b/tests/qapi-schema/returns-array-bad.exit @@ -1 +1 @@ -0 +1 diff --git a/tests/qapi-schema/returns-array-bad.json b/tests/qapi-schema/returns-array-bad.json index 14882c1e45..09b0b1f182 100644 --- a/tests/qapi-schema/returns-array-bad.json +++ b/tests/qapi-schema/returns-array-bad.json @@ -1,2 +1,2 @@ -# FIXME: we should reject an array return that is not a single type +# we reject an array return that is not a single type { 'command': 'oops', 'returns': [ 'str', 'str' ] } diff --git a/tests/qapi-schema/returns-array-bad.out b/tests/qapi-schema/returns-array-bad.out index eccad55219..e69de29bb2 100644 --- a/tests/qapi-schema/returns-array-bad.out +++ b/tests/qapi-schema/returns-array-bad.out @@ -1,3 +0,0 @@ -[OrderedDict([('command', 'oops'), ('returns', ['str', 'str'])])] -[] -[] diff --git a/tests/qapi-schema/returns-unknown.err b/tests/qapi-schema/returns-unknown.err index e69de29bb2..1f43e3ac9f 100644 --- a/tests/qapi-schema/returns-unknown.err +++ b/tests/qapi-schema/returns-unknown.err @@ -0,0 +1 @@ +tests/qapi-schema/returns-unknown.json:2: 'returns' for command 'oops' uses unknown type 'NoSuchType' diff --git a/tests/qapi-schema/returns-unknown.exit b/tests/qapi-schema/returns-unknown.exit index 573541ac97..d00491fd7e 100644 --- a/tests/qapi-schema/returns-unknown.exit +++ b/tests/qapi-schema/returns-unknown.exit @@ -1 +1 @@ -0 +1 diff --git a/tests/qapi-schema/returns-unknown.json b/tests/qapi-schema/returns-unknown.json index 61f20ebb02..25bd498bff 100644 --- a/tests/qapi-schema/returns-unknown.json +++ b/tests/qapi-schema/returns-unknown.json @@ -1,2 +1,2 @@ -# FIXME: we should reject returns if it does not contain a known type +# we reject returns if it does not contain a known type { 'command': 'oops', 'returns': 'NoSuchType' } diff --git a/tests/qapi-schema/returns-unknown.out b/tests/qapi-schema/returns-unknown.out index a482c837ce..e69de29bb2 100644 --- a/tests/qapi-schema/returns-unknown.out +++ b/tests/qapi-schema/returns-unknown.out @@ -1,3 +0,0 @@ -[OrderedDict([('command', 'oops'), ('returns', 'NoSuchType')])] -[] -[] diff --git a/tests/qapi-schema/union-unknown.err b/tests/qapi-schema/union-unknown.err index e69de29bb2..54fe456f9c 100644 --- a/tests/qapi-schema/union-unknown.err +++ b/tests/qapi-schema/union-unknown.err @@ -0,0 +1 @@ +tests/qapi-schema/union-unknown.json:2: Member 'unknown' of union 'Union' uses unknown type 'MissingType' diff --git a/tests/qapi-schema/union-unknown.exit b/tests/qapi-schema/union-unknown.exit index 573541ac97..d00491fd7e 100644 --- a/tests/qapi-schema/union-unknown.exit +++ b/tests/qapi-schema/union-unknown.exit @@ -1 +1 @@ -0 +1 diff --git a/tests/qapi-schema/union-unknown.json b/tests/qapi-schema/union-unknown.json index 258f1d3821..aa7e8143d8 100644 --- a/tests/qapi-schema/union-unknown.json +++ b/tests/qapi-schema/union-unknown.json @@ -1,3 +1,3 @@ -# FIXME: we should reject a union with unknown type in branch +# we reject a union with unknown type in branch { 'union': 'Union', 'data': { 'unknown': 'MissingType' } } diff --git a/tests/qapi-schema/union-unknown.out b/tests/qapi-schema/union-unknown.out index 8223dcf2c0..e69de29bb2 100644 --- a/tests/qapi-schema/union-unknown.out +++ b/tests/qapi-schema/union-unknown.out @@ -1,3 +0,0 @@ -[OrderedDict([('union', 'Union'), ('data', OrderedDict([('unknown', 'MissingType')]))])] -[{'enum_name': 'UnionKind', 'enum_values': None}] -[] |