All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, John Snow <jsnow@redhat.com>,
	"open list:Floppy" <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PATCH v5 08/13] tests: Rely more on global_qtest
Date: Fri, 18 Aug 2017 16:15:37 -0500	[thread overview]
Message-ID: <20170818211542.5380-9-eblake@redhat.com> (raw)
In-Reply-To: <20170818211542.5380-1-eblake@redhat.com>

libqtest provides two layers of functions: qtest_*() that operate
on an explicit object, and a plain version that operates on the
'global_qtest' object.  However, very few tests care about the
distinction, and even the tests that manipulate multiple qtest
connections at once are just fine reassigning global_qtest around
the blocks of code that will then operate on the updated global,
rather than calling the verbose form.  Before the next few patches
get rid of the qtest_* layer, we first need to update the remaining
few spots that were using the long form where we can instead rely
on the short form.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/fdc-test.c         |  2 +-
 tests/ide-test.c         | 10 +++++-----
 tests/ipmi-bt-test.c     |  2 +-
 tests/ipmi-kcs-test.c    |  2 +-
 tests/libqos/libqos-pc.c |  2 +-
 tests/postcopy-test.c    | 14 +++++++-------
 tests/rtc-test.c         |  9 +++------
 tests/tco-test.c         |  5 ++---
 tests/wdt_ib700-test.c   | 30 +++++++++++++++++-------------
 9 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/tests/fdc-test.c b/tests/fdc-test.c
index 325712e0f2..0b68d9aec4 100644
--- a/tests/fdc-test.c
+++ b/tests/fdc-test.c
@@ -565,7 +565,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);

     qtest_start("-device floppy,id=floppy0");
-    qtest_irq_intercept_in(global_qtest, "ioapic");
+    irq_intercept_in("ioapic");
     qtest_add_func("/fdc/cmos", test_cmos);
     qtest_add_func("/fdc/no_media_on_start", test_no_media_on_start);
     qtest_add_func("/fdc/read_without_media", test_read_without_media);
diff --git a/tests/ide-test.c b/tests/ide-test.c
index aa9de065fc..505a800b44 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -462,7 +462,7 @@ static void test_bmdma_setup(void)
         "-drive file=%s,if=ide,serial=%s,cache=writeback,format=raw "
         "-global ide-hd.ver=%s",
         tmp_path, "testdisk", "version");
-    qtest_irq_intercept_in(global_qtest, "ioapic");
+    irq_intercept_in("ioapic");
 }

 static void test_bmdma_teardown(void)
@@ -584,7 +584,7 @@ static void test_flush(void)

     dev = get_pci_device(&bmdma_bar, &ide_bar);

-    qtest_irq_intercept_in(global_qtest, "ioapic");
+    irq_intercept_in("ioapic");

     /* Dirty media so that CMD_FLUSH_CACHE will actually go to disk */
     make_dirty(0);
@@ -635,7 +635,7 @@ static void test_retry_flush(const char *machine)

     dev = get_pci_device(&bmdma_bar, &ide_bar);

-    qtest_irq_intercept_in(global_qtest, "ioapic");
+    irq_intercept_in("ioapic");

     /* Dirty media so that CMD_FLUSH_CACHE will actually go to disk */
     make_dirty(0);
@@ -826,7 +826,7 @@ static void cdrom_pio_impl(int nblocks)
     ide_test_start("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 "
                    "-device ide-cd,drive=sr0,bus=ide.0", tmp_path);
     dev = get_pci_device(&bmdma_bar, &ide_bar);
-    qtest_irq_intercept_in(global_qtest, "ioapic");
+    irq_intercept_in("ioapic");

     /* PACKET command on device 0 */
     qpci_io_writeb(dev, ide_bar, reg_device, 0);
@@ -909,7 +909,7 @@ static void test_cdrom_dma(void)

     ide_test_start("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 "
                    "-device ide-cd,drive=sr0,bus=ide.0", tmp_path);
