diff mbox

[22/36] qtest: Avoid dynamic JSON in pc-cpu-test

Message ID 1480535094-23831-23-git-send-email-eblake@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eric Blake Nov. 30, 2016, 7:44 p.m. UTC
As argued elsewhere, it's less code to maintain if we convert
from a dynamic string passed to qobject_from_jsonv() to instead
use a hand-built QDict.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/pc-cpu-test.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/tests/pc-cpu-test.c b/tests/pc-cpu-test.c
index c3a2633..7df7c54 100644
--- a/tests/pc-cpu-test.c
+++ b/tests/pc-cpu-test.c
@@ -37,8 +37,10 @@  static void test_pc_with_cpu_add(gconstpointer data)
     qtest_start(args);

     for (i = s->sockets * s->cores * s->threads; i < s->maxcpus; i++) {
-        response = qmp("{ 'execute': 'cpu-add',"
-                       "  'arguments': { 'id': %d } }", i);
+        QDict *id = qdict_new();
+
+        qdict_put_int(id, "id", i);
+        response = qmp_cmd("cpu-add", id);
         g_assert(response);
         g_assert(!qdict_haskey(response, "error"));
         QDECREF(response);
@@ -53,6 +55,7 @@  static void test_pc_without_cpu_add(gconstpointer data)
     const PCTestData *s = data;
     char *args;
     QDict *response;
+    QDict *id = qdict_new();

     args = g_strdup_printf("-machine %s -cpu %s "
                            "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
@@ -60,9 +63,8 @@  static void test_pc_without_cpu_add(gconstpointer data)
                            s->sockets, s->cores, s->threads, s->maxcpus);
     qtest_start(args);

-    response = qmp("{ 'execute': 'cpu-add',"
-                   "  'arguments': { 'id': %d } }",
-                   s->sockets * s->cores * s->threads);
+    qdict_put_int(id, "id", s->sockets * s->cores * s->threads);
+    response = qmp_cmd("cpu-add", id);
     g_assert(response);
     g_assert(qdict_haskey(response, "error"));
     QDECREF(response);