diff options
author | Sumit Bose <sbose@redhat.com> | 2010-02-03 11:54:46 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-02-03 10:35:18 -0500 |
commit | 067fbea128ea5f6298feb37f9aaab347afd59d8a (patch) | |
tree | cdfcd2ab310a249dc510be271dfb7d7e547f3569 /server/tests/common.c | |
parent | f77224d2141c713afefd5f953515ad1e42dca3e5 (diff) | |
download | sssd-067fbea128ea5f6298feb37f9aaab347afd59d8a.tar.gz sssd-067fbea128ea5f6298feb37f9aaab347afd59d8a.tar.bz2 sssd-067fbea128ea5f6298feb37f9aaab347afd59d8a.zip |
Make resolve and failover test work with CK_FORK=no
The leak checking code which is used by the resolve and failover tests
frees talloc's autofree context which is not recommended. As a
consequence the initialization of tevent failed when it was called by
the second test and CF_FORK=no, because it holds some data in the
autofree context.
This patch introduces a global talloc context which should be uses by
the test as the root of their memory hierarchy instead of NULL. This
global context is used in the leak checking routines.
Not all types of memory leaks can be detected by the new version , it is
recommended to use valgrind or similar tools additionally.
Diffstat (limited to 'server/tests/common.c')
-rw-r--r-- | server/tests/common.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/server/tests/common.c b/server/tests/common.c index 5b341abc..dad9dc66 100644 --- a/server/tests/common.c +++ b/server/tests/common.c @@ -47,7 +47,7 @@ _check_leaks(TALLOC_CTX *ctx, size_t bytes, const char *location) bytes_allocated = talloc_total_size(ctx); if (bytes_allocated != bytes) { fprintf(stderr, "Leak report for %s:\n", location); - talloc_report_full(NULL, stderr); + talloc_report_full(ctx, stderr); fail("%s: memory leaks detected, %d bytes still allocated", location, bytes_allocated - bytes); } @@ -91,14 +91,17 @@ void leak_check_setup(void) { talloc_enable_null_tracking(); + global_talloc_context = talloc_new(NULL); + fail_unless(global_talloc_context != NULL, "talloc_new failed"); + check_leaks_push(global_talloc_context); } void leak_check_teardown(void) { + check_leaks_pop(global_talloc_context); if (snapshot_stack != NULL) { fail("Exiting with a non-empty stack"); } - talloc_free(talloc_autofree_context()); - check_leaks(NULL, 0); + check_leaks(global_talloc_context, 0); } |