Commit | Line | Data |
---|---|---|
501e5104 MR |
1 | # *-*- Mode: Python -*-* |
2 | ||
625b251c EB |
3 | # This file is a stress test of supported qapi constructs that must |
4 | # parse and compile correctly. | |
5 | ||
748053c9 EB |
6 | { 'struct': 'TestStruct', |
7 | 'data': { 'integer': 'int', 'boolean': 'bool', 'string': 'str' } } | |
8 | ||
501e5104 | 9 | # for testing enums |
895a2a80 | 10 | { 'struct': 'NestedEnumsOne', |
70478cef EB |
11 | 'data': { 'enum1': 'EnumOne', # Intentional forward reference |
12 | '*enum2': 'EnumOne', 'enum3': 'EnumOne', '*enum4': 'EnumOne' } } | |
501e5104 | 13 | |
625b251c EB |
14 | # An empty enum, although unusual, is currently acceptable |
15 | { 'enum': 'MyEnum', 'data': [ ] } | |
16 | ||
19767083 EB |
17 | # Likewise for an empty struct, including an empty base |
18 | { 'struct': 'Empty1', 'data': { } } | |
19 | { 'struct': 'Empty2', 'base': 'Empty1', 'data': { } } | |
20 | ||
972a1101 EB |
21 | { 'command': 'user_def_cmd0', 'data': 'Empty2', 'returns': 'Empty2' } |
22 | ||
351d36e4 DB |
23 | # for testing override of default naming heuristic |
24 | { 'enum': 'QEnumTwo', | |
25 | 'prefix': 'QENUM_TWO', | |
26 | 'data': [ 'value1', 'value2' ] } | |
27 | ||
501e5104 | 28 | # for testing nested structs |
895a2a80 | 29 | { 'struct': 'UserDefOne', |
8c3f8e77 | 30 | 'base': 'UserDefZero', # intentional forward reference |
70478cef EB |
31 | 'data': { 'string': 'str', |
32 | '*enum1': 'EnumOne' } } # intentional forward reference | |
33 | ||
34 | { 'enum': 'EnumOne', | |
35 | 'data': [ 'value1', 'value2', 'value3' ] } | |
501e5104 | 36 | |
8c3f8e77 MA |
37 | { 'struct': 'UserDefZero', |
38 | 'data': { 'integer': 'int' } } | |
39 | ||
6446a592 EB |
40 | { 'struct': 'UserDefTwoDictDict', |
41 | 'data': { 'userdef': 'UserDefOne', 'string': 'str' } } | |
42 | ||
43 | { 'struct': 'UserDefTwoDict', | |
44 | 'data': { 'string1': 'str', | |
45 | 'dict2': 'UserDefTwoDictDict', | |
46 | '*dict3': 'UserDefTwoDictDict' } } | |
47 | ||
895a2a80 | 48 | { 'struct': 'UserDefTwo', |
f294f82a | 49 | 'data': { 'string0': 'str', |
6446a592 | 50 | 'dict1': 'UserDefTwoDict' } } |
f294f82a | 51 | |
9f08c8ec EB |
52 | # dummy struct to force generation of array types not otherwise mentioned |
53 | { 'struct': 'ForceArrays', | |
748053c9 EB |
54 | 'data': { 'unused1':['UserDefOne'], 'unused2':['UserDefTwo'], |
55 | 'unused3':['TestStruct'] } } | |
9f08c8ec | 56 | |
dc8fb6df | 57 | # for testing unions |
d220fbcd EB |
58 | # Among other things, test that a name collision between branches does |
59 | # not cause any problems (since only one branch can be in use at a time), | |
60 | # by intentionally using two branches that both have a C member 'a_b' | |
895a2a80 | 61 | { 'struct': 'UserDefA', |
d220fbcd | 62 | 'data': { 'boolean': 'bool', '*a_b': 'int' } } |
dc8fb6df | 63 | |
895a2a80 | 64 | { 'struct': 'UserDefB', |
d220fbcd | 65 | 'data': { 'intb': 'int', '*a-b': 'bool' } } |
dc8fb6df | 66 | |
2fc00432 | 67 | { 'union': 'UserDefFlatUnion', |
8c3f8e77 | 68 | 'base': 'UserDefUnionBase', # intentional forward reference |
5223070c | 69 | 'discriminator': 'enum1', |
8c3f8e77 MA |
70 | 'data': { 'value1' : 'UserDefA', |
71 | 'value2' : 'UserDefB', | |
72 | 'value3' : 'UserDefB' } } | |
2fc00432 | 73 | |
8c3f8e77 | 74 | { 'struct': 'UserDefUnionBase', |
80e60a19 | 75 | 'base': 'UserDefZero', |
8c3f8e77 MA |
76 | 'data': { 'string': 'str', 'enum1': 'EnumOne' } } |
77 | ||
9d3524b3 EB |
78 | { 'struct': 'UserDefUnionBase2', |
79 | 'base': 'UserDefZero', | |
80 | 'data': { 'string': 'str', 'enum1': 'QEnumTwo' } } | |
81 | ||
14f00c6c | 82 | # this variant of UserDefFlatUnion defaults to a union that uses members with |
cb55111b MR |
83 | # allocated types to test corner cases in the cleanup/dealloc visitor |
84 | { 'union': 'UserDefFlatUnion2', | |
9d3524b3 | 85 | 'base': 'UserDefUnionBase2', |
cb55111b | 86 | 'discriminator': 'enum1', |
8c3f8e77 | 87 | 'data': { 'value1' : 'UserDefC', # intentional forward reference |
9d3524b3 | 88 | 'value2' : 'UserDefB' } } |
cb55111b | 89 | |
68d07839 EB |
90 | { 'struct': 'WrapAlternate', |
91 | 'data': { 'alt': 'UserDefAlternate' } } | |
ab916fad | 92 | { 'alternate': 'UserDefAlternate', |
68d07839 | 93 | 'data': { 'udfu': 'UserDefFlatUnion', 's': 'str', 'i': 'int' } } |
2c38b600 | 94 | |
8c3f8e77 MA |
95 | { 'struct': 'UserDefC', |
96 | 'data': { 'string1': 'str', 'string2': 'str' } } | |
97 | ||
9c51b441 EB |
98 | # for testing use of 'number' within alternates |
99 | { 'alternate': 'AltStrBool', 'data': { 's': 'str', 'b': 'bool' } } | |
100 | { 'alternate': 'AltStrNum', 'data': { 's': 'str', 'n': 'number' } } | |
101 | { 'alternate': 'AltNumStr', 'data': { 'n': 'number', 's': 'str' } } | |
102 | { 'alternate': 'AltStrInt', 'data': { 's': 'str', 'i': 'int' } } | |
103 | { 'alternate': 'AltIntNum', 'data': { 'i': 'int', 'n': 'number' } } | |
104 | { 'alternate': 'AltNumInt', 'data': { 'n': 'number', 'i': 'int' } } | |
105 | ||
83c84667 MR |
106 | # for testing native lists |
107 | { 'union': 'UserDefNativeListUnion', | |
108 | 'data': { 'integer': ['int'], | |
109 | 's8': ['int8'], | |
110 | 's16': ['int16'], | |
111 | 's32': ['int32'], | |
112 | 's64': ['int64'], | |
113 | 'u8': ['uint8'], | |
114 | 'u16': ['uint16'], | |
115 | 'u32': ['uint32'], | |
116 | 'u64': ['uint64'], | |
117 | 'number': ['number'], | |
118 | 'boolean': ['bool'], | |
cb17f79e | 119 | 'string': ['str'], |
28770e05 MA |
120 | 'sizes': ['size'], |
121 | 'any': ['any'] } } | |
83c84667 | 122 | |
501e5104 MR |
123 | # testing commands |
124 | { 'command': 'user_def_cmd', 'data': {} } | |
125 | { 'command': 'user_def_cmd1', 'data': {'ud1a': 'UserDefOne'} } | |
ab22ad96 MA |
126 | { 'command': 'user_def_cmd2', |
127 | 'data': {'ud1a': 'UserDefOne', '*ud1b': 'UserDefOne'}, | |
128 | 'returns': 'UserDefTwo' } | |
cae95eae EB |
129 | |
130 | # Returning a non-dictionary requires a name from the whitelist | |
131 | { 'command': 'guest-get-time', 'data': {'a': 'int', '*b': 'int' }, | |
c2216a8a | 132 | 'returns': 'int' } |
28770e05 | 133 | { 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' } |
3953e3a5 LE |
134 | |
135 | # For testing integer range flattening in opts-visitor. The following schema | |
136 | # corresponds to the option format: | |
137 | # | |
138 | # -userdef i64=3-6,i64=-5--1,u64=2,u16=1,u16=7-12 | |
139 | # | |
140 | # For simplicity, this example doesn't use [type=]discriminator nor optargs | |
141 | # specific to discriminator values. | |
895a2a80 | 142 | { 'struct': 'UserDefOptions', |
3953e3a5 LE |
143 | 'data': { |
144 | '*i64' : [ 'int' ], | |
145 | '*u64' : [ 'uint64' ], | |
146 | '*u16' : [ 'uint16' ], | |
147 | '*i64x': 'int' , | |
148 | '*u64x': 'uint64' } } | |
f6dadb02 WX |
149 | |
150 | # testing event | |
895a2a80 | 151 | { 'struct': 'EventStructOne', |
f6dadb02 WX |
152 | 'data': { 'struct1': 'UserDefOne', 'string': 'str', '*enum2': 'EnumOne' } } |
153 | ||
154 | { 'event': 'EVENT_A' } | |
155 | { 'event': 'EVENT_B', | |
156 | 'data': { } } | |
157 | { 'event': 'EVENT_C', | |
158 | 'data': { '*a': 'int', '*b': 'UserDefOne', 'c': 'str' } } | |
159 | { 'event': 'EVENT_D', | |
160 | 'data': { 'a' : 'EventStructOne', 'b' : 'str', '*c': 'str', '*enum3': 'EnumOne' } } | |
fce384b8 | 161 | |
c43567c1 EB |
162 | # test that we correctly compile downstream extensions, as well as munge |
163 | # ticklish names | |
fce384b8 | 164 | { 'enum': '__org.qemu_x-Enum', 'data': [ '__org.qemu_x-value' ] } |
83a02706 EB |
165 | { 'struct': '__org.qemu_x-Base', |
166 | 'data': { '__org.qemu_x-member1': '__org.qemu_x-Enum' } } | |
167 | { 'struct': '__org.qemu_x-Struct', 'base': '__org.qemu_x-Base', | |
c43567c1 | 168 | 'data': { '__org.qemu_x-member2': 'str', '*wchar-t': 'int' } } |
bb337290 | 169 | { 'union': '__org.qemu_x-Union1', 'data': { '__org.qemu_x-branch': 'str' } } |
857af5f0 EB |
170 | { 'struct': '__org.qemu_x-Struct2', |
171 | 'data': { 'array': ['__org.qemu_x-Union1'] } } | |
172 | { 'union': '__org.qemu_x-Union2', 'base': '__org.qemu_x-Base', | |
173 | 'discriminator': '__org.qemu_x-member1', | |
174 | 'data': { '__org.qemu_x-value': '__org.qemu_x-Struct2' } } | |
d1f07c86 EB |
175 | { 'alternate': '__org.qemu_x-Alt', |
176 | 'data': { '__org.qemu_x-branch': 'str', 'b': '__org.qemu_x-Base' } } | |
e3c4c3d7 EB |
177 | { 'event': '__ORG.QEMU_X-EVENT', 'data': '__org.qemu_x-Struct' } |
178 | { 'command': '__org.qemu_x-command', | |
179 | 'data': { 'a': ['__org.qemu_x-Enum'], 'b': ['__org.qemu_x-Struct'], | |
180 | 'c': '__org.qemu_x-Union2', 'd': '__org.qemu_x-Alt' }, | |
181 | 'returns': '__org.qemu_x-Union1' } |