]> git.proxmox.com Git - mirror_qemu.git/blame - tests/qapi-schema/qapi-schema-test.json
include/hw/core: Remove i386 conditional on fake_user_interrupt
[mirror_qemu.git] / tests / qapi-schema / qapi-schema-test.json
CommitLineData
501e5104 1# *-*- Mode: Python -*-*
f7160f32 2# vim: filetype=python
501e5104 3
625b251c
EB
4# This file is a stress test of supported qapi constructs that must
5# parse and compile correctly.
6
1554a8fa
MA
7# Whitelists to permit QAPI rule violations
8{ 'pragma': {
5aceeac0
MA
9 # Types whose member names may use '_'
10 'member-name-exceptions': [
11 'UserDefA'
12 ],
1554a8fa 13 # Commands allowed to return a non-dictionary:
b86df374 14 'command-returns-exceptions': [
1554a8fa
MA
15 'guest-get-time',
16 'guest-sync' ] } }
17
748053c9 18{ 'struct': 'TestStruct',
87adbbff 19 'data': { 'integer': {'type': 'int'}, 'boolean': 'bool', 'string': 'str' } }
748053c9 20
501e5104 21# for testing enums
895a2a80 22{ 'struct': 'NestedEnumsOne',
70478cef
EB
23 'data': { 'enum1': 'EnumOne', # Intentional forward reference
24 '*enum2': 'EnumOne', 'enum3': 'EnumOne', '*enum4': 'EnumOne' } }
501e5104 25
625b251c
EB
26# An empty enum, although unusual, is currently acceptable
27{ 'enum': 'MyEnum', 'data': [ ] }
28
19767083
EB
29# Likewise for an empty struct, including an empty base
30{ 'struct': 'Empty1', 'data': { } }
31{ 'struct': 'Empty2', 'base': 'Empty1', 'data': { } }
32
4e99f4b1 33# Likewise for an empty union
0ced9531
MA
34{ 'union': 'Union',
35 'base': { 'type': 'EnumOne' }, 'discriminator': 'type',
36 'data': { } }
37
05ebf841 38{ 'command': 'user-def-cmd0', 'data': 'Empty2', 'returns': 'Empty2' }
972a1101 39
351d36e4
DB
40# for testing override of default naming heuristic
41{ 'enum': 'QEnumTwo',
42 'prefix': 'QENUM_TWO',
43 'data': [ 'value1', 'value2' ] }
44
501e5104 45# for testing nested structs
895a2a80 46{ 'struct': 'UserDefOne',
8c3f8e77 47 'base': 'UserDefZero', # intentional forward reference
70478cef
EB
48 'data': { 'string': 'str',
49 '*enum1': 'EnumOne' } } # intentional forward reference
50
51{ 'enum': 'EnumOne',
800877bb 52 'data': [ 'value1', 'value2', 'value3', 'value4' ] }
501e5104 53
8c3f8e77
MA
54{ 'struct': 'UserDefZero',
55 'data': { 'integer': 'int' } }
56
6446a592
EB
57{ 'struct': 'UserDefTwoDictDict',
58 'data': { 'userdef': 'UserDefOne', 'string': 'str' } }
59
60{ 'struct': 'UserDefTwoDict',
61 'data': { 'string1': 'str',
62 'dict2': 'UserDefTwoDictDict',
63 '*dict3': 'UserDefTwoDictDict' } }
64
895a2a80 65{ 'struct': 'UserDefTwo',
f294f82a 66 'data': { 'string0': 'str',
6446a592 67 'dict1': 'UserDefTwoDict' } }
f294f82a 68
967c8851
MAL
69{ 'struct': 'UserDefThree',
70 'data': { 'string0': 'str' } }
71
9f08c8ec
EB
72# dummy struct to force generation of array types not otherwise mentioned
73{ 'struct': 'ForceArrays',
748053c9
EB
74 'data': { 'unused1':['UserDefOne'], 'unused2':['UserDefTwo'],
75 'unused3':['TestStruct'] } }
9f08c8ec 76
dc8fb6df 77# for testing unions
d220fbcd
EB
78# Among other things, test that a name collision between branches does
79# not cause any problems (since only one branch can be in use at a time),
80# by intentionally using two branches that both have a C member 'a_b'
895a2a80 81{ 'struct': 'UserDefA',
d220fbcd 82 'data': { 'boolean': 'bool', '*a_b': 'int' } }
dc8fb6df 83
895a2a80 84{ 'struct': 'UserDefB',
d220fbcd 85 'data': { 'intb': 'int', '*a-b': 'bool' } }
dc8fb6df 86
2fc00432 87{ 'union': 'UserDefFlatUnion',
8c3f8e77 88 'base': 'UserDefUnionBase', # intentional forward reference
5223070c 89 'discriminator': 'enum1',
87adbbff 90 'data': { 'value1' : {'type': 'UserDefA'},
8c3f8e77 91 'value2' : 'UserDefB',
800877bb
AN
92 'value3' : 'UserDefB'
93 # 'value4' defaults to empty
94 } }
2fc00432 95
8c3f8e77 96{ 'struct': 'UserDefUnionBase',
80e60a19 97 'base': 'UserDefZero',
8c3f8e77
MA
98 'data': { 'string': 'str', 'enum1': 'EnumOne' } }
99
14f00c6c 100# this variant of UserDefFlatUnion defaults to a union that uses members with
cb55111b
MR
101# allocated types to test corner cases in the cleanup/dealloc visitor
102{ 'union': 'UserDefFlatUnion2',
ac4338f8 103 'base': { '*integer': 'int', 'string': 'str', 'enum1': 'QEnumTwo' },
cb55111b 104 'discriminator': 'enum1',
8c3f8e77 105 'data': { 'value1' : 'UserDefC', # intentional forward reference
9d3524b3 106 'value2' : 'UserDefB' } }
cb55111b 107
68d07839
EB
108{ 'struct': 'WrapAlternate',
109 'data': { 'alt': 'UserDefAlternate' } }
ab916fad 110{ 'alternate': 'UserDefAlternate',
87adbbff 111 'data': { 'udfu': {'type': 'UserDefFlatUnion'}, 'e': 'EnumOne', 'i': 'int',
4d2d5c41 112 'n': 'null' } }
2c38b600 113
8c3f8e77
MA
114{ 'struct': 'UserDefC',
115 'data': { 'string1': 'str', 'string2': 'str' } }
116
a17dbc4b
DB
117# this tests that unions can contain other unions in their branches
118{ 'enum': 'TestUnionEnum',
119 'data': [ 'value-a', 'value-b' ] }
120
121{ 'enum': 'TestUnionEnumA',
122 'data': [ 'value-a1', 'value-a2' ] }
123
124{ 'struct': 'TestUnionTypeA1',
125 'data': { 'integer': 'int',
126 'name': 'str'} }
127
128{ 'struct': 'TestUnionTypeA2',
129 'data': { 'integer': 'int',
130 'size': 'int' } }
131
132{ 'union': 'TestUnionTypeA',
133 'base': { 'type-a': 'TestUnionEnumA' },
134 'discriminator': 'type-a',
135 'data': { 'value-a1': 'TestUnionTypeA1',
136 'value-a2': 'TestUnionTypeA2' } }
137
138{ 'struct': 'TestUnionTypeB',
139 'data': { 'integer': 'int',
140 'onoff': 'bool' } }
141
142{ 'union': 'TestUnionInUnion',
143 'base': { 'type': 'TestUnionEnum' },
144 'discriminator': 'type',
145 'data': { 'value-a': 'TestUnionTypeA',
146 'value-b': 'TestUnionTypeB' } }
147
148
9c51b441 149# for testing use of 'number' within alternates
8168ca8e
MA
150{ 'alternate': 'AltEnumBool', 'data': { 'e': 'EnumOne', 'b': 'bool' } }
151{ 'alternate': 'AltEnumNum', 'data': { 'e': 'EnumOne', 'n': 'number' } }
8168ca8e
MA
152{ 'alternate': 'AltNumEnum', 'data': { 'n': 'number', 'e': 'EnumOne' } }
153{ 'alternate': 'AltEnumInt', 'data': { 'e': 'EnumOne', 'i': 'int' } }
79db9948 154{ 'alternate': 'AltListInt', 'data': { 'l': ['int'], 'i': 'int' } }
9c51b441 155
c0644771
MA
156# for testing use of 'str' within alternates
157{ 'alternate': 'AltStrObj', 'data': { 's': 'str', 'o': 'TestStruct' } }
158
dffd8ff9
MA
159{ 'struct': 'ArrayStruct',
160 'data': { 'integer': ['int'],
161 's8': ['int8'],
162 's16': ['int16'],
163 's32': ['int32'],
164 's64': ['int64'],
165 'u8': ['uint8'],
166 'u16': ['uint16'],
167 'u32': ['uint32'],
168 'u64': ['uint64'],
169 'number': ['number'],
170 'boolean': ['bool'],
171 'string': ['str'],
172 '*sz': ['size'],
173 '*any': ['any'],
174 '*user': ['Status'] } } # intentional forward ref. to sub-module
83c84667 175
709395f8
MA
176# for testing sub-modules
177{ 'include': 'include/sub-module.json' }
178
501e5104 179# testing commands
05ebf841
MA
180{ 'command': 'user-def-cmd', 'data': {} }
181{ 'command': 'user-def-cmd1', 'data': {'ud1a': 'UserDefOne'} }
182{ 'command': 'user-def-cmd2',
87adbbff 183 'data': {'ud1a': {'type': 'UserDefOne'}, '*ud1b': 'UserDefOne'},
ab22ad96 184 'returns': 'UserDefTwo' }
cae95eae 185
ae6bf766 186{ 'command': 'cmd-success-response', 'data': {}, 'success-response': false }
04f22362 187{ 'command': 'coroutine-cmd', 'data': {}, 'coroutine': true }
ae6bf766 188
cae95eae
EB
189# Returning a non-dictionary requires a name from the whitelist
190{ 'command': 'guest-get-time', 'data': {'a': 'int', '*b': 'int' },
c2216a8a 191 'returns': 'int' }
28770e05 192{ 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' }
c818408e 193{ 'command': 'boxed-struct', 'boxed': true, 'data': 'UserDefZero' }
1e65e16c 194{ 'command': 'boxed-union', 'data': 'UserDefFlatUnion', 'boxed': true }
675b214b 195{ 'command': 'boxed-empty', 'boxed': true, 'data': 'Empty1' }
3953e3a5 196
c0698212 197# Smoke test on out-of-band and allow-preconfig-test
7b13f2c2 198{ 'command': 'test-flags-command', 'allow-oob': true, 'allow-preconfig': true }
1a1b11dc 199
3953e3a5
LE
200# For testing integer range flattening in opts-visitor. The following schema
201# corresponds to the option format:
202#
203# -userdef i64=3-6,i64=-5--1,u64=2,u16=1,u16=7-12
204#
205# For simplicity, this example doesn't use [type=]discriminator nor optargs
206# specific to discriminator values.
895a2a80 207{ 'struct': 'UserDefOptions',
3953e3a5
LE
208 'data': {
209 '*i64' : [ 'int' ],
210 '*u64' : [ 'uint64' ],
211 '*u16' : [ 'uint16' ],
212 '*i64x': 'int' ,
213 '*u64x': 'uint64' } }
f6dadb02
WX
214
215# testing event
895a2a80 216{ 'struct': 'EventStructOne',
87adbbff 217 'data': { 'struct1': {'type': 'UserDefOne'}, 'string': 'str', '*enum2': 'EnumOne' } }
f6dadb02
WX
218
219{ 'event': 'EVENT_A' }
220{ 'event': 'EVENT_B',
221 'data': { } }
222{ 'event': 'EVENT_C',
223 'data': { '*a': 'int', '*b': 'UserDefOne', 'c': 'str' } }
224{ 'event': 'EVENT_D',
225 'data': { 'a' : 'EventStructOne', 'b' : 'str', '*c': 'str', '*enum3': 'EnumOne' } }
c818408e 226{ 'event': 'EVENT_E', 'boxed': true, 'data': 'UserDefZero' }
b22e8658 227{ 'event': 'EVENT_F', 'boxed': true, 'data': 'UserDefFlatUnion' }
675b214b 228{ 'event': 'EVENT_G', 'boxed': true, 'data': 'Empty1' }
fce384b8 229
c43567c1
EB
230# test that we correctly compile downstream extensions, as well as munge
231# ticklish names
f0325536 232# also test union and alternate with just one branch
fce384b8 233{ 'enum': '__org.qemu_x-Enum', 'data': [ '__org.qemu_x-value' ] }
83a02706
EB
234{ 'struct': '__org.qemu_x-Base',
235 'data': { '__org.qemu_x-member1': '__org.qemu_x-Enum' } }
236{ 'struct': '__org.qemu_x-Struct', 'base': '__org.qemu_x-Base',
c43567c1 237 'data': { '__org.qemu_x-member2': 'str', '*wchar-t': 'int' } }
f0325536 238{ 'alternate': '__org.qemu_x-Alt1', 'data': { '__org.qemu_x-branch': 'str' } }
857af5f0 239{ 'struct': '__org.qemu_x-Struct2',
bb5821dd
MA
240 'data': { 'array': ['__org.qemu_x-Union'] } }
241{ 'union': '__org.qemu_x-Union', 'base': '__org.qemu_x-Base',
857af5f0
EB
242 'discriminator': '__org.qemu_x-member1',
243 'data': { '__org.qemu_x-value': '__org.qemu_x-Struct2' } }
d1f07c86 244{ 'alternate': '__org.qemu_x-Alt',
f0325536 245 'data': { '__org.qemu_x-branch': '__org.qemu_x-Base' } }
e3c4c3d7
EB
246{ 'event': '__ORG.QEMU_X-EVENT', 'data': '__org.qemu_x-Struct' }
247{ 'command': '__org.qemu_x-command',
248 'data': { 'a': ['__org.qemu_x-Enum'], 'b': ['__org.qemu_x-Struct'],
bb5821dd 249 'c': '__org.qemu_x-Union', 'd': '__org.qemu_x-Alt' } }
967c8851
MAL
250
251# test 'if' condition handling
252
4cfd6537
MA
253{ 'struct': 'TestIfStruct',
254 'data': { 'foo': 'int',
fa32eb90
MA
255 'bar': { 'type': 'int', 'if': 'TEST_IF_STRUCT_MEMBER'},
256 '*baz': { 'type': 'str', 'if': 'TEST_IF_STRUCT_MEMBER'} },
8a9f1e1d 257 'if': 'TEST_IF_STRUCT' }
967c8851 258
4cfd6537 259{ 'enum': 'TestIfEnum',
40e350f0 260 'data': [ 'foo', { 'name' : 'bar', 'if': 'TEST_IF_ENUM_MEMBER' } ],
39d2cc8e 261 'if': 'TEST_IF_UNION' }
967c8851 262
4cfd6537 263{ 'union': 'TestIfUnion',
54501863
MA
264 'base': { 'type': 'TestIfEnum' },
265 'discriminator': 'type',
4cfd6537 266 'data': { 'foo': 'TestStruct',
40e350f0 267 'bar': { 'type': 'UserDefZero', 'if': 'TEST_IF_ENUM_MEMBER'} },
8a9f1e1d 268 'if': { 'all': ['TEST_IF_UNION', 'TEST_IF_STRUCT'] } }
967c8851 269
05ebf841 270{ 'command': 'test-if-union-cmd',
5aceeac0 271 'data': { 'union-cmd-arg': 'TestIfUnion' },
cdcc04fa 272 'if': { 'all': ['TEST_IF_UNION', 'TEST_IF_STRUCT'] } }
f8c4fdd6 273
4cfd6537
MA
274{ 'alternate': 'TestIfAlternate',
275 'data': { 'foo': 'int',
40e350f0 276 'bar': { 'type': 'TestStruct', 'if': 'TEST_IF_ALT_MEMBER'} },
8a9f1e1d 277 'if': { 'all': ['TEST_IF_ALT', 'TEST_IF_STRUCT'] } }
967c8851 278
05ebf841 279{ 'command': 'test-if-alternate-cmd',
5aceeac0 280 'data': { 'alt-cmd-arg': 'TestIfAlternate' },
cdcc04fa 281 'if': { 'all': ['TEST_IF_ALT', 'TEST_IF_STRUCT'] } }
f8c4fdd6 282
05ebf841 283{ 'command': 'test-if-cmd',
de3b3f52
MA
284 'boxed': true,
285 'data': 'TestIfStruct',
967c8851 286 'returns': 'UserDefThree',
8a9f1e1d 287 'if': { 'all': ['TEST_IF_CMD', 'TEST_IF_STRUCT'] } }
967c8851 288
05ebf841 289{ 'command': 'test-cmd-return-def-three', 'returns': 'UserDefThree' }
967c8851 290
4cfd6537 291{ 'event': 'TEST_IF_EVENT',
de3b3f52
MA
292 'boxed': true,
293 'data': 'TestIfStruct',
8a9f1e1d 294 'if': { 'all': ['TEST_IF_EVT', 'TEST_IF_STRUCT'] } }
8aa3a33e 295
dd044023 296{ 'event': 'TEST_IF_EVENT2', 'data': {},
dd044023
MA
297 'if': { 'not': { 'any': [ { 'not': 'TEST_IF_EVT' },
298 { 'not': 'TEST_IF_STRUCT' } ] } } }
299
013b4efc 300# test 'features'
8aa3a33e
KW
301
302{ 'struct': 'FeatureStruct0',
303 'data': { 'foo': 'int' },
304 'features': [] }
305{ 'struct': 'FeatureStruct1',
f965e8fe 306 'data': { 'foo': { 'type': 'int', 'features': [ 'deprecated' ] } },
8aa3a33e
KW
307 'features': [ 'feature1' ] }
308{ 'struct': 'FeatureStruct2',
a3c45b3e 309 'data': { 'foo': { 'type': 'int', 'features': [ 'unstable' ] } },
8aa3a33e
KW
310 'features': [ { 'name': 'feature1' } ] }
311{ 'struct': 'FeatureStruct3',
312 'data': { 'foo': 'int' },
313 'features': [ 'feature1', 'feature2' ] }
314{ 'struct': 'FeatureStruct4',
315 'data': { 'namespace-test': 'int' },
316 'features': [ 'namespace-test', 'int', 'name', 'if' ] }
317
318{ 'struct': 'CondFeatureStruct1',
319 'data': { 'foo': 'int' },
8a9f1e1d 320 'features': [ { 'name': 'feature1', 'if': 'TEST_IF_FEATURE_1'} ] }
8aa3a33e
KW
321{ 'struct': 'CondFeatureStruct2',
322 'data': { 'foo': 'int' },
8a9f1e1d
MAL
323 'features': [ { 'name': 'feature1', 'if': 'TEST_IF_FEATURE_1'},
324 { 'name': 'feature2', 'if': 'TEST_IF_FEATURE_2'} ] }
8aa3a33e
KW
325{ 'struct': 'CondFeatureStruct3',
326 'data': { 'foo': 'int' },
5d83b9a1 327 'features': [ { 'name': 'feature1',
8a9f1e1d
MAL
328 'if': { 'all': [ 'TEST_IF_COND_1',
329 'TEST_IF_COND_2'] } } ] }
3ad64edf
MAL
330{ 'struct': 'CondFeatureStruct4',
331 'data': { 'foo': 'int' },
332 'features': [ { 'name': 'feature1',
8a9f1e1d
MAL
333 'if': {'any': ['TEST_IF_COND_1',
334 'TEST_IF_COND_2'] } } ] }
013b4efc
MA
335
336{ 'enum': 'FeatureEnum1',
b6c18755
MA
337 'data': [ 'eins', 'zwei',
338 { 'name': 'drei', 'features': [ 'deprecated' ] } ],
013b4efc
MA
339 'features': [ 'feature1' ] }
340
341{ 'union': 'FeatureUnion1',
342 'base': { 'tag': 'FeatureEnum1' },
343 'discriminator': 'tag',
344 'data': { 'eins': 'FeatureStruct1' },
345 'features': [ 'feature1' ] }
346
347{ 'alternate': 'FeatureAlternate1',
348 'data': { 'eins': 'FeatureStruct1' },
349 'features': [ 'feature1' ] }
350
351{ 'command': 'test-features0',
91fa93e5
MA
352 'data': { '*fs0': 'FeatureStruct0',
353 '*fs1': 'FeatureStruct1',
354 '*fs2': 'FeatureStruct2',
355 '*fs3': 'FeatureStruct3',
356 '*fs4': 'FeatureStruct4',
357 '*cfs1': 'CondFeatureStruct1',
358 '*cfs2': 'CondFeatureStruct2',
3ad64edf
MAL
359 '*cfs3': 'CondFeatureStruct3',
360 '*cfs4': 'CondFeatureStruct4' },
91fa93e5 361 'returns': 'FeatureStruct1',
2e2e0df2 362 'features': [] }
013b4efc 363
2e2e0df2 364{ 'command': 'test-command-features1',
f965e8fe 365 'features': [ 'deprecated' ] }
2e2e0df2 366{ 'command': 'test-command-features3',
a3c45b3e 367 'features': [ 'unstable', 'feature1', 'feature2' ] }
2e2e0df2
PK
368
369{ 'command': 'test-command-cond-features1',
8a9f1e1d 370 'features': [ { 'name': 'feature1', 'if': 'TEST_IF_FEATURE_1'} ] }
2e2e0df2 371{ 'command': 'test-command-cond-features2',
8a9f1e1d
MAL
372 'features': [ { 'name': 'feature1', 'if': 'TEST_IF_FEATURE_1'},
373 { 'name': 'feature2', 'if': 'TEST_IF_FEATURE_2'} ] }
2e2e0df2 374{ 'command': 'test-command-cond-features3',
5d83b9a1 375 'features': [ { 'name': 'feature1',
8a9f1e1d
MAL
376 'if': { 'all': [ 'TEST_IF_COND_1',
377 'TEST_IF_COND_2'] } } ] }
013b4efc 378
d4f4cae8 379{ 'event': 'TEST_EVENT_FEATURES0',
a291a38f
MA
380 'data': 'FeatureStruct1' }
381
d4f4cae8 382{ 'event': 'TEST_EVENT_FEATURES1',
f965e8fe 383 'features': [ 'deprecated' ] }
a3c45b3e
MA
384
385{ 'event': 'TEST_EVENT_FEATURES2',
386 'features': [ 'unstable' ] }