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