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

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



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

Attachment: signature.asc
Description: OpenPGP digital signature


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