qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 32/36] qtest: Avoid dynamic JSON in qom-test


From: Eric Blake
Subject: [Qemu-devel] [PATCH 32/36] qtest: Avoid dynamic JSON in qom-test
Date: Wed, 30 Nov 2016 13:44:50 -0600

As argued elsewhere, it's less code to maintain if we convert
from a dynamic string passed to qobject_from_jsonv() to instead
use hand-built QDict.

Signed-off-by: Eric Blake <address@hidden>
---
Optional; the "%s" handling in earlier patches is sufficient to
handle this without hand-built QDict, so it is a judgment call
which version is more legible.
---
 tests/qom-test.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/tests/qom-test.c b/tests/qom-test.c
index d48f890..780c775 100644
--- a/tests/qom-test.c
+++ b/tests/qom-test.c
@@ -46,13 +46,14 @@ static bool is_blacklisted(const char *arch, const char 
*mach)
 static void test_properties(const char *path, bool recurse)
 {
     char *child_path;
-    QDict *response, *tuple, *tmp;
+    QDict *response, *tuple, *tmp, *args;
     QList *list;
     QListEntry *entry;

     g_test_message("Obtaining properties of %s", path);
-    response = qmp("{ 'execute': 'qom-list',"
-                   "  'arguments': { 'path': %s } }", path);
+    args = qdict_new();
+    qdict_put_str(args, "path", path);
+    response = qmp_cmd("qom-list", args);
     g_assert(response);

     if (!recurse) {
@@ -75,10 +76,10 @@ static void test_properties(const char *path, bool recurse)
         } else {
             const char *prop = qdict_get_str(tuple, "name");
             g_test_message("Testing property %s.%s", path, prop);
-            tmp = qmp("{ 'execute': 'qom-get',"
-                      "  'arguments': { 'path': %s,"
-                      "                 'property': %s } }",
-                      path, prop);
+            args = qdict_new();
+            qdict_put_str(args, "path", path);
+            qdict_put_str(args, "property", prop);
+            tmp = qmp_cmd("qom-get", args);
             /* qom-get may fail but should not, e.g., segfault. */
             g_assert(tmp);
             QDECREF(tmp);
-- 
2.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]