[libvirt] [PATCH 07/18] qemumonitorjsontest: Test qemuMonitorJSONGetVirtType
Eric Blake
eblake at redhat.com
Wed Oct 2 18:37:40 UTC 2013
On 10/02/2013 11:09 AM, Michal Privoznik wrote:
>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
> tests/qemumonitorjsontest.c | 38 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> 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)
> + 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", virtType);
> + goto cleanup;
> + }
This should also test the case where the command returns failure
(commandnotfound) and/or returns success but "enabled":false, to make
sure we don't report VIR_DOMAIN_VIRT_KVM in those cases.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131002/fff671e8/attachment-0001.sig>
More information about the libvir-list
mailing list