qemu-devel
[Top][All Lists]
Advanced

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

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


From: Eric Blake
Subject: [Qemu-devel] [PATCH 22/36] qtest: Avoid dynamic JSON in pc-cpu-test
Date: Wed, 30 Nov 2016 13:44:40 -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 a hand-built QDict.

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

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);
-- 
2.7.4




reply via email to

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