#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h"
#include "qapi/error.h"
-#include "qemu/module.h"
#include "qapi/qobject-input-visitor.h"
#include "tests/test-qapi-types.h"
#include "tests/test-qapi-visit.h"
static QmpCommandList qmp_commands;
+#if defined(TEST_IF_STRUCT) && defined(TEST_IF_CMD)
+UserDefThree *qmp_TestIfCmd(TestIfStruct *foo, Error **errp)
+{
+ return NULL;
+}
+#endif
+
+UserDefThree *qmp_TestCmdReturnDefThree(Error **errp)
+{
+ return NULL;
+}
+
void qmp_user_def_cmd(Error **errp)
{
}
{
}
+void qmp_cmd_success_response(Error **errp)
+{
+}
+
Empty2 *qmp_user_def_cmd0(Error **errp)
{
return g_new0(Empty2, 1);
{
}
+void qmp_test_features(FeatureStruct0 *fs0, FeatureStruct1 *fs1,
+ FeatureStruct2 *fs2, FeatureStruct3 *fs3,
+ FeatureStruct4 *fs4, CondFeatureStruct1 *cfs1,
+ CondFeatureStruct2 *cfs2, CondFeatureStruct3 *cfs3,
+ Error **errp)
+{
+}
+
UserDefTwo *qmp_user_def_cmd2(UserDefOne *ud1a,
bool has_udb1, UserDefOne *ud1b,
Error **errp)
{
}
-void qmp_boxed_union(UserDefNativeListUnion *arg, Error **errp)
+void qmp_boxed_union(UserDefListUnion *arg, Error **errp)
{
}
static void test_dispatch_cmd(void)
{
QDict *req = qdict_new();
- QObject *resp;
+ QDict *resp;
qdict_put_str(req, "execute", "user_def_cmd");
resp = qmp_dispatch(&qmp_commands, QOBJECT(req), false);
assert(resp != NULL);
- assert(!qdict_haskey(qobject_to(QDict, resp), "error"));
+ assert(!qdict_haskey(resp, "error"));
+
+ qobject_unref(resp);
+ qobject_unref(req);
+}
+
+static void test_dispatch_cmd_oob(void)
+{
+ QDict *req = qdict_new();
+ QDict *resp;
+
+ qdict_put_str(req, "exec-oob", "test-flags-command");
+
+ resp = qmp_dispatch(&qmp_commands, QOBJECT(req), true);
+ assert(resp != NULL);
+ assert(!qdict_haskey(resp, "error"));
qobject_unref(resp);
qobject_unref(req);
{
QDict *req = qdict_new();
QDict *args = qdict_new();
- QObject *resp;
+ QDict *resp;
qdict_put_str(req, "execute", "user_def_cmd2");
resp = qmp_dispatch(&qmp_commands, QOBJECT(req), false);
assert(resp != NULL);
- assert(qdict_haskey(qobject_to(QDict, resp), "error"));
+ assert(qdict_haskey(resp, "error"));
qobject_unref(resp);
qobject_unref(req);
resp = qmp_dispatch(&qmp_commands, QOBJECT(req), false);
assert(resp != NULL);
- assert(qdict_haskey(qobject_to(QDict, resp), "error"));
+ assert(qdict_haskey(resp, "error"));
qobject_unref(resp);
qobject_unref(req);
}
+static void test_dispatch_cmd_success_response(void)
+{
+ QDict *req = qdict_new();
+ QDict *resp;
+
+ qdict_put_str(req, "execute", "cmd-success-response");
+ resp = qmp_dispatch(&qmp_commands, QOBJECT(req), false);
+ g_assert_null(resp);
+ qobject_unref(req);
+}
+
static QObject *test_qmp_dispatch(QDict *req)
{
- QObject *resp_obj;
QDict *resp;
QObject *ret;
- resp_obj = qmp_dispatch(&qmp_commands, QOBJECT(req), false);
- assert(resp_obj);
- resp = qobject_to(QDict, resp_obj);
+ resp = qmp_dispatch(&qmp_commands, QOBJECT(req), false);
assert(resp && !qdict_haskey(resp, "error"));
ret = qdict_get(resp, "return");
assert(ret);
qobject_ref(ret);
- qobject_unref(resp_obj);
+ qobject_unref(resp);
return ret;
}
{
g_test_init(&argc, &argv, NULL);
- g_test_add_func("/0.15/dispatch_cmd", test_dispatch_cmd);
- g_test_add_func("/0.15/dispatch_cmd_failure", test_dispatch_cmd_failure);
- g_test_add_func("/0.15/dispatch_cmd_io", test_dispatch_cmd_io);
- g_test_add_func("/0.15/dealloc_types", test_dealloc_types);
- g_test_add_func("/0.15/dealloc_partial", test_dealloc_partial);
+ g_test_add_func("/qmp/dispatch_cmd", test_dispatch_cmd);
+ g_test_add_func("/qmp/dispatch_cmd_oob", test_dispatch_cmd_oob);
+ g_test_add_func("/qmp/dispatch_cmd_failure", test_dispatch_cmd_failure);
+ 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/dealloc_types", test_dealloc_types);
+ g_test_add_func("/qmp/dealloc_partial", test_dealloc_partial);
test_qmp_init_marshal(&qmp_commands);
g_test_run();