From patchwork Wed May 15 17:43:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10945039 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 0EA0976 for ; Wed, 15 May 2019 17:45:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F277E28763 for ; Wed, 15 May 2019 17:45:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6B8928776; Wed, 15 May 2019 17:45:41 +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 8C7C828763 for ; Wed, 15 May 2019 17:45:41 +0000 (UTC) Received: from localhost ([127.0.0.1]:40475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQxyG-0006MS-Pb for patchwork-qemu-devel@patchwork.kernel.org; Wed, 15 May 2019 13:45:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQxwI-0004Xp-FO for qemu-devel@nongnu.org; Wed, 15 May 2019 13:43:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQxwH-0004Lt-BL for qemu-devel@nongnu.org; Wed, 15 May 2019 13:43:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37332) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQxwH-0004LZ-4I for qemu-devel@nongnu.org; Wed, 15 May 2019 13:43:37 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 65FBC30833A8 for ; Wed, 15 May 2019 17:43:36 +0000 (UTC) Received: from thuth.com (ovpn-117-96.ams2.redhat.com [10.36.117.96]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DAB73DED; Wed, 15 May 2019 17:43:35 +0000 (UTC) From: Thomas Huth To: Laurent Vivier , qemu-devel@nongnu.org Date: Wed, 15 May 2019 19:43:24 +0200 Message-Id: <20190515174328.16361-3-thuth@redhat.com> In-Reply-To: <20190515174328.16361-1-thuth@redhat.com> References: <20190515174328.16361-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 15 May 2019 17:43:36 +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] [PATCH 2/6] tests/q35-test: Make test independent of global_qtest 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: Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use a local QTestState variable, so that we can finally get rid of the undesired global_qtest variable in this file, too. Signed-off-by: Thomas Huth --- tests/q35-test.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/tests/q35-test.c b/tests/q35-test.c index 34b34bc2b9..a68183d513 100644 --- a/tests/q35-test.c +++ b/tests/q35-test.c @@ -84,10 +84,11 @@ static void test_smram_lock(void) QPCIBus *pcibus; QPCIDevice *pcidev; QDict *response; + QTestState *qts; - qtest_start("-M q35"); + qts = qtest_init("-M q35"); - pcibus = qpci_new_pc(global_qtest, NULL); + pcibus = qpci_new_pc(qts, NULL); g_assert(pcibus != NULL); pcidev = qpci_device_find(pcibus, 0); @@ -106,7 +107,7 @@ static void test_smram_lock(void) g_assert(smram_test_bit(pcidev, MCH_HOST_BRIDGE_SMRAM_D_OPEN) == false); /* reset */ - response = qmp("{'execute': 'system_reset', 'arguments': {} }"); + response = qtest_qmp(qts, "{'execute': 'system_reset', 'arguments': {} }"); g_assert(response); g_assert(!qdict_haskey(response, "error")); qobject_unref(response); @@ -120,33 +121,29 @@ static void test_smram_lock(void) g_free(pcidev); qpci_free_pc(pcibus); - qtest_end(); + qtest_quit(qts); } static void test_tseg_size(const void *data) { const TsegSizeArgs *args = data; - char *cmdline; QPCIBus *pcibus; QPCIDevice *pcidev; uint8_t smram_val; uint8_t esmramc_val; uint32_t ram_offs; + QTestState *qts; if (args->esmramc_tseg_sz == MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_MASK) { - cmdline = g_strdup_printf("-M q35 -m %uM " - "-global mch.extended-tseg-mbytes=%u", - TSEG_SIZE_TEST_GUEST_RAM_MBYTES, - args->extended_tseg_mbytes); + qts = qtest_initf("-M q35 -m %uM -global mch.extended-tseg-mbytes=%u", + TSEG_SIZE_TEST_GUEST_RAM_MBYTES, + args->extended_tseg_mbytes); } else { - cmdline = g_strdup_printf("-M q35 -m %uM", - TSEG_SIZE_TEST_GUEST_RAM_MBYTES); + qts = qtest_initf("-M q35 -m %uM", TSEG_SIZE_TEST_GUEST_RAM_MBYTES); } - qtest_start(cmdline); - g_free(cmdline); /* locate the DRAM controller */ - pcibus = qpci_new_pc(global_qtest, NULL); + pcibus = qpci_new_pc(qts, NULL); g_assert(pcibus != NULL); pcidev = qpci_device_find(pcibus, 0); g_assert(pcidev != NULL); @@ -175,18 +172,18 @@ static void test_tseg_size(const void *data) */ ram_offs = (TSEG_SIZE_TEST_GUEST_RAM_MBYTES - args->expected_tseg_mbytes) * 1024 * 1024 - 1; - g_assert_cmpint(readb(ram_offs), ==, 0); - writeb(ram_offs, 1); - g_assert_cmpint(readb(ram_offs), ==, 1); + g_assert_cmpint(qtest_readb(qts, ram_offs), ==, 0); + qtest_writeb(qts, ram_offs, 1); + g_assert_cmpint(qtest_readb(qts, ram_offs), ==, 1); ram_offs++; - g_assert_cmpint(readb(ram_offs), ==, 0xff); - writeb(ram_offs, 1); - g_assert_cmpint(readb(ram_offs), ==, 0xff); + g_assert_cmpint(qtest_readb(qts, ram_offs), ==, 0xff); + qtest_writeb(qts, ram_offs, 1); + g_assert_cmpint(qtest_readb(qts, ram_offs), ==, 0xff); g_free(pcidev); qpci_free_pc(pcibus); - qtest_end(); + qtest_quit(qts); } int main(int argc, char **argv)