On Fri, Nov 29, 2013 at 04:18:37PM +0100, 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 | 242 ++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 250 insertions(+) > create mode 100644 tests/objecteventtest.c Cool, nice approach to testing this. > + dom = virDomainCreateXML(test->conn, domainDef, 0); Should check for dom == NULL > + > + if (virEventRunDefaultImpl() < 0) { > + ret = -1; > + goto cleanup; > + } > + > + if (counter.startEvents != 1) { > + ret = -1; > + goto cleanup; > + } > + > +cleanup: > + virConnectDomainEventDeregisterAny(test->conn, id); > + virDomainDestroy(dom); > + > + virDomainFree(dom); and void calling destroy/free if dom == NULL > +static int > +testDomainDefine(const void *data) > +{ > + const struct objecteventTest *test = data; > + struct lifecycleEventCounter counter; > + int eventId = VIR_DOMAIN_EVENT_ID_LIFECYCLE; > + virDomainPtr dom; > + int id; > + int ret = 0; > + > + lifecycleEventCounter_reset(&counter); > + > + id = virConnectDomainEventRegisterAny(test->conn, NULL, eventId, > + VIR_DOMAIN_EVENT_CALLBACK(&domainLifecycleCb), > + &counter, NULL); > + > + /* Make sure the define event is triggered */ > + dom = virDomainDefineXML(test->conn, domainDef); Same comment as before, and few more places - won't repeat myself for the others. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list