]> Git Repo - qemu.git/blame - tests/qapi-schema/qapi-schema-test.json
qapi: Add tests for empty unions
[qemu.git] / tests / qapi-schema / qapi-schema-test.json
CommitLineData
501e5104
MR
1# *-*- Mode: Python -*-*
2
3# for testing enums
4{ 'enum': 'EnumOne',
5 'data': [ 'value1', 'value2', 'value3' ] }
895a2a80 6{ 'struct': 'NestedEnumsOne',
501e5104
MR
7 'data': { 'enum1': 'EnumOne', '*enum2': 'EnumOne', 'enum3': 'EnumOne', '*enum4': 'EnumOne' } }
8
351d36e4
DB
9# for testing override of default naming heuristic
10{ 'enum': 'QEnumTwo',
11 'prefix': 'QENUM_TWO',
12 'data': [ 'value1', 'value2' ] }
13
501e5104 14# for testing nested structs
895a2a80 15{ 'struct': 'UserDefOne',
8c3f8e77 16 'base': 'UserDefZero', # intentional forward reference
aabbd472 17 'data': { 'string': 'str', '*enum1': 'EnumOne' } }
501e5104 18
8c3f8e77
MA
19{ 'struct': 'UserDefZero',
20 'data': { 'integer': 'int' } }
21
6446a592
EB
22{ 'struct': 'UserDefTwoDictDict',
23 'data': { 'userdef': 'UserDefOne', 'string': 'str' } }
24
25{ 'struct': 'UserDefTwoDict',
26 'data': { 'string1': 'str',
27 'dict2': 'UserDefTwoDictDict',
28 '*dict3': 'UserDefTwoDictDict' } }
29
895a2a80 30{ 'struct': 'UserDefTwo',
f294f82a 31 'data': { 'string0': 'str',
6446a592 32 'dict1': 'UserDefTwoDict' } }
f294f82a 33
dc8fb6df 34# for testing unions
d220fbcd
EB
35# Among other things, test that a name collision between branches does
36# not cause any problems (since only one branch can be in use at a time),
37# by intentionally using two branches that both have a C member 'a_b'
895a2a80 38{ 'struct': 'UserDefA',
d220fbcd 39 'data': { 'boolean': 'bool', '*a_b': 'int' } }
dc8fb6df 40
895a2a80 41{ 'struct': 'UserDefB',
d220fbcd 42 'data': { 'intb': 'int', '*a-b': 'bool' } }
dc8fb6df 43
2fc00432 44{ 'union': 'UserDefFlatUnion',
8c3f8e77 45 'base': 'UserDefUnionBase', # intentional forward reference
5223070c 46 'discriminator': 'enum1',
8c3f8e77
MA
47 'data': { 'value1' : 'UserDefA',
48 'value2' : 'UserDefB',
49 'value3' : 'UserDefB' } }
2fc00432 50
8c3f8e77 51{ 'struct': 'UserDefUnionBase',
80e60a19 52 'base': 'UserDefZero',
8c3f8e77
MA
53 'data': { 'string': 'str', 'enum1': 'EnumOne' } }
54
cb55111b
MR
55# this variant of UserDefFlatUnion defaults to a union that uses fields with
56# allocated types to test corner cases in the cleanup/dealloc visitor
57{ 'union': 'UserDefFlatUnion2',
58 'base': 'UserDefUnionBase',
59 'discriminator': 'enum1',
8c3f8e77
MA
60 'data': { 'value1' : 'UserDefC', # intentional forward reference
61 'value2' : 'UserDefB',
62 'value3' : 'UserDefA' } }
cb55111b 63
ab916fad 64{ 'alternate': 'UserDefAlternate',
2c38b600
MA
65 'data': { 'uda': 'UserDefA', 's': 'str', 'i': 'int' } }
66
8c3f8e77
MA
67{ 'struct': 'UserDefC',
68 'data': { 'string1': 'str', 'string2': 'str' } }
69
83c84667
MR
70# for testing native lists
71{ 'union': 'UserDefNativeListUnion',
72 'data': { 'integer': ['int'],
73 's8': ['int8'],
74 's16': ['int16'],
75 's32': ['int32'],
76 's64': ['int64'],
77 'u8': ['uint8'],
78 'u16': ['uint16'],
79 'u32': ['uint32'],
80 'u64': ['uint64'],
81 'number': ['number'],
82 'boolean': ['bool'],
cb17f79e 83 'string': ['str'],
28770e05
MA
84 'sizes': ['size'],
85 'any': ['any'] } }
83c84667 86
501e5104
MR
87# testing commands
88{ 'command': 'user_def_cmd', 'data': {} }
89{ 'command': 'user_def_cmd1', 'data': {'ud1a': 'UserDefOne'} }
ab22ad96
MA
90{ 'command': 'user_def_cmd2',
91 'data': {'ud1a': 'UserDefOne', '*ud1b': 'UserDefOne'},
92 'returns': 'UserDefTwo' }
c2216a8a
MA
93{ 'command': 'user_def_cmd3', 'data': {'a': 'int', '*b': 'int' },
94 'returns': 'int' }
28770e05
MA
95# note: command name 'guest-sync' chosen to avoid "cannot use built-in" error
96{ 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' }
3953e3a5
LE
97
98# For testing integer range flattening in opts-visitor. The following schema
99# corresponds to the option format:
100#
101# -userdef i64=3-6,i64=-5--1,u64=2,u16=1,u16=7-12
102#
103# For simplicity, this example doesn't use [type=]discriminator nor optargs
104# specific to discriminator values.
895a2a80 105{ 'struct': 'UserDefOptions',
3953e3a5
LE
106 'data': {
107 '*i64' : [ 'int' ],
108 '*u64' : [ 'uint64' ],
109 '*u16' : [ 'uint16' ],
110 '*i64x': 'int' ,
111 '*u64x': 'uint64' } }
f6dadb02
WX
112
113# testing event
895a2a80 114{ 'struct': 'EventStructOne',
f6dadb02
WX
115 'data': { 'struct1': 'UserDefOne', 'string': 'str', '*enum2': 'EnumOne' } }
116
117{ 'event': 'EVENT_A' }
118{ 'event': 'EVENT_B',
119 'data': { } }
120{ 'event': 'EVENT_C',
121 'data': { '*a': 'int', '*b': 'UserDefOne', 'c': 'str' } }
122{ 'event': 'EVENT_D',
123 'data': { 'a' : 'EventStructOne', 'b' : 'str', '*c': 'str', '*enum3': 'EnumOne' } }
fce384b8
EB
124
125# test that we correctly compile downstream extensions
126{ 'enum': '__org.qemu_x-Enum', 'data': [ '__org.qemu_x-value' ] }
83a02706
EB
127{ 'struct': '__org.qemu_x-Base',
128 'data': { '__org.qemu_x-member1': '__org.qemu_x-Enum' } }
129{ 'struct': '__org.qemu_x-Struct', 'base': '__org.qemu_x-Base',
130 'data': { '__org.qemu_x-member2': 'str' } }
bb337290 131{ 'union': '__org.qemu_x-Union1', 'data': { '__org.qemu_x-branch': 'str' } }
857af5f0
EB
132{ 'struct': '__org.qemu_x-Struct2',
133 'data': { 'array': ['__org.qemu_x-Union1'] } }
134{ 'union': '__org.qemu_x-Union2', 'base': '__org.qemu_x-Base',
135 'discriminator': '__org.qemu_x-member1',
136 'data': { '__org.qemu_x-value': '__org.qemu_x-Struct2' } }
d1f07c86
EB
137{ 'alternate': '__org.qemu_x-Alt',
138 'data': { '__org.qemu_x-branch': 'str', 'b': '__org.qemu_x-Base' } }
e3c4c3d7
EB
139{ 'event': '__ORG.QEMU_X-EVENT', 'data': '__org.qemu_x-Struct' }
140{ 'command': '__org.qemu_x-command',
141 'data': { 'a': ['__org.qemu_x-Enum'], 'b': ['__org.qemu_x-Struct'],
142 'c': '__org.qemu_x-Union2', 'd': '__org.qemu_x-Alt' },
143 'returns': '__org.qemu_x-Union1' }
This page took 0.329472 seconds and 4 git commands to generate.