From patchwork Wed Nov 30 19:44:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 701150 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tTWKC4HrDz9t2D for ; Thu, 1 Dec 2016 06:52:15 +1100 (AEDT) Received: from localhost ([::1]:46093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCAvM-0000tf-Tj for incoming@patchwork.ozlabs.org; Wed, 30 Nov 2016 14:52:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCAop-0003w8-Q0 for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCAoo-000209-SA for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cCAoo-0001yv-MI for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:26 -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 CD05BAACE5 for ; Wed, 30 Nov 2016 19:45:25 +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 uAUJj2nT025934; Wed, 30 Nov 2016 14:45:25 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 30 Nov 2016 13:44:40 -0600 Message-Id: <1480535094-23831-23-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.25]); Wed, 30 Nov 2016 19:45:25 +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 22/36] qtest: Avoid dynamic JSON in pc-cpu-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 Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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/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);