mirror of https://github.com/xqemu/xqemu.git
tests: Clean up wait for event
We still use hacks like qmp("") to wait for an event, even though we have qmp_eventwait() since commit8fe941f
, and qmp_eventwait_ref() since commit7ffe312
. Both commits neglected to convert all the existing hacks. Make up what they missed. Bonus: gets rid of empty format strings. A step towards compile-time format string checking without triggering -Wformat-zero-length. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com> [thuth: dropped the hunks from the usb tests - not needed anymore] Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
bec9c64ef7
commit
2c58c27bee
|
@ -41,7 +41,7 @@ static void test_a_boot_order(const char *machine,
|
||||||
* system_reset only requests reset. We get a RESET event after
|
* system_reset only requests reset. We get a RESET event after
|
||||||
* the actual reset completes. Need to wait for that.
|
* the actual reset completes. Need to wait for that.
|
||||||
*/
|
*/
|
||||||
qmp_discard_response(""); /* HACK: wait for event */
|
qmp_eventwait("RESET");
|
||||||
actual = read_boot_order();
|
actual = read_boot_order();
|
||||||
g_assert_cmphex(actual, ==, expected_reboot);
|
g_assert_cmphex(actual, ==, expected_reboot);
|
||||||
qtest_quit(global_qtest);
|
qtest_quit(global_qtest);
|
||||||
|
|
|
@ -173,9 +173,5 @@ void qpci_unplug_acpi_device_test(const char *id, uint8_t slot)
|
||||||
|
|
||||||
outb(ACPI_PCIHP_ADDR + PCI_EJ_BASE, 1 << slot);
|
outb(ACPI_PCIHP_ADDR + PCI_EJ_BASE, 1 << slot);
|
||||||
|
|
||||||
response = qmp("");
|
qmp_eventwait("DEVICE_DELETED");
|
||||||
g_assert(response);
|
|
||||||
g_assert(qdict_haskey(response, "event"));
|
|
||||||
g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
|
|
||||||
QDECREF(response);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,9 +237,8 @@ static void test_tco_max_timeout(void)
|
||||||
|
|
||||||
static QDict *get_watchdog_action(void)
|
static QDict *get_watchdog_action(void)
|
||||||
{
|
{
|
||||||
QDict *ev = qmp("");
|
QDict *ev = qmp_eventwait_ref("WATCHDOG");
|
||||||
QDict *data;
|
QDict *data;
|
||||||
g_assert(!strcmp(qdict_get_str(ev, "event"), "WATCHDOG"));
|
|
||||||
|
|
||||||
data = qdict_get_qdict(ev, "data");
|
data = qdict_get_qdict(ev, "data");
|
||||||
QINCREF(data);
|
QINCREF(data);
|
||||||
|
|
|
@ -19,26 +19,10 @@ static void qmp_check_no_event(void)
|
||||||
QDECREF(resp);
|
QDECREF(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QDict *qmp_get_event(const char *name)
|
|
||||||
{
|
|
||||||
QDict *event = qmp("");
|
|
||||||
QDict *data;
|
|
||||||
g_assert(qdict_haskey(event, "event"));
|
|
||||||
g_assert(!strcmp(qdict_get_str(event, "event"), name));
|
|
||||||
|
|
||||||
if (qdict_haskey(event, "data")) {
|
|
||||||
data = qdict_get_qdict(event, "data");
|
|
||||||
QINCREF(data);
|
|
||||||
} else {
|
|
||||||
data = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDECREF(event);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
static QDict *ib700_program_and_wait(QTestState *s)
|
static QDict *ib700_program_and_wait(QTestState *s)
|
||||||
{
|
{
|
||||||
|
QDict *event, *data;
|
||||||
|
|
||||||
clock_step(NANOSECONDS_PER_SECOND * 40);
|
clock_step(NANOSECONDS_PER_SECOND * 40);
|
||||||
qmp_check_no_event();
|
qmp_check_no_event();
|
||||||
|
|
||||||
|
@ -62,7 +46,11 @@ static QDict *ib700_program_and_wait(QTestState *s)
|
||||||
clock_step(3 * NANOSECONDS_PER_SECOND);
|
clock_step(3 * NANOSECONDS_PER_SECOND);
|
||||||
qmp_check_no_event();
|
qmp_check_no_event();
|
||||||
clock_step(2 * NANOSECONDS_PER_SECOND);
|
clock_step(2 * NANOSECONDS_PER_SECOND);
|
||||||
return qmp_get_event("WATCHDOG");
|
event = qmp_eventwait_ref("WATCHDOG");
|
||||||
|
data = qdict_get_qdict(event, "data");
|
||||||
|
QINCREF(data);
|
||||||
|
QDECREF(event);
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,8 +62,7 @@ static void ib700_pause(void)
|
||||||
d = ib700_program_and_wait(s);
|
d = ib700_program_and_wait(s);
|
||||||
g_assert(!strcmp(qdict_get_str(d, "action"), "pause"));
|
g_assert(!strcmp(qdict_get_str(d, "action"), "pause"));
|
||||||
QDECREF(d);
|
QDECREF(d);
|
||||||
d = qmp_get_event("STOP");
|
qmp_eventwait("STOP");
|
||||||
QDECREF(d);
|
|
||||||
qtest_end();
|
qtest_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,8 +74,7 @@ static void ib700_reset(void)
|
||||||
d = ib700_program_and_wait(s);
|
d = ib700_program_and_wait(s);
|
||||||
g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
|
g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
|
||||||
QDECREF(d);
|
QDECREF(d);
|
||||||
d = qmp_get_event("RESET");
|
qmp_eventwait("RESET");
|
||||||
QDECREF(d);
|
|
||||||
qtest_end();
|
qtest_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +86,7 @@ static void ib700_shutdown(void)
|
||||||
d = ib700_program_and_wait(s);
|
d = ib700_program_and_wait(s);
|
||||||
g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
|
g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
|
||||||
QDECREF(d);
|
QDECREF(d);
|
||||||
d = qmp_get_event("SHUTDOWN");
|
qmp_eventwait("SHUTDOWN");
|
||||||
QDECREF(d);
|
|
||||||
qtest_end();
|
qtest_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue