Re: [PATCH 3/5] Introduce a test suite for the JSON monitor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/20/2012 07:49 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]