From 9c62d6619b87f1255ef6515280a20552fca9d925 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Sat, 24 Oct 2015 15:39:21 +0200 Subject: TESTS: Initialize leak check If leak_check_setup is not called then global_talloc_context was not initialized and check_leaks_pop(global_talloc_context) will fail. Reviewed-by: Petr Cech --- src/tests/cmocka/test_child_common.c | 3 +++ src/tests/cwrap/test_become_user.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/tests/cmocka/test_child_common.c b/src/tests/cmocka/test_child_common.c index 1a62a9099..f8fd762fe 100644 --- a/src/tests/cmocka/test_child_common.c +++ b/src/tests/cmocka/test_child_common.c @@ -45,6 +45,8 @@ static int child_test_setup(void **state) struct child_test_ctx *child_tctx; errno_t ret; + assert_true(leak_check_setup()); + check_leaks_push(global_talloc_context); child_tctx = talloc(global_talloc_context, struct child_test_ctx); assert_non_null(child_tctx); @@ -75,6 +77,7 @@ static int child_test_teardown(void **state) talloc_free(child_tctx); check_leaks_pop(global_talloc_context); + assert_true(leak_check_teardown()); return 0; } diff --git a/src/tests/cwrap/test_become_user.c b/src/tests/cwrap/test_become_user.c index b9e8a5c3b..48e16d4c7 100644 --- a/src/tests/cwrap/test_become_user.c +++ b/src/tests/cwrap/test_become_user.c @@ -78,6 +78,8 @@ void test_switch_user(void **state) struct sss_creds *saved_creds; struct sss_creds *saved_creds2 = NULL; + assert_true(leak_check_setup()); + check_leaks_push(global_talloc_context); tmp_ctx = talloc_new(global_talloc_context); assert_non_null(tmp_ctx); @@ -121,6 +123,7 @@ void test_switch_user(void **state) check_leaks_pop(tmp_ctx); talloc_free(tmp_ctx); check_leaks_pop(global_talloc_context); + assert_true(leak_check_teardown()); } int main(int argc, const char *argv[]) -- cgit