From: Thomas Huth <thuth@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: ehabkost@redhat.com
Subject: [Qemu-devel] [PULL 02/14] tests/tco: Make test independent of global_qtest
Date: Thu, 9 May 2019 10:19:18 +0200 [thread overview]
Message-ID: <20190509081930.19081-3-thuth@redhat.com> (raw)
In-Reply-To: <20190509081930.19081-1-thuth@redhat.com>
Pass around the QTestState in the TestData, so we do not need the
global_qtest variable here anymore.
Message-Id: <20190409085245.31548-2-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/tco-test.c | 63 ++++++++++++++++++++++++------------------------
1 file changed, 32 insertions(+), 31 deletions(-)
diff --git a/tests/tco-test.c b/tests/tco-test.c
index f89a42cdcc..254f735370 100644
--- a/tests/tco-test.c
+++ b/tests/tco-test.c
@@ -45,13 +45,14 @@ typedef struct {
QPCIDevice *dev;
QPCIBar tco_io_bar;
QPCIBus *bus;
+ QTestState *qts;
} TestData;
static void test_end(TestData *d)
{
g_free(d->dev);
qpci_free_pc(d->bus);
- qtest_end();
+ qtest_quit(d->qts);
}
static void test_init(TestData *d)
@@ -61,7 +62,6 @@ static void test_init(TestData *d)
qs = qtest_initf("-machine q35 %s %s",
d->noreboot ? "" : "-global ICH9-LPC.noreboot=false",
!d->args ? "" : d->args);
- global_qtest = qs;
qtest_irq_intercept_in(qs, "ioapic");
d->bus = qpci_new_pc(qs, NULL);
@@ -78,6 +78,7 @@ static void test_init(TestData *d)
qpci_config_writel(d->dev, ICH9_LPC_RCBA, RCBA_BASE_ADDR | 0x1);
d->tco_io_bar = qpci_legacy_iomap(d->dev, PM_IO_BASE_ADDR + 0x60);
+ d->qts = qs;
}
static void stop_tco(const TestData *d)
@@ -115,17 +116,17 @@ static void clear_tco_status(const TestData *d)
qpci_io_writew(d->dev, d->tco_io_bar, TCO2_STS, 0x0004);
}
-static void reset_on_second_timeout(bool enable)
+static void reset_on_second_timeout(const TestData *td, bool enable)
{
uint32_t val;
- val = readl(RCBA_BASE_ADDR + ICH9_CC_GCS);
+ val = qtest_readl(td->qts, RCBA_BASE_ADDR + ICH9_CC_GCS);
if (enable) {
val &= ~ICH9_CC_GCS_NO_REBOOT;
} else {
val |= ICH9_CC_GCS_NO_REBOOT;
}
- writel(RCBA_BASE_ADDR + ICH9_CC_GCS, val);
+ qtest_writel(td->qts, RCBA_BASE_ADDR + ICH9_CC_GCS, val);
}
static void test_tco_defaults(void)
@@ -171,11 +172,11 @@ static void test_tco_timeout(void)
stop_tco(&d);
clear_tco_status(&d);
- reset_on_second_timeout(false);
+ reset_on_second_timeout(&d, false);
set_tco_timeout(&d, ticks);
load_tco(&d);
start_tco(&d);
- clock_step(ticks * TCO_TICK_NSEC);
+ qtest_clock_step(d.qts, ticks * TCO_TICK_NSEC);
/* test first timeout */
val = qpci_io_readw(d.dev, d.tco_io_bar, TCO1_STS);
@@ -190,7 +191,7 @@ static void test_tco_timeout(void)
g_assert(ret == 0);
/* test second timeout */
- clock_step(ticks * TCO_TICK_NSEC);
+ qtest_clock_step(d.qts, ticks * TCO_TICK_NSEC);
val = qpci_io_readw(d.dev, d.tco_io_bar, TCO1_STS);
ret = val & TCO_TIMEOUT ? 1 : 0;
g_assert(ret == 1);
@@ -215,18 +216,18 @@ static void test_tco_max_timeout(void)
stop_tco(&d);
clear_tco_status(&d);
- reset_on_second_timeout(false);
+ reset_on_second_timeout(&d, false);
set_tco_timeout(&d, ticks);
load_tco(&d);
start_tco(&d);
- clock_step(((ticks & TCO_TMR_MASK) - 1) * TCO_TICK_NSEC);
+ qtest_clock_step(d.qts, ((ticks & TCO_TMR_MASK) - 1) * TCO_TICK_NSEC);
val = qpci_io_readw(d.dev, d.tco_io_bar, TCO_RLD);
g_assert_cmpint(val & TCO_RLD_MASK, ==, 1);
val = qpci_io_readw(d.dev, d.tco_io_bar, TCO1_STS);
ret = val & TCO_TIMEOUT ? 1 : 0;
g_assert(ret == 0);
- clock_step(TCO_TICK_NSEC);
+ qtest_clock_step(d.qts, TCO_TICK_NSEC);
val = qpci_io_readw(d.dev, d.tco_io_bar, TCO1_STS);
ret = val & TCO_TIMEOUT ? 1 : 0;
g_assert(ret == 1);
@@ -235,9 +236,9 @@ static void test_tco_max_timeout(void)
test_end(&d);
}
-static QDict *get_watchdog_action(void)
+static QDict *get_watchdog_action(const TestData *td)
{
- QDict *ev = qmp_eventwait_ref("WATCHDOG");
+ QDict *ev = qtest_qmp_eventwait_ref(td->qts, "WATCHDOG");
QDict *data;
data = qdict_get_qdict(ev, "data");
@@ -258,12 +259,12 @@ static void test_tco_second_timeout_pause(void)
stop_tco(&td);
clear_tco_status(&td);
- reset_on_second_timeout(true);
+ reset_on_second_timeout(&td, true);
set_tco_timeout(&td, TCO_SECS_TO_TICKS(16));
load_tco(&td);
start_tco(&td);
- clock_step(ticks * TCO_TICK_NSEC * 2);
- ad = get_watchdog_action();
+ qtest_clock_step(td.qts, ticks * TCO_TICK_NSEC * 2);
+ ad = get_watchdog_action(&td);
g_assert(!strcmp(qdict_get_str(ad, "action"), "pause"));
qobject_unref(ad);
@@ -283,12 +284,12 @@ static void test_tco_second_timeout_reset(void)
stop_tco(&td);
clear_tco_status(&td);
- reset_on_second_timeout(true);
+ reset_on_second_timeout(&td, true);
set_tco_timeout(&td, TCO_SECS_TO_TICKS(16));
load_tco(&td);
start_tco(&td);
- clock_step(ticks * TCO_TICK_NSEC * 2);
- ad = get_watchdog_action();
+ qtest_clock_step(td.qts, ticks * TCO_TICK_NSEC * 2);
+ ad = get_watchdog_action(&td);
g_assert(!strcmp(qdict_get_str(ad, "action"), "reset"));
qobject_unref(ad);
@@ -308,12 +309,12 @@ static void test_tco_second_timeout_shutdown(void)
stop_tco(&td);
clear_tco_status(&td);
- reset_on_second_timeout(true);
+ reset_on_second_timeout(&td, true);
set_tco_timeout(&td, ticks);
load_tco(&td);
start_tco(&td);
- clock_step(ticks * TCO_TICK_NSEC * 2);
- ad = get_watchdog_action();
+ qtest_clock_step(td.qts, ticks * TCO_TICK_NSEC * 2);
+ ad = get_watchdog_action(&td);
g_assert(!strcmp(qdict_get_str(ad, "action"), "shutdown"));
qobject_unref(ad);
@@ -333,12 +334,12 @@ static void test_tco_second_timeout_none(void)
stop_tco(&td);
clear_tco_status(&td);
- reset_on_second_timeout(true);
+ reset_on_second_timeout(&td, true);
set_tco_timeout(&td, ticks);
load_tco(&td);
start_tco(&td);
- clock_step(ticks * TCO_TICK_NSEC * 2);
- ad = get_watchdog_action();
+ qtest_clock_step(td.qts, ticks * TCO_TICK_NSEC * 2);
+ ad = get_watchdog_action(&td);
g_assert(!strcmp(qdict_get_str(ad, "action"), "none"));
qobject_unref(ad);
@@ -358,7 +359,7 @@ static void test_tco_ticks_counter(void)
stop_tco(&d);
clear_tco_status(&d);
- reset_on_second_timeout(false);
+ reset_on_second_timeout(&d, false);
set_tco_timeout(&d, ticks);
load_tco(&d);
start_tco(&d);
@@ -366,7 +367,7 @@ static void test_tco_ticks_counter(void)
do {
rld = qpci_io_readw(d.dev, d.tco_io_bar, TCO_RLD) & TCO_RLD_MASK;
g_assert_cmpint(rld, ==, ticks);
- clock_step(TCO_TICK_NSEC);
+ qtest_clock_step(d.qts, TCO_TICK_NSEC);
ticks--;
} while (!(qpci_io_readw(d.dev, d.tco_io_bar, TCO1_STS) & TCO_TIMEOUT));
@@ -405,11 +406,11 @@ static void test_tco1_status_bits(void)
stop_tco(&d);
clear_tco_status(&d);
- reset_on_second_timeout(false);
+ reset_on_second_timeout(&d, false);
set_tco_timeout(&d, ticks);
load_tco(&d);
start_tco(&d);
- clock_step(ticks * TCO_TICK_NSEC);
+ qtest_clock_step(d.qts, ticks * TCO_TICK_NSEC);
qpci_io_writeb(d.dev, d.tco_io_bar, TCO_DAT_IN, 0);
qpci_io_writeb(d.dev, d.tco_io_bar, TCO_DAT_OUT, 0);
@@ -434,11 +435,11 @@ static void test_tco2_status_bits(void)
stop_tco(&d);
clear_tco_status(&d);
- reset_on_second_timeout(true);
+ reset_on_second_timeout(&d, true);
set_tco_timeout(&d, ticks);
load_tco(&d);
start_tco(&d);
- clock_step(ticks * TCO_TICK_NSEC * 2);
+ qtest_clock_step(d.qts, ticks * TCO_TICK_NSEC * 2);
val = qpci_io_readw(d.dev, d.tco_io_bar, TCO2_STS);
ret = val & (TCO_SECOND_TO_STS | TCO_BOOT_STS) ? 1 : 0;
--
2.21.0
next prev parent reply other threads:[~2019-05-09 8:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-09 8:19 [Qemu-devel] [PULL 00/14] qtests, copyright statement clarifications and misc patches Thomas Huth
2019-05-09 8:19 ` [Qemu-devel] [PULL 01/14] tests: Force Python I/O encoding for check-qapi-schema Thomas Huth
2019-05-09 8:19 ` Thomas Huth [this message]
2019-05-09 8:19 ` [Qemu-devel] [PULL 03/14] tests/megasas: Make test independent of global_qtest Thomas Huth
2019-05-09 8:19 ` [Qemu-devel] [PULL 04/14] tests/qmp-cmd-test: Use qtest_init() instead of qtest_start() Thomas Huth
2019-05-09 8:19 ` [Qemu-devel] [PULL 05/14] tests/test-hmp: " Thomas Huth
2019-05-09 8:19 ` [Qemu-devel] [PULL 06/14] tests/ide-test: Make test independent of global_qtest Thomas Huth
2019-05-09 8:19 ` [Qemu-devel] [PULL 07/14] tests/tpm-tests: Use g_test_skip() to mark skipped tests Thomas Huth
2019-05-09 8:19 ` [Qemu-devel] [PULL 08/14] tests/Makefile: Remove unused test-obj-y variable Thomas Huth
2019-05-09 8:19 ` [Qemu-devel] [PULL 09/14] tests/drive_del-test: Use qtest_init() instead of qtest_start() Thomas Huth
2019-05-09 8:19 ` [Qemu-devel] [PULL 10/14] tests: qpci_unplug_acpi_device_test() should not rely on global_qtest Thomas Huth
2019-05-09 8:19 ` [Qemu-devel] [PULL 11/14] hw/i2c/smbus_ich9: Fix the confusing contributions-after-2012 statement Thomas Huth
2019-05-09 8:19 ` [Qemu-devel] [PULL 12/14] target/openrisc: Fix LGPL information in the file headers Thomas Huth
2019-05-09 8:19 ` [Qemu-devel] [PULL 13/14] target/sh4: " Thomas Huth
2019-05-09 8:19 ` [Qemu-devel] [PULL 14/14] include/exec/poison: Mark TARGET_FMT_lu as poisoned, too Thomas Huth
2019-05-09 15:30 ` [Qemu-devel] [PULL 00/14] qtests, copyright statement clarifications and misc 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=20190509081930.19081-3-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=ehabkost@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 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.