summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2015-10-24 15:39:21 +0200
committerJakub Hrozek <jhrozek@redhat.com>2015-11-11 12:10:43 +0100
commit9c62d6619b87f1255ef6515280a20552fca9d925 (patch)
treed3a7775292a0217124f5573a45be8bc48b6341da
parent5455da4f944145239295a2d8344f1a7602b4454d (diff)
downloadsssd-9c62d6619b87f1255ef6515280a20552fca9d925.tar.gz
sssd-9c62d6619b87f1255ef6515280a20552fca9d925.tar.xz
sssd-9c62d6619b87f1255ef6515280a20552fca9d925.zip
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 <pcech@redhat.com>
-rw-r--r--src/tests/cmocka/test_child_common.c3
-rw-r--r--src/tests/cwrap/test_become_user.c3
2 files changed, 6 insertions, 0 deletions
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[])