]> xenbits.xensource.com Git - libvirt.git/commit
event: share state driver between test:///default connections
authorEric Blake <eblake@redhat.com>
Wed, 1 Jan 2014 16:30:12 +0000 (09:30 -0700)
committerEric Blake <eblake@redhat.com>
Tue, 7 Jan 2014 15:30:32 +0000 (08:30 -0700)
commitfc967c3ec90b3d48a41e1213f9d0a1dce709e3d8
treeaf0c7b8bcc02d2c63d1702a40ba579bab8b95588
parentd847792f860f3b9bcad36d8862d9403aed27e649
event: share state driver between test:///default connections

Prior to this patch, every test:/// URI has its own event manager,
which means that registering for an event can only ever receive
events from the connection where it issued the API that triggered
the event.  But the whole idea of events is to be able to learn
about something where an API call did NOT trigger the action.

In order to actually test asynchronous events, I wanted to be able
to tie multiple test connections to the same state.  Use of a file
in a test URI is still per-connection state, but now parallel
connections to test:///default (from the same binary, of course)
now share common state and can affect one another.

The updated testsuite fails without the rest of this patch.
Valgrind didn't report any leaks.

* src/test/test_driver.c (testConnectOpen): Move per-connection
state initialization...
(testOpenFromFile): ...here.
(defaultConn, defaultConnections, defaultLock, testOnceInit): New
shared state.
(testOpenDefault): Only initialize on first connection.
(testConnectClose): Don't clobber state if still shared.
* tests/objecteventtest.c (testDomainStartStopEvent): Enhance to
cover this.
(timeout, mymain): Ensure test fails rather than blocks.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/test/test_driver.c
tests/objecteventtest.c