tests: qtest: print device_add error before failing test

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20230112140312.3096331-2-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Igor Mammedov 2023-01-12 15:02:33 +01:00 committed by Michael S. Tsirkin
parent eac7a7791b
commit 0711c28497

View File

@ -1435,6 +1435,10 @@ void qtest_qmp_device_add_qdict(QTestState *qts, const char *drv,
resp = qtest_qmp(qts, "{'execute': 'device_add', 'arguments': %p}", args);
g_assert(resp);
g_assert(!qdict_haskey(resp, "event")); /* We don't expect any events */
if (qdict_haskey(resp, "error")) {
fprintf(stderr, "error: %s\n",
qdict_get_str(qdict_get_qdict(resp, "error"), "desc"));
}
g_assert(!qdict_haskey(resp, "error"));
qobject_unref(resp);
}