[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 2/4] tests/qapi-schema: Test for good feature lists
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PATCH 2/4] tests/qapi-schema: Test for good feature lists in structs |
Date: |
Mon, 8 Apr 2019 16:35:41 +0200 |
Signed-off-by: Kevin Wolf <address@hidden>
---
tests/qapi-schema/qapi-schema-test.json | 27 +++++++++++++++++++++++++
tests/qapi-schema/qapi-schema-test.out | 26 ++++++++++++++++++++++++
tests/qapi-schema/test-qapi.py | 4 ++++
3 files changed, 57 insertions(+)
diff --git a/tests/qapi-schema/qapi-schema-test.json
b/tests/qapi-schema/qapi-schema-test.json
index 0952c68734..263514b448 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -242,3 +242,30 @@
{ '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': '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)'] } ] }
diff --git a/tests/qapi-schema/qapi-schema-test.out
b/tests/qapi-schema/qapi-schema-test.out
index 77fb1e1aa9..490e202f65 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -354,3 +354,29 @@ object q_obj_TestIfEvent-arg
event TestIfEvent q_obj_TestIfEvent-arg
boxed=False
if ['defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)']
+object FeatureStruct0
+ member foo: int optional=False
+object FeatureStruct1
+ member foo: int optional=False
+ feature feature1
+object FeatureStruct2
+ member foo: int optional=False
+ feature feature1
+object FeatureStruct3
+ member foo: int optional=False
+ feature feature1
+ feature feature2
+object CondFeatureStruct1
+ member foo: int optional=False
+ feature feature1
+ if ['defined(TEST_IF_FEATURE_1)']
+object CondFeatureStruct2
+ member foo: int optional=False
+ feature feature1
+ if ['defined(TEST_IF_FEATURE_1)']
+ feature feature2
+ if ['defined(TEST_IF_FEATURE_2)']
+object CondFeatureStruct3
+ member foo: int optional=False
+ feature feature1
+ if ['defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)']
diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
index f2d6815c86..08e29c23a6 100644
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -49,6 +49,10 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
self._print_if(m.ifcond, 8)
self._print_variants(variants)
self._print_if(ifcond)
+ if features:
+ for f in features:
+ print(' feature %s' % f['name'])
+ self._print_if(f.get('if'), 8)
def visit_alternate_type(self, name, info, ifcond, variants):
print('alternate %s' % name)
--
2.20.1
- [Qemu-block] [PATCH 0/4] file-posix: Add dynamic-auto-read-only QAPI feature, Kevin Wolf, 2019/04/08
- [Qemu-block] [PATCH 1/4] qapi: Support features for structs, Kevin Wolf, 2019/04/08
- [Qemu-block] [PATCH 2/4] tests/qapi-schema: Test for good feature lists in structs,
Kevin Wolf <=
- [Qemu-block] [PATCH 3/4] tests/qapi-schema: Error case tests for features in structs, Kevin Wolf, 2019/04/08
- [Qemu-block] [PATCH 4/4] file-posix: Add dynamic-auto-read-only QAPI feature, Kevin Wolf, 2019/04/08
- Re: [Qemu-block] [PATCH 0/4] file-posix: Add dynamic-auto-read-only QAPI feature, Peter Krempa, 2019/04/08
- Re: [Qemu-block] [PATCH 0/4] file-posix: Add dynamic-auto-read-only QAPI feature, Kevin Wolf, 2019/04/18
- Re: [Qemu-block] [Qemu-devel] [PATCH 0/4] file-posix: Add dynamic-auto-read-only QAPI feature, Markus Armbruster, 2019/04/18