From: Thomas Huth <thuth@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 16/18] tests/m48t59: Make the test independent of global_qtest
Date: Wed, 14 Feb 2018 12:20:32 +0100 [thread overview]
Message-ID: <1518607234-17739-17-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1518607234-17739-1-git-send-email-thuth@redhat.com>
Stop using the functions that require global_qtest here and pass
around the QTestState instead (global_qtest should finally get
removed since this causes problems with tests running in parallel).
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/m48t59-test.c | 60 ++++++++++++++++++++++++++---------------------------
1 file changed, 30 insertions(+), 30 deletions(-)
diff --git a/tests/m48t59-test.c b/tests/m48t59-test.c
index a85f84d..8c25467 100644
--- a/tests/m48t59-test.c
+++ b/tests/m48t59-test.c
@@ -30,45 +30,45 @@ static uint16_t reg_base = 0x1ff0; /* 0x7f0 for m48t02 */
static int base_year;
static bool use_mmio;
-static uint8_t cmos_read_mmio(uint8_t reg)
+static uint8_t cmos_read_mmio(QTestState *s, uint8_t reg)
{
- return readb(base + (uint32_t)reg_base + (uint32_t)reg);
+ return qtest_readb(s, base + (uint32_t)reg_base + (uint32_t)reg);
}
-static void cmos_write_mmio(uint8_t reg, uint8_t val)
+static void cmos_write_mmio(QTestState *s, uint8_t reg, uint8_t val)
{
uint8_t data = val;
- writeb(base + (uint32_t)reg_base + (uint32_t)reg, data);
+ qtest_writeb(s, base + (uint32_t)reg_base + (uint32_t)reg, data);
}
-static uint8_t cmos_read_ioio(uint8_t reg)
+static uint8_t cmos_read_ioio(QTestState *s, uint8_t reg)
{
- outw(base + 0, reg_base + (uint16_t)reg);
- return inb(base + 3);
+ qtest_outw(s, base + 0, reg_base + (uint16_t)reg);
+ return qtest_inb(s, base + 3);
}
-static void cmos_write_ioio(uint8_t reg, uint8_t val)
+static void cmos_write_ioio(QTestState *s, uint8_t reg, uint8_t val)
{
- outw(base + 0, reg_base + (uint16_t)reg);
- outb(base + 3, val);
+ qtest_outw(s, base + 0, reg_base + (uint16_t)reg);
+ qtest_outb(s, base + 3, val);
}
-static uint8_t cmos_read(uint8_t reg)
+static uint8_t cmos_read(QTestState *s, uint8_t reg)
{
if (use_mmio) {
- return cmos_read_mmio(reg);
+ return cmos_read_mmio(s, reg);
} else {
- return cmos_read_ioio(reg);
+ return cmos_read_ioio(s, reg);
}
}
-static void cmos_write(uint8_t reg, uint8_t val)
+static void cmos_write(QTestState *s, uint8_t reg, uint8_t val)
{
if (use_mmio) {
- cmos_write_mmio(reg, val);
+ cmos_write_mmio(s, reg, val);
} else {
- cmos_write_ioio(reg, val);
+ cmos_write_ioio(s, reg, val);
}
}
@@ -106,18 +106,18 @@ static void print_tm(struct tm *tm)
}
#endif
-static void cmos_get_date_time(struct tm *date)
+static void cmos_get_date_time(QTestState *s, struct tm *date)
{
int sec, min, hour, mday, mon, year;
time_t ts;
struct tm dummy;
- sec = cmos_read(RTC_SECONDS);
- min = cmos_read(RTC_MINUTES);
- hour = cmos_read(RTC_HOURS);
- mday = cmos_read(RTC_DAY_OF_MONTH);
- mon = cmos_read(RTC_MONTH);
- year = cmos_read(RTC_YEAR);
+ sec = cmos_read(s, RTC_SECONDS);
+ min = cmos_read(s, RTC_MINUTES);
+ hour = cmos_read(s, RTC_HOURS);
+ mday = cmos_read(s, RTC_DAY_OF_MONTH);
+ mon = cmos_read(s, RTC_MONTH);
+ year = cmos_read(s, RTC_YEAR);
sec = bcd2dec(sec);
min = bcd2dec(min);
@@ -145,7 +145,7 @@ static void cmos_get_date_time(struct tm *date)
static QTestState *m48t59_qtest_start(void)
{
- return qtest_start("-rtc clock=vm");
+ return qtest_init("-rtc clock=vm");
}
static void bcd_check_time(void)
@@ -172,10 +172,10 @@ static void bcd_check_time(void)
ts = time(NULL);
gmtime_r(&ts, &start);
- cmos_get_date_time(&date[0]);
- cmos_get_date_time(&date[1]);
- cmos_get_date_time(&date[2]);
- cmos_get_date_time(&date[3]);
+ cmos_get_date_time(s, &date[0]);
+ cmos_get_date_time(s, &date[1]);
+ cmos_get_date_time(s, &date[2]);
+ cmos_get_date_time(s, &date[3]);
ts = time(NULL);
gmtime_r(&ts, &end);
@@ -226,8 +226,8 @@ static void fuzz_registers(void)
continue;
}
- cmos_write(reg, val);
- cmos_read(reg);
+ cmos_write(s, reg, val);
+ cmos_read(s, reg);
}
qtest_quit(s);
--
1.8.3.1
next prev parent reply other threads:[~2018-02-14 11:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-14 11:20 [Qemu-devel] [PULL 00/18] qtest patches Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 01/18] tests: Clean up wait for event Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 02/18] libqtest: Use qemu_strtoul() Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 03/18] libqos: Track QTestState with QPCIBus Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 04/18] libqos: Use explicit QTestState for fw_cfg operations Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 05/18] libqos: Use explicit QTestState for rtas operations Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 06/18] libqos: Use explicit QTestState for i2c operations Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 07/18] libqos: Use explicit QTestState for ahci operations Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 08/18] libqos: Use explicit QTestState for remaining libqos operations Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 09/18] qmp-test: Drop dependence on global_qtest Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 10/18] tests/boot-sector: " Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 11/18] wdt_ib700-test: " Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 12/18] tests/boot-serial: Enable the boot-serial test on SPARC machines, too Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 13/18] tests/boot-serial: Add tests for PowerPC Mac machines Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 14/18] tests/boot-serial-test: Add support for the aarch64 virt machine Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 15/18] tests/m48t59: Fix and re-enable the test for sparc Thomas Huth
2018-02-14 11:20 ` Thomas Huth [this message]
2018-02-14 11:20 ` [Qemu-devel] [PULL 17/18] tests/Makefile: Derive check-qtest-ppc64-y from check-qtest-ppc-y Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 18/18] tests/m48t59: Use the m48t59 test on ppc, too Thomas Huth
2018-02-15 14:15 ` [Qemu-devel] [PULL 00/18] qtest 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=1518607234-17739-17-git-send-email-thuth@redhat.com \
--to=thuth@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).