Kevin Wolf <kw...@redhat.com> writes: > Signed-off-by: Kevin Wolf <kw...@redhat.com> > --- > tests/qapi-schema/qapi-schema-test.json | 30 +++++++++++++++++++++++ > tests/qapi-schema/qapi-schema-test.out | 32 +++++++++++++++++++++++++ > tests/qapi-schema/test-qapi.py | 4 ++++ > 3 files changed, 66 insertions(+) > > diff --git a/tests/qapi-schema/qapi-schema-test.json > b/tests/qapi-schema/qapi-schema-test.json > index 0952c68734..35a50fbe54 100644 > --- a/tests/qapi-schema/qapi-schema-test.json > +++ b/tests/qapi-schema/qapi-schema-test.json > @@ -242,3 +242,33 @@ > { 'foo': 'TestIfStruct', > 'bar': { 'type': ['TestIfEnum'], 'if': 'defined(TEST_IF_EVT_BAR)' } }, > 'if': 'defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)' } > + > +# test 'features' for structs > + > +{ 'struct': 'FeatureStruct0', > + 'data': { 'foo': 'int' }, > + 'features': [] } > +{ 'struct': 'FeatureStruct1', > + 'data': { 'foo': 'int' }, > + 'features': [ 'feature1' ] } > +{ 'struct': 'FeatureStruct2', > + 'data': { 'foo': 'int' }, > + 'features': [ { 'name': 'feature1' } ] } > +{ 'struct': 'FeatureStruct3', > + 'data': { 'foo': 'int' }, > + 'features': [ 'feature1', 'feature2' ] } > +{ 'struct': 'FeatureStruct4', > + 'data': { 'namespace-test': 'int' }, > + 'features': [ 'namespace-test', 'int', 'name', 'if' ] } > + > +{ 'struct': 'CondFeatureStruct1', > + 'data': { 'foo': 'int' }, > + 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'} ] } > +{ 'struct': 'CondFeatureStruct2', > + 'data': { 'foo': 'int' }, > + 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'}, > + { 'name': 'feature2', 'if': 'defined(TEST_IF_FEATURE_2)'} ] } > +{ 'struct': 'CondFeatureStruct3', > + 'data': { 'foo': 'int' }, > + 'features': [ { 'name': 'feature1', 'if': [ 'defined(TEST_IF_COND_1)', > + 'defined(TEST_IF_COND_2)'] } ] > }
Let's add { 'command': 'test-features', 'data': { 'fs0': 'FeatureStruct0', 'fs1': 'FeatureStruct1', 'fs2': 'FeatureStruct2', 'fs3': 'FeatureStruct3', 'cfs1': 'CondFeatureStruct1', 'cfs2': 'CondFeatureStruct2', 'cfs3': 'CondFeatureStruct3' } } because without it, the feature test cases won't generate introspection code. [...]