aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-09-19 18:06:51 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-09-19 18:06:52 +0100
commit33e1666b4289313306371fee0740f5c85517e406 (patch)
tree726cbda5a2767aacb679543bcc940f194815c50c /tests
parent3d47a1390bd80b7b974185827a340012d21ad1e3 (diff)
parentbd6092e407a5d682fbfddcbc510038b84bc1a1aa (diff)
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2016-09-19' into staging
QAPI patches for 2016-09-19 # gpg: Signature made Mon 19 Sep 2016 17:27:42 BST # gpg: using RSA key 0x3870B400EB918653 # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2016-09-19: Replace qmp-commands.hx by docs/qmp-commands.txt qmp-commands.hx: fix some styling build-sys: remove qmp-commands-old.h monitor: use qmp_dispatch() tests: add a test to check invalid args qapi: check invalid arguments on no-args commands qapi: remove the "middle" mode monitor: remove mhandler.cmd_new monitor: implement 'qmp_query_commands' without qmp_cmds monitor: use qmp_find_command() (using generated qapi code) qapi: export the marshallers qmp: Hack to keep commands configuration-specific qapi: Support unregistering QMP commands monitor: register gen:false commands manually monitor: simplify invalid_qmp_mode() qapi-schema: add 'device_add' qapi-schema: use generated marshaller for 'qmp_capabilities' build-sys: define QEMU_VERSION_{MAJOR, MINOR, MICRO} Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/test-qga.c21
-rw-r--r--tests/test-qmp-commands.c15
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/test-qga.c b/tests/test-qga.c
index 21f44f8915..40af64987a 100644
--- a/tests/test-qga.c
+++ b/tests/test-qga.c
@@ -198,6 +198,26 @@ static void test_qga_ping(gconstpointer fix)
QDECREF(ret);
}
+static void test_qga_invalid_args(gconstpointer fix)
+{
+ const TestFixture *fixture = fix;
+ QDict *ret, *error;
+ const gchar *class, *desc;
+
+ ret = qmp_fd(fixture->fd, "{'execute': 'guest-ping', "
+ "'arguments': {'foo': 42 }}");
+ g_assert_nonnull(ret);
+
+ error = qdict_get_qdict(ret, "error");
+ class = qdict_get_try_str(error, "class");
+ desc = qdict_get_try_str(error, "desc");
+
+ g_assert_cmpstr(class, ==, "GenericError");
+ g_assert_cmpstr(desc, ==, "QMP input object member 'foo' is unexpected");
+
+ QDECREF(ret);
+}
+
static void test_qga_invalid_cmd(gconstpointer fix)
{
const TestFixture *fixture = fix;
@@ -911,6 +931,7 @@ int main(int argc, char **argv)
g_test_add_data_func("/qga/file-write-read", &fix, test_qga_file_write_read);
g_test_add_data_func("/qga/get-time", &fix, test_qga_get_time);
g_test_add_data_func("/qga/invalid-cmd", &fix, test_qga_invalid_cmd);
+ g_test_add_data_func("/qga/invalid-args", &fix, test_qga_invalid_args);
g_test_add_data_func("/qga/fsfreeze-status", &fix,
test_qga_fsfreeze_status);
diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c
index 261fd9e313..81cbe545c4 100644
--- a/tests/test-qmp-commands.c
+++ b/tests/test-qmp-commands.c
@@ -106,6 +106,7 @@ static void test_dispatch_cmd(void)
static void test_dispatch_cmd_failure(void)
{
QDict *req = qdict_new();
+ QDict *args = qdict_new();
QObject *resp;
qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2")));
@@ -116,6 +117,20 @@ static void test_dispatch_cmd_failure(void)
qobject_decref(resp);
QDECREF(req);
+
+ /* check that with extra arguments it throws an error */
+ req = qdict_new();
+ qdict_put(args, "a", qint_from_int(66));
+ qdict_put(req, "arguments", args);
+
+ qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd")));
+
+ resp = qmp_dispatch(QOBJECT(req));
+ assert(resp != NULL);
+ assert(qdict_haskey(qobject_to_qdict(resp), "error"));
+
+ qobject_decref(resp);
+ QDECREF(req);
}
static QObject *test_qmp_dispatch(QDict *req)