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

Eric Blake eblake at redhat.com
Tue Dec 3 00:19:58 UTC 2013


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131202/e5cbaf11/attachment-0001.sig>


More information about the libvir-list mailing list