summaryrefslogtreecommitdiffstats
path: root/tests/qtest/migration-helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/qtest/migration-helpers.c')
-rw-r--r--tests/qtest/migration-helpers.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c
index 516093b39a..b799dbafb7 100644
--- a/tests/qtest/migration-helpers.c
+++ b/tests/qtest/migration-helpers.c
@@ -17,10 +17,12 @@
bool got_stop;
-static void stop_cb(void *opaque, const char *name, QDict *data)
+static void check_stop_event(QTestState *who)
{
- if (!strcmp(name, "STOP")) {
+ QDict *event = qtest_qmp_event_ref(who, "STOP");
+ if (event) {
got_stop = true;
+ qobject_unref(event);
}
}
@@ -30,12 +32,19 @@ static void stop_cb(void *opaque, const char *name, QDict *data)
QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...)
{
va_list ap;
+ QDict *resp;
va_start(ap, command);
qtest_qmp_vsend_fds(who, &fd, 1, command, ap);
va_end(ap);
- return qtest_qmp_receive_success(who, stop_cb, NULL);
+ resp = qtest_qmp_receive(who);
+ check_stop_event(who);
+
+ g_assert(!qdict_haskey(resp, "error"));
+ g_assert(qdict_haskey(resp, "return"));
+
+ return qdict_get_qdict(resp, "return");
}
/*
@@ -44,12 +53,18 @@ QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...)
QDict *wait_command(QTestState *who, const char *command, ...)
{
va_list ap;
+ QDict *resp;
va_start(ap, command);
- qtest_qmp_vsend(who, command, ap);
+ resp = qtest_vqmp(who, command, ap);
va_end(ap);
- return qtest_qmp_receive_success(who, stop_cb, NULL);
+ check_stop_event(who);
+
+ g_assert(!qdict_haskey(resp, "error"));
+ g_assert(qdict_haskey(resp, "return"));
+
+ return qdict_get_qdict(resp, "return");
}
/*