diff options
author | Markus Armbruster <armbru@redhat.com> | 2020-03-17 12:54:31 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2020-03-17 19:58:34 +0100 |
commit | ef9f5f0d59471dbd5c0764fec67c982d95f4de20 (patch) | |
tree | 7a8a07d41041a38308be02f8e122ea479c532752 /tests/test-qmp-cmds.c | |
parent | 3306459a78b210290583d47639ad37e6e0556bac (diff) | |
download | qemu-ef9f5f0d59471dbd5c0764fec67c982d95f4de20.zip |
tests/test-qmp-cmds: Check responses more thoroughly
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200317115459.31821-7-armbru@redhat.com>
Diffstat (limited to 'tests/test-qmp-cmds.c')
-rw-r--r-- | tests/test-qmp-cmds.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index fb18475c7e..1563556e7c 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -151,9 +151,10 @@ static QObject *do_qmp_dispatch(QDict *req, bool allow_oob) QObject *ret; resp = qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob); - g_assert(resp && !qdict_haskey(resp, "error")); + g_assert(resp); ret = qdict_get(resp, "return"); g_assert(ret); + g_assert(qdict_size(resp) == 1); qobject_ref(ret); qobject_unref(resp); @@ -163,9 +164,17 @@ static QObject *do_qmp_dispatch(QDict *req, bool allow_oob) static void do_qmp_dispatch_error(QDict *req, bool allow_oob, ErrorClass cls) { QDict *resp; + QDict *error; resp = qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob); - g_assert(resp && qdict_haskey(resp, "error")); + g_assert(resp); + error = qdict_get_qdict(resp, "error"); + g_assert(error); + g_assert_cmpstr(qdict_get_try_str(error, "class"), + ==, QapiErrorClass_str(cls)); + g_assert(qdict_get_try_str(error, "desc")); + g_assert(qdict_size(error) == 2); + g_assert(qdict_size(resp) == 1); qobject_unref(resp); } @@ -174,11 +183,12 @@ static void do_qmp_dispatch_error(QDict *req, bool allow_oob, ErrorClass cls) static void test_dispatch_cmd(void) { QDict *req = qdict_new(); - QObject *ret; + QDict *ret; qdict_put_str(req, "execute", "user_def_cmd"); - ret = do_qmp_dispatch(req, false); + ret = qobject_to(QDict, do_qmp_dispatch(req, false)); + assert(ret && qdict_size(ret) == 0); qobject_unref(ret); qobject_unref(req); @@ -187,11 +197,12 @@ static void test_dispatch_cmd(void) static void test_dispatch_cmd_oob(void) { QDict *req = qdict_new(); - QObject *ret; + QDict *ret; qdict_put_str(req, "exec-oob", "test-flags-command"); - ret = do_qmp_dispatch(req, true); + ret = qobject_to(QDict, do_qmp_dispatch(req, true)); + assert(ret && qdict_size(ret) == 0); qobject_unref(ret); qobject_unref(req); |