[libvirt] [PATCH 3/5] Introduce a test suite for the JSON monitor
Eric Blake
eblake at redhat.com
Mon Aug 20 14:17:54 UTC 2012
On 08/20/2012 07:49 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
>
> Take advantage of the previously added monitor helpers to
> create a test suite for the QEMU JSON monitor impl. As a
> proof of concept, this tests the 'qemuMonitorGetStatus'
> implementation
> ---
> .gitignore | 1 +
> tests/Makefile.am | 11 +++-
> tests/qemumonitorjsontest.c | 150 ++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 161 insertions(+), 1 deletion(-)
> create mode 100644 tests/qemumonitorjsontest.c
>
> + if (!test)
> + return -1;
> +
> + if (qemuMonitorTestAddItem(test, "query-status",
> + "{ "
> + " \"return\": { "
> + " \"status\": \"running\", "
> + " \"singlestep\": false, "
> + " \"running\": true "
> + " } "
> + "}") < 0)
> + goto cleanup;
> + if (qemuMonitorTestAddItem(test, "query-status",
> + "{ "
> + " \"return\": { "
> + " \"singlestep\": false, "
> + " \"running\": false "
> + " } "
> + "}") < 0)
> + goto cleanup;
So the trick is to batch up several replies (even if the same command
will be queried more than once),
> + if (qemuMonitorGetStatus(qemuMonitorTestGetMonitor(test),
> + &running, &reason) < 0)
> + goto cleanup;
then as each call triggers a monitor command, our batched replies start
getting fed back, and we can see that the rest of the qemu driver
handled the reply as expected. Looks good; should be easy enough to
copy to add more tests of a similar nature.
ACK.
--
Eric Blake eblake at 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: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120820/87a617a7/attachment-0001.sig>
More information about the libvir-list
mailing list