]> Git Repo - qemu.git/commitdiff
tests: add a test to check invalid args
authorMarc-André Lureau <[email protected]>
Mon, 12 Sep 2016 09:19:09 +0000 (13:19 +0400)
committerMarkus Armbruster <[email protected]>
Mon, 19 Sep 2016 15:32:22 +0000 (17:32 +0200)
Check that invalid args on commands without arguments returns an error.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20160912091913[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
tests/test-qga.c

index 21f44f8915626dd36df975dc3ea7e47e2b328ebc..40af64987a365151e528f1b5711a52aec1e089d7 100644 (file)
@@ -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);
 
This page took 0.027708 seconds and 4 git commands to generate.