提交 ae6bf766 编写于 作者: M Marc-André Lureau 提交者: Thomas Huth

tests: add a qmp success-response test

Verify the usage of this schema feature and the API behaviour.  This
should be the only case where qmp_dispatch() returns NULL.
Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
Signed-off-by: NThomas Huth <thuth@redhat.com>
上级 2b70ea92
......@@ -137,6 +137,8 @@
'data': {'ud1a': 'UserDefOne', '*ud1b': 'UserDefOne'},
'returns': 'UserDefTwo' }
{ 'command': 'cmd-success-response', 'data': {}, 'success-response': false }
# Returning a non-dictionary requires a name from the whitelist
{ 'command': 'guest-get-time', 'data': {'a': 'int', '*b': 'int' },
'returns': 'int' }
......
......@@ -156,6 +156,8 @@ object q_obj_user_def_cmd2-arg
member ud1b: UserDefOne optional=True
command user_def_cmd2 q_obj_user_def_cmd2-arg -> UserDefTwo
gen=True success_response=True boxed=False oob=False preconfig=False
command cmd-success-response None -> None
gen=True success_response=False boxed=False oob=False preconfig=False
object q_obj_guest-get-time-arg
member a: int optional=False
member b: int optional=True
......
......@@ -32,6 +32,10 @@ void qmp_test_flags_command(Error **errp)
{
}
void qmp_cmd_success_response(Error **errp)
{
}
Empty2 *qmp_user_def_cmd0(Error **errp)
{
return g_new0(Empty2, 1);
......@@ -153,6 +157,17 @@ static void test_dispatch_cmd_failure(void)
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)
{
QDict *resp;
......@@ -289,6 +304,8 @@ int main(int argc, char **argv)
g_test_add_func("/qmp/dispatch_cmd", test_dispatch_cmd);
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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册