From patchwork Tue May 21 10:53:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10953425 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C104D1395 for ; Tue, 21 May 2019 10:55:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B10CB28958 for ; Tue, 21 May 2019 10:55:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5085289B7; Tue, 21 May 2019 10:55:38 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4CD0E28958 for ; Tue, 21 May 2019 10:55:38 +0000 (UTC) Received: from localhost ([127.0.0.1]:51336 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hT2Qj-0001LP-I5 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 21 May 2019 06:55:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hT2PH-00006E-H2 for qemu-devel@nongnu.org; Tue, 21 May 2019 06:54:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hT2PG-0004hm-I1 for qemu-devel@nongnu.org; Tue, 21 May 2019 06:54:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40416) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hT2PG-0004hD-9e for qemu-devel@nongnu.org; Tue, 21 May 2019 06:54:06 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92DA830832E9; Tue, 21 May 2019 10:54:05 +0000 (UTC) Received: from thuth.com (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6239C6085B; Tue, 21 May 2019 10:54:04 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Tue, 21 May 2019 12:53:37 +0200 Message-Id: <20190521105344.11637-7-thuth@redhat.com> In-Reply-To: <20190521105344.11637-1-thuth@redhat.com> References: <20190521105344.11637-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 21 May 2019 10:54:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/13] tests/qom-test: Use qtest_init() instead of qtest_start() 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: kwolf@redhat.com, lvivier@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP qtest_start() + qtest_end() should be avoided, since they use the global_qtest variable that we want to get rid of in the long run. Use qtest_init() and qtest_quit() instead. Message-Id: <20190515174328.16361-5-thuth@redhat.com> Signed-off-by: Thomas Huth --- tests/qom-test.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/tests/qom-test.c b/tests/qom-test.c index 73c52af3bb..4f94cc678c 100644 --- a/tests/qom-test.c +++ b/tests/qom-test.c @@ -44,7 +44,7 @@ static bool is_blacklisted(const char *arch, const char *mach) return false; } -static void test_properties(const char *path, bool recurse) +static void test_properties(QTestState *qts, const char *path, bool recurse) { char *child_path; QDict *response, *tuple, *tmp; @@ -52,8 +52,8 @@ static void test_properties(const char *path, bool recurse) QListEntry *entry; g_test_message("Obtaining properties of %s", path); - response = qmp("{ 'execute': 'qom-list'," - " 'arguments': { 'path': %s } }", path); + response = qtest_qmp(qts, "{ 'execute': 'qom-list'," + " 'arguments': { 'path': %s } }", path); g_assert(response); if (!recurse) { @@ -71,15 +71,15 @@ static void test_properties(const char *path, bool recurse) if (is_child || is_link) { child_path = g_strdup_printf("%s/%s", path, qdict_get_str(tuple, "name")); - test_properties(child_path, is_child); + test_properties(qts, child_path, is_child); g_free(child_path); } 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); + tmp = qtest_qmp(qts, + "{ 'execute': 'qom-get'," + " 'arguments': { 'path': %s, 'property': %s } }", + path, prop); /* qom-get may fail but should not, e.g., segfault. */ g_assert(tmp); qobject_unref(tmp); @@ -91,20 +91,18 @@ static void test_properties(const char *path, bool recurse) static void test_machine(gconstpointer data) { const char *machine = data; - char *args; QDict *response; + QTestState *qts; - args = g_strdup_printf("-machine %s", machine); - qtest_start(args); + qts = qtest_initf("-machine %s", machine); - test_properties("/machine", true); + test_properties(qts, "/machine", true); - response = qmp("{ 'execute': 'quit' }"); + response = qtest_qmp(qts, "{ 'execute': 'quit' }"); g_assert(qdict_haskey(response, "return")); qobject_unref(response); - qtest_end(); - g_free(args); + qtest_quit(qts); g_free((void *)machine); }