qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

qapi: Add some enum tests

Demonstrate that the qapi generator doesn't deal well with enums
that aren't up to par. Later patches will update the expected
results as the generator is made stricter.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>

authored by

Eric Blake and committed by
Markus Armbruster
ad11dbb9 fe2a9303

+66 -1
+5 -1
tests/Makefile
··· 207 207 $(eval check-qtest-$(target)-y += tests/qom-test$(EXESUF)))) 208 208 209 209 check-qapi-schema-y := $(addprefix tests/qapi-schema/, \ 210 - comments.json empty.json funny-char.json indented-expr.json \ 210 + comments.json empty.json enum-empty.json enum-missing-data.json \ 211 + enum-wrong-data.json enum-int-member.json enum-dict-member.json \ 212 + enum-clash-member.json enum-max-member.json enum-union-clash.json \ 213 + enum-bad-name.json \ 214 + funny-char.json indented-expr.json \ 211 215 missing-colon.json missing-comma-list.json \ 212 216 missing-comma-object.json non-objects.json \ 213 217 qapi-schema-test.json quoted-structural-chars.json \
tests/qapi-schema/enum-bad-name.err

This is a binary file and will not be displayed.

+1
tests/qapi-schema/enum-bad-name.exit
··· 1 + 0
+2
tests/qapi-schema/enum-bad-name.json
··· 1 + # FIXME: we should ensure all enum names can map to C 2 + { 'enum': 'MyEnum', 'data': [ 'not^possible' ] }
+3
tests/qapi-schema/enum-bad-name.out
··· 1 + [OrderedDict([('enum', 'MyEnum'), ('data', ['not^possible'])])] 2 + [{'enum_name': 'MyEnum', 'enum_values': ['not^possible']}] 3 + []
tests/qapi-schema/enum-clash-member.err

This is a binary file and will not be displayed.

+1
tests/qapi-schema/enum-clash-member.exit
··· 1 + 0
+2
tests/qapi-schema/enum-clash-member.json
··· 1 + # FIXME: we should reject enums where members will clash when mapped to C enum 2 + { 'enum': 'MyEnum', 'data': [ 'one', 'ONE' ] }
+3
tests/qapi-schema/enum-clash-member.out
··· 1 + [OrderedDict([('enum', 'MyEnum'), ('data', ['one', 'ONE'])])] 2 + [{'enum_name': 'MyEnum', 'enum_values': ['one', 'ONE']}] 3 + []
tests/qapi-schema/enum-dict-member.err

This is a binary file and will not be displayed.

+1
tests/qapi-schema/enum-dict-member.exit
··· 1 + 0
+2
tests/qapi-schema/enum-dict-member.json
··· 1 + # FIXME: we should reject any enum member that is not a string 2 + { 'enum': 'MyEnum', 'data': [ { 'value': 'str' } ] }
+3
tests/qapi-schema/enum-dict-member.out
··· 1 + [OrderedDict([('enum', 'MyEnum'), ('data', [OrderedDict([('value', 'str')])])])] 2 + [{'enum_name': 'MyEnum', 'enum_values': [OrderedDict([('value', 'str')])]}] 3 + []
tests/qapi-schema/enum-empty.err

This is a binary file and will not be displayed.

+1
tests/qapi-schema/enum-empty.exit
··· 1 + 0
+2
tests/qapi-schema/enum-empty.json
··· 1 + # An empty enum, although unusual, is currently acceptable 2 + { 'enum': 'MyEnum', 'data': [ ] }
+3
tests/qapi-schema/enum-empty.out
··· 1 + [OrderedDict([('enum', 'MyEnum'), ('data', [])])] 2 + [{'enum_name': 'MyEnum', 'enum_values': []}] 3 + []
+1
tests/qapi-schema/enum-int-member.err
··· 1 + tests/qapi-schema/enum-int-member.json:3:31: Stray "1"
+1
tests/qapi-schema/enum-int-member.exit
··· 1 + 1
+3
tests/qapi-schema/enum-int-member.json
··· 1 + # we reject any enum member that is not a string 2 + # FIXME: once the parser understands integer inputs, improve the error message 3 + { 'enum': 'MyEnum', 'data': [ 1 ] }
tests/qapi-schema/enum-int-member.out

This is a binary file and will not be displayed.

tests/qapi-schema/enum-max-member.err

This is a binary file and will not be displayed.

+1
tests/qapi-schema/enum-max-member.exit
··· 1 + 0
+3
tests/qapi-schema/enum-max-member.json
··· 1 + # FIXME: we should reject user-supplied 'max' for clashing with implicit enum end 2 + # TODO: should we instead munge the implicit value to avoid the clash? 3 + { 'enum': 'MyEnum', 'data': [ 'max' ] }
+3
tests/qapi-schema/enum-max-member.out
··· 1 + [OrderedDict([('enum', 'MyEnum'), ('data', ['max'])])] 2 + [{'enum_name': 'MyEnum', 'enum_values': ['max']}] 3 + []
+6
tests/qapi-schema/enum-missing-data.err
··· 1 + Traceback (most recent call last): 2 + File "tests/qapi-schema/test-qapi.py", line 19, in <module> 3 + exprs = parse_schema(sys.argv[1]) 4 + File "scripts/qapi.py", line 334, in parse_schema 5 + add_enum(expr['enum'], expr['data']) 6 + KeyError: 'data'
+1
tests/qapi-schema/enum-missing-data.exit
··· 1 + 1
+2
tests/qapi-schema/enum-missing-data.json
··· 1 + # FIXME: we should require that all QAPI enums have a data array 2 + { 'enum': 'MyEnum' }
tests/qapi-schema/enum-missing-data.out

This is a binary file and will not be displayed.

tests/qapi-schema/enum-union-clash.err

This is a binary file and will not be displayed.

+1
tests/qapi-schema/enum-union-clash.exit
··· 1 + 0
+4
tests/qapi-schema/enum-union-clash.json
··· 1 + # FIXME: we should reject types that would conflict with implicit union enum 2 + { 'enum': 'UnionKind', 'data': [ 'oops' ] } 3 + { 'union': 'Union', 4 + 'data': { 'a': 'int' } }
+5
tests/qapi-schema/enum-union-clash.out
··· 1 + [OrderedDict([('enum', 'UnionKind'), ('data', ['oops'])]), 2 + OrderedDict([('union', 'Union'), ('data', OrderedDict([('a', 'int')]))])] 3 + [{'enum_name': 'UnionKind', 'enum_values': ['oops']}, 4 + {'enum_name': 'UnionKind', 'enum_values': None}] 5 + []
tests/qapi-schema/enum-wrong-data.err

This is a binary file and will not be displayed.

+1
tests/qapi-schema/enum-wrong-data.exit
··· 1 + 0
+2
tests/qapi-schema/enum-wrong-data.json
··· 1 + # FIXME: we should require that all qapi enums have an array for data 2 + { 'enum': 'MyEnum', 'data': { 'value': 'str' } }
+3
tests/qapi-schema/enum-wrong-data.out
··· 1 + [OrderedDict([('enum', 'MyEnum'), ('data', OrderedDict([('value', 'str')]))])] 2 + [{'enum_name': 'MyEnum', 'enum_values': OrderedDict([('value', 'str')])}] 3 + []