>From 9fa269ee45fb37b2c8946668aaf07a4343ce654f Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Wed, 16 Sep 2015 15:31:02 +0200 Subject: [PATCH 2/4] tests: Move named_domain from test_utils to common test code This handy function should be reused by other parts of the code. --- src/tests/cmocka/test_utils.c | 17 ----------------- src/tests/common.h | 4 ++++ src/tests/common_dom.c | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/tests/cmocka/test_utils.c b/src/tests/cmocka/test_utils.c index c7ebe0997ec00197e8852bedbcf26ef1f6394fc3..6a10be31ccc89532d59b422ccec9e439b61a40ba 100644 --- a/src/tests/cmocka/test_utils.c +++ b/src/tests/cmocka/test_utils.c @@ -454,23 +454,6 @@ void test_find_domain_by_sid_disabled(void **state) } } -static struct sss_domain_info *named_domain(TALLOC_CTX *mem_ctx, - const char *name, - struct sss_domain_info *parent) -{ - struct sss_domain_info *dom = NULL; - - dom = talloc_zero(mem_ctx, struct sss_domain_info); - assert_non_null(dom); - - dom->name = talloc_strdup(dom, name); - assert_non_null(dom->name); - - dom->parent = parent; - - return dom; -} - /* * dom1 -> sub1a * | diff --git a/src/tests/common.h b/src/tests/common.h index 1c6de2c3d6eb924ba7306bd350f8546d61f30751..c0ceebfbf5d9277a422065fbe4ddfdd65c758de8 100644 --- a/src/tests/common.h +++ b/src/tests/common.h @@ -134,4 +134,8 @@ test_dbus_call_sync(DBusConnection *conn, int first_arg_type, ...); +struct sss_domain_info *named_domain(TALLOC_CTX *mem_ctx, + const char *name, + struct sss_domain_info *parent); + #endif /* !__TESTS_COMMON_H__ */ diff --git a/src/tests/common_dom.c b/src/tests/common_dom.c index 41f876555352744c4f61215c1a88369918f5192c..5b87e7a3a0831619d654e2a5bd50bb6b9e03a8e6 100644 --- a/src/tests/common_dom.c +++ b/src/tests/common_dom.c @@ -384,3 +384,25 @@ void test_dom_suite_cleanup(const char *tests_path, test_multidom_suite_cleanup(tests_path, cdb_file, domains); } + +struct sss_domain_info *named_domain(TALLOC_CTX *mem_ctx, + const char *name, + struct sss_domain_info *parent) +{ + struct sss_domain_info *dom = NULL; + + dom = talloc_zero(mem_ctx, struct sss_domain_info); + if (dom == NULL) { + return NULL; + } + + dom->name = talloc_strdup(dom, name); + if (dom->name == NULL) { + talloc_free(dom); + return NULL; + } + + dom->parent = parent; + + return dom; +} -- 2.4.3