-    qtest_irq_intercept_in(global_qtest, "ioapic");
+    irq_intercept_in("ioapic");

     guest_buf = guest_alloc(guest_malloc, len);
     prdt[0].addr = cpu_to_le32(guest_buf);
diff --git a/tests/ipmi-bt-test.c b/tests/ipmi-bt-test.c
index 7e21a9bbcb..891f5bfb13 100644
--- a/tests/ipmi-bt-test.c
+++ b/tests/ipmi-bt-test.c
@@ -421,7 +421,7 @@ int main(int argc, char **argv)
           " -device isa-ipmi-bt,bmc=bmc0", emu_port);
     qtest_start(cmdline);
     g_free(cmdline);
-    qtest_irq_intercept_in(global_qtest, "ioapic");
+    irq_intercept_in("ioapic");
     qtest_add_func("/ipmi/extern/connect", test_connect);
     qtest_add_func("/ipmi/extern/bt_base", test_bt_base);
     qtest_add_func("/ipmi/extern/bt_enable_irq", test_enable_irq);
diff --git a/tests/ipmi-kcs-test.c b/tests/ipmi-kcs-test.c
index 178ffc1797..53127d2884 100644
--- a/tests/ipmi-kcs-test.c
+++ b/tests/ipmi-kcs-test.c
@@ -280,7 +280,7 @@ int main(int argc, char **argv)
                               " -device isa-ipmi-kcs,bmc=bmc0");
     qtest_start(cmdline);
     g_free(cmdline);
-    qtest_irq_intercept_in(global_qtest, "ioapic");
+    irq_intercept_in("ioapic");
     qtest_add_func("/ipmi/local/kcs_base", test_kcs_base);
     qtest_add_func("/ipmi/local/kcs_abort", test_kcs_abort);
     qtest_add_func("/ipmi/local/kcs_enable_irq", test_enable_irq);
diff --git a/tests/libqos/libqos-pc.c b/tests/libqos/libqos-pc.c
index b554758802..6a2ff6608b 100644
--- a/tests/libqos/libqos-pc.c
+++ b/tests/libqos/libqos-pc.c
@@ -25,7 +25,7 @@ QOSState *qtest_pc_boot(const char *cmdline_fmt, ...)
     qs = qtest_vboot(&qos_ops, cmdline_fmt, ap);
     va_end(ap);

-    qtest_irq_intercept_in(global_qtest, "ioapic");
+    irq_intercept_in("ioapic");

     return qs;
 }
diff --git a/tests/postcopy-test.c b/tests/postcopy-test.c
index 8142f2ab90..9c4e37473d 100644
--- a/tests/postcopy-test.c
+++ b/tests/postcopy-test.c
@@ -236,7 +236,7 @@ static QDict *return_or_event(QDict *response)
         got_stop = true;
     }
     QDECREF(response);
-    return return_or_event(qtest_qmp_receive(global_qtest));
+    return return_or_event(qmp_receive());
 }


@@ -318,13 +318,13 @@ static void check_guests_ram(void)
     bool hit_edge = false;
     bool bad = false;

