mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
tests: add qmp_assert_error_class()
This helper will simplify a bunch of code checking for QMP errors and can be shared by various tests. Note that test-qga does check for error description as well, so don't replace the code there for now. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
b8e1f74b0a
commit
ebb4d82d88
5 changed files with 46 additions and 61 deletions
|
@ -1194,3 +1194,14 @@ bool qmp_rsp_is_err(QDict *rsp)
|
|||
qobject_unref(rsp);
|
||||
return !!error;
|
||||
}
|
||||
|
||||
void qmp_assert_error_class(QDict *rsp, const char *class)
|
||||
{
|
||||
QDict *error = qdict_get_qdict(rsp, "error");
|
||||
|
||||
g_assert_cmpstr(qdict_get_try_str(error, "class"), ==, class);
|
||||
g_assert_nonnull(qdict_get_try_str(error, "desc"));
|
||||
g_assert(!qdict_haskey(rsp, "return"));
|
||||
|
||||
qobject_unref(rsp);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue