dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0121-test-avoid-leaks-in-leak-tests.patch

905b4d
From 664843123793879049459326127c2686f6361106 Mon Sep 17 00:00:00 2001
905b4d
From: Sumit Bose <sbose@redhat.com>
905b4d
Date: Fri, 28 Nov 2014 18:16:33 +0100
905b4d
Subject: [PATCH 121/128] test: avoid leaks in leak tests
905b4d
905b4d
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
905b4d
---
905b4d
 src/tests/cmocka/test_ifp.c | 5 ++++-
905b4d
 src/tests/leak_check.c      | 6 +++++-
905b4d
 2 files changed, 9 insertions(+), 2 deletions(-)
905b4d
905b4d
diff --git a/src/tests/cmocka/test_ifp.c b/src/tests/cmocka/test_ifp.c
905b4d
index d6e41706d5f55414c0376bd04d299ec6ad73c11e..5793f91911c1e15c2c241aaa51ffcd4196daea63 100644
905b4d
--- a/src/tests/cmocka/test_ifp.c
905b4d
+++ b/src/tests/cmocka/test_ifp.c
905b4d
@@ -209,6 +209,8 @@ void test_el_to_dict(void **state)
905b4d
     dbus_message_iter_get_basic(&iter_dict, &attr_val);
905b4d
     assert_string_equal(attr_val, "two");
905b4d
     assert_false(dbus_message_iter_next(&iter_dict));
905b4d
+
905b4d
+    talloc_free(sr);
905b4d
 }
905b4d
 
905b4d
 static void assert_string_list_equal(const char **s1,
905b4d
@@ -500,7 +502,8 @@ int main(int argc, const char *argv[])
905b4d
         unit_test(ifp_test_req_create),
905b4d
         unit_test(ifp_test_req_wrong_uid),
905b4d
         unit_test(test_path_prefix),
905b4d
-        unit_test(test_el_to_dict),
905b4d
+        unit_test_setup_teardown(test_el_to_dict,
905b4d
+                                 ifp_test_req_setup, ifp_test_req_teardown),
905b4d
         unit_test(test_attr_acl),
905b4d
         unit_test(test_attr_acl_ex),
905b4d
         unit_test(test_attr_allowed),
905b4d
diff --git a/src/tests/leak_check.c b/src/tests/leak_check.c
905b4d
index bb5698cd80d5b360433d95a6297b740bb5cded87..1eaa2cd097bda54094098a2947bb3834a9bf04f4 100644
905b4d
--- a/src/tests/leak_check.c
905b4d
+++ b/src/tests/leak_check.c
905b4d
@@ -130,10 +130,14 @@ leak_check_setup(void)
905b4d
 bool
905b4d
 leak_check_teardown(void)
905b4d
 {
905b4d
+    bool res;
905b4d
     check_leaks_pop(global_talloc_context);
905b4d
     if (snapshot_stack != NULL) {
905b4d
         _set_leak_err_msg("Exiting with a non-empty stack");
905b4d
         return false;
905b4d
     }
905b4d
-    return check_leaks(global_talloc_context, 0);
905b4d
+    res = check_leaks(global_talloc_context, 0);
905b4d
+    talloc_disable_null_tracking();
905b4d
+    talloc_free(global_talloc_context);
905b4d
+    return res;
905b4d
 }
905b4d
-- 
905b4d
1.9.3
905b4d