aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-09-12 13:19:09 +0400
committerMarkus Armbruster <armbru@redhat.com>2016-09-19 17:32:22 +0200
commit4bdadd86718c901fc1a512a7e3e0cbe7518cf277 (patch)
treeb138faaedb102aaa542585105a3ce1ef3f58732c
parenta0067da1577e3eb0c60758384282568f4b2328fe (diff)
downloadqemu-4bdadd86718c901fc1a512a7e3e0cbe7518cf277.zip
qemu-4bdadd86718c901fc1a512a7e3e0cbe7518cf277.tar.gz
qemu-4bdadd86718c901fc1a512a7e3e0cbe7518cf277.tar.bz2
tests: add a test to check invalid args
Check that invalid args on commands without arguments returns an error. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20160912091913.15831-15-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
-rw-r--r--tests/test-qga.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test-qga.c b/tests/test-qga.c
index 21f44f8..40af649 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);