qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, lvivier@redhat.com, mreitz@redhat.com
Subject: [Qemu-devel] [PULL 04/13] tests/q35-test: Make test independent of global_qtest
Date: Tue, 21 May 2019 12:53:35 +0200	[thread overview]
Message-ID: <20190521105344.11637-5-thuth@redhat.com> (raw)
In-Reply-To: <20190521105344.11637-1-thuth@redhat.com>

Use a local QTestState variable, so that we can finally get rid
of the undesired global_qtest variable in this file, too.

Message-Id: <20190515174328.16361-3-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 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)
-- 
2.21.0



  parent reply	other threads:[~2019-05-21 10:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-21 10:53 [Qemu-devel] [PULL 00/13] qtests and some iotest patches Thomas Huth
2019-05-21 10:53 ` [Qemu-devel] [PULL 01/13] tests/libqtest: Remove unused global_qtest-related wrapper functions Thomas Huth
2019-05-21 10:53 ` [Qemu-devel] [PULL 02/13] tests/libqtest: Fix description of qtest_vinitf() and qtest_initf() Thomas Huth
2019-05-21 10:53 ` [Qemu-devel] [PULL 03/13] tests/libqos: Get rid of global_qtest dependency in qvring_init() Thomas Huth
2019-05-21 10:53 ` Thomas Huth [this message]
2019-05-21 10:53 ` [Qemu-devel] [PULL 05/13] tests/numa-test: Use qtest_init() instead of qtest_start() Thomas Huth
2019-05-21 10:53 ` [Qemu-devel] [PULL 06/13] tests/qom-test: " Thomas Huth
2019-05-21 10:53 ` [Qemu-devel] [PULL 07/13] tests/device-introspect: " Thomas Huth
2019-05-21 10:53 ` [Qemu-devel] [PULL 08/13] tests/hd-geo-test: " Thomas Huth
2019-05-21 10:53 ` [Qemu-devel] [PULL 09/13] tests/qemu-iotests/005: Add a sanity check for large sparse file support Thomas Huth
2019-05-21 10:53 ` [Qemu-devel] [PULL 10/13] tests/qemu-iotests/check: Pick a default machine if necessary Thomas Huth
2019-05-21 10:53 ` [Qemu-devel] [PULL 11/13] tests/qemu-iotests: Do not hard-code the path to bash Thomas Huth
2019-05-24  8:12   ` Ed Maste
2019-05-21 10:53 ` [Qemu-devel] [PULL 12/13] cirrus / travis: Add gnu-sed and bash for macOS and FreeBSD Thomas Huth
2019-05-21 10:53 ` [Qemu-devel] [PULL 13/13] tests/qemu-iotests: Remove the "_supported_os Linux" line from many tests Thomas Huth
2019-05-24  8:11   ` Ed Maste
2019-05-21 13:56 ` [Qemu-devel] [PULL 00/13] qtests and some iotest patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190521105344.11637-5-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).