Commit Graph

12 Commits

Author SHA1 Message Date
Eric Blake
20986e58aa tests: simplify common setup
A few of the tests were missing basic sanity checks, while most
of them were doing copy-and-paste initialization (in fact, some
of them pasted the argc > 1 check more than once!).  It's much
nicer to do things in one common place, and minimizes the size of
the next patch that fixes getcwd usage.

* tests/testutils.h (EXIT_AM_HARDFAIL): New define.
(progname, abs_srcdir): Define for all tests.
(VIRT_TEST_MAIN): Change callback signature.
* tests/testutils.c (virtTestMain): Do more common init.
* tests/commandtest.c (mymain): Simplify.
* tests/cputest.c (mymain): Likewise.
* tests/esxutilstest.c (mymain): Likewise.
* tests/eventtest.c (mymain): Likewise.
* tests/hashtest.c (mymain): Likewise.
* tests/networkxml2xmltest.c (mymain): Likewise.
* tests/nodedevxml2xmltest.c (myname): Likewise.
* tests/nodeinfotest.c (mymain): Likewise.
* tests/nwfilterxml2xmltest.c (mymain): Likewise.
* tests/qemuargv2xmltest.c (mymain): Likewise.
* tests/qemuhelptest.c (mymain): Likewise.
* tests/qemuxml2argvtest.c (mymain): Likewise.
* tests/qemuxml2xmltest.c (mymain): Likewise.
* tests/qparamtest.c (mymain): Likewise.
* tests/sexpr2xmltest.c (mymain): Likewise.
* tests/sockettest.c (mymain): Likewise.
* tests/statstest.c (mymain): Likewise.
* tests/storagepoolxml2xmltest.c (mymain): Likewise.
* tests/storagevolxml2xmltest.c (mymain): Likewise.
* tests/virbuftest.c (mymain): Likewise.
* tests/virshtest.c (mymain): Likewise.
* tests/vmx2xmltest.c (mymain): Likewise.
* tests/xencapstest.c (mymain): Likewise.
* tests/xmconfigtest.c (mymain): Likewise.
* tests/xml2sexprtest.c (mymain): Likewise.
* tests/xml2vmxtest.c (mymain): Likewise.
2011-04-29 10:21:20 -06:00
Daniel P. Berrange
329e9dc629 Enable use of -Wmissing-noreturn
* src/internal.h: Define a ATTRIBUTE_NO_RETURN annotation
* src/lxc/lxc_container.c: Annotate lxcContainerDummyChild
  with ATTRIBUTE_NO_RETURN
* tests/eventtest.c: Mark async thread as ATTRIBUTE_NO_RETURN
* m4/virt-compile-warnings.m4: Enable -Wmissing-noreturn
2011-04-05 11:39:58 +01:00
Daniel P. Berrange
343eaa150b Move event code out of the daemon/ into src/util/
The event loop implementation is used by more than just the
daemon, so move it into the shared area.

* daemon/event.c, src/util/event_poll.c: Renamed
* daemon/event.h, src/util/event_poll.h: Renamed
* tools/Makefile.am, tools/console.c, tools/virsh.c: Update
  to use new virEventPoll APIs
* daemon/mdns.c, daemon/mdns.c, daemon/Makefile.am: Update
  to use new virEventPoll APIs
2011-03-07 14:16:13 +00:00
Eric Blake
a7483a5631 event: fix event-handling allocation crash
Regression introduced in commit e6b68d7 (Nov 2010).

Prior to that point, handlesAlloc was always a multiple of
EVENT_ALLOC_EXTENT (10), and was an int (so even if the subtraction
had been able to wrap, a negative value would be less than the count
not try to free the handles array).  But after that point,
VIR_RESIZE_N made handlesAlloc grow geometrically (with a pattern of
10, 20, 30, 45 for the handles array) but still freed in multiples of
EVENT_ALLOC_EXTENT; and the count changed to size_t.  Which means that
after 31 handles have been created, then 30 handles destroyed,
handlesAlloc is 5 while handlesCount is 1, and since (size_t)(1 - 5)
is indeed greater than 1, this then tried to free 10 elements, which
had the awful effect of nuking the handles array while there were
still live handles.

Nuking live handles puts libvirtd in an inconsistent state, and was
easily reproducible by starting and then stopping 60 faqemu guests.

* daemon/event.c (virEventCleanupTimeouts, virEventCleanupHandles):
Avoid integer wrap-around causing us to delete the entire array
while entries are still active.
* tests/eventtest.c (mymain): Expose the bug.
2011-01-27 09:12:36 -07:00
Daniel P. Berrange
e8ac4a79f1 Make test suite output less verbose
Only print out '.' for each test case, full test output can be
re-enabled with VIR_TEST_VERBOSE=1, or VIR_TEST_DEBUG=XXXX

Sample output now looks like

  TEST: statstest
        ........................................ 40
        ...................................      75  OK
  PASS: statstest
  TEST: qparamtest
        ................................         32  OK
  PASS: qparamtest
  TEST:
        ............                             12  OK
2010-01-15 16:28:05 +00:00
Daniel P. Berrange
5c2a1ae876 Rename qemud/ directory to daemon/
* qemud/: Rename to daemon/
* Makefile.am, configure.in, src/Makefile.am, src/remote_internal.c,
  tests/Makefile.am, tests/eventtest.c: s/qemud/daemon/ where needed
2009-09-21 14:41:42 +01:00
Jim Meyering
25b20b7103 eventtest.c: detect write failure and avoid dead stores
* tests/eventtest.c (mymain): Exit nonzero upon write failure.
This also avoids several dead stores of the form ret = safewrite...
2009-09-04 18:59:29 +02:00
Daniel P. Berrange
34d22c1ed5 Avoid polling on FDs with no events enabled
If a file descriptor with events=0 was added to the libvirtd
event loop, it would still be added to the poll() fds' array.
While it wouldn't see any POLLIN/OUT events, it'd still get
triggered for HANGUP/ERROR events which was not in compliance
with the libvirt events API contract.

* qemud/event.c: Don't poll on FDs with events=0
* tests/eventtest.c: Add test case to validate fix to event.c
2009-09-03 18:06:16 +01:00
Amy Griffis
63fbcc6927 Consolidate code for parsing the logging env
* src/logging.c src/logging.h src/libvirt_private.syms:
  define new functions virLogSetFromEnv and virLogParseDefaultPriority
* qemud/qemud.c src/libvirt.c tests/eventtest.c: cleanup to use the
  unified functions
2009-08-06 15:55:07 +02:00
Amy Griffis
e542d52a7c Cleanup VIR_LOG_DEBUG parsing in eventtest
* tests/eventtest.c: don't covert high priority levels to debug level.
  Consider an invalid priority level setting a setup failure.
2009-08-06 15:50:40 +02:00
Cole Robinson
af8600678d Update POTFILES, and s/write/safewrite/ to appease 'make syntax-check' 2009-05-12 20:44:29 +00:00
Daniel P. Berrange
37ede4d5f5 Add test case for exercising the event loop 2009-05-12 16:45:14 +00:00