[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/12] tests: qapi: Test 'features' of commands
From: |
Markus Armbruster |
Subject: |
[PULL 10/12] tests: qapi: Test 'features' of commands |
Date: |
Tue, 22 Oct 2019 09:56:13 +0200 |
From: Peter Krempa <address@hidden>
Signed-off-by: Peter Krempa <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>
---
tests/test-qmp-cmds.c | 24 ++++++++++++++++++++++++
tests/qapi-schema/qapi-schema-test.json | 18 ++++++++++++++++++
tests/qapi-schema/qapi-schema-test.out | 23 +++++++++++++++++++++++
tests/qapi-schema/test-qapi.py | 13 +++++++++----
4 files changed, 74 insertions(+), 4 deletions(-)
diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c
index 36fdf5b115..27b0afe55a 100644
--- a/tests/test-qmp-cmds.c
+++ b/tests/test-qmp-cmds.c
@@ -51,6 +51,30 @@ void qmp_test_features(FeatureStruct0 *fs0, FeatureStruct1
*fs1,
{
}
+void qmp_test_command_features0(Error **errp)
+{
+}
+
+void qmp_test_command_features1(Error **errp)
+{
+}
+
+void qmp_test_command_features3(Error **errp)
+{
+}
+
+void qmp_test_command_cond_features1(Error **errp)
+{
+}
+
+void qmp_test_command_cond_features2(Error **errp)
+{
+}
+
+void qmp_test_command_cond_features3(Error **errp)
+{
+}
+
UserDefTwo *qmp_user_def_cmd2(UserDefOne *ud1a,
bool has_udb1, UserDefOne *ud1b,
Error **errp)
diff --git a/tests/qapi-schema/qapi-schema-test.json
b/tests/qapi-schema/qapi-schema-test.json
index 75c42eb0e3..9abf175fe0 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -290,3 +290,21 @@
'cfs1': 'CondFeatureStruct1',
'cfs2': 'CondFeatureStruct2',
'cfs3': 'CondFeatureStruct3' } }
+
+# test 'features' for command
+
+{ 'command': 'test-command-features0',
+ 'features': [] }
+{ 'command': 'test-command-features1',
+ 'features': [ 'feature1' ] }
+{ 'command': 'test-command-features3',
+ 'features': [ 'feature1', 'feature2' ] }
+
+{ 'command': 'test-command-cond-features1',
+ 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'} ] }
+{ 'command': 'test-command-cond-features2',
+ 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'},
+ { 'name': 'feature2', 'if': 'defined(TEST_IF_FEATURE_2)'} ] }
+{ 'command': 'test-command-cond-features3',
+ '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 aca43186a9..3660e75a48 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -412,3 +412,26 @@ object q_obj_test-features-arg
member cfs3: CondFeatureStruct3 optional=False
command test-features q_obj_test-features-arg -> None
gen=True success_response=True boxed=False oob=False preconfig=False
+command test-command-features0 None -> None
+ gen=True success_response=True boxed=False oob=False preconfig=False
+command test-command-features1 None -> None
+ gen=True success_response=True boxed=False oob=False preconfig=False
+ feature feature1
+command test-command-features3 None -> None
+ gen=True success_response=True boxed=False oob=False preconfig=False
+ feature feature1
+ feature feature2
+command test-command-cond-features1 None -> None
+ gen=True success_response=True boxed=False oob=False preconfig=False
+ feature feature1
+ if ['defined(TEST_IF_FEATURE_1)']
+command test-command-cond-features2 None -> None
+ gen=True success_response=True boxed=False oob=False preconfig=False
+ feature feature1
+ if ['defined(TEST_IF_FEATURE_1)']
+ feature feature2
+ if ['defined(TEST_IF_FEATURE_2)']
+command test-command-cond-features3 None -> None
+ gen=True success_response=True boxed=False oob=False preconfig=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 d31ac4bbb7..2bd9fd8742 100755
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -61,10 +61,7 @@ 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.ifcond, 8)
+ self._print_features(features)
def visit_alternate_type(self, name, info, ifcond, variants):
print('alternate %s' % name)
@@ -80,6 +77,7 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
print(' gen=%s success_response=%s boxed=%s oob=%s preconfig=%s'
% (gen, success_response, boxed, allow_oob, allow_preconfig))
self._print_if(ifcond)
+ self._print_features(features)
def visit_event(self, name, info, ifcond, arg_type, boxed):
print('event %s %s' % (name, arg_type and arg_type.name))
@@ -99,6 +97,13 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
if ifcond:
print('%sif %s' % (' ' * indent, ifcond))
+ @classmethod
+ def _print_features(cls, features):
+ if features:
+ for f in features:
+ print(' feature %s' % f.name)
+ cls._print_if(f.ifcond, 8)
+
def test_frontend(fname):
schema = QAPISchema(fname)
--
2.21.0
- [PULL 00/12] QAPI patches for 2019-10-22, Markus Armbruster, 2019/10/22
- [PULL 03/12] qapi: Eliminate accidental global frontend state, Markus Armbruster, 2019/10/22
- [PULL 05/12] qapi: Move gen_enum(), gen_enum_lookup() back to qapi/types.py, Markus Armbruster, 2019/10/22
- [PULL 01/12] qapi: Don't suppress doc generation without pragma doc-required, Markus Armbruster, 2019/10/22
- [PULL 02/12] qapi: Store pragma state in QAPISourceInfo, not global state, Markus Armbruster, 2019/10/22
- [PULL 12/12] qapi: Allow introspecting fix for savevm's cooperation with blockdev, Markus Armbruster, 2019/10/22
- [PULL 10/12] tests: qapi: Test 'features' of commands,
Markus Armbruster <=
- [PULL 08/12] tests/qapi-schema: Tidy up test output indentation, Markus Armbruster, 2019/10/22
- [PULL 07/12] qapi: Clear scripts/qapi/doc.py executable bits again, Markus Armbruster, 2019/10/22
- [PULL 09/12] qapi: Add feature flags to commands, Markus Armbruster, 2019/10/22
- [PULL 11/12] tests/qapi-schema: Cover feature documentation comments, Markus Armbruster, 2019/10/22
- [PULL 04/12] qapi: Speed up frontend tests, Markus Armbruster, 2019/10/22
- [PULL 06/12] qapi: Split up scripts/qapi/common.py, Markus Armbruster, 2019/10/22
- Re: [PULL 00/12] QAPI patches for 2019-10-22, Peter Maydell, 2019/10/22