From b090aa80e23b33e8f9710412e9453dbcdb6811c5 Mon Sep 17 00:00:00 2001
From: Petr Cech <pcech@redhat.com>
Date: Mon, 11 Apr 2016 00:26:19 -0400
Subject: [PATCH] REFACTOR: global_talloc_context push/pop remove

Push/pop global_talloc_context into check_leaks is redudant. It is done
in leak_check_setup() and leak_check_teardown() functions in
src/tests/check_leaks.
---
 src/tests/cmocka/test_ad_common.c     | 2 --
 src/tests/cmocka/test_child_common.c  | 2 --
 src/tests/cmocka/test_tools_colondb.c | 2 --
 src/tests/cmocka/test_utils.c         | 4 ----
 src/tests/cwrap/test_become_user.c    | 2 --
 5 files changed, 12 deletions(-)

diff --git a/src/tests/cmocka/test_ad_common.c b/src/tests/cmocka/test_ad_common.c
index b1929ae35df6ed17c391772009b48dcbf33fa69e..d2a29a2ffdabb123977caf11b2e94679c7b69d9b 100644
--- a/src/tests/cmocka/test_ad_common.c
+++ b/src/tests/cmocka/test_ad_common.c
@@ -90,7 +90,6 @@ static int test_ad_common_setup(void **state)
     test_dom_suite_setup(TESTS_PATH);
 
     assert_true(leak_check_setup());
-    check_leaks_push(global_talloc_context);
 
     test_ctx = talloc_zero(global_talloc_context, struct ad_common_test_ctx);
     assert_non_null(test_ctx);
@@ -121,7 +120,6 @@ static int test_ad_common_teardown(void **state)
 
     assert_true(check_leaks_pop(test_ctx) == true);
     talloc_free(test_ctx);
-    assert_true(check_leaks_pop(global_talloc_context) == true);
     assert_true(leak_check_teardown());
 
     ret = rmdir(TESTS_PATH);
diff --git a/src/tests/cmocka/test_child_common.c b/src/tests/cmocka/test_child_common.c
index 423132bdf7c1e429ce895821c8c7ed5e013ecb55..be842c4f502f134ac54d720abf19669d4b7f8c46 100644
--- a/src/tests/cmocka/test_child_common.c
+++ b/src/tests/cmocka/test_child_common.c
@@ -49,7 +49,6 @@ static int child_test_setup(void **state)
 
     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);
 
@@ -79,7 +78,6 @@ static int child_test_teardown(void **state)
 
     talloc_free(child_tctx);
 
-    assert_true(check_leaks_pop(global_talloc_context));
     assert_true(leak_check_teardown());
     return 0;
 }
diff --git a/src/tests/cmocka/test_tools_colondb.c b/src/tests/cmocka/test_tools_colondb.c
index 5aa105896b3690127b5bf3241fe2b27d2ae2f920..21610213946e46a67e576c9e9e0ac1ba095e9f0a 100644
--- a/src/tests/cmocka/test_tools_colondb.c
+++ b/src/tests/cmocka/test_tools_colondb.c
@@ -99,7 +99,6 @@ static int setup(void **state, int file_state)
 
     assert_true(leak_check_setup());
 
-    check_leaks_push(global_talloc_context);
     test_ctx = talloc_new(global_talloc_context);
     assert_non_null(test_ctx);
 
@@ -151,7 +150,6 @@ static int teardown(void **state)
     talloc_zfree(*state);
 
     test_dom_suite_cleanup(TESTS_PATH, NULL, NULL);
-    assert_true(check_leaks_pop(global_talloc_context));
     assert_true(leak_check_teardown());
 
     return 0;
diff --git a/src/tests/cmocka/test_utils.c b/src/tests/cmocka/test_utils.c
index fecc5579d85490a62641e3f7d5db22639fc5ed26..996d99ea06fb466929e01ed10e8e9dfd1b770e73 100644
--- a/src/tests/cmocka/test_utils.c
+++ b/src/tests/cmocka/test_utils.c
@@ -1135,13 +1135,11 @@ static int setup_add_strings_lists(void **state)
 {
     assert_true(leak_check_setup());
 
-    check_leaks_push(global_talloc_context);
     return 0;
 }
 
 static int teardown_add_strings_lists(void **state)
 {
-    assert_true(check_leaks_pop(global_talloc_context) == true);
     assert_true(leak_check_teardown());
     return 0;
 }
@@ -1338,7 +1336,6 @@ static int unique_file_test_setup(void **state)
     struct unique_file_test_ctx *test_ctx;
 
     assert_true(leak_check_setup());
-    check_leaks_push(global_talloc_context);
 
     test_ctx = talloc_zero(global_talloc_context, struct unique_file_test_ctx);
     assert_non_null(test_ctx);
@@ -1364,7 +1361,6 @@ static int unique_file_test_teardown(void **state)
     }
 
     talloc_free(test_ctx);
-    assert_true(check_leaks_pop(global_talloc_context) == true);
     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 feb6889521d8af47eb0ef563c6bd6f1801b3619f..f08182ce0e82c750ae2d759cf22e3ed432feb32c 100644
--- a/src/tests/cwrap/test_become_user.c
+++ b/src/tests/cwrap/test_become_user.c
@@ -80,7 +80,6 @@ void test_switch_user(void **state)
 
     assert_true(leak_check_setup());
 
-    check_leaks_push(global_talloc_context);
     tmp_ctx = talloc_new(global_talloc_context);
     assert_non_null(tmp_ctx);
 
@@ -123,7 +122,6 @@ void test_switch_user(void **state)
     assert_true(check_leaks_pop(tmp_ctx));
     talloc_free(tmp_ctx);
 
-    assert_true(check_leaks_pop(global_talloc_context));
     assert_true(leak_check_teardown());
 }
 
-- 
2.5.5

