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