-    qtest_memread(global_qtest, start_address, &first_byte, 1);
+    memread(start_address, &first_byte, 1);
     last_byte = first_byte;

     for (address = start_address + 4096; address < end_address; address += 4096)
     {
         uint8_t b;
-        qtest_memread(global_qtest, address, &b, 1);
+        memread(address, &b, 1);
         if (b != last_byte) {
             if (((b + 1) % 256) == last_byte && !hit_edge) {
                 /* This is OK, the guest stopped at the point of
@@ -474,19 +474,19 @@ static void test_migrate(void)

     global_qtest = to;

-    qtest_memread(to, start_address, &dest_byte_a, 1);
+    memread(start_address, &dest_byte_a, 1);

     /* Destination still running, wait for a byte to change */
     do {
-        qtest_memread(to, start_address, &dest_byte_b, 1);
+        memread(start_address, &dest_byte_b, 1);
         usleep(10 * 1000);
     } while (dest_byte_a == dest_byte_b);

     qmp_discard_response("{ 'execute' : 'stop'}");
     /* With it stopped, check nothing changes */
-    qtest_memread(to, start_address, &dest_byte_c, 1);
+    memread(start_address, &dest_byte_c, 1);
     sleep(1);
-    qtest_memread(to, start_address, &dest_byte_d, 1);
+    memread(start_address, &dest_byte_d, 1);
     g_assert_cmpint(dest_byte_c, ==, dest_byte_d);

     check_guests_ram();
diff --git a/tests/rtc-test.c b/tests/rtc-test.c
index d7a96cbd79..bdd234d316 100644
--- a/tests/rtc-test.c
+++ b/tests/rtc-test.c
@@ -685,13 +685,12 @@ static void periodic_timer(void)

 int main(int argc, char **argv)
 {
-    QTestState *s = NULL;
     int ret;

     g_test_init(&argc, &argv, NULL);

-    s = qtest_start("-rtc clock=vm");
-    qtest_irq_intercept_in(s, "ioapic");
+    qtest_start("-rtc clock=vm");
+    irq_intercept_in("ioapic");

     qtest_add_func("/rtc/check-time/bcd", bcd_check_time);
     qtest_add_func("/rtc/check-time/dec", dec_check_time);
@@ -711,9 +710,7 @@ int main(int argc, char **argv)

     ret = g_test_run();

-    if (s) {
-        qtest_quit(s);
-    }
+    qtest_end();

     return ret;
 }
diff --git a/tests/tco-test.c b/tests/tco-test.c
index c4c264eb3d..5b87bc16b9 100644
--- a/tests/tco-test.c
+++ b/tests/tco-test.c
@@ -54,14 +54,13 @@ static void test_end(TestData *d)

 static void test_init(TestData *d)
 {
-    QTestState *qs;
     char *s;

     s = g_strdup_printf("-machine q35 %s %s",
                         d->noreboot ? "" : "-global ICH9-LPC.noreboot=false",
                         !d->args ? "" : d->args);
-    qs = qtest_start(s);
-    qtest_irq_intercept_in(qs, "ioapic");
+    qtest_start(s);
+    irq_intercept_in("ioapic");
     g_free(s);

     d->bus = qpci_init_pc(NULL);
diff --git a/tests/wdt_ib700-test.c b/tests/wdt_ib700-test.c
index 49f4f0c221..59ba184a82 100644
--- a/tests/wdt_ib700-test.c
+++ b/tests/wdt_ib700-test.c
@@ -36,7 +36,7 @@ static QDict *qmp_get_event(const char *name)
     return data;
 }

-static QDict *ib700_program_and_wait(QTestState *s)
+static QDict *ib700_program_and_wait(void)
 {
     clock_step(NANOSECONDS_PER_SECOND * 40);
     qmp_check_no_event();
@@ -68,9 +68,10 @@ static QDict *ib700_program_and_wait(QTestState *s)
 static void ib700_pause(void)
 {
     QDict *d;
-    QTestState *s = qtest_start("-watchdog-action pause -device ib700");
-    qtest_irq_intercept_in(s, "ioapic");
-    d = ib700_program_and_wait(s);
+
+    qtest_start("-watchdog-action pause -device ib700");
+    irq_intercept_in("ioapic");
+    d = ib700_program_and_wait();
     g_assert(!strcmp(qdict_get_str(d, "action"), "pause"));
     QDECREF(d);
     d = qmp_get_event("STOP");
@@ -81,9 +82,10 @@ static void ib700_pause(void)
 static void ib700_reset(void)
 {
     QDict *d;
-    QTestState *s = qtest_start("-watchdog-action reset -device ib700");
-    qtest_irq_intercept_in(s, "ioapic");
-    d = ib700_program_and_wait(s);
+
+    qtest_start("-watchdog-action reset -device ib700");
+    irq_intercept_in("ioapic");
+    d = ib700_program_and_wait();
     g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
     QDECREF(d);
     d = qmp_get_event("RESET");
@@ -94,9 +96,10 @@ static void ib700_reset(void)
 static void ib700_shutdown(void)
 {
     QDict *d;
-    QTestState *s = qtest_start("-watchdog-action reset -no-reboot -device ib700");
-    qtest_irq_intercept_in(s, "ioapic");
-    d = ib700_program_and_wait(s);
+
+    qtest_start("-watchdog-action reset -no-reboot -device ib700");
+    irq_intercept_in("ioapic");
+    d = ib700_program_and_wait();
     g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
     QDECREF(d);
     d = qmp_get_event("SHUTDOWN");
@@ -107,9 +110,10 @@ static void ib700_shutdown(void)
 static void ib700_none(void)
 {
     QDict *d;
-    QTestState *s = qtest_start("-watchdog-action none -device ib700");
-    qtest_irq_intercept_in(s, "ioapic");
-    d = ib700_program_and_wait(s);
+
+    qtest_start("-watchdog-action none -device ib700");
+    irq_intercept_in("ioapic");
+    d = ib700_program_and_wait();
     g_assert(!strcmp(qdict_get_str(d, "action"), "none"));
     QDECREF(d);
     qtest_end();
-- 
2.13.5

  parent reply	other threads:[~2017-08-18 21:16 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-18 21:15 [Qemu-devel] [PATCH v5 00/13] Preliminary libqtest cleanups Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 01/13] test-qga: Kill broken and dead QGA_TEST_SIDE_EFFECTING code Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 02/13] qtest: Don't perform side effects inside assertion Eric Blake
2017-08-18 21:33   ` Philippe Mathieu-Daudé
2017-08-18 21:39     ` Eric Blake
2017-08-18 21:52       ` Philippe Mathieu-Daudé
2017-08-18 21:58       ` Eric Blake
2017-08-18 22:03         ` Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 03/13] libqtest: Remove dead qtest_instances variable Eric Blake
2017-08-18 21:33   ` Philippe Mathieu-Daudé
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 04/13] libqtest: Let socket_send() compute length Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 05/13] libqtest: Use qemu_strtoul() Eric Blake
2017-08-18 21:36   ` Philippe Mathieu-Daudé
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 06/13] libqtest: Topologically sort functions Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 07/13] libqtest: Inline qtest_query_target_endianness() Eric Blake
2017-08-18 21:46   ` Philippe Mathieu-Daudé
2017-08-18 22:08     ` Eric Blake
2017-08-18 21:15 ` Eric Blake [this message]
2017-08-18 21:33   ` [Qemu-devel] [PATCH v5 08/13] tests: Rely more on global_qtest John Snow
2017-08-19 16:34     ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2017-08-23 19:26       ` Eric Blake
2017-08-23 20:02         ` Paolo Bonzini
2017-08-23 21:30           ` Eric Blake
2017-08-23 21:50             ` Paolo Bonzini
2017-08-24  7:42               ` Markus Armbruster
2017-08-24  8:52                 ` Paolo Bonzini
2017-08-24 10:09                   ` Markus Armbruster
2017-08-24 10:20                     ` Paolo Bonzini
2017-08-24 12:07                       ` Markus Armbruster
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 09/13] libqtest: Shorten a couple more qtest_* functions Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 10/13] libqtest: Drop qtest_init() and qtest_qmp_discard_response() Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 11/13] libqtest: Drop many static inline qtest_ wrappers Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 12/13] libqtest: Use global_qtest in qtest_sendf() and qtest_rsp() Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 13/13] numa-test: Use hmp() Eric Blake
2017-08-18 21:56   ` Philippe Mathieu-Daudé

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=20170818211542.5380-9-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=qemu-block@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.