Re: [v3 01/32] Added domain start/stop/define/undefine event unit tests

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

 



On 12/02/2013 09:39 AM, Cédric Bosdonnat wrote:
> These unit tests are aiming at providing some help during the domain
> events refactoring.
> ---
>  .gitignore              |   1 +
>  tests/Makefile.am       |   7 ++
>  tests/objecteventtest.c | 246 ++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 254 insertions(+)
>  create mode 100644 tests/objecteventtest.c
> 

> +
> +struct lifecycleEventCounter {
> +    int startEvents;
> +    int stopEvents;
> +    int defineEvents;
> +    int undefineEvents;
> +};

Style: use a typedef here, so you don't have to repeat 'struct' below.

> +
> +static void lifecycleEventCounter_reset(struct lifecycleEventCounter* counter)

Style: return type on separate line, '*' hugs the variable name, not the
type name.

static void
lifecycleEventCounter_reset(lifecycleEventCounter *counter)

> +static int domainLifecycleCb(virConnectPtr conn ATTRIBUTE_UNUSED,
> +                             virDomainPtr dom ATTRIBUTE_UNUSED,
> +                             int event,
> +                             int detail ATTRIBUTE_UNUSED,
> +                             void *opaque)
> +{
> +    struct lifecycleEventCounter *counter = opaque;
> +
> +    switch (event) {
> +        case VIR_DOMAIN_EVENT_STARTED:
> +            counter->startEvents++;
> +            break;
> +        case VIR_DOMAIN_EVENT_STOPPED:
> +            counter->stopEvents++;
> +            break;
> +        case VIR_DOMAIN_EVENT_DEFINED:
> +            counter->defineEvents++;
> +            break;
> +        case VIR_DOMAIN_EVENT_UNDEFINED:
> +            counter->undefineEvents++;
> +            break;
> +        default:
> +            /* Ignore other events */

Should we at least count the number of other events?

But overall looking very useful.

-- 
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]