sssd/0040-tests-convert-all-unit-tests-to-cmocka-1.0-or-later.patch

2796 lines
118 KiB
Diff

From 8d1ae1f350f5618f1d8f00211d6db6b025e52dd6 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek@redhat.com>
Date: Mon, 9 Mar 2015 21:48:11 +0100
Subject: [PATCH 40/99] tests: convert all unit tests to cmocka 1.0 or later
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
All tests now use the cmocka-1.0-compatible API.
Signed-off-by: Lukas Slebodnik <lslebodn@redhat.com>
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
---
src/tests/cmocka/sbus_internal_tests.c | 22 ++--
src/tests/cmocka/sss_nss_idmap-tests.c | 8 +-
src/tests/cmocka/test_ad_access_filter.c | 86 ++++++-------
src/tests/cmocka/test_ad_common.c | 22 ++--
src/tests/cmocka/test_ad_gpo.c | 58 ++++-----
src/tests/cmocka/test_authtok.c | 29 +++--
src/tests/cmocka/test_be_ptask.c | 12 +-
src/tests/cmocka/test_child_common.c | 22 ++--
src/tests/cmocka/test_copy_ccache.c | 14 ++-
src/tests/cmocka/test_copy_keytab.c | 22 ++--
src/tests/cmocka/test_dp_opts.c | 40 ++++---
src/tests/cmocka/test_dyndns.c | 45 ++++---
src/tests/cmocka/test_find_uid.c | 10 +-
src/tests/cmocka/test_fo_srv.c | 22 ++--
src/tests/cmocka/test_fqnames.c | 80 +++++++------
src/tests/cmocka/test_ifp.c | 38 +++---
src/tests/cmocka/test_io.c | 32 ++---
src/tests/cmocka/test_ipa_idmap.c | 16 +--
src/tests/cmocka/test_negcache.c | 39 +++---
src/tests/cmocka/test_nested_groups.c | 16 +--
src/tests/cmocka/test_nss_srv.c | 160 ++++++++++++++-----------
src/tests/cmocka/test_resolv_fake.c | 16 +--
src/tests/cmocka/test_responder_common.c | 34 +++---
src/tests/cmocka/test_sdap.c | 76 ++++++------
src/tests/cmocka/test_search_bases.c | 14 +--
src/tests/cmocka/test_sss_idmap.c | 67 ++++++-----
src/tests/cmocka/test_sss_sifp.c | 199 ++++++++++++++++---------------
src/tests/cmocka/test_sysdb_views.c | 30 ++---
src/tests/cmocka/test_utils.c | 104 +++++++++-------
src/tests/cwrap/test_become_user.c | 8 +-
src/tests/cwrap/test_responder_common.c | 22 ++--
src/tests/cwrap/test_server.c | 10 +-
src/tests/cwrap/test_usertools.c | 10 +-
33 files changed, 743 insertions(+), 640 deletions(-)
diff --git a/src/tests/cmocka/sbus_internal_tests.c b/src/tests/cmocka/sbus_internal_tests.c
index a79f54d266375036915c8a2ff95378a379ee4448..db5738caa3c40d8d6a950a227d8c6c403530654a 100644
--- a/src/tests/cmocka/sbus_internal_tests.c
+++ b/src/tests/cmocka/sbus_internal_tests.c
@@ -114,7 +114,7 @@ int sss_dbus_conn_send(DBusConnection *dbus_conn,
return EOK;
}
-void sbus_get_id_test_setup(void **state)
+int sbus_get_id_test_setup(void **state)
{
struct sbus_get_id_ctx *test_ctx;
int ret;
@@ -133,6 +133,7 @@ void sbus_get_id_test_setup(void **state)
*state = test_ctx;
global_test_ctx = test_ctx;
+ return 0;
}
void sbus_int_test_get_uid_done(struct tevent_req *req)
@@ -218,11 +219,12 @@ void sbus_int_test_get_uid_no_sender(void **state)
assert_int_equal(ret, EOK);
}
-void sbus_get_id_test_teardown(void **state)
+int sbus_get_id_test_teardown(void **state)
{
struct sbus_get_id_ctx *test_ctx = talloc_get_type(*state,
struct sbus_get_id_ctx);
talloc_free(test_ctx);
+ return 0;
}
int main(int argc, const char *argv[])
@@ -235,13 +237,13 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(sbus_int_test_get_uid,
- sbus_get_id_test_setup,
- sbus_get_id_test_teardown),
- unit_test_setup_teardown(sbus_int_test_get_uid_no_sender,
- sbus_get_id_test_setup,
- sbus_get_id_test_teardown),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(sbus_int_test_get_uid,
+ sbus_get_id_test_setup,
+ sbus_get_id_test_teardown),
+ cmocka_unit_test_setup_teardown(sbus_int_test_get_uid_no_sender,
+ sbus_get_id_test_setup,
+ sbus_get_id_test_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -261,5 +263,5 @@ int main(int argc, const char *argv[])
DEBUG_CLI_INIT(debug_level);
tests_set_cwd();
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/sss_nss_idmap-tests.c b/src/tests/cmocka/sss_nss_idmap-tests.c
index 4141a32797734ae1ee17c9c39c522f0315fdf2ab..4ba8f2f9265389d63983e44fe14f026c9a7b8d50 100644
--- a/src/tests/cmocka/sss_nss_idmap-tests.c
+++ b/src/tests/cmocka/sss_nss_idmap-tests.c
@@ -137,10 +137,10 @@ void test_getorigbyname(void **state)
int main(int argc, const char *argv[])
{
- const UnitTest tests[] = {
- unit_test(test_getsidbyname),
- unit_test(test_getorigbyname),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_getsidbyname),
+ cmocka_unit_test(test_getorigbyname),
};
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_ad_access_filter.c b/src/tests/cmocka/test_ad_access_filter.c
index 7654e8498b4d5e346598964e4725f55410149585..eebc46b710481a81e44fd589e4d4a339704ec1dd 100644
--- a/src/tests/cmocka/test_ad_access_filter.c
+++ b/src/tests/cmocka/test_ad_access_filter.c
@@ -42,7 +42,7 @@ struct ad_access_test_ctx {
static struct ad_access_test_ctx *test_ctx;
-void ad_access_filter_test_setup(void **state)
+int ad_access_filter_test_setup(void **state)
{
assert_true(leak_check_setup());
test_ctx = talloc_zero(global_talloc_context,
@@ -54,12 +54,14 @@ void ad_access_filter_test_setup(void **state)
test_ctx->dom->name = talloc_strdup(test_ctx->dom, DOM_NAME);
assert_non_null(test_ctx->dom->name);
+ return 0;
}
-void ad_access_filter_test_teardown(void **state)
+int ad_access_filter_test_teardown(void **state)
{
talloc_free(test_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
struct filter_parse_result {
@@ -153,14 +155,16 @@ void test_filter_no_match(void **state)
}
-void parse_test_setup(void **state)
+int parse_test_setup(void **state)
{
assert_true(leak_check_setup());
+ return 0;
}
-void parse_test_teardown(void **state)
+int parse_test_teardown(void **state)
{
assert_true(leak_check_teardown());
+ return 0;
}
struct parse_result {
@@ -295,42 +299,42 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_parse_plain,
- parse_test_setup,
- parse_test_teardown),
-
- unit_test_setup_teardown(test_parse_dom_without_kw,
- parse_test_setup,
- parse_test_teardown),
-
- unit_test_setup_teardown(test_parse_dom_kw,
- parse_test_setup,
- parse_test_teardown),
-
- unit_test_setup_teardown(test_parse_forest_kw,
- parse_test_setup,
- parse_test_teardown),
-
- unit_test_setup_teardown(test_parse_malformed,
- parse_test_setup,
- parse_test_teardown),
-
- unit_test_setup_teardown(test_no_filter,
- ad_access_filter_test_setup,
- ad_access_filter_test_teardown),
-
- unit_test_setup_teardown(test_single_filter,
- ad_access_filter_test_setup,
- ad_access_filter_test_teardown),
-
- unit_test_setup_teardown(test_filter_order,
- ad_access_filter_test_setup,
- ad_access_filter_test_teardown),
-
- unit_test_setup_teardown(test_filter_no_match,
- ad_access_filter_test_setup,
- ad_access_filter_test_teardown),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_parse_plain,
+ parse_test_setup,
+ parse_test_teardown),
+
+ cmocka_unit_test_setup_teardown(test_parse_dom_without_kw,
+ parse_test_setup,
+ parse_test_teardown),
+
+ cmocka_unit_test_setup_teardown(test_parse_dom_kw,
+ parse_test_setup,
+ parse_test_teardown),
+
+ cmocka_unit_test_setup_teardown(test_parse_forest_kw,
+ parse_test_setup,
+ parse_test_teardown),
+
+ cmocka_unit_test_setup_teardown(test_parse_malformed,
+ parse_test_setup,
+ parse_test_teardown),
+
+ cmocka_unit_test_setup_teardown(test_no_filter,
+ ad_access_filter_test_setup,
+ ad_access_filter_test_teardown),
+
+ cmocka_unit_test_setup_teardown(test_single_filter,
+ ad_access_filter_test_setup,
+ ad_access_filter_test_teardown),
+
+ cmocka_unit_test_setup_teardown(test_filter_order,
+ ad_access_filter_test_setup,
+ ad_access_filter_test_teardown),
+
+ cmocka_unit_test_setup_teardown(test_filter_no_match,
+ ad_access_filter_test_setup,
+ ad_access_filter_test_teardown),
};
@@ -353,5 +357,5 @@ int main(int argc, const char *argv[])
tests_set_cwd();
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_ad_common.c b/src/tests/cmocka/test_ad_common.c
index c4b6bd0f21827424291176abf520008d2d9488de..19a4d395ba3fc4eae6601b3ad7056c41384a5c4f 100644
--- a/src/tests/cmocka/test_ad_common.c
+++ b/src/tests/cmocka/test_ad_common.c
@@ -47,7 +47,7 @@ struct ad_common_test_ctx {
struct sss_domain_info *subdom;
};
-static void
+static int
ad_common_test_setup(void **state)
{
struct ad_common_test_ctx *test_ctx;
@@ -111,9 +111,10 @@ ad_common_test_setup(void **state)
check_leaks_push(test_ctx);
*state = test_ctx;
+ return 0;
}
-static void
+static int
ad_common_test_teardown(void **state)
{
struct ad_common_test_ctx *test_ctx = talloc_get_type(*state,
@@ -124,6 +125,7 @@ ad_common_test_teardown(void **state)
talloc_free(test_ctx);
assert_true(check_leaks_pop(global_talloc_context) == true);
assert_true(leak_check_teardown());
+ return 0;
}
errno_t
@@ -210,13 +212,13 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_ldap_conn_list,
- ad_common_test_setup,
- ad_common_test_teardown),
- unit_test_setup_teardown(test_conn_list,
- ad_common_test_setup,
- ad_common_test_teardown),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_ldap_conn_list,
+ ad_common_test_setup,
+ ad_common_test_teardown),
+ cmocka_unit_test_setup_teardown(test_conn_list,
+ ad_common_test_setup,
+ ad_common_test_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -238,5 +240,5 @@ int main(int argc, const char *argv[])
tests_set_cwd();
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_ad_gpo.c b/src/tests/cmocka/test_ad_gpo.c
index 4753c95d32651ab13a107a945769a5fbc8e38b7d..4dadcf1b2988e43ec2ad05ad1aedd630c2aa9c18 100644
--- a/src/tests/cmocka/test_ad_gpo.c
+++ b/src/tests/cmocka/test_ad_gpo.c
@@ -40,7 +40,7 @@ struct ad_gpo_test_ctx {
static struct ad_gpo_test_ctx *test_ctx;
-void ad_gpo_test_setup(void **state)
+static int ad_gpo_test_setup(void **state)
{
assert_true(leak_check_setup());
test_ctx = talloc_zero(global_talloc_context,
@@ -49,12 +49,14 @@ void ad_gpo_test_setup(void **state)
test_ctx->ldb_ctx = ldb_init(test_ctx, NULL);
assert_non_null(test_ctx->ldb_ctx);
+ return 0;
}
-void ad_gpo_test_teardown(void **state)
+static int ad_gpo_test_teardown(void **state)
{
talloc_free(test_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
struct som_list_result {
@@ -337,31 +339,31 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_populate_som_list_plain,
- ad_gpo_test_setup,
- ad_gpo_test_teardown),
- unit_test_setup_teardown(test_populate_som_list_malformed,
- ad_gpo_test_setup,
- ad_gpo_test_teardown),
- unit_test_setup_teardown(test_populate_gplink_list_plain,
- ad_gpo_test_setup,
- ad_gpo_test_teardown),
- unit_test_setup_teardown(test_populate_gplink_list_with_ignored,
- ad_gpo_test_setup,
- ad_gpo_test_teardown),
- unit_test_setup_teardown(test_populate_gplink_list_with_allow_enforced,
- ad_gpo_test_setup,
- ad_gpo_test_teardown),
- unit_test_setup_teardown(test_populate_gplink_list_malformed,
- ad_gpo_test_setup,
- ad_gpo_test_teardown),
- unit_test_setup_teardown(test_ad_gpo_ace_includes_client_sid_true,
- ad_gpo_test_setup,
- ad_gpo_test_teardown),
- unit_test_setup_teardown(test_ad_gpo_ace_includes_client_sid_false,
- ad_gpo_test_setup,
- ad_gpo_test_teardown),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_populate_som_list_plain,
+ ad_gpo_test_setup,
+ ad_gpo_test_teardown),
+ cmocka_unit_test_setup_teardown(test_populate_som_list_malformed,
+ ad_gpo_test_setup,
+ ad_gpo_test_teardown),
+ cmocka_unit_test_setup_teardown(test_populate_gplink_list_plain,
+ ad_gpo_test_setup,
+ ad_gpo_test_teardown),
+ cmocka_unit_test_setup_teardown(test_populate_gplink_list_with_ignored,
+ ad_gpo_test_setup,
+ ad_gpo_test_teardown),
+ cmocka_unit_test_setup_teardown(test_populate_gplink_list_with_allow_enforced,
+ ad_gpo_test_setup,
+ ad_gpo_test_teardown),
+ cmocka_unit_test_setup_teardown(test_populate_gplink_list_malformed,
+ ad_gpo_test_setup,
+ ad_gpo_test_teardown),
+ cmocka_unit_test_setup_teardown(test_ad_gpo_ace_includes_client_sid_true,
+ ad_gpo_test_setup,
+ ad_gpo_test_teardown),
+ cmocka_unit_test_setup_teardown(test_ad_gpo_ace_includes_client_sid_false,
+ ad_gpo_test_setup,
+ ad_gpo_test_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -383,5 +385,5 @@ int main(int argc, const char *argv[])
tests_set_cwd();
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_authtok.c b/src/tests/cmocka/test_authtok.c
index 50205cc33e9b64cdf4537c6adbe54370b1f3de3b..e37e92f68373d564f53b1267f078ea89c31ae051 100644
--- a/src/tests/cmocka/test_authtok.c
+++ b/src/tests/cmocka/test_authtok.c
@@ -35,7 +35,7 @@ struct test_state {
struct sss_auth_token *authtoken;
};
-static void setup(void **state)
+static int setup(void **state)
{
struct test_state *ts = NULL;
@@ -46,12 +46,14 @@ static void setup(void **state)
assert_non_null(ts->authtoken);
*state = (void *)ts;
+ return 0;
}
-static void teardown(void **state)
+static int teardown(void **state)
{
struct test_state *ts = talloc_get_type_abort(*state, struct test_state);
talloc_free(ts);
+ return 0;
}
static void test_sss_authtok_new(void **state)
@@ -289,15 +291,20 @@ static void test_sss_authtok_copy(void **state)
int main(void)
{
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_sss_authtok_new, setup, teardown),
- unit_test_setup_teardown(test_sss_authtok_password, setup, teardown),
- unit_test_setup_teardown(test_sss_authtok_ccfile, setup, teardown),
- unit_test_setup_teardown(test_sss_authtok_empty, setup, teardown),
- unit_test_setup_teardown(test_sss_authtok_wipe_password, setup,
- teardown),
- unit_test_setup_teardown(test_sss_authtok_copy, setup, teardown)
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_sss_authtok_new,
+ setup, teardown),
+ cmocka_unit_test_setup_teardown(test_sss_authtok_password,
+ setup, teardown),
+ cmocka_unit_test_setup_teardown(test_sss_authtok_ccfile,
+ setup, teardown),
+ cmocka_unit_test_setup_teardown(test_sss_authtok_empty,
+ setup, teardown),
+ cmocka_unit_test_setup_teardown(test_sss_authtok_wipe_password,
+ setup, teardown),
+ cmocka_unit_test_setup_teardown(test_sss_authtok_copy,
+ setup, teardown)
};
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_be_ptask.c b/src/tests/cmocka/test_be_ptask.c
index 205204214c758f4e95a10824db42e78dd29bc0fb..f4a120c0c6201a6a306004445445024684f713d1 100644
--- a/src/tests/cmocka/test_be_ptask.c
+++ b/src/tests/cmocka/test_be_ptask.c
@@ -34,7 +34,7 @@
#define PERIOD 1
#define new_test(test) \
- unit_test_setup_teardown(test_ ## test, test_setup, test_teardown)
+ cmocka_unit_test_setup_teardown(test_ ## test, test_setup, test_teardown)
struct test_ctx {
struct be_ctx *be_ctx;
@@ -265,7 +265,7 @@ errno_t test_be_ptask_sync_error(TALLOC_CTX *mem_ctx,
return ERR_INTERNAL;
}
-void test_setup(void **state)
+static int test_setup(void **state)
{
struct test_ctx *test_ctx = NULL;
@@ -282,12 +282,14 @@ void test_setup(void **state)
assert_non_null(test_ctx->be_ctx->ev);
*state = test_ctx;
+ return 0;
}
-void test_teardown(void **state)
+static int test_teardown(void **state)
{
talloc_zfree(*state);
assert_true(leak_check_teardown());
+ return 0;
}
void test_be_ptask_create_einval_be(void **state)
@@ -944,7 +946,7 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
+ const struct CMUnitTest tests[] = {
new_test(be_ptask_create_einval_be),
new_test(be_ptask_create_einval_period),
new_test(be_ptask_create_einval_send),
@@ -987,5 +989,5 @@ int main(int argc, const char *argv[])
DEBUG_CLI_INIT(debug_level);
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_child_common.c b/src/tests/cmocka/test_child_common.c
index 23e14ce49ff75c8c14320be687b456cfcad1982e..c8428cb764c800bd1c776bba606cfb8b3f33bef3 100644
--- a/src/tests/cmocka/test_child_common.c
+++ b/src/tests/cmocka/test_child_common.c
@@ -38,7 +38,7 @@ struct child_test_ctx {
struct sss_test_ctx *test_ctx;
};
-void child_test_setup(void **state)
+static int child_test_setup(void **state)
{
struct child_test_ctx *child_tctx;
errno_t ret;
@@ -63,15 +63,17 @@ void child_test_setup(void **state)
child_tctx->pipefd_to_child[1]);
*state = child_tctx;
+ return 0;
}
-void child_test_teardown(void **state)
+static int child_test_teardown(void **state)
{
struct child_test_ctx *child_tctx = talloc_get_type(*state,
struct child_test_ctx);
talloc_free(child_tctx);
check_leaks_pop(global_talloc_context);
+ return 0;
}
/* Just make sure the exec works. The child does nothing but exits */
@@ -165,13 +167,13 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_exec_child,
- child_test_setup,
- child_test_teardown),
- unit_test_setup_teardown(test_exec_child_extra_args,
- child_test_setup,
- child_test_teardown),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_exec_child,
+ child_test_setup,
+ child_test_teardown),
+ cmocka_unit_test_setup_teardown(test_exec_child_extra_args,
+ child_test_setup,
+ child_test_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -191,6 +193,6 @@ int main(int argc, const char *argv[])
DEBUG_CLI_INIT(debug_level);
- rv = run_tests(tests);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
return rv;
}
diff --git a/src/tests/cmocka/test_copy_ccache.c b/src/tests/cmocka/test_copy_ccache.c
index c7a5573b83b8faeb5c7447b48fa40ec8957e1aaf..711f8f0ab46cf37da89d6c24e4f23c398f3e0587 100644
--- a/src/tests/cmocka/test_copy_ccache.c
+++ b/src/tests/cmocka/test_copy_ccache.c
@@ -39,7 +39,7 @@ struct ccache_test_ctx {
krb5_principal server_principal;
};
-void setup_ccache(void **state)
+static int setup_ccache(void **state)
{
struct ccache_test_ctx *test_ctx;
krb5_error_code kerr;
@@ -131,9 +131,10 @@ void setup_ccache(void **state)
*state = test_ctx;
krb5_free_authdata(test_ctx->kctx, test_creds.authdata);
+ return 0;
}
-void teardown_ccache(void **state)
+static int teardown_ccache(void **state)
{
int ret;
struct ccache_test_ctx *test_ctx = talloc_get_type(*state,
@@ -150,6 +151,7 @@ void teardown_ccache(void **state)
assert_true(check_leaks_pop(test_ctx) == true);
talloc_free(test_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
void test_copy_ccache(void **state)
@@ -206,9 +208,9 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_copy_ccache,
- setup_ccache, teardown_ccache),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_copy_ccache,
+ setup_ccache, teardown_ccache),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -232,7 +234,7 @@ int main(int argc, const char *argv[])
* they might not after a failed run. Remove the old db to be sure */
tests_set_cwd();
- rv = run_tests(tests);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
return rv;
}
diff --git a/src/tests/cmocka/test_copy_keytab.c b/src/tests/cmocka/test_copy_keytab.c
index a9f2161a2b25e9cf67319399cc7c54487e687841..1999de3bf74772121b416f99d42d3734b5e1b72a 100644
--- a/src/tests/cmocka/test_copy_keytab.c
+++ b/src/tests/cmocka/test_copy_keytab.c
@@ -37,7 +37,7 @@ struct keytab_test_ctx {
krb5_principal principal;
};
-void setup_keytab(void **state)
+static int setup_keytab(void **state)
{
struct keytab_test_ctx *test_ctx;
krb5_error_code kerr;
@@ -98,9 +98,10 @@ void setup_keytab(void **state)
check_leaks_push(test_ctx);
*state = test_ctx;
+ return 0;
}
-void teardown_keytab(void **state)
+static int teardown_keytab(void **state)
{
int ret;
struct keytab_test_ctx *test_ctx = talloc_get_type(*state,
@@ -116,6 +117,7 @@ void teardown_keytab(void **state)
assert_true(check_leaks_pop(test_ctx) == true);
talloc_free(test_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
void test_copy_keytab(void **state)
@@ -292,13 +294,13 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_copy_keytab,
- setup_keytab, teardown_keytab),
- unit_test_setup_teardown(test_sss_krb5_kt_have_content,
- setup_keytab, teardown_keytab),
- unit_test_setup_teardown(test_copy_keytab_order,
- setup_keytab, teardown_keytab),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_copy_keytab,
+ setup_keytab, teardown_keytab),
+ cmocka_unit_test_setup_teardown(test_sss_krb5_kt_have_content,
+ setup_keytab, teardown_keytab),
+ cmocka_unit_test_setup_teardown(test_copy_keytab_order,
+ setup_keytab, teardown_keytab),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -322,7 +324,7 @@ int main(int argc, const char *argv[])
* they might not after a failed run. Remove the old db to be sure */
tests_set_cwd();
- rv = run_tests(tests);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
return rv;
}
diff --git a/src/tests/cmocka/test_dp_opts.c b/src/tests/cmocka/test_dp_opts.c
index 0f3052ab3c2add8286db6d5f065a8ca9391aae13..be7751a7a98116f3ef2bbf5704d8d3a3b6ef44fc 100644
--- a/src/tests/cmocka/test_dp_opts.c
+++ b/src/tests/cmocka/test_dp_opts.c
@@ -265,7 +265,7 @@ void opt_test_get(void **state)
assert_true(bo == false);
}
-void opt_test_getset_setup(void **state)
+static int opt_test_getset_setup(void **state)
{
int ret;
struct dp_option *opts;
@@ -276,12 +276,14 @@ void opt_test_getset_setup(void **state)
assert_defaults(opts);
*state = opts;
+ return 0;
}
-void opt_test_getset_teardown(void **state)
+static int opt_test_getset_teardown(void **state)
{
struct dp_option *opts = talloc_get_type(*state, struct dp_option);
talloc_free(opts);
+ return 0;
}
void opt_test_getset_string(void **state)
@@ -367,22 +369,22 @@ int main(int argc, const char *argv[])
_("Do not delete the test database after a test run"), NULL },
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(opt_test_getset_string,
- opt_test_getset_setup,
- opt_test_getset_teardown),
- unit_test_setup_teardown(opt_test_getset_int,
- opt_test_getset_setup,
- opt_test_getset_teardown),
- unit_test_setup_teardown(opt_test_getset_bool,
- opt_test_getset_setup,
- opt_test_getset_teardown),
- unit_test_setup_teardown(opt_test_getset_blob,
- opt_test_getset_setup,
- opt_test_getset_teardown),
- unit_test(opt_test_copy_default),
- unit_test(opt_test_copy_options),
- unit_test(opt_test_get)
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(opt_test_getset_string,
+ opt_test_getset_setup,
+ opt_test_getset_teardown),
+ cmocka_unit_test_setup_teardown(opt_test_getset_int,
+ opt_test_getset_setup,
+ opt_test_getset_teardown),
+ cmocka_unit_test_setup_teardown(opt_test_getset_bool,
+ opt_test_getset_setup,
+ opt_test_getset_teardown),
+ cmocka_unit_test_setup_teardown(opt_test_getset_blob,
+ opt_test_getset_setup,
+ opt_test_getset_teardown),
+ cmocka_unit_test(opt_test_copy_default),
+ cmocka_unit_test(opt_test_copy_options),
+ cmocka_unit_test(opt_test_get)
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -408,7 +410,7 @@ int main(int argc, const char *argv[])
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
test_dom_suite_setup(TESTS_PATH);
- ret = run_tests(tests);
+ ret = cmocka_run_group_tests(tests, NULL, NULL);
if (ret == 0 && !no_cleanup) {
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
}
diff --git a/src/tests/cmocka/test_dyndns.c b/src/tests/cmocka/test_dyndns.c
index 345c170f1e595c0a9c116eb7e8fa84a6bc95ef40..eaf106ec6224e36c446d42d2a09e16350a8c9b13 100644
--- a/src/tests/cmocka/test_dyndns.c
+++ b/src/tests/cmocka/test_dyndns.c
@@ -393,7 +393,7 @@ void dyndns_test_interval(void **state)
}
/* Testsuite setup and teardown */
-void dyndns_test_setup(void **state)
+static int dyndns_test_setup(void **state)
{
struct sss_test_conf_param params[] = {
{ "dyndns_update", "true" },
@@ -419,9 +419,10 @@ void dyndns_test_setup(void **state)
dyndns_test_ctx->be_ctx->cdb = dyndns_test_ctx->tctx->confdb;
dyndns_test_ctx->be_ctx->ev = dyndns_test_ctx->tctx->ev;
dyndns_test_ctx->be_ctx->conf_path = dyndns_test_ctx->tctx->conf_dom_path;
+ return 0;
}
-void dyndns_test_simple_setup(void **state)
+static int dyndns_test_simple_setup(void **state)
{
assert_true(leak_check_setup());
global_mock_context = talloc_new(global_talloc_context);
@@ -429,13 +430,15 @@ void dyndns_test_simple_setup(void **state)
dyndns_test_ctx = talloc_zero(global_talloc_context, struct dyndns_test_ctx);
assert_non_null(dyndns_test_ctx);
+ return 0;
}
-void dyndns_test_teardown(void **state)
+static int dyndns_test_teardown(void **state)
{
talloc_free(dyndns_test_ctx);
talloc_free(global_mock_context);
assert_true(leak_check_teardown());
+ return 0;
}
int main(int argc, const char *argv[])
@@ -452,24 +455,28 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
+ const struct CMUnitTest tests[] = {
/* Utility functions unit test */
- unit_test_setup_teardown(dyndns_test_get_ifaddr,
- dyndns_test_simple_setup,
- dyndns_test_teardown),
- unit_test_setup_teardown(dyndns_test_get_multi_ifaddr,
- dyndns_test_simple_setup,
- dyndns_test_teardown),
+ cmocka_unit_test_setup_teardown(dyndns_test_get_ifaddr,
+ dyndns_test_simple_setup,
+ dyndns_test_teardown),
+ cmocka_unit_test_setup_teardown(dyndns_test_get_multi_ifaddr,
+ dyndns_test_simple_setup,
+ dyndns_test_teardown),
/* Dynamic DNS update unit tests*/
- unit_test_setup_teardown(dyndns_test_ok,
- dyndns_test_setup, dyndns_test_teardown),
- unit_test_setup_teardown(dyndns_test_error,
- dyndns_test_setup, dyndns_test_teardown),
- unit_test_setup_teardown(dyndns_test_timeout,
- dyndns_test_setup, dyndns_test_teardown),
- unit_test_setup_teardown(dyndns_test_interval,
- dyndns_test_setup, dyndns_test_teardown),
+ cmocka_unit_test_setup_teardown(dyndns_test_ok,
+ dyndns_test_setup,
+ dyndns_test_teardown),
+ cmocka_unit_test_setup_teardown(dyndns_test_error,
+ dyndns_test_setup,
+ dyndns_test_teardown),
+ cmocka_unit_test_setup_teardown(dyndns_test_timeout,
+ dyndns_test_setup,
+ dyndns_test_teardown),
+ cmocka_unit_test_setup_teardown(dyndns_test_interval,
+ dyndns_test_setup,
+ dyndns_test_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -495,7 +502,7 @@ int main(int argc, const char *argv[])
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
test_dom_suite_setup(TESTS_PATH);
- rv = run_tests(tests);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
if (rv == 0 && !no_cleanup) {
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
}
diff --git a/src/tests/cmocka/test_find_uid.c b/src/tests/cmocka/test_find_uid.c
index dcc367962bbd7a9a16643c79f08c856cc8635f2f..63a426a16cfde2db8d3772d3167cd58124805ac0 100644
--- a/src/tests/cmocka/test_find_uid.c
+++ b/src/tests/cmocka/test_find_uid.c
@@ -95,11 +95,11 @@ void test_get_uid_table(void **state)
int main(void)
{
- const UnitTest tests[] = {
- unit_test(test_check_if_uid_is_active_success),
- unit_test(test_check_if_uid_is_active_fail),
- unit_test(test_get_uid_table)
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_check_if_uid_is_active_success),
+ cmocka_unit_test(test_check_if_uid_is_active_fail),
+ cmocka_unit_test(test_get_uid_table)
};
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_fo_srv.c b/src/tests/cmocka/test_fo_srv.c
index 3ee308bd5967f44abda1980e7bff8e0a5c00dde0..7a6321006d8383ed901fe9d5df3fddc514c53550 100644
--- a/src/tests/cmocka/test_fo_srv.c
+++ b/src/tests/cmocka/test_fo_srv.c
@@ -207,7 +207,7 @@ int test_fo_srv_data_cmp(void *ud1, void *ud2)
return strcasecmp((char*) ud1, (char*) ud2);
}
-void test_fo_srv_setup(void **state)
+static int test_fo_srv_setup(void **state)
{
struct test_fo_srv_ctx *test_ctx;
errno_t ret;
@@ -253,9 +253,10 @@ void test_fo_srv_setup(void **state)
assert_int_equal(ret, ERR_OK);
*state = test_ctx;
+ return 0;
}
-void test_fo_srv_teardown(void **state)
+static int test_fo_srv_teardown(void **state)
{
struct test_fo_srv_ctx *test_ctx =
talloc_get_type(*state, struct test_fo_srv_ctx);
@@ -263,6 +264,7 @@ void test_fo_srv_teardown(void **state)
talloc_free(test_ctx);
talloc_free(global_mock_context);
assert_true(leak_check_teardown());
+ return 0;
}
/* reply_list and dns_domain must be a talloc context so it can be used as
@@ -564,13 +566,13 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_fo_srv,
- test_fo_srv_setup,
- test_fo_srv_teardown),
- unit_test_setup_teardown(test_fo_srv_ttl_change,
- test_fo_srv_setup,
- test_fo_srv_teardown),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_fo_srv,
+ test_fo_srv_setup,
+ test_fo_srv_teardown),
+ cmocka_unit_test_setup_teardown(test_fo_srv_ttl_change,
+ test_fo_srv_setup,
+ test_fo_srv_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -594,6 +596,6 @@ int main(int argc, const char *argv[])
* they might not after a failed run. Remove the old db to be sure */
tests_set_cwd();
- rv = run_tests(tests);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
return rv;
}
diff --git a/src/tests/cmocka/test_fqnames.c b/src/tests/cmocka/test_fqnames.c
index b9b6230b9e2c86dafae159630d5202e46992f5f3..0326d5a645bad0396d8b20f635e6ee6b3e4b5587 100644
--- a/src/tests/cmocka/test_fqnames.c
+++ b/src/tests/cmocka/test_fqnames.c
@@ -69,7 +69,7 @@ struct fqdn_test_ctx {
struct sss_names_ctx *nctx;
};
-void fqdn_test_setup(void **state)
+static int fqdn_test_setup(void **state)
{
struct fqdn_test_ctx *test_ctx;
@@ -83,21 +83,23 @@ void fqdn_test_setup(void **state)
check_leaks_push(test_ctx);
*state = test_ctx;
+ return 0;
}
-void fqdn_test_teardown(void **state)
+static int fqdn_test_teardown(void **state)
{
struct fqdn_test_ctx *test_ctx = talloc_get_type(*state,
struct fqdn_test_ctx);
if (test_ctx == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "Type mismatch\n");
- return;
+ return 1;
}
assert_true(check_leaks_pop(test_ctx) == true);
talloc_free(test_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
void test_default(void **state)
@@ -270,7 +272,7 @@ void parse_name_check(struct parse_name_test_ctx *test_ctx,
assert_true(check_leaks_pop(test_ctx) == true);
}
-void parse_name_test_setup(void **state)
+static int parse_name_test_setup(void **state)
{
struct parse_name_test_ctx *test_ctx;
struct sss_domain_info *dom;
@@ -312,9 +314,10 @@ void parse_name_test_setup(void **state)
check_leaks_push(test_ctx);
*state = test_ctx;
+ return 0;
}
-void parse_name_test_teardown(void **state)
+static int parse_name_test_teardown(void **state)
{
struct parse_name_test_ctx *test_ctx = talloc_get_type(*state,
struct parse_name_test_ctx);
@@ -322,6 +325,7 @@ void parse_name_test_teardown(void **state)
assert_true(check_leaks_pop(test_ctx) == true);
talloc_free(test_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
void sss_parse_name_check(struct parse_name_test_ctx *test_ctx,
@@ -513,40 +517,40 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_default,
- fqdn_test_setup, fqdn_test_teardown),
- unit_test_setup_teardown(test_all,
- fqdn_test_setup, fqdn_test_teardown),
- unit_test_setup_teardown(test_flat,
- fqdn_test_setup, fqdn_test_teardown),
- unit_test_setup_teardown(test_flat_fallback,
- fqdn_test_setup, fqdn_test_teardown),
- unit_test_setup_teardown(test_init_nouser,
- fqdn_test_setup, fqdn_test_teardown),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_default,
+ fqdn_test_setup, fqdn_test_teardown),
+ cmocka_unit_test_setup_teardown(test_all,
+ fqdn_test_setup, fqdn_test_teardown),
+ cmocka_unit_test_setup_teardown(test_flat,
+ fqdn_test_setup, fqdn_test_teardown),
+ cmocka_unit_test_setup_teardown(test_flat_fallback,
+ fqdn_test_setup, fqdn_test_teardown),
+ cmocka_unit_test_setup_teardown(test_init_nouser,
+ fqdn_test_setup, fqdn_test_teardown),
- unit_test_setup_teardown(parse_name_plain,
- parse_name_test_setup,
- parse_name_test_teardown),
- unit_test_setup_teardown(parse_name_fqdn,
- parse_name_test_setup,
- parse_name_test_teardown),
- unit_test_setup_teardown(parse_name_sub,
- parse_name_test_setup,
- parse_name_test_teardown),
- unit_test_setup_teardown(parse_name_flat,
- parse_name_test_setup,
- parse_name_test_teardown),
- unit_test_setup_teardown(parse_name_default,
- parse_name_test_setup,
- parse_name_test_teardown),
- unit_test_setup_teardown(sss_parse_name_fail,
- parse_name_test_setup,
- parse_name_test_teardown),
+ cmocka_unit_test_setup_teardown(parse_name_plain,
+ parse_name_test_setup,
+ parse_name_test_teardown),
+ cmocka_unit_test_setup_teardown(parse_name_fqdn,
+ parse_name_test_setup,
+ parse_name_test_teardown),
+ cmocka_unit_test_setup_teardown(parse_name_sub,
+ parse_name_test_setup,
+ parse_name_test_teardown),
+ cmocka_unit_test_setup_teardown(parse_name_flat,
+ parse_name_test_setup,
+ parse_name_test_teardown),
+ cmocka_unit_test_setup_teardown(parse_name_default,
+ parse_name_test_setup,
+ parse_name_test_teardown),
+ cmocka_unit_test_setup_teardown(sss_parse_name_fail,
+ parse_name_test_setup,
+ parse_name_test_teardown),
- unit_test_setup_teardown(test_sss_get_domain_name,
- parse_name_test_setup,
- parse_name_test_teardown),
+ cmocka_unit_test_setup_teardown(test_sss_get_domain_name,
+ parse_name_test_setup,
+ parse_name_test_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -570,5 +574,5 @@ int main(int argc, const char *argv[])
* they might not after a failed run. Remove the old db to be sure */
tests_set_cwd();
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_ifp.c b/src/tests/cmocka/test_ifp.c
index 5793f91911c1e15c2c241aaa51ffcd4196daea63..b9f5ba0d31f75fb61ce92ac004888fb2db1ad450 100644
--- a/src/tests/cmocka/test_ifp.c
+++ b/src/tests/cmocka/test_ifp.c
@@ -426,7 +426,7 @@ struct ifp_test_req_ctx {
struct ifp_ctx *ifp_ctx;
};
-void ifp_test_req_setup(void **state)
+static int ifp_test_req_setup(void **state)
{
struct ifp_test_req_ctx *test_ctx;
errno_t ret;
@@ -447,9 +447,10 @@ void ifp_test_req_setup(void **state)
check_leaks_push(test_ctx);
*state = test_ctx;
+ return 0;
}
-void ifp_test_req_teardown(void **state)
+static int ifp_test_req_teardown(void **state)
{
struct ifp_test_req_ctx *test_ctx = talloc_get_type_abort(*state,
struct ifp_test_req_ctx);
@@ -460,6 +461,7 @@ void ifp_test_req_teardown(void **state)
talloc_free(test_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
void test_reply_path(void **state)
@@ -498,20 +500,22 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test(ifp_test_req_create),
- unit_test(ifp_test_req_wrong_uid),
- unit_test(test_path_prefix),
- unit_test_setup_teardown(test_el_to_dict,
- ifp_test_req_setup, ifp_test_req_teardown),
- unit_test(test_attr_acl),
- unit_test(test_attr_acl_ex),
- 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),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(ifp_test_req_create),
+ cmocka_unit_test(ifp_test_req_wrong_uid),
+ cmocka_unit_test_setup_teardown(test_el_to_dict,
+ ifp_test_req_setup,
+ ifp_test_req_teardown),
+ cmocka_unit_test(test_attr_acl),
+ cmocka_unit_test(test_attr_acl_ex),
+ cmocka_unit_test(test_attr_allowed),
+ cmocka_unit_test(test_path_escape_unescape),
+ cmocka_unit_test_setup_teardown(test_reply_path,
+ ifp_test_req_setup,
+ ifp_test_req_teardown),
+ cmocka_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. */
@@ -535,5 +539,5 @@ int main(int argc, const char *argv[])
* they might not after a failed run. Remove the old db to be sure */
tests_set_cwd();
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_io.c b/src/tests/cmocka/test_io.c
index 2f95388570f4189fc2ca70e6a55be688f7921467..9bdb7107e06aa350b5de473a132137befb6de3ea 100644
--- a/src/tests/cmocka/test_io.c
+++ b/src/tests/cmocka/test_io.c
@@ -67,7 +67,7 @@ static char *get_random_filepath(const char *template)
return path;
}
-void test_file_setup(void **state)
+static int test_file_setup(void **state)
{
int ret;
char *file_path;
@@ -83,9 +83,10 @@ void test_file_setup(void **state)
assert_int_equal(ret, ENOENT);
*state = file_path;
+ return 0;
}
-void test_file_teardown(void **state)
+static int test_file_teardown(void **state)
{
int ret;
char *file_path = (char *)*state;
@@ -96,6 +97,7 @@ void test_file_teardown(void **state)
ret = rmdir(TESTS_PATH);
assert_int_equal(ret, EOK);
+ return 0;
}
struct dir_state {
@@ -107,7 +109,7 @@ struct dir_state {
char *filename;
};
-void test_dir_setup(void **state)
+static int test_dir_setup(void **state)
{
struct dir_state *data;
int ret;
@@ -139,9 +141,10 @@ void test_dir_setup(void **state)
assert_int_equal(ret, ENOENT);
*state = data;
+ return 0;
}
-void test_dir_teardown(void **state)
+static int test_dir_teardown(void **state)
{
int ret;
struct dir_state *data = (struct dir_state *) *state;
@@ -157,6 +160,7 @@ void test_dir_teardown(void **state)
assert_int_equal(ret, EOK);
free(data);
+ return 0;
}
void test_sss_open_cloexec_success(void **state)
@@ -223,17 +227,17 @@ void test_sss_openat_cloexec_fail(void **state)
int main(void)
{
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_sss_open_cloexec_success,
- test_file_setup, test_file_teardown),
- unit_test_setup_teardown(test_sss_open_cloexec_fail,
- test_file_setup, test_file_teardown),
- unit_test_setup_teardown(test_sss_openat_cloexec_success,
- test_dir_setup, test_dir_teardown),
- unit_test_setup_teardown(test_sss_openat_cloexec_fail,
- test_dir_setup, test_dir_teardown)
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_sss_open_cloexec_success,
+ test_file_setup, test_file_teardown),
+ cmocka_unit_test_setup_teardown(test_sss_open_cloexec_fail,
+ test_file_setup, test_file_teardown),
+ cmocka_unit_test_setup_teardown(test_sss_openat_cloexec_success,
+ test_dir_setup, test_dir_teardown),
+ cmocka_unit_test_setup_teardown(test_sss_openat_cloexec_fail,
+ test_dir_setup, test_dir_teardown)
};
tests_set_cwd();
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_ipa_idmap.c b/src/tests/cmocka/test_ipa_idmap.c
index 8ad56298757c6b8fd2e857e1d92d0eb767b9e8c9..fba41ae2fa33a2645ab07a90f3b608655756cafa 100644
--- a/src/tests/cmocka/test_ipa_idmap.c
+++ b/src/tests/cmocka/test_ipa_idmap.c
@@ -142,7 +142,7 @@ static struct range_info **get_range_list(TALLOC_CTX *mem_ctx)
return range_list;
}
-void setup_idmap_ctx(void **state)
+static int setup_idmap_ctx(void **state)
{
int ret;
struct test_ctx *test_ctx;
@@ -177,9 +177,10 @@ void setup_idmap_ctx(void **state)
check_leaks_push(test_ctx);
*state = test_ctx;
+ return 0;
}
-void teardown_idmap_ctx(void **state)
+static int teardown_idmap_ctx(void **state)
{
struct test_ctx *test_ctx = talloc_get_type(*state, struct test_ctx);
@@ -189,6 +190,7 @@ void teardown_idmap_ctx(void **state)
talloc_free(test_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
void test_ipa_idmap_get_ranges_from_sysdb(void **state)
@@ -220,10 +222,10 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test(test_get_idmap_data_from_range),
- unit_test_setup_teardown(test_ipa_idmap_get_ranges_from_sysdb,
- setup_idmap_ctx, teardown_idmap_ctx),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_get_idmap_data_from_range),
+ cmocka_unit_test_setup_teardown(test_ipa_idmap_get_ranges_from_sysdb,
+ setup_idmap_ctx, teardown_idmap_ctx),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -245,5 +247,5 @@ int main(int argc, const char *argv[])
tests_set_cwd();
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_negcache.c b/src/tests/cmocka/test_negcache.c
index b6bcb6b087c5c8b4d5f7699feaca3911e2fdc5d8..5ab5bb3c359cf2ecaf2be6c7c9f91600fd03ede4 100644
--- a/src/tests/cmocka/test_negcache.c
+++ b/src/tests/cmocka/test_negcache.c
@@ -132,7 +132,7 @@ struct test_state {
struct resp_ctx *rctx;
};
-static void setup(void **state)
+static int setup(void **state)
{
int ret;
struct test_state *ts;
@@ -145,12 +145,14 @@ static void setup(void **state)
assert_non_null(ts->ctx);
*state = (void *)ts;
+ return 0;
}
-static void teardown(void **state)
+static int teardown(void **state)
{
struct test_state *ts = talloc_get_type_abort(*state, struct test_state);
talloc_free(ts);
+ return 0;
}
static void test_sss_ncache_init(void **state)
@@ -621,28 +623,29 @@ static void test_sss_ncache_prepopulate(void **state)
int main(void)
{
int rv;
- const UnitTest tests[] = {
- unit_test(test_sss_ncache_init),
- unit_test_setup_teardown(test_sss_ncache_uid, setup, teardown),
- unit_test_setup_teardown(test_sss_ncache_gid, setup, teardown),
- unit_test_setup_teardown(test_sss_ncache_sid, setup, teardown),
- unit_test_setup_teardown(test_sss_ncache_user, setup, teardown),
- unit_test_setup_teardown(test_sss_ncache_group, setup, teardown),
- unit_test_setup_teardown(test_sss_ncache_netgr, setup, teardown),
- unit_test_setup_teardown(test_sss_ncache_service_name, setup,
- teardown),
- unit_test_setup_teardown(test_sss_ncache_service_port, setup,
- teardown),
- unit_test_setup_teardown(test_sss_ncache_reset_permanent, setup,
- teardown),
- unit_test_setup_teardown(test_sss_ncache_prepopulate, setup, teardown)
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_sss_ncache_init),
+ cmocka_unit_test_setup_teardown(test_sss_ncache_uid, setup, teardown),
+ cmocka_unit_test_setup_teardown(test_sss_ncache_gid, setup, teardown),
+ cmocka_unit_test_setup_teardown(test_sss_ncache_sid, setup, teardown),
+ cmocka_unit_test_setup_teardown(test_sss_ncache_user, setup, teardown),
+ cmocka_unit_test_setup_teardown(test_sss_ncache_group, setup, teardown),
+ cmocka_unit_test_setup_teardown(test_sss_ncache_netgr, setup, teardown),
+ cmocka_unit_test_setup_teardown(test_sss_ncache_service_name, setup,
+ teardown),
+ cmocka_unit_test_setup_teardown(test_sss_ncache_service_port,
+ setup, teardown),
+ cmocka_unit_test_setup_teardown(test_sss_ncache_reset_permanent, setup,
+ teardown),
+ cmocka_unit_test_setup_teardown(test_sss_ncache_prepopulate,
+ setup, teardown)
};
tests_set_cwd();
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
test_dom_suite_setup(TESTS_PATH);
- rv = run_tests(tests);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
if (rv == 0) {
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
}
diff --git a/src/tests/cmocka/test_nested_groups.c b/src/tests/cmocka/test_nested_groups.c
index b64d67d3cc802d9bb1e585a63da04b68ecc460c4..f2861847b2011e2a8c4941bd296f1eb567860e75 100644
--- a/src/tests/cmocka/test_nested_groups.c
+++ b/src/tests/cmocka/test_nested_groups.c
@@ -38,9 +38,9 @@
#define TEST_ID_PROVIDER "ldap"
#define new_test(test) \
- unit_test_setup_teardown(nested_groups_test_ ## test, \
- nested_groups_test_setup, \
- nested_groups_test_teardown)
+ cmocka_unit_test_setup_teardown(nested_groups_test_ ## test, \
+ nested_groups_test_setup, \
+ nested_groups_test_teardown)
/* put users and groups under the same container so we can easily run the
* same tests cases for several search base scenarios */
@@ -393,7 +393,7 @@ static void nested_groups_test_one_group_dup_group_members(void **state)
expected, N_ELEMENTS(expected));
}
-void nested_groups_test_setup(void **state)
+static int nested_groups_test_setup(void **state)
{
errno_t ret;
struct nested_groups_test_ctx *test_ctx = NULL;
@@ -439,11 +439,13 @@ void nested_groups_test_setup(void **state)
ret = sdap_idmap_init(test_ctx, test_ctx->sdap_id_ctx, &test_ctx->idmap_ctx);
assert_int_equal(ret, EOK);
test_ctx->sdap_opts->idmap_ctx = test_ctx->idmap_ctx;
+ return 0;
}
-void nested_groups_test_teardown(void **state)
+static int nested_groups_test_teardown(void **state)
{
talloc_zfree(*state);
+ return 0;
}
int main(int argc, const char *argv[])
@@ -460,7 +462,7 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
+ const struct CMUnitTest tests[] = {
new_test(one_group_no_members),
new_test(one_group_unique_members),
new_test(one_group_dup_users),
@@ -491,7 +493,7 @@ int main(int argc, const char *argv[])
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
test_dom_suite_setup(TESTS_PATH);
- rv = run_tests(tests);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
if (rv == 0 && !no_cleanup) {
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
}
diff --git a/src/tests/cmocka/test_nss_srv.c b/src/tests/cmocka/test_nss_srv.c
index ba84fccf718c1a3f4a8ff20a54d8e82c2aa58a1e..2406adfe20e7ac30662f338e097fbb350371384d 100644
--- a/src/tests/cmocka/test_nss_srv.c
+++ b/src/tests/cmocka/test_nss_srv.c
@@ -2072,7 +2072,7 @@ void test_nss_getorigbyname_multi_value_attrs(void **state)
assert_int_equal(ret, EOK);
}
-void nss_test_setup(void **state)
+static int nss_test_setup(void **state)
{
struct sss_test_conf_param params[] = {
{ "enumerate", "false" },
@@ -2080,9 +2080,10 @@ void nss_test_setup(void **state)
};
test_nss_setup(params, state);
+ return 0;
}
-void nss_fqdn_test_setup(void **state)
+static int nss_fqdn_test_setup(void **state)
{
struct sss_test_conf_param params[] = {
{ "enumerate", "false" },
@@ -2091,9 +2092,10 @@ void nss_fqdn_test_setup(void **state)
};
test_nss_setup(params, state);
+ return 0;
}
-void nss_test_setup_extra_attr(void **state)
+static int nss_test_setup_extra_attr(void **state)
{
struct sss_test_conf_param params[] = {
{ "enumerate", "false" },
@@ -2103,9 +2105,10 @@ void nss_test_setup_extra_attr(void **state)
test_nss_setup(params, state);
nss_test_ctx->nctx->extra_attributes = global_extra_attrs;
+ return 0;
}
-void nss_subdom_test_setup(void **state)
+static int nss_subdom_test_setup(void **state)
{
const char *const testdom[4] = { TEST_SUBDOM_NAME, "TEST.SUB", "test", "S-3" };
struct sss_domain_info *subdomain;
@@ -2127,9 +2130,10 @@ void nss_subdom_test_setup(void **state)
assert_int_equal(ret, EOK);
nss_test_ctx->subdom = subdomain;
+ return 0;
}
-void nss_fqdn_fancy_test_setup(void **state)
+static int nss_fqdn_fancy_test_setup(void **state)
{
struct sss_test_conf_param params[] = {
{ "enumerate", "false" },
@@ -2138,11 +2142,13 @@ void nss_fqdn_fancy_test_setup(void **state)
};
test_nss_setup(params, state);
+ return 0;
}
-void nss_test_teardown(void **state)
+static int nss_test_teardown(void **state)
{
talloc_free(nss_test_ctx);
+ return 0;
}
int main(int argc, const char *argv[])
@@ -2159,71 +2165,81 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_nss_getpwnam,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getpwuid,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getpwnam_neg,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getpwuid_neg,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getpwnam_search,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getpwuid_search,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getpwnam_update,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getpwuid_update,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getpwnam_fqdn,
- nss_fqdn_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getpwnam_fqdn_fancy,
- nss_fqdn_fancy_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getpwnam_space,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getpwnam_space_sub,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getpwnam_space_sub_query,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getgrnam_no_members,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getgrnam_members,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getgrnam_members_fqdn,
- nss_fqdn_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getgrnam_members_subdom,
- nss_subdom_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getgrnam_mix_dom,
- nss_subdom_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getgrnam_mix_dom_fqdn,
- nss_subdom_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getgrnam_mix_subdom,
- nss_subdom_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getgrnam_space,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getgrnam_space_sub,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_well_known_getnamebysid,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_well_known_getnamebysid_special,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_well_known_getnamebysid_non_existing,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_well_known_getidbysid_failure,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_well_known_getsidbyname,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_well_known_getsidbyname_nonexisting,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_well_known_getsidbyname_special,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getorigbyname,
- nss_test_setup, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getorigbyname_extra_attrs,
- nss_test_setup_extra_attr, nss_test_teardown),
- unit_test_setup_teardown(test_nss_getorigbyname_multi_value_attrs,
- nss_test_setup_extra_attr, nss_test_teardown),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_nss_getpwnam,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getpwuid,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getpwnam_neg,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getpwuid_neg,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getpwnam_search,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getpwuid_search,
+ nss_test_setup,
+ nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getpwnam_update,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getpwuid_update,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getpwnam_fqdn,
+ nss_fqdn_test_setup,
+ nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getpwnam_fqdn_fancy,
+ nss_fqdn_fancy_test_setup,
+ nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getpwnam_space,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getpwnam_space_sub,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getpwnam_space_sub_query,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getgrnam_no_members,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getgrnam_members,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getgrnam_members_fqdn,
+ nss_fqdn_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getgrnam_members_subdom,
+ nss_subdom_test_setup,
+ nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getgrnam_mix_dom,
+ nss_subdom_test_setup,
+ nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getgrnam_mix_dom_fqdn,
+ nss_subdom_test_setup,
+ nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getgrnam_mix_subdom,
+ nss_subdom_test_setup,
+ nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getgrnam_space,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getgrnam_space_sub,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_well_known_getnamebysid,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_well_known_getnamebysid_special,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_well_known_getnamebysid_non_existing,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_well_known_getidbysid_failure,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_well_known_getsidbyname,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_well_known_getsidbyname_nonexisting,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_well_known_getsidbyname_special,
+ nss_test_setup, nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getorigbyname,
+ nss_test_setup,
+ nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getorigbyname_extra_attrs,
+ nss_test_setup_extra_attr,
+ nss_test_teardown),
+ cmocka_unit_test_setup_teardown(test_nss_getorigbyname_multi_value_attrs,
+ nss_test_setup_extra_attr,
+ nss_test_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -2249,7 +2265,7 @@ int main(int argc, const char *argv[])
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
test_dom_suite_setup(TESTS_PATH);
- rv = run_tests(tests);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
if (rv == 0 && !no_cleanup) {
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
}
diff --git a/src/tests/cmocka/test_resolv_fake.c b/src/tests/cmocka/test_resolv_fake.c
index 6c201e7023c4138703a8057f6eb10c9210385499..eac5697e49ce30224a89a686fe3fb5fdffe2b15b 100644
--- a/src/tests/cmocka/test_resolv_fake.c
+++ b/src/tests/cmocka/test_resolv_fake.c
@@ -221,7 +221,7 @@ struct resolv_fake_ctx {
struct sss_test_ctx *ctx;
};
-void test_resolv_fake_setup(void **state)
+static int test_resolv_fake_setup(void **state)
{
struct resolv_fake_ctx *test_ctx;
int ret;
@@ -242,9 +242,10 @@ void test_resolv_fake_setup(void **state)
assert_int_equal(ret, EOK);
*state = test_ctx;
+ return 0;
}
-void test_resolv_fake_teardown(void **state)
+static int test_resolv_fake_teardown(void **state)
{
struct resolv_fake_ctx *test_ctx =
talloc_get_type(*state, struct resolv_fake_ctx);
@@ -252,6 +253,7 @@ void test_resolv_fake_teardown(void **state)
talloc_free(test_ctx);
talloc_free(global_mock_context);
assert_true(leak_check_teardown());
+ return 0;
}
void test_resolv_fake_srv_done(struct tevent_req *req)
@@ -342,10 +344,10 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_resolv_fake_srv,
- test_resolv_fake_setup,
- test_resolv_fake_teardown),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_resolv_fake_srv,
+ test_resolv_fake_setup,
+ test_resolv_fake_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -369,6 +371,6 @@ int main(int argc, const char *argv[])
* they might not after a failed run. Remove the old db to be sure */
tests_set_cwd();
- rv = run_tests(tests);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
return rv;
}
diff --git a/src/tests/cmocka/test_responder_common.c b/src/tests/cmocka/test_responder_common.c
index a6f642ab23a973a423a8393b44807e37f79e5c0e..8d727b20843082667185c0ecc5d613b50b671694 100644
--- a/src/tests/cmocka/test_responder_common.c
+++ b/src/tests/cmocka/test_responder_common.c
@@ -84,7 +84,7 @@ struct parse_inp_test_ctx {
struct resp_ctx *rctx;
};
-void parse_inp_test_setup(void **state)
+static int parse_inp_test_setup(void **state)
{
struct parse_inp_test_ctx *parse_inp_ctx;
int ret;
@@ -115,9 +115,10 @@ void parse_inp_test_setup(void **state)
check_leaks_push(parse_inp_ctx);
*state = parse_inp_ctx;
+ return 0;
}
-void parse_inp_test_teardown(void **state)
+static int parse_inp_test_teardown(void **state)
{
struct parse_inp_test_ctx *parse_inp_ctx = talloc_get_type(*state,
struct parse_inp_test_ctx);
@@ -126,6 +127,7 @@ void parse_inp_test_teardown(void **state)
talloc_free(parse_inp_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
int __real_sss_parse_name_for_domains(TALLOC_CTX *memctx,
@@ -279,19 +281,19 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(parse_inp_simple,
- parse_inp_test_setup,
- parse_inp_test_teardown),
- unit_test_setup_teardown(parse_inp_call_dp,
- parse_inp_test_setup,
- parse_inp_test_teardown),
- unit_test_setup_teardown(parse_inp_call_attach,
- parse_inp_test_setup,
- parse_inp_test_teardown),
- unit_test_setup_teardown(parse_inp_call_neg,
- parse_inp_test_setup,
- parse_inp_test_teardown),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(parse_inp_simple,
+ parse_inp_test_setup,
+ parse_inp_test_teardown),
+ cmocka_unit_test_setup_teardown(parse_inp_call_dp,
+ parse_inp_test_setup,
+ parse_inp_test_teardown),
+ cmocka_unit_test_setup_teardown(parse_inp_call_attach,
+ parse_inp_test_setup,
+ parse_inp_test_teardown),
+ cmocka_unit_test_setup_teardown(parse_inp_call_neg,
+ parse_inp_test_setup,
+ parse_inp_test_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -317,7 +319,7 @@ int main(int argc, const char *argv[])
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
test_dom_suite_setup(TESTS_PATH);
- rv = run_tests(tests);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
if (rv == 0 && !no_cleanup) {
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
}
diff --git a/src/tests/cmocka/test_sdap.c b/src/tests/cmocka/test_sdap.c
index 404e100a841dbb157de7fa02864838d0412145f9..a1c9aefd86ba7b048916d681025dd1bb644b128e 100644
--- a/src/tests/cmocka/test_sdap.c
+++ b/src/tests/cmocka/test_sdap.c
@@ -246,7 +246,7 @@ struct parse_test_ctx {
struct sdap_msg sm;
};
-void parse_entry_test_setup(void **state)
+static int parse_entry_test_setup(void **state)
{
struct parse_test_ctx *test_ctx;
@@ -257,9 +257,10 @@ void parse_entry_test_setup(void **state)
check_leaks_push(test_ctx);
*state = test_ctx;
+ return 0;
}
-void parse_entry_test_teardown(void **state)
+static int parse_entry_test_teardown(void **state)
{
struct parse_test_ctx *test_ctx = talloc_get_type_abort(*state,
struct parse_test_ctx);
@@ -267,6 +268,7 @@ void parse_entry_test_teardown(void **state)
assert_true(check_leaks_pop(test_ctx) == true);
talloc_free(test_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
void test_parse_with_map(void **state)
@@ -728,41 +730,41 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_parse_with_map,
- parse_entry_test_setup,
- parse_entry_test_teardown),
- unit_test_setup_teardown(test_parse_no_map,
- parse_entry_test_setup,
- parse_entry_test_teardown),
- unit_test_setup_teardown(test_parse_no_attrs,
- parse_entry_test_setup,
- parse_entry_test_teardown),
- unit_test_setup_teardown(test_parse_dups,
- parse_entry_test_setup,
- parse_entry_test_teardown),
- unit_test_setup_teardown(test_parse_deref,
- parse_entry_test_setup,
- parse_entry_test_teardown),
- unit_test_setup_teardown(test_parse_deref_no_attrs,
- parse_entry_test_setup,
- parse_entry_test_teardown),
- unit_test_setup_teardown(test_parse_secondary_oc,
- parse_entry_test_setup,
- parse_entry_test_teardown),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_parse_with_map,
+ parse_entry_test_setup,
+ parse_entry_test_teardown),
+ cmocka_unit_test_setup_teardown(test_parse_no_map,
+ parse_entry_test_setup,
+ parse_entry_test_teardown),
+ cmocka_unit_test_setup_teardown(test_parse_no_attrs,
+ parse_entry_test_setup,
+ parse_entry_test_teardown),
+ cmocka_unit_test_setup_teardown(test_parse_dups,
+ parse_entry_test_setup,
+ parse_entry_test_teardown),
+ cmocka_unit_test_setup_teardown(test_parse_deref,
+ parse_entry_test_setup,
+ parse_entry_test_teardown),
+ cmocka_unit_test_setup_teardown(test_parse_deref_no_attrs,
+ parse_entry_test_setup,
+ parse_entry_test_teardown),
+ cmocka_unit_test_setup_teardown(test_parse_secondary_oc,
+ parse_entry_test_setup,
+ parse_entry_test_teardown),
/* Negative tests */
- unit_test_setup_teardown(test_parse_no_oc,
- parse_entry_test_setup,
- parse_entry_test_teardown),
- unit_test_setup_teardown(test_parse_bad_oc,
- parse_entry_test_setup,
- parse_entry_test_teardown),
- unit_test_setup_teardown(test_parse_no_dn,
- parse_entry_test_setup,
- parse_entry_test_teardown),
- unit_test_setup_teardown(test_parse_deref_map_mismatch,
- parse_entry_test_setup,
- parse_entry_test_teardown),
+ cmocka_unit_test_setup_teardown(test_parse_no_oc,
+ parse_entry_test_setup,
+ parse_entry_test_teardown),
+ cmocka_unit_test_setup_teardown(test_parse_bad_oc,
+ parse_entry_test_setup,
+ parse_entry_test_teardown),
+ cmocka_unit_test_setup_teardown(test_parse_no_dn,
+ parse_entry_test_setup,
+ parse_entry_test_teardown),
+ cmocka_unit_test_setup_teardown(test_parse_deref_map_mismatch,
+ parse_entry_test_setup,
+ parse_entry_test_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -786,5 +788,5 @@ int main(int argc, const char *argv[])
* they might not after a failed run. Remove the old db to be sure */
tests_set_cwd();
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_search_bases.c b/src/tests/cmocka/test_search_bases.c
index e03ef3662685d92335bce4a7023e1ac7e64432c8..4538eaceb8bad2f516614c6e72c704e9265b09fb 100644
--- a/src/tests/cmocka/test_search_bases.c
+++ b/src/tests/cmocka/test_search_bases.c
@@ -179,13 +179,13 @@ void test_get_by_dn_fail(void **state)
int main(void)
{
- const UnitTest tests[] = {
- unit_test(test_search_bases_fail),
- unit_test(test_search_bases_success),
- unit_test(test_get_by_dn_fail),
- unit_test(test_get_by_dn),
- unit_test(test_get_by_dn2)
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_search_bases_fail),
+ cmocka_unit_test(test_search_bases_success),
+ cmocka_unit_test(test_get_by_dn_fail),
+ cmocka_unit_test(test_get_by_dn),
+ cmocka_unit_test(test_get_by_dn2)
};
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_sss_idmap.c b/src/tests/cmocka/test_sss_idmap.c
index ccdfa63ad6065b29187637b721b5e93548a09372..1e52c8507461ab3caa04eb2c0e63410c363ba723 100644
--- a/src/tests/cmocka/test_sss_idmap.c
+++ b/src/tests/cmocka/test_sss_idmap.c
@@ -58,7 +58,7 @@ static void idmap_free(void *ptr, void *pvt)
talloc_free(ptr);
}
-void test_sss_idmap_setup(void **state)
+static int test_sss_idmap_setup(void **state)
{
struct test_ctx *test_ctx;
enum idmap_error_code err;
@@ -78,10 +78,11 @@ void test_sss_idmap_setup(void **state)
assert_int_equal(err, IDMAP_SUCCESS);
*state = test_ctx;
+ return 0;
}
-void setup_ranges(struct test_ctx *test_ctx, bool external_mapping,
- bool second_domain)
+static int setup_ranges(struct test_ctx *test_ctx, bool external_mapping,
+ bool second_domain)
{
struct sss_idmap_range range;
enum idmap_error_code err;
@@ -112,9 +113,10 @@ void setup_ranges(struct test_ctx *test_ctx, bool external_mapping,
err = sss_idmap_add_domain_ex(test_ctx->idmap_ctx, name, sid, &range, NULL,
TEST_OFFSET, external_mapping);
assert_int_equal(err, IDMAP_SUCCESS);
+ return 0;
}
-void test_sss_idmap_setup_with_domains(void **state) {
+static int test_sss_idmap_setup_with_domains(void **state) {
struct test_ctx *test_ctx;
test_sss_idmap_setup(state);
@@ -123,9 +125,10 @@ void test_sss_idmap_setup_with_domains(void **state) {
assert_non_null(test_ctx);
setup_ranges(test_ctx, false, false);
+ return 0;
}
-void test_sss_idmap_setup_with_external_mappings(void **state) {
+static int test_sss_idmap_setup_with_external_mappings(void **state) {
struct test_ctx *test_ctx;
test_sss_idmap_setup(state);
@@ -134,9 +137,10 @@ void test_sss_idmap_setup_with_external_mappings(void **state) {
assert_non_null(test_ctx);
setup_ranges(test_ctx, true, false);
+ return 0;
}
-void test_sss_idmap_setup_with_both(void **state) {
+static int test_sss_idmap_setup_with_both(void **state) {
struct test_ctx *test_ctx;
test_sss_idmap_setup(state);
@@ -146,9 +150,10 @@ void test_sss_idmap_setup_with_both(void **state) {
setup_ranges(test_ctx, false, false);
setup_ranges(test_ctx, true, true);
+ return 0;
}
-void test_sss_idmap_teardown(void **state)
+static int test_sss_idmap_teardown(void **state)
{
struct test_ctx *test_ctx;
@@ -161,6 +166,7 @@ void test_sss_idmap_teardown(void **state)
assert_true(check_leaks_pop(test_ctx) == true);
talloc_free(test_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
void test_add_domain(void **state)
@@ -510,28 +516,29 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_add_domain,
- test_sss_idmap_setup, test_sss_idmap_teardown),
- unit_test_setup_teardown(test_map_id,
- test_sss_idmap_setup_with_domains,
- test_sss_idmap_teardown),
- unit_test_setup_teardown(test_map_id_external,
- test_sss_idmap_setup_with_external_mappings,
- test_sss_idmap_teardown),
- unit_test_setup_teardown(test_check_sid_id,
- test_sss_idmap_setup_with_domains,
- test_sss_idmap_teardown),
- unit_test_setup_teardown(test_check_sid_id,
- test_sss_idmap_setup_with_external_mappings,
- test_sss_idmap_teardown),
- unit_test_setup_teardown(test_has_algorithmic,
- test_sss_idmap_setup_with_both,
- test_sss_idmap_teardown),
- unit_test_setup_teardown(test_has_algorithmic_by_name,
- test_sss_idmap_setup_with_both,
- test_sss_idmap_teardown),
- unit_test(test_sss_idmap_check_collision_ex),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_add_domain,
+ test_sss_idmap_setup,
+ test_sss_idmap_teardown),
+ cmocka_unit_test_setup_teardown(test_map_id,
+ test_sss_idmap_setup_with_domains,
+ test_sss_idmap_teardown),
+ cmocka_unit_test_setup_teardown(test_map_id_external,
+ test_sss_idmap_setup_with_external_mappings,
+ test_sss_idmap_teardown),
+ cmocka_unit_test_setup_teardown(test_check_sid_id,
+ test_sss_idmap_setup_with_domains,
+ test_sss_idmap_teardown),
+ cmocka_unit_test_setup_teardown(test_check_sid_id,
+ test_sss_idmap_setup_with_external_mappings,
+ test_sss_idmap_teardown),
+ cmocka_unit_test_setup_teardown(test_has_algorithmic,
+ test_sss_idmap_setup_with_both,
+ test_sss_idmap_teardown),
+ cmocka_unit_test_setup_teardown(test_has_algorithmic_by_name,
+ test_sss_idmap_setup_with_both,
+ test_sss_idmap_teardown),
+ cmocka_unit_test(test_sss_idmap_check_collision_ex),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -553,5 +560,5 @@ int main(int argc, const char *argv[])
tests_set_cwd();
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_sss_sifp.c b/src/tests/cmocka/test_sss_sifp.c
index 3c009d9780cb8c4824ed86a3a9b1bf98e2d06c25..9773d0f9554a7742f6855fb5245fae18123d6dc0 100644
--- a/src/tests/cmocka/test_sss_sifp.c
+++ b/src/tests/cmocka/test_sss_sifp.c
@@ -116,7 +116,7 @@ static void reply_variant_array(DBusMessage *reply,
assert_true(bret);
}
-static void test_setup(void **state)
+static int test_setup(void **state)
{
sss_sifp_error ret;
@@ -125,23 +125,26 @@ static void test_setup(void **state)
test_ctx.reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
assert_non_null(test_ctx.reply);
+ return 0;
}
-static void test_teardown_parser(void **state)
+static int test_teardown_parser(void **state)
{
sss_sifp_free(&test_ctx.dbus_ctx);
assert_null(test_ctx.dbus_ctx);
dbus_message_unref(test_ctx.reply);
test_ctx.reply = NULL;
+ return 0;
}
-static void test_teardown_api(void **state)
+static int test_teardown_api(void **state)
{
sss_sifp_free(&test_ctx.dbus_ctx);
assert_null(test_ctx.dbus_ctx);
/* sss_sifp is responsible for freeing the reply */
+ return 0;
}
void test_sss_sifp_strdup_valid(void **state)
@@ -2150,100 +2153,100 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_sss_sifp_strdup_valid,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_strdup_null,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_strcat_valid,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_strcat_left_null,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_strcat_right_null,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_strcat_both_null,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_object_path_valid,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_object_path_invalid,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_object_path_list_valid,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_object_path_list_invalid,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_bool,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_int16,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_uint16,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_int32,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_uint32,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_int64,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_uint64,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_string,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_object_path,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_string_dict,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_bool_array,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_bool_array_empty,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_int32_array,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_int32_array_empty,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_uint32_array,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_uint32_array_empty,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_int64_array,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_int64_array_empty,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_uint64_array,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_uint64_array_empty,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_string_array,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_string_array_empty,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_object_path_array,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_object_path_array_empty,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_string_dict_array,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_list,
- test_setup, test_teardown_parser),
- unit_test_setup_teardown(test_sss_sifp_parse_attr_list_empty,
- test_setup, test_teardown_parser),
- unit_test(test_sss_sifp_get_iface_for_object),
- unit_test_setup_teardown(test_sss_sifp_fetch_attr,
- test_setup, test_teardown_api),
- unit_test_setup_teardown(test_sss_sifp_fetch_all_attrs,
- test_setup, test_teardown_api),
- unit_test_setup_teardown(test_sss_sifp_fetch_object,
- test_setup, test_teardown_api),
- unit_test_setup_teardown(test_sss_sifp_invoke_list_zeroargs,
- test_setup, test_teardown_api),
- unit_test_setup_teardown(test_sss_sifp_invoke_list_withargs,
- test_setup, test_teardown_api),
- unit_test_setup_teardown(test_sss_sifp_invoke_find_zeroargs,
- test_setup, test_teardown_api),
- unit_test_setup_teardown(test_sss_sifp_invoke_find_withargs,
- test_setup, test_teardown_api),
- unit_test_setup_teardown(test_sss_sifp_list_domains,
- test_setup, test_teardown_api),
- unit_test_setup_teardown(test_sss_sifp_fetch_domain_by_name,
- test_setup, test_teardown_api),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_sss_sifp_strdup_valid,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_strdup_null,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_strcat_valid,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_strcat_left_null,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_strcat_right_null,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_strcat_both_null,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_object_path_valid,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_object_path_invalid,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_object_path_list_valid,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_object_path_list_invalid,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_bool,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_int16,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_uint16,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_int32,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_uint32,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_int64,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_uint64,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_string,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_object_path,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_string_dict,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_bool_array,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_bool_array_empty,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_int32_array,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_int32_array_empty,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_uint32_array,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_uint32_array_empty,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_int64_array,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_int64_array_empty,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_uint64_array,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_uint64_array_empty,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_string_array,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_string_array_empty,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_object_path_array,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_object_path_array_empty,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_string_dict_array,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_list,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_list_empty,
+ test_setup, test_teardown_parser),
+ cmocka_unit_test(test_sss_sifp_get_iface_for_object),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_fetch_attr,
+ test_setup, test_teardown_api),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_fetch_all_attrs,
+ test_setup, test_teardown_api),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_fetch_object,
+ test_setup, test_teardown_api),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_invoke_list_zeroargs,
+ test_setup, test_teardown_api),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_invoke_list_withargs,
+ test_setup, test_teardown_api),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_invoke_find_zeroargs,
+ test_setup, test_teardown_api),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_invoke_find_withargs,
+ test_setup, test_teardown_api),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_list_domains,
+ test_setup, test_teardown_api),
+ cmocka_unit_test_setup_teardown(test_sss_sifp_fetch_domain_by_name,
+ test_setup, test_teardown_api),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -2263,7 +2266,7 @@ int main(int argc, const char *argv[])
DEBUG_CLI_INIT(debug_level);
- rv = run_tests(tests);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
return rv;
}
diff --git a/src/tests/cmocka/test_sysdb_views.c b/src/tests/cmocka/test_sysdb_views.c
index f5a5377ef1c924aa93102fe2170c11d036b6da4b..69118cd87a172696f8220e1446df7a856e368cb6 100644
--- a/src/tests/cmocka/test_sysdb_views.c
+++ b/src/tests/cmocka/test_sysdb_views.c
@@ -116,7 +116,7 @@ static int _setup_sysdb_tests(struct sysdb_test_ctx **ctx, bool enumerate)
#define setup_sysdb_tests(ctx) _setup_sysdb_tests((ctx), false)
-static void test_sysdb_setup(void **state)
+static int test_sysdb_setup(void **state)
{
int ret;
struct sysdb_test_ctx *test_ctx;
@@ -127,15 +127,17 @@ static void test_sysdb_setup(void **state)
assert_int_equal(ret, EOK);
*state = (void *) test_ctx;
+ return 0;
}
-static void test_sysdb_teardown(void **state)
+static int test_sysdb_teardown(void **state)
{
struct sysdb_test_ctx *test_ctx = talloc_get_type_abort(*state,
struct sysdb_test_ctx);
talloc_free(test_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
static void test_sysdb_store_override(void **state)
@@ -440,17 +442,17 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_sysdb_store_override,
- test_sysdb_setup, test_sysdb_teardown),
- unit_test_setup_teardown(test_sysdb_add_overrides_to_object,
- test_sysdb_setup, test_sysdb_teardown),
- unit_test_setup_teardown(test_split_ipa_anchor,
- test_sysdb_setup, test_sysdb_teardown),
- unit_test_setup_teardown(test_sysdb_delete_view_tree,
- test_sysdb_setup, test_sysdb_teardown),
- unit_test_setup_teardown(test_sysdb_invalidate_overrides,
- test_sysdb_setup, test_sysdb_teardown),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_sysdb_store_override,
+ test_sysdb_setup, test_sysdb_teardown),
+ cmocka_unit_test_setup_teardown(test_sysdb_add_overrides_to_object,
+ test_sysdb_setup, test_sysdb_teardown),
+ cmocka_unit_test_setup_teardown(test_split_ipa_anchor,
+ test_sysdb_setup, test_sysdb_teardown),
+ cmocka_unit_test_setup_teardown(test_sysdb_delete_view_tree,
+ test_sysdb_setup, test_sysdb_teardown),
+ cmocka_unit_test_setup_teardown(test_sysdb_invalidate_overrides,
+ test_sysdb_setup, test_sysdb_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -473,7 +475,7 @@ int main(int argc, const char *argv[])
tests_set_cwd();
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_FILE, LOCAL_SYSDB_FILE);
test_dom_suite_setup(TESTS_PATH);
- rv = run_tests(tests);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
if (rv == 0 && no_cleanup == 0) {
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_FILE, LOCAL_SYSDB_FILE);
diff --git a/src/tests/cmocka/test_utils.c b/src/tests/cmocka/test_utils.c
index dc6e35dc02204714c5befbf4d67e7e7cbd8f4af1..2203e2c49efacab27e9cf4c6c699319cfdf5370c 100644
--- a/src/tests/cmocka/test_utils.c
+++ b/src/tests/cmocka/test_utils.c
@@ -56,7 +56,7 @@ struct dom_list_test_ctx {
};
-void setup_dom_list(void **state)
+static int setup_dom_list(void **state)
{
struct dom_list_test_ctx *test_ctx;
struct sss_domain_info *dom = NULL;
@@ -87,20 +87,22 @@ void setup_dom_list(void **state)
check_leaks_push(test_ctx);
*state = test_ctx;
+ return 0;
}
-void teardown_dom_list(void **state)
+static int teardown_dom_list(void **state)
{
struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
struct dom_list_test_ctx);
if (test_ctx == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "Type mismatch\n");
- return;
+ return 1;
}
assert_true(check_leaks_pop(test_ctx) == true);
talloc_free(test_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
void test_find_domain_by_name_null(void **state)
@@ -465,7 +467,7 @@ struct name_init_test_ctx {
"((?P<name>[^@]+)@(?P<domain>.+$))|" \
"(^(?P<name>[^@\\\\]+)$))"
-void confdb_test_setup(void **state)
+static int confdb_test_setup(void **state)
{
struct name_init_test_ctx *test_ctx;
char *conf_db = NULL;
@@ -524,9 +526,10 @@ void confdb_test_setup(void **state)
check_leaks_push(test_ctx);
*state = test_ctx;
+ return 0;
}
-void confdb_test_teardown(void **state)
+static int confdb_test_teardown(void **state)
{
struct name_init_test_ctx *test_ctx;
@@ -535,6 +538,7 @@ void confdb_test_teardown(void **state)
assert_true(check_leaks_pop(test_ctx) == true);
talloc_free(test_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
void test_sss_names_init(void **state)
@@ -721,7 +725,7 @@ void check_expanded_value(TALLOC_CTX *tmp_ctx,
talloc_free(homedir);
}
-void setup_homedir_ctx(void **state)
+static int setup_homedir_ctx(void **state)
{
struct sss_nss_homedir_ctx *homedir_ctx;
@@ -740,20 +744,22 @@ void setup_homedir_ctx(void **state)
check_leaks_push(homedir_ctx);
*state = homedir_ctx;
+ return 0;
}
-void teardown_homedir_ctx(void **state)
+static int teardown_homedir_ctx(void **state)
{
struct sss_nss_homedir_ctx *homedir_ctx = talloc_get_type(*state,
struct sss_nss_homedir_ctx);
if (homedir_ctx == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "Type mismatch\n");
- return;
+ return 1;
}
assert_true(check_leaks_pop(homedir_ctx) == true);
talloc_free(homedir_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
void test_expand_homedir_template_NULL(void **state)
@@ -877,17 +883,19 @@ void test_expand_homedir_template(void **state)
talloc_free(tmp_ctx);
}
-void setup_add_strings_lists(void **state)
+static int setup_add_strings_lists(void **state)
{
assert_true(leak_check_setup());
check_leaks_push(global_talloc_context);
+ return 0;
}
-void teardown_add_strings_lists(void **state)
+static int teardown_add_strings_lists(void **state)
{
assert_true(check_leaks_pop(global_talloc_context) == true);
assert_true(leak_check_teardown());
+ return 0;
}
void test_add_strings_lists(void **state)
@@ -1083,45 +1091,49 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_find_domain_by_sid_null,
- setup_dom_list, teardown_dom_list),
- unit_test_setup_teardown(test_find_domain_by_sid,
- setup_dom_list, teardown_dom_list),
- unit_test_setup_teardown(test_find_domain_by_sid_missing_sid,
- setup_dom_list, teardown_dom_list),
- unit_test_setup_teardown(test_find_domain_by_sid_disabled,
- setup_dom_list, teardown_dom_list),
- unit_test_setup_teardown(test_find_domain_by_name_null,
- setup_dom_list, teardown_dom_list),
- unit_test_setup_teardown(test_find_domain_by_name,
- setup_dom_list, teardown_dom_list),
- unit_test_setup_teardown(test_find_domain_by_name_missing_flat_name,
- setup_dom_list, teardown_dom_list),
- unit_test_setup_teardown(test_find_domain_by_name_disabled,
- setup_dom_list, teardown_dom_list),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_find_domain_by_sid_null,
+ setup_dom_list, teardown_dom_list),
+ cmocka_unit_test_setup_teardown(test_find_domain_by_sid,
+ setup_dom_list, teardown_dom_list),
+ cmocka_unit_test_setup_teardown(test_find_domain_by_sid_missing_sid,
+ setup_dom_list, teardown_dom_list),
+ cmocka_unit_test_setup_teardown(test_find_domain_by_sid_disabled,
+ setup_dom_list, teardown_dom_list),
+ cmocka_unit_test_setup_teardown(test_find_domain_by_name_null,
+ setup_dom_list, teardown_dom_list),
+ cmocka_unit_test_setup_teardown(test_find_domain_by_name,
+ setup_dom_list, teardown_dom_list),
+ cmocka_unit_test_setup_teardown(test_find_domain_by_name_missing_flat_name,
+ setup_dom_list, teardown_dom_list),
+ cmocka_unit_test_setup_teardown(test_find_domain_by_name_disabled,
+ setup_dom_list, teardown_dom_list),
- unit_test_setup_teardown(test_sss_names_init,
- confdb_test_setup, confdb_test_teardown),
+ cmocka_unit_test_setup_teardown(test_sss_names_init,
+ confdb_test_setup,
+ confdb_test_teardown),
- unit_test(test_well_known_sid_to_name),
- unit_test(test_name_to_well_known_sid),
+ cmocka_unit_test(test_well_known_sid_to_name),
+ cmocka_unit_test(test_name_to_well_known_sid),
- unit_test_setup_teardown(test_sss_filter_sanitize_for_dom,
- setup_dom_list, teardown_dom_list),
+ cmocka_unit_test_setup_teardown(test_sss_filter_sanitize_for_dom,
+ setup_dom_list,
+ teardown_dom_list),
- unit_test(test_expand_homedir_template_NULL),
- unit_test_setup_teardown(test_expand_homedir_template,
- setup_homedir_ctx, teardown_homedir_ctx),
- unit_test(test_textual_public_key),
- unit_test(test_replace_whitespaces),
- unit_test(test_reverse_replace_whitespaces),
- unit_test_setup_teardown(test_add_strings_lists,
- setup_add_strings_lists,
- teardown_add_strings_lists),
- unit_test(test_sss_write_krb5_conf_snippet),
- unit_test_setup_teardown(test_fix_domain_in_name_list,
- confdb_test_setup, confdb_test_teardown),
+ cmocka_unit_test(test_expand_homedir_template_NULL),
+ cmocka_unit_test_setup_teardown(test_expand_homedir_template,
+ setup_homedir_ctx,
+ teardown_homedir_ctx),
+ cmocka_unit_test(test_textual_public_key),
+ cmocka_unit_test(test_replace_whitespaces),
+ cmocka_unit_test(test_reverse_replace_whitespaces),
+ cmocka_unit_test_setup_teardown(test_add_strings_lists,
+ setup_add_strings_lists,
+ teardown_add_strings_lists),
+ cmocka_unit_test(test_sss_write_krb5_conf_snippet),
+ cmocka_unit_test_setup_teardown(test_fix_domain_in_name_list,
+ confdb_test_setup,
+ confdb_test_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -1147,7 +1159,7 @@ int main(int argc, const char *argv[])
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
test_dom_suite_setup(TESTS_PATH);
- rv = run_tests(tests);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
if (rv == 0) {
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
}
diff --git a/src/tests/cwrap/test_become_user.c b/src/tests/cwrap/test_become_user.c
index 7ecea5aac34bb73ca81d94ad481f05b338e65ed0..b9e8a5c3bf216570292b2fbae25832268c6bf17b 100644
--- a/src/tests/cwrap/test_become_user.c
+++ b/src/tests/cwrap/test_become_user.c
@@ -133,9 +133,9 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test(test_become_user),
- unit_test(test_switch_user),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_become_user),
+ cmocka_unit_test(test_switch_user),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -159,5 +159,5 @@ int main(int argc, const char *argv[])
* they might not after a failed run. Remove the old db to be sure */
tests_set_cwd();
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cwrap/test_responder_common.c b/src/tests/cwrap/test_responder_common.c
index 7e3f2e025a0dce15cc93e560a42bb566eff9fb30..2c92ff080e28151bc68e52fa02420c331d2ed4cf 100644
--- a/src/tests/cwrap/test_responder_common.c
+++ b/src/tests/cwrap/test_responder_common.c
@@ -111,7 +111,7 @@ struct create_pipe_ctx {
const char *sock_name;
};
-void test_create_pipe_fd_setup(void **state)
+static int test_create_pipe_fd_setup(void **state)
{
struct create_pipe_ctx *ctx;
@@ -120,6 +120,7 @@ void test_create_pipe_fd_setup(void **state)
ctx->fd = -1;
*state = ctx;
+ return 0;
}
void check_sock_properties(struct create_pipe_ctx *ctx, mode_t mode)
@@ -181,7 +182,7 @@ void test_create_pipe_fd(void **state)
check_sock_properties(ctx, 0777);
}
-void test_create_pipe_fd_teardown(void **state)
+static int test_create_pipe_fd_teardown(void **state)
{
struct create_pipe_ctx *ctx;
@@ -191,6 +192,7 @@ void test_create_pipe_fd_teardown(void **state)
unlink(ctx->sock_name);
close(ctx->fd);
}
+ return 0;
}
int main(int argc, const char *argv[])
@@ -203,13 +205,13 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test(test_uid_csv_to_uid_list),
- unit_test(test_name_csv_to_uid_list),
- unit_test(test_csv_to_uid_list_neg),
- unit_test_setup_teardown(test_create_pipe_fd,
- test_create_pipe_fd_setup,
- test_create_pipe_fd_teardown)
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_uid_csv_to_uid_list),
+ cmocka_unit_test(test_name_csv_to_uid_list),
+ cmocka_unit_test(test_csv_to_uid_list_neg),
+ cmocka_unit_test_setup_teardown(test_create_pipe_fd,
+ test_create_pipe_fd_setup,
+ test_create_pipe_fd_teardown)
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -231,5 +233,5 @@ int main(int argc, const char *argv[])
tests_set_cwd();
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cwrap/test_server.c b/src/tests/cwrap/test_server.c
index d0aeac47d0b067fdbc3399037c0a74f150337a23..f6884f14d75b5884e1a2c80b05fbb660757dced0 100644
--- a/src/tests/cwrap/test_server.c
+++ b/src/tests/cwrap/test_server.c
@@ -169,10 +169,10 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test(test_run_as_root_fg),
- unit_test(test_run_as_sssd_fg),
- unit_test(test_run_as_root_daemon),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_run_as_root_fg),
+ cmocka_unit_test(test_run_as_sssd_fg),
+ cmocka_unit_test(test_run_as_root_daemon),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -198,7 +198,7 @@ int main(int argc, const char *argv[])
test_dom_suite_cleanup(TEST_DB_PATH, CONFDB_FILE, NULL);
test_dom_suite_setup(TEST_DB_PATH);
- rv = run_tests(tests);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
if (rv != 0) {
test_dom_suite_cleanup(TEST_DB_PATH, CONFDB_FILE, NULL);
}
diff --git a/src/tests/cwrap/test_usertools.c b/src/tests/cwrap/test_usertools.c
index 6423059456a06f0c8f8ebdd803641b7207e862fd..91eb2bc968dd741f8b1541edd2d9303626b1175f 100644
--- a/src/tests/cwrap/test_usertools.c
+++ b/src/tests/cwrap/test_usertools.c
@@ -77,10 +77,10 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test(test_get_user_num),
- unit_test(test_get_user_str),
- unit_test(test_get_user_nullparm),
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_get_user_num),
+ cmocka_unit_test(test_get_user_str),
+ cmocka_unit_test(test_get_user_nullparm),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -102,5 +102,5 @@ int main(int argc, const char *argv[])
tests_set_cwd();
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
--
2.4.0