summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2015-03-09 21:48:11 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-03-11 14:39:35 +0100
commit4e5e846de22407f825fe3b4040d79606818a2419 (patch)
tree99bf02588f00f39d29f0d2f9e3a439b65fd5d6c3 /src/tests
parent0aad066baeed6833cf061b71d72c6bbbb2d2b9e8 (diff)
downloadsssd-4e5e846de22407f825fe3b4040d79606818a2419.tar.gz
sssd-4e5e846de22407f825fe3b4040d79606818a2419.tar.xz
sssd-4e5e846de22407f825fe3b4040d79606818a2419.zip
tests: convert all unit tests to cmocka 1.0 or later
All tests now use the cmocka-1.0-compatible API. Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/cmocka/sbus_internal_tests.c22
-rw-r--r--src/tests/cmocka/sss_nss_idmap-tests.c8
-rw-r--r--src/tests/cmocka/test_ad_access_filter.c70
-rw-r--r--src/tests/cmocka/test_ad_common.c22
-rw-r--r--src/tests/cmocka/test_ad_gpo.c58
-rw-r--r--src/tests/cmocka/test_authtok.c29
-rw-r--r--src/tests/cmocka/test_be_ptask.c12
-rw-r--r--src/tests/cmocka/test_child_common.c46
-rw-r--r--src/tests/cmocka/test_copy_ccache.c14
-rw-r--r--src/tests/cmocka/test_copy_keytab.c22
-rw-r--r--src/tests/cmocka/test_dp_opts.c40
-rw-r--r--src/tests/cmocka/test_dyndns.c45
-rw-r--r--src/tests/cmocka/test_find_uid.c10
-rw-r--r--src/tests/cmocka/test_fo_srv.c22
-rw-r--r--src/tests/cmocka/test_fqnames.c84
-rw-r--r--src/tests/cmocka/test_ifp.c25
-rw-r--r--src/tests/cmocka/test_io.c32
-rw-r--r--src/tests/cmocka/test_ipa_idmap.c16
-rw-r--r--src/tests/cmocka/test_negcache.c39
-rw-r--r--src/tests/cmocka/test_nested_groups.c16
-rw-r--r--src/tests/cmocka/test_nss_srv.c160
-rw-r--r--src/tests/cmocka/test_resolv_fake.c16
-rw-r--r--src/tests/cmocka/test_responder_cache_req.c28
-rw-r--r--src/tests/cmocka/test_responder_common.c34
-rw-r--r--src/tests/cmocka/test_sbus_opath.c14
-rw-r--r--src/tests/cmocka/test_sdap.c76
-rw-r--r--src/tests/cmocka/test_search_bases.c14
-rw-r--r--src/tests/cmocka/test_sss_idmap.c67
-rw-r--r--src/tests/cmocka/test_sss_sifp.c199
-rw-r--r--src/tests/cmocka/test_sysdb_views.c30
-rw-r--r--src/tests/cmocka/test_utils.c112
-rw-r--r--src/tests/cwrap/test_become_user.c8
-rw-r--r--src/tests/cwrap/test_responder_common.c22
-rw-r--r--src/tests/cwrap/test_server.c10
-rw-r--r--src/tests/cwrap/test_usertools.c10
35 files changed, 769 insertions, 663 deletions
diff --git a/src/tests/cmocka/sbus_internal_tests.c b/src/tests/cmocka/sbus_internal_tests.c
index a79f54d26..db5738caa 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 4141a3279..4ba8f2f92 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 7654e8498..eebc46b71 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),
+ const struct CMUnitTest tests[] = {
+ cmocka_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),
+ cmocka_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),
+ cmocka_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),
+ cmocka_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),
+ cmocka_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),
+ cmocka_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),
+ cmocka_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),
+ cmocka_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),
+ 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 c4b6bd0f2..19a4d395b 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 4753c95d3..4dadcf1b2 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 50205cc33..e37e92f68 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 205204214..f4a120c0c 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 11e383e52..1a62a9099 100644
--- a/src/tests/cmocka/test_child_common.c
+++ b/src/tests/cmocka/test_child_common.c
@@ -40,7 +40,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;
@@ -65,15 +65,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 */
@@ -453,25 +455,25 @@ 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),
- unit_test_setup_teardown(test_exec_child_io_destruct,
- child_test_setup,
- child_test_teardown),
- unit_test_setup_teardown(test_exec_child_handler,
- child_test_setup,
- child_test_teardown),
- unit_test_setup_teardown(test_exec_child_echo,
- child_test_setup,
- child_test_teardown),
- unit_test_setup_teardown(test_sss_child,
- 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),
+ cmocka_unit_test_setup_teardown(test_exec_child_io_destruct,
+ child_test_setup,
+ child_test_teardown),
+ cmocka_unit_test_setup_teardown(test_exec_child_handler,
+ child_test_setup,
+ child_test_teardown),
+ cmocka_unit_test_setup_teardown(test_exec_child_echo,
+ child_test_setup,
+ child_test_teardown),
+ cmocka_unit_test_setup_teardown(test_sss_child,
+ child_test_setup,
+ child_test_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -491,6 +493,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 c7a5573b8..711f8f0ab 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 a9f2161a2..1999de3bf 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 8794906e7..9192eaaca 100644
--- a/src/tests/cmocka/test_dp_opts.c
+++ b/src/tests/cmocka/test_dp_opts.c
@@ -264,7 +264,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;
@@ -275,12 +275,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)
@@ -366,22 +368,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. */
@@ -407,7 +409,7 @@ int main(int argc, const char *argv[])
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
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_DOM_NAME);
}
diff --git a/src/tests/cmocka/test_dyndns.c b/src/tests/cmocka/test_dyndns.c
index 58b8aad30..97fac9425 100644
--- a/src/tests/cmocka/test_dyndns.c
+++ b/src/tests/cmocka/test_dyndns.c
@@ -392,7 +392,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" },
@@ -418,9 +418,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);
@@ -428,13 +429,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[])
@@ -451,24 +454,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. */
@@ -494,7 +501,7 @@ int main(int argc, const char *argv[])
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
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_DOM_NAME);
}
diff --git a/src/tests/cmocka/test_find_uid.c b/src/tests/cmocka/test_find_uid.c
index dcc367962..63a426a16 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 3ee308bd5..7a6321006 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 b9b6230b9..0326d5a64 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),
-
- 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),
-
- unit_test_setup_teardown(test_sss_get_domain_name,
- parse_name_test_setup,
- parse_name_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),
+
+ 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),
+
+ 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 484ab8568..a0fb5883c 100644
--- a/src/tests/cmocka/test_ifp.c
+++ b/src/tests/cmocka/test_ifp.c
@@ -360,7 +360,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;
@@ -381,9 +381,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);
@@ -394,6 +395,7 @@ void ifp_test_req_teardown(void **state)
talloc_free(test_ctx);
assert_true(leak_check_teardown());
+ return 0;
}
int main(int argc, const char *argv[])
@@ -406,14 +408,15 @@ 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_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),
+ 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),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -437,5 +440,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 2f9538857..9bdb7107e 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 8ad562987..fba41ae2f 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 d8e28d853..f98081337 100644
--- a/src/tests/cmocka/test_negcache.c
+++ b/src/tests/cmocka/test_negcache.c
@@ -131,7 +131,7 @@ struct test_state {
struct resp_ctx *rctx;
};
-static void setup(void **state)
+static int setup(void **state)
{
int ret;
struct test_state *ts;
@@ -144,12 +144,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)
@@ -620,28 +622,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_DOM_NAME);
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_DOM_NAME);
}
diff --git a/src/tests/cmocka/test_nested_groups.c b/src/tests/cmocka/test_nested_groups.c
index ac1045f1d..4f748a170 100644
--- a/src/tests/cmocka/test_nested_groups.c
+++ b/src/tests/cmocka/test_nested_groups.c
@@ -37,9 +37,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 */
@@ -563,7 +563,7 @@ static void nested_groups_test_nested_chain_with_error(void **state)
assert_int_equal(ret, EIO);
}
-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;
@@ -609,11 +609,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[])
@@ -630,7 +632,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),
@@ -663,7 +665,7 @@ int main(int argc, const char *argv[])
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
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_DOM_NAME);
}
diff --git a/src/tests/cmocka/test_nss_srv.c b/src/tests/cmocka/test_nss_srv.c
index 2a792cff4..4dbda3bd6 100644
--- a/src/tests/cmocka/test_nss_srv.c
+++ b/src/tests/cmocka/test_nss_srv.c
@@ -2071,7 +2071,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" },
@@ -2079,9 +2079,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" },
@@ -2090,9 +2091,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" },
@@ -2102,9 +2104,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;
@@ -2126,9 +2129,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" },
@@ -2137,11 +2141,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[])
@@ -2158,71 +2164,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. */
@@ -2248,7 +2264,7 @@ int main(int argc, const char *argv[])
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
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_DOM_NAME);
}
diff --git a/src/tests/cmocka/test_resolv_fake.c b/src/tests/cmocka/test_resolv_fake.c
index 6c201e702..eac5697e4 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_cache_req.c b/src/tests/cmocka/test_responder_cache_req.c
index 694e8dd46..51c98a5d6 100644
--- a/src/tests/cmocka/test_responder_cache_req.c
+++ b/src/tests/cmocka/test_responder_cache_req.c
@@ -34,14 +34,14 @@
#define TEST_ID_PROVIDER "ldap"
#define new_single_domain_test(test) \
- unit_test_setup_teardown(test_ ## test, \
- test_single_domain_setup, \
- test_single_domain_teardown)
+ cmocka_unit_test_setup_teardown(test_ ## test, \
+ test_single_domain_setup, \
+ test_single_domain_teardown)
#define new_multi_domain_test(test) \
- unit_test_setup_teardown(test_ ## test, \
- test_multi_domain_setup, \
- test_multi_domain_teardown)
+ cmocka_unit_test_setup_teardown(test_ ## test, \
+ test_multi_domain_setup, \
+ test_multi_domain_teardown)
struct cache_req_test_ctx {
struct sss_test_ctx *tctx;
@@ -108,7 +108,7 @@ static void cache_req_user_test_done(struct tevent_req *req)
ctx->tctx->done = true;
}
-void test_single_domain_setup(void **state)
+static int test_single_domain_setup(void **state)
{
struct cache_req_test_ctx *test_ctx = NULL;
errno_t ret;
@@ -129,15 +129,17 @@ void test_single_domain_setup(void **state)
ret = sss_ncache_init(test_ctx, &test_ctx->ncache);
assert_int_equal(ret, EOK);
+ return 0;
}
-void test_single_domain_teardown(void **state)
+static int test_single_domain_teardown(void **state)
{
talloc_zfree(*state);
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
+ return 0;
}
-void test_multi_domain_setup(void **state)
+static int test_multi_domain_setup(void **state)
{
struct cache_req_test_ctx *test_ctx = NULL;
errno_t ret;
@@ -159,12 +161,14 @@ void test_multi_domain_setup(void **state)
ret = sss_ncache_init(test_ctx, &test_ctx->ncache);
assert_int_equal(ret, EOK);
+ return 0;
}
-void test_multi_domain_teardown(void **state)
+static int test_multi_domain_teardown(void **state)
{
talloc_zfree(*state);
test_multidom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, domains);
+ return 0;
}
void test_user_multiple_domains_found(void **state)
@@ -491,7 +495,7 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
+ const struct CMUnitTest tests[] = {
new_single_domain_test(user_cache_valid),
new_single_domain_test(user_cache_expired),
new_single_domain_test(user_cache_midpoint),
@@ -525,5 +529,5 @@ int main(int argc, const char *argv[])
test_multidom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, domains);
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
- return run_tests(tests);
+ return cmocka_run_group_tests(tests, NULL, NULL);
}
diff --git a/src/tests/cmocka/test_responder_common.c b/src/tests/cmocka/test_responder_common.c
index 48beb15fc..44c93c1d5 100644
--- a/src/tests/cmocka/test_responder_common.c
+++ b/src/tests/cmocka/test_responder_common.c
@@ -83,7 +83,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;
@@ -114,9 +114,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);
@@ -125,6 +126,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,
@@ -278,19 +280,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. */
@@ -316,7 +318,7 @@ int main(int argc, const char *argv[])
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
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_DOM_NAME);
}
diff --git a/src/tests/cmocka/test_sbus_opath.c b/src/tests/cmocka/test_sbus_opath.c
index a91a3e2f6..4c57c56e7 100644
--- a/src/tests/cmocka/test_sbus_opath.c
+++ b/src/tests/cmocka/test_sbus_opath.c
@@ -153,12 +153,12 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
- const UnitTest tests[] = {
- unit_test(test_sbus_opath_strip_prefix),
- unit_test(test_sbus_opath_escape_unescape),
- unit_test(test_sbus_opath_compose),
- unit_test(test_sbus_opath_compose_escape),
- unit_test(test_sbus_opath_get_object_name)
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_sbus_opath_strip_prefix),
+ cmocka_unit_test(test_sbus_opath_escape_unescape),
+ cmocka_unit_test(test_sbus_opath_compose),
+ cmocka_unit_test(test_sbus_opath_compose_escape),
+ cmocka_unit_test(test_sbus_opath_get_object_name)
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
@@ -178,5 +178,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_sdap.c b/src/tests/cmocka/test_sdap.c
index 404e100a8..a1c9aefd8 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 e03ef3662..4538eaceb 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 ccdfa63ad..1e52c8507 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 3c009d978..9773d0f95 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 f5a5377ef..69118cd87 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 e04a1af3d..848317afc 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),
-
- 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),
-
- 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),
+ 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),
+
+ cmocka_unit_test_setup_teardown(test_sss_names_init,
+ confdb_test_setup,
+ confdb_test_teardown),
+
+ cmocka_unit_test(test_well_known_sid_to_name),
+ cmocka_unit_test(test_name_to_well_known_sid),
+
+ cmocka_unit_test_setup_teardown(test_sss_filter_sanitize_for_dom,
+ setup_dom_list,
+ teardown_dom_list),
+
+ 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_DOM_NAME);
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_DOM_NAME);
}
diff --git a/src/tests/cwrap/test_become_user.c b/src/tests/cwrap/test_become_user.c
index 7ecea5aac..b9e8a5c3b 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 7e3f2e025..2c92ff080 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 55ef2ecae..799de26f5 100644
--- a/src/tests/cwrap/test_server.c
+++ b/src/tests/cwrap/test_server.c
@@ -172,10 +172,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. */
@@ -201,7 +201,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 642305945..91eb2bc96 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);
}