dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone
Blob Blame History Raw
From 664843123793879049459326127c2686f6361106 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose@redhat.com>
Date: Fri, 28 Nov 2014 18:16:33 +0100
Subject: [PATCH 121/128] test: avoid leaks in leak tests

Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
---
 src/tests/cmocka/test_ifp.c | 5 ++++-
 src/tests/leak_check.c      | 6 +++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/tests/cmocka/test_ifp.c b/src/tests/cmocka/test_ifp.c
index d6e41706d5f55414c0376bd04d299ec6ad73c11e..5793f91911c1e15c2c241aaa51ffcd4196daea63 100644
--- a/src/tests/cmocka/test_ifp.c
+++ b/src/tests/cmocka/test_ifp.c
@@ -209,6 +209,8 @@ void test_el_to_dict(void **state)
     dbus_message_iter_get_basic(&iter_dict, &attr_val);
     assert_string_equal(attr_val, "two");
     assert_false(dbus_message_iter_next(&iter_dict));
+
+    talloc_free(sr);
 }
 
 static void assert_string_list_equal(const char **s1,
@@ -500,7 +502,8 @@ int main(int argc, const char *argv[])
         unit_test(ifp_test_req_create),
         unit_test(ifp_test_req_wrong_uid),
         unit_test(test_path_prefix),
-        unit_test(test_el_to_dict),
+        unit_test_setup_teardown(test_el_to_dict,
+                                 ifp_test_req_setup, ifp_test_req_teardown),
         unit_test(test_attr_acl),
         unit_test(test_attr_acl_ex),
         unit_test(test_attr_allowed),
diff --git a/src/tests/leak_check.c b/src/tests/leak_check.c
index bb5698cd80d5b360433d95a6297b740bb5cded87..1eaa2cd097bda54094098a2947bb3834a9bf04f4 100644
--- a/src/tests/leak_check.c
+++ b/src/tests/leak_check.c
@@ -130,10 +130,14 @@ leak_check_setup(void)
 bool
 leak_check_teardown(void)
 {
+    bool res;
     check_leaks_pop(global_talloc_context);
     if (snapshot_stack != NULL) {
         _set_leak_err_msg("Exiting with a non-empty stack");
         return false;
     }
-    return check_leaks(global_talloc_context, 0);
+    res = check_leaks(global_talloc_context, 0);
+    talloc_disable_null_tracking();
+    talloc_free(global_talloc_context);
+    return res;
 }
-- 
1.9.3