diff mbox

[21/36] qtest: Avoid dynamic JSON in tmp105-test

Message ID 1480535094-23831-22-git-send-email-eblake@redhat.com
State New
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/tmp105-test.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c
index a7940a4..7019445 100644
--- a/tests/tmp105-test.c
+++ b/tests/tmp105-test.c
@@ -80,9 +80,12 @@  static int qmp_tmp105_get_temperature(const char *id)
 static void qmp_tmp105_set_temperature(const char *id, int value)
 {
     QDict *response;
+    QDict *args = qdict_new();

-    response = qmp("{ 'execute': 'qom-set', 'arguments': { 'path': %s, "
-                   "'property': 'temperature', 'value': %d } }", id, value);
+    qdict_put_str(args, "path", id);
+    qdict_put_str(args, "property", "temperature");
+    qdict_put_int(args, "value", value);
+    response = qmp_cmd("qom-set", args);
     g_assert(qdict_haskey(response, "return"));
     QDECREF(response);
 }