>From 075d01323cf8490e3d73810eb347f40a9e83060e Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Sun, 11 May 2014 16:18:28 +0200 Subject: [PATCH 3/3] IFP: Add a unit test for ifp_reply_objpath --- src/tests/cmocka/test_ifp.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/tests/cmocka/test_ifp.c b/src/tests/cmocka/test_ifp.c index 8d9b8563563d1cb274eb44f044ebc05bb210596f..650a9496978854c4c1aa6b72f58e831d60ca7c10 100644 --- a/src/tests/cmocka/test_ifp.c +++ b/src/tests/cmocka/test_ifp.c @@ -410,6 +410,32 @@ void ifp_test_req_teardown(void **state) assert_true(leak_check_teardown()); } +void test_reply_path(void **state) +{ + struct ifp_test_req_ctx *test_ctx = talloc_get_type_abort(*state, + struct ifp_test_req_ctx); + char *path; + + /* Doesn't need escaping */ + path = ifp_reply_objpath(test_ctx->ireq, PATH_BASE, "domname", NULL); + assert_non_null(path); + assert_string_equal(path, PATH_BASE"/domname"); + talloc_free(path); +} + +void test_reply_path_escape(void **state) +{ + struct ifp_test_req_ctx *test_ctx = talloc_get_type_abort(*state, + struct ifp_test_req_ctx); + char *path; + + /* A dot needs escaping */ + path = ifp_reply_objpath(test_ctx->ireq, PATH_BASE, "redhat.com", NULL); + assert_non_null(path); + assert_string_equal(path, PATH_BASE"/redhat_2ecom"); + talloc_free(path); +} + int main(int argc, const char *argv[]) { poptContext pc; @@ -428,6 +454,10 @@ int main(int argc, const char *argv[]) unit_test(test_attr_acl), unit_test(test_attr_allowed), unit_test(test_path_escape_unescape), + unit_test_setup_teardown(test_reply_path, + ifp_test_req_setup, ifp_test_req_teardown), + unit_test_setup_teardown(test_reply_path_escape, + ifp_test_req_setup, ifp_test_req_teardown), }; /* Set debug level to invalid value so we can deside if -d 0 was used. */ -- 1.9.0