From 370a7a79596e39a9f21f93bf29be8a5a32d8fef2 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Wed, 2 Oct 2013 11:56:43 +0200 Subject: [PATCH] qemumonitorjsontest: Test qemuMonitorJSONGetVirtType Signed-off-by: Michal Privoznik --- tests/qemumonitorjsontest.c | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 3be530a87b..259b2c26eb 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1283,6 +1283,58 @@ cleanup: return ret; } +static int +testQemuMonitorJSONqemuMonitorJSONGetVirtType(const void *data) +{ + virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; + qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt); + int ret = -1; + int virtType; + + if (!test) + return -1; + + if (qemuMonitorTestAddItem(test, "query-kvm", + "{" + " \"return\": {" + " \"enabled\": true," + " \"present\": true" + " }," + " \"id\": \"libvirt-8\"" + "}") < 0 || + qemuMonitorTestAddItem(test, "query-kvm", + "{" + " \"return\": {" + " \"enabled\": false," + " \"present\": true" + " }," + " \"id\": \"libvirt-7\"" + "}") < 0) + goto cleanup; + + if (qemuMonitorJSONGetVirtType(qemuMonitorTestGetMonitor(test), &virtType) < 0) + goto cleanup; + + if (virtType != VIR_DOMAIN_VIRT_KVM) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "Unexpected virt type: %d, expecting %d", virtType, VIR_DOMAIN_VIRT_KVM); + goto cleanup; + } + + if (qemuMonitorJSONGetVirtType(qemuMonitorTestGetMonitor(test), &virtType) < 0) + goto cleanup; + + if (virtType != VIR_DOMAIN_VIRT_QEMU) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "Unexpected virt type: %d, expecting %d", virtType, VIR_DOMAIN_VIRT_QEMU); + } + + ret = 0; +cleanup: + qemuMonitorTestFree(test); + return ret; +} + static int testHashEqualQemuDomainDiskInfo(const void *value1, const void *value2) { @@ -1975,6 +2027,7 @@ mymain(void) DO_TEST(qemuMonitorJSONGetTargetArch); DO_TEST(qemuMonitorJSONGetMigrationCapability); DO_TEST(qemuMonitorJSONGetCPUInfo); + DO_TEST(qemuMonitorJSONGetVirtType); virObjectUnref(xmlopt);