From 8f15f19596a5f8bacabead14940b314566c56c74 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 6 Aug 2018 14:35:20 +0200 Subject: [PATCH] tests: qemumonitorjson: Simplify debugging of 'blockInfo' test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Print the differences in case when the expected data does not match. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- tests/qemumonitorjsontest.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index e9b2632655..3a0490bd26 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1585,12 +1585,29 @@ testQemuMonitorJSONqemuMonitorJSONGetVirtType(const void *data) return ret; } + +static void +testQemuMonitorJSONGetBlockInfoPrint(const struct qemuDomainDiskInfo *d) +{ + VIR_TEST_VERBOSE("removable: %d, tray: %d, tray_open: %d, empty: %d, " + "io_status: %d, nodename: '%s'\n", + d->removable, d->tray, d->tray_open, d->empty, + d->io_status, NULLSTR(d->nodename)); +} + + static int testHashEqualQemuDomainDiskInfo(const void *value1, const void *value2) { const struct qemuDomainDiskInfo *info1 = value1, *info2 = value2; + int ret; - return memcmp(info1, info2, sizeof(*info1)); + if ((ret = memcmp(info1, info2, sizeof(*info1))) != 0) { + testQemuMonitorJSONGetBlockInfoPrint(info1); + testQemuMonitorJSONGetBlockInfoPrint(info2); + } + + return ret; } static int