>From 21bf7449bb53209ad24c0ec4079a5810bb6f707b Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Sat, 24 Oct 2015 15:15:39 +0200 Subject: [PATCH 3/5] TESTS: Check return value of check_leaks_pop --- src/tests/cmocka/test_child_common.c | 3 ++- src/tests/cwrap/test_become_user.c | 5 +++-- src/tests/cwrap/test_responder_common.c | 6 +++--- src/tests/krb5_utils-tests.c | 6 +++--- src/tests/leak_check.c | 6 +++++- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/tests/cmocka/test_child_common.c b/src/tests/cmocka/test_child_common.c index f8fd762fee5e8c0a39ea526835631f736e2dfc2d..bf500fa5a1f2b2fe79833e23a53cdf0b06b81260 100644 --- a/src/tests/cmocka/test_child_common.c +++ b/src/tests/cmocka/test_child_common.c @@ -76,7 +76,8 @@ static int child_test_teardown(void **state) struct child_test_ctx); talloc_free(child_tctx); - check_leaks_pop(global_talloc_context); + + assert_true(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 48e16d4c75351cf90c64503f377b591038f549e2..feb6889521d8af47eb0ef563c6bd6f1801b3619f 100644 --- a/src/tests/cwrap/test_become_user.c +++ b/src/tests/cwrap/test_become_user.c @@ -120,9 +120,10 @@ void test_switch_user(void **state) assert_int_equal(getgid(), 0); talloc_free(saved_creds); - check_leaks_pop(tmp_ctx); + assert_true(check_leaks_pop(tmp_ctx)); talloc_free(tmp_ctx); - check_leaks_pop(global_talloc_context); + + assert_true(check_leaks_pop(global_talloc_context)); assert_true(leak_check_teardown()); } diff --git a/src/tests/cwrap/test_responder_common.c b/src/tests/cwrap/test_responder_common.c index 2c92ff080e28151bc68e52fa02420c331d2ed4cf..024065bc10f7fff52b4a9df0e9581dafb26e786e 100644 --- a/src/tests/cwrap/test_responder_common.c +++ b/src/tests/cwrap/test_responder_common.c @@ -60,7 +60,7 @@ void test_uid_csv_to_uid_list(void **state) assert_int_equal(list[2], 3); talloc_free(list); - check_leaks_pop(tmp_ctx); + assert_true(check_leaks_pop(tmp_ctx)); talloc_free(tmp_ctx); } @@ -83,7 +83,7 @@ void test_name_csv_to_uid_list(void **state) assert_int_equal(list[1], 10001); talloc_free(list); - check_leaks_pop(tmp_ctx); + assert_true(check_leaks_pop(tmp_ctx)); talloc_free(tmp_ctx); } @@ -102,7 +102,7 @@ void test_csv_to_uid_list_neg(void **state) ret = csv_string_to_uid_array(tmp_ctx, "nosuchuser", true, &count, &list); assert_int_not_equal(ret, EOK); - check_leaks_pop(tmp_ctx); + assert_true(check_leaks_pop(tmp_ctx)); talloc_free(tmp_ctx); } diff --git a/src/tests/krb5_utils-tests.c b/src/tests/krb5_utils-tests.c index c2db5af9a2ee50de525ed56481293dc3784a6ec2..ea40feb4584749d01c4d3fb07ab34a93a80a8ab3 100644 --- a/src/tests/krb5_utils-tests.c +++ b/src/tests/krb5_utils-tests.c @@ -634,7 +634,7 @@ START_TEST(test_parse_krb5_map_user) name_to_primary[0].krb_primary == NULL); talloc_free(name_to_primary); - check_leaks_pop(mem_ctx); + fail_unless(check_leaks_pop(mem_ctx)); } /* valid input */ { @@ -653,7 +653,7 @@ START_TEST(test_parse_krb5_map_user) compare_map_id_name_to_krb_primary(name_to_primary, expected, sizeof(expected)/sizeof(const char*)/2); talloc_free(name_to_primary); - check_leaks_pop(mem_ctx); + fail_unless(check_leaks_pop(mem_ctx)); } /* invalid input */ { @@ -677,7 +677,7 @@ START_TEST(test_parse_krb5_map_user) ret = parse_krb5_map_user(mem_ctx, "joe:j:user", &name_to_primary); fail_unless(ret == EINVAL); - check_leaks_pop(mem_ctx); + fail_unless(check_leaks_pop(mem_ctx)); } talloc_free(mem_ctx); diff --git a/src/tests/leak_check.c b/src/tests/leak_check.c index 1eaa2cd097bda54094098a2947bb3834a9bf04f4..79c8f05f6a3b9a1893d442af4aa67510f1e7a957 100644 --- a/src/tests/leak_check.c +++ b/src/tests/leak_check.c @@ -131,7 +131,11 @@ bool leak_check_teardown(void) { bool res; - check_leaks_pop(global_talloc_context); + res = check_leaks_pop(global_talloc_context); + if (!res) { + _set_leak_err_msg("check_leaks_pop failed in leak_check_teardown"); + } + if (snapshot_stack != NULL) { _set_leak_err_msg("Exiting with a non-empty stack"); return false; -- 2.5.0