From 878fa7d0d4a3c9de1e813a550c5968153faae0a9 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Tue, 28 Nov 2017 12:20:26 +0100 Subject: [PATCH 68/79] test_responder: Check memory leak in sized_output_name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: https://pagure.io/SSSD/sssd/issue/3588 Reviewed-by: Fabiano FidĂȘncio --- src/tests/cmocka/test_responder_common.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/tests/cmocka/test_responder_common.c b/src/tests/cmocka/test_responder_common.c index fb7e4ee500570319999e6e85ee14a05cddea8de3..5441167caeb284982ee76926117da029966ec997 100644 --- a/src/tests/cmocka/test_responder_common.c +++ b/src/tests/cmocka/test_responder_common.c @@ -316,6 +316,23 @@ void test_schedule_get_domains_task(void **state) talloc_free(dummy_ncache_ptr); } +void test_sss_output_fqname(void **state) +{ + struct parse_inp_test_ctx *parse_inp_ctx = talloc_get_type(*state, + struct parse_inp_test_ctx); + errno_t ret; + struct sized_string *res = NULL; + + ret = sized_output_name(parse_inp_ctx, parse_inp_ctx->rctx, "dummy", + parse_inp_ctx->tctx->dom, &res); + assert_int_equal(ret, EOK); + assert_non_null(res); + assert_string_equal("dummy", res->str); + assert_int_equal(6, res->len); + + talloc_zfree(res); +} + int main(int argc, const char *argv[]) { int rv; @@ -346,6 +363,9 @@ int main(int argc, const char *argv[]) cmocka_unit_test_setup_teardown(test_schedule_get_domains_task, parse_inp_test_setup, parse_inp_test_teardown), + cmocka_unit_test_setup_teardown(test_sss_output_fqname, + parse_inp_test_setup, + parse_inp_test_teardown), }; /* Set debug level to invalid value so we can deside if -d 0 was used. */ -- 2.15.1