From patchwork Wed Nov 30 19:44:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9454851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 80A896071C for ; Wed, 30 Nov 2016 20:26:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 748022015F for ; Wed, 30 Nov 2016 20:26:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69645284A2; Wed, 30 Nov 2016 20:26:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 24D7D2015F for ; Wed, 30 Nov 2016 20:26:19 +0000 (UTC) Received: from localhost ([::1]:46297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCBSM-0003yx-BH for patchwork-qemu-devel@patchwork.kernel.org; Wed, 30 Nov 2016 15:26:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCAoy-00046s-Aq for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCAov-00025s-DG for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44652) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cCAov-00025C-3l for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:33 -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 3C120C05AA54; Wed, 30 Nov 2016 19:45:32 +0000 (UTC) Received: from red.redhat.com (ovpn-116-172.phx2.redhat.com [10.3.116.172]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAUJj2nd025934; Wed, 30 Nov 2016 14:45:31 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 30 Nov 2016 13:44:50 -0600 Message-Id: <1480535094-23831-33-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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 30 Nov 2016 19:45:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 32/36] qtest: Avoid dynamic JSON in qom-test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, armbru@redhat.com, =?UTF-8?q?Andreas=20F=C3=A4rber?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);