The test_cdrom_param() function uses qtest_hmp() to run "info block", which depends on the human-monitor-command QMP endpoint. Replace it with the QMP query-block command so the test works when HMP is disabled (-Dhmp=disabled).
Signed-off-by: Marc-André Lureau <[email protected]> --- tests/qtest/cdrom-test.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/tests/qtest/cdrom-test.c b/tests/qtest/cdrom-test.c index a65854d2bc5..bf997be6d69 100644 --- a/tests/qtest/cdrom-test.c +++ b/tests/qtest/cdrom-test.c @@ -14,6 +14,7 @@ #include "libqtest.h" #include "boot-sector.h" #include "qobject/qdict.h" +#include "qobject/qlist.h" static char isoimage[] = "cdrom-boot-iso-XXXXXX"; @@ -92,17 +93,35 @@ cleanup: /** * Check that at least the -cdrom parameter is basically working, i.e. we can - * see the filename of the ISO image in the output of "info block" afterwards + * see the filename of the ISO image in the output of "query-block" afterwards */ static void test_cdrom_param(gconstpointer data) { QTestState *qts; - char *resp; + QDict *response; + QList *ret; + QListEntry *entry; + bool found = false; qts = qtest_initf("-M %s -cdrom %s", (const char *)data, isoimage); - resp = qtest_hmp(qts, "info block"); - g_assert(strstr(resp, isoimage) != 0); - g_free(resp); + response = qtest_qmp(qts, "{'execute': 'query-block'}"); + g_assert(response && qdict_haskey(response, "return")); + ret = qdict_get_qlist(response, "return"); + + QLIST_FOREACH_ENTRY(ret, entry) { + QDict *entry_dict = qobject_to(QDict, entry->value); + QDict *inserted = qdict_get_qdict(entry_dict, "inserted"); + if (inserted) { + const char *file = qdict_get_str(inserted, "file"); + if (file && strstr(file, isoimage)) { + found = true; + break; + } + } + } + + g_assert(found); + qobject_unref(response); qtest_quit(qts); } -- 2.54.0
