Received: from eggs.gnu.org ([2001:4830:134:3::10]:35692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCAor-0003ye-Lv for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCAon-0001yE-Pz for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44112) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cCAon-0001wr-Jp for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:25 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A2D5868BC for ; Wed, 30 Nov 2016 19:45:24 +0000 (UTC) From: Eric Blake Date: Wed, 30 Nov 2016 13:44:38 -0600 Message-Id: <1480535094-23831-21-git-send-email-eblake@redhat.com> In-Reply-To: <1480535094-23831-1-git-send-email-eblake@redhat.com> References: <1480535094-23831-1-git-send-email-eblake@redhat.com> Subject: [Qemu-devel] [PATCH 20/36] qtest: Avoid dynamic JSON in device-introspect-test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: armbru@redhat.com, pbonzini@redhat.com 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 --- tests/device-introspect-test.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c index 37debc1..9655a49 100644 --- a/tests/device-introspect-test.c +++ b/tests/device-introspect-test.c @@ -19,6 +19,8 @@ #include "qemu/osdep.h" #include "qemu-common.h" +#include "qapi/qmp/qbool.h" +#include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" #include "libqtest.h" @@ -28,10 +30,11 @@ static QList *device_type_list(bool abstract) { QDict *resp; QList *ret; + QDict *args = qdict_new(); - resp = qmp("{'execute': 'qom-list-types'," - " 'arguments': {'implements': 'device', 'abstract': %i}}", - abstract); + qdict_put_str(args, "implements", "device"); + qdict_put_bool(args, "abstract", abstract); + resp = qmp_cmd("qom-list-types", args); g_assert(qdict_haskey(resp, "return")); ret = qdict_get_qlist(resp, "return"); QINCREF(ret); @@ -43,10 +46,10 @@ static void test_one_device(const char *type) { QDict *resp; char *help, *qom_tree; + QDict *args = qdict_new(); - resp = qmp("{'execute': 'device-list-properties'," - " 'arguments': {'typename': %s}}", - type); + qdict_put_str(args, "typename", type); + resp = qmp_cmd("device-list-properties", args); QDECREF(resp); help = hmp("device_add \"%s,help\"", type); -- 2.7.4