From c3af5ccdbc22e8990d04ec2f89ad1f2e053655e9 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 24 Mar 2003 03:16:58 +0000 Subject: 2003-03-23 Havoc Pennington * dbus/dbus-threads.c (dbus_mutex_new, dbus_condvar_new): with DBUS_BUILD_TESTS, actually alloc/free a block of memory for the mutex, so we can check for proper memory management and OOM handling. * dbus/dbus-dataslot.c: remove the mutex from DBusDataSlotAllocator and lock it manually when using it, to simplify fitting it into the global slots framework. * dbus/dbus-threads.c (init_static_locks): rework how we're handling global locks so they are easily shut down. * bus/policy.c (bus_policy_append_rule): fix * bus/test-main.c (main): check for memleaks * dbus/dbus-test.c (dbus_internal_do_not_use_run_tests): make test suite check for memleaks * dbus/dbus-memory.c: add support in test mode for tracking number of outstanding blocks --- dbus/dbus-test.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'dbus/dbus-test.c') diff --git a/dbus/dbus-test.c b/dbus/dbus-test.c index 466e8b84..34160116 100644 --- a/dbus/dbus-test.c +++ b/dbus/dbus-test.c @@ -24,15 +24,18 @@ #include #include "dbus-test.h" #include "dbus-sysdeps.h" +#include "dbus-internals.h" #include #include +#ifdef DBUS_BUILD_TESTS static void die (const char *failure) { fprintf (stderr, "Unit test failed: %s\n", failure); exit (1); } +#endif /* DBUS_BUILD_TESTS */ /** * An exported symbol to be run in order to execute @@ -58,7 +61,7 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir) printf ("%s: running string tests\n", "dbus-test"); if (!_dbus_string_test ()) die ("strings"); - + printf ("%s: running data slot tests\n", "dbus-test"); if (!_dbus_data_slot_test ()) die ("dataslot"); @@ -96,7 +99,7 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir) printf ("%s: running memory pool tests\n", "dbus-test"); if (!_dbus_mem_pool_test ()) die ("memory pools"); - + printf ("%s: running linked list tests\n", "dbus-test"); if (!_dbus_list_test ()) die ("lists"); @@ -104,11 +107,21 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir) printf ("%s: running hash table tests\n", "dbus-test"); if (!_dbus_hash_test ()) die ("hash tables"); - + printf ("%s: running dict tests\n", "dbus-test"); if (!_dbus_dict_test ()) die ("dicts"); + dbus_shutdown (); + + printf ("%s: checking for memleaks\n", "dbus-test"); + if (_dbus_get_malloc_blocks_outstanding () != 0) + { + _dbus_warn ("%d dbus_malloc blocks were not freed\n", + _dbus_get_malloc_blocks_outstanding ()); + die ("memleaks"); + } + printf ("%s: completed successfully\n", "dbus-test"); #else printf ("Not compiled with unit tests, not running any\n"); -- cgit