aboutsummaryrefslogtreecommitdiff
path: root/tests/wdt_ib700-test.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-09-11 12:19:48 -0500
committerThomas Huth <thuth@redhat.com>2018-02-14 10:08:40 +0100
commit2c58c27beeba1a5be4bceeb283cbc90d4233a090 (patch)
tree812da89e85c44a2967e2112b1f2a51fe3151fe92 /tests/wdt_ib700-test.c
parentbec9c64ef7be8063f1192608b83877bc5c9ea217 (diff)
tests: Clean up wait for event
We still use hacks like qmp("") to wait for an event, even though we have qmp_eventwait() since commit 8fe941f, and qmp_eventwait_ref() since commit 7ffe312. 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>
Diffstat (limited to 'tests/wdt_ib700-test.c')
-rw-r--r--tests/wdt_ib700-test.c35
1 files changed, 10 insertions, 25 deletions
diff --git a/tests/wdt_ib700-test.c b/tests/wdt_ib700-test.c
index 6062d4e942..d777f3212e 100644
--- a/tests/wdt_ib700-test.c
+++ b/tests/wdt_ib700-test.c
@@ -19,26 +19,10 @@ static void qmp_check_no_event(void)
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)
{
+ QDict *event, *data;
+
clock_step(NANOSECONDS_PER_SECOND * 40);
qmp_check_no_event();
@@ -62,7 +46,11 @@ static QDict *ib700_program_and_wait(QTestState *s)
clock_step(3 * NANOSECONDS_PER_SECOND);
qmp_check_no_event();
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);
g_assert(!strcmp(qdict_get_str(d, "action"), "pause"));
QDECREF(d);
- d = qmp_get_event("STOP");
- QDECREF(d);
+ qmp_eventwait("STOP");
qtest_end();
}
@@ -87,8 +74,7 @@ static void ib700_reset(void)
d = ib700_program_and_wait(s);
g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
QDECREF(d);
- d = qmp_get_event("RESET");
- QDECREF(d);
+ qmp_eventwait("RESET");
qtest_end();
}
@@ -100,8 +86,7 @@ static void ib700_shutdown(void)
d = ib700_program_and_wait(s);
g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
QDECREF(d);
- d = qmp_get_event("SHUTDOWN");
- QDECREF(d);
+ qmp_eventwait("SHUTDOWN");
qtest_end();
}