Re: [PATCH] tests: Introduce qemucapabilitiestest

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

 



On 09/27/2013 04:25 AM, Michal Privoznik wrote:
> This test is there to ensure that our capabilities detection code isn't
> broken somehow.
> 
> How to gather test data:
> 
> Firstly, the data is split into two separate files. The former (with
> suffix .replies) contains all the qemu replies. This is very fragile as
> introducing a new device can mean yet another monitor command and hence
> edit of this file in the future. But there's no better way of doing
> this. To get this data simply turn on debug logs and copy all the
> QEMU_MONITOR_IO_PROCESS lines. But be careful to not copy incomplete
> ones (yeah, we report some incomplete lines too). Long story short, at
> the libvirtd startup, a dummy qemu is spawn to get all the capabilities.
> 
> The latter (with suffix .caps) contains capabilities XML. Just start a
> domain and copy the corresponding part from its state XML file.
> Including <qemuCaps> tag.
> 
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  .gitignore                                      |    1 +
>  tests/Makefile.am                               |   12 +-
>  tests/qemucapabilitiesdata/caps_1.5.3-1.caps    |  133 ++
>  tests/qemucapabilitiesdata/caps_1.5.3-1.replies | 2519 +++++++++++++++++++++++
>  tests/qemucapabilitiestest.c                    |  241 +++
>  5 files changed, 2904 insertions(+), 2 deletions(-)
>  create mode 100644 tests/qemucapabilitiesdata/caps_1.5.3-1.caps
>  create mode 100644 tests/qemucapabilitiesdata/caps_1.5.3-1.replies
>  create mode 100644 tests/qemucapabilitiestest.c
> 

> +static qemuMonitorTestPtr
> +testQemuFeedMonitor(char *replies,
> +                    virDomainXMLOptionPtr xmlopt)
> +{
> +    qemuMonitorTestPtr test = NULL;
> +    char *tmp = replies;
> +    char *singleReply = tmp;
> +
> +    /* Our JSON parser expects replies to be separated by a newline character.
> +     * Hence we must preprocess the file a bit. */
> +    while ((tmp = strchr(tmp, '\n'))) {
> +        /* It is safe to touch (tmp + 1) since all strings ends with '\0'. */
> +        bool eof = *(tmp + 1) == '\0';

More compact as:

bool eof = !tmp[1];

but that's not worth a respin :)

ACK - as this just touches the testsuite, I'm fine with including it in
1.1.3 rather than waiting.

-- 
Eric Blake   eblake redhat com    +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]