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