Commit 9050c65b authored by Eric Blake's avatar Eric Blake Committed by Markus Armbruster
Browse files

qapi: Add some expr tests



Demonstrate that the qapi generator doesn't deal well with
expressions that aren't up to par. Later patches will improve
the expected results as the generator is made stricter.  Only
a few of the the added tests actually behave sanely at
rejecting obvious problems or demonstrating success.

Note that in some cases, we reject bad QAPI merely because our
pseudo-JSON parser does not yet know how to parse numbers.  This
series does not address that, but when a later series adds support
for numeric defaults of integer fields, the testsuite will ensure
that we don't lose the error (and hopefully that the error
message quality is improved).

Signed-off-by: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
parent ab916fad
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -210,8 +210,10 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, \
	comments.json empty.json enum-empty.json enum-missing-data.json \
	enum-wrong-data.json enum-int-member.json enum-dict-member.json \
	enum-clash-member.json enum-max-member.json enum-union-clash.json \
	enum-bad-name.json \
	funny-char.json indented-expr.json \
	enum-bad-name.json funny-char.json indented-expr.json \
	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 \
	missing-colon.json missing-comma-list.json \
	missing-comma-object.json non-objects.json \
	qapi-schema-test.json quoted-structural-chars.json \
@@ -232,7 +234,7 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, \
	include-simple.json include-relpath.json include-format-err.json \
	include-non-file.json include-no-file.json include-before-err.json \
	include-nested-err.json include-self-cycle.json include-cycle.json \
	include-repetition.json event-nest-struct.json)
	include-repetition.json event-nest-struct.json event-case.json)

GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h \
		     tests/test-qmp-commands.h tests/test-qapi-event.h
+0 −0

Empty file added.

+1 −0
Original line number Diff line number Diff line
0
+3 −0
Original line number Diff line number Diff line
# FIXME: we should reject a base that is not a struct
{ 'union': 'Union', 'data': { 'a': 'int', 'b': 'str' } }
{ 'type': 'MyType', 'base': 'Union', 'data': { 'c': 'int' } }
+4 −0
Original line number Diff line number Diff line
[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')]))])]
Loading