mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
tests/qtest: replace wait_command() with qtest_qmp_assert_success
Most usage of wait_command() is followed by qobject_unref(), which is just a verbose re-implementation of qtest_qmp_assert_success(). Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20230601161347.1803440-7-berrange@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
cdf5ab5587
commit
aca0406958
3 changed files with 74 additions and 157 deletions
|
@ -36,54 +36,6 @@ bool migrate_watch_for_stop(QTestState *who, const char *name,
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
/*
|
||||
* Events can get in the way of responses we are actually waiting for.
|
||||
*/
|
||||
QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...)
|
||||
{
|
||||
va_list ap;
|
||||
QDict *resp, *ret;
|
||||
|
||||
va_start(ap, command);
|
||||
qtest_qmp_vsend_fds(who, &fd, 1, command, ap);
|
||||
va_end(ap);
|
||||
|
||||
resp = qtest_qmp_receive(who);
|
||||
|
||||
g_assert(!qdict_haskey(resp, "error"));
|
||||
g_assert(qdict_haskey(resp, "return"));
|
||||
|
||||
ret = qdict_get_qdict(resp, "return");
|
||||
qobject_ref(ret);
|
||||
qobject_unref(resp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Events can get in the way of responses we are actually waiting for.
|
||||
*/
|
||||
QDict *wait_command(QTestState *who, const char *command, ...)
|
||||
{
|
||||
va_list ap;
|
||||
QDict *resp, *ret;
|
||||
|
||||
va_start(ap, command);
|
||||
resp = qtest_vqmp(who, command, ap);
|
||||
va_end(ap);
|
||||
|
||||
g_assert(!qdict_haskey(resp, "error"));
|
||||
g_assert(qdict_haskey(resp, "return"));
|
||||
|
||||
ret = qdict_get_qdict(resp, "return");
|
||||
qobject_ref(ret);
|
||||
qobject_unref(resp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Send QMP command "migrate".
|
||||
* Arguments are built from @fmt... (formatted like
|
||||
|
@ -111,7 +63,7 @@ void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...)
|
|||
*/
|
||||
QDict *migrate_query(QTestState *who)
|
||||
{
|
||||
return wait_command(who, "{ 'execute': 'query-migrate' }");
|
||||
return qtest_qmp_assert_success_ref(who, "{ 'execute': 'query-migrate' }");
|
||||
}
|
||||
|
||||
QDict *migrate_query_not_failed(QTestState *who)
|
||||
|
@ -209,7 +161,8 @@ void wait_for_migration_fail(QTestState *from, bool allow_active)
|
|||
} while (!failed);
|
||||
|
||||
/* Is the machine currently running? */
|
||||
rsp_return = wait_command(from, "{ 'execute': 'query-status' }");
|
||||
rsp_return = qtest_qmp_assert_success_ref(from,
|
||||
"{ 'execute': 'query-status' }");
|
||||
g_assert(qdict_haskey(rsp_return, "running"));
|
||||
g_assert(qdict_get_bool(rsp_return, "running"));
|
||||
qobject_unref(rsp_return);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue