aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/test-qmp-cmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/test-qmp-cmds.c')
-rw-r--r--tests/unit/test-qmp-cmds.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/tests/unit/test-qmp-cmds.c b/tests/unit/test-qmp-cmds.c
index d3413bfef0..1079d35122 100644
--- a/tests/unit/test-qmp-cmds.c
+++ b/tests/unit/test-qmp-cmds.c
@@ -1,4 +1,5 @@
#include "qemu/osdep.h"
+#include "qapi/compat-policy.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qjson.h"
#include "qapi/qmp/qnum.h"
@@ -49,12 +50,17 @@ void qmp_user_def_cmd1(UserDefOne * ud1, Error **errp)
{
}
-void qmp_test_features0(FeatureStruct0 *fs0, FeatureStruct1 *fs1,
- FeatureStruct2 *fs2, FeatureStruct3 *fs3,
- FeatureStruct4 *fs4, CondFeatureStruct1 *cfs1,
- CondFeatureStruct2 *cfs2, CondFeatureStruct3 *cfs3,
- Error **errp)
+FeatureStruct1 *qmp_test_features0(bool has_fs0, FeatureStruct0 *fs0,
+ bool has_fs1, FeatureStruct1 *fs1,
+ bool has_fs2, FeatureStruct2 *fs2,
+ bool has_fs3, FeatureStruct3 *fs3,
+ bool has_fs4, FeatureStruct4 *fs4,
+ bool has_cfs1, CondFeatureStruct1 *cfs1,
+ bool has_cfs2, CondFeatureStruct2 *cfs2,
+ bool has_cfs3, CondFeatureStruct3 *cfs3,
+ Error **errp)
{
+ return g_new0(FeatureStruct1, 1);
}
void qmp_test_command_features1(Error **errp)
@@ -275,6 +281,30 @@ static void test_dispatch_cmd_io(void)
qobject_unref(ret3);
}
+static void test_dispatch_cmd_ret_deprecated(void)
+{
+ const char *cmd = "{ 'execute': 'test-features0' }";
+ QDict *ret;
+
+ memset(&compat_policy, 0, sizeof(compat_policy));
+
+ /* default accept */
+ ret = qobject_to(QDict, do_qmp_dispatch(false, cmd));
+ assert(ret && qdict_size(ret) == 1);
+ qobject_unref(ret);
+
+ compat_policy.has_deprecated_output = true;
+ compat_policy.deprecated_output = COMPAT_POLICY_OUTPUT_ACCEPT;
+ ret = qobject_to(QDict, do_qmp_dispatch(false, cmd));
+ assert(ret && qdict_size(ret) == 1);
+ qobject_unref(ret);
+
+ compat_policy.deprecated_output = COMPAT_POLICY_OUTPUT_HIDE;
+ ret = qobject_to(QDict, do_qmp_dispatch(false, cmd));
+ assert(ret && qdict_size(ret) == 0);
+ qobject_unref(ret);
+}
+
/* test generated dealloc functions for generated types */
static void test_dealloc_types(void)
{
@@ -349,6 +379,8 @@ int main(int argc, char **argv)
g_test_add_func("/qmp/dispatch_cmd_io", test_dispatch_cmd_io);
g_test_add_func("/qmp/dispatch_cmd_success_response",
test_dispatch_cmd_success_response);
+ g_test_add_func("/qmp/dispatch_cmd_ret_deprecated",
+ test_dispatch_cmd_ret_deprecated);
g_test_add_func("/qmp/dealloc_types", test_dealloc_types);
g_test_add_func("/qmp/dealloc_partial", test_dealloc_partial);