summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2015-07-03 11:15:32 +0200
committerJakub Hrozek <jhrozek@redhat.com>2015-07-06 15:23:38 +0200
commiteca74a9559ce1b0f123c14906ad8394fc303f468 (patch)
tree279f1e9305be14ae49aefb7852753c6be0d67c3e
parent537e277876a7e4b81e68eb3836586b1a765ba0dc (diff)
downloadsssd-eca74a9559ce1b0f123c14906ad8394fc303f468.tar.gz
sssd-eca74a9559ce1b0f123c14906ad8394fc303f468.tar.xz
sssd-eca74a9559ce1b0f123c14906ad8394fc303f468.zip
tests: Reduce duplication with new function test_ev_done
Reviewed-by: Sumit Bose <sbose@redhat.com>
-rw-r--r--src/tests/cmocka/test_ipa_subdomains_server.c11
-rw-r--r--src/tests/cmocka/test_resolv_fake.c3
-rw-r--r--src/tests/cmocka/test_responder_common.c8
-rw-r--r--src/tests/common.h3
-rw-r--r--src/tests/common_tev.c6
5 files changed, 16 insertions, 15 deletions
diff --git a/src/tests/cmocka/test_ipa_subdomains_server.c b/src/tests/cmocka/test_ipa_subdomains_server.c
index 28e998b57..a4cb8c2b7 100644
--- a/src/tests/cmocka/test_ipa_subdomains_server.c
+++ b/src/tests/cmocka/test_ipa_subdomains_server.c
@@ -266,7 +266,6 @@ static int test_ipa_server_create_trusts_teardown(void **state)
static void test_ipa_server_create_trusts_none(struct tevent_req *req);
static void test_ipa_server_create_trusts_twoway(struct tevent_req *req);
-static void test_ipa_server_create_trusts_finish(struct trust_test_ctx *test_ctx);
static void test_ipa_server_create_trusts(void **state)
{
@@ -427,13 +426,7 @@ static void test_ipa_server_create_trusts_twoway(struct tevent_req *req)
DOM_REALM);
assert_null(test_ctx->ipa_ctx->server_mode->trusts->next);
- test_ipa_server_create_trusts_finish(test_ctx);
-}
-
-static void test_ipa_server_create_trusts_finish(struct trust_test_ctx *test_ctx)
-{
- test_ctx->tctx->error = EOK;
- test_ctx->tctx->done = true;
+ test_ev_done(test_ctx->tctx, EOK);
}
static void
@@ -669,7 +662,7 @@ static void test_ipa_server_create_trusts_oneway(struct tevent_req *req)
SUBDOM_REALM);
assert_null(test_ctx->ipa_ctx->server_mode->trusts->next->next);
- test_ipa_server_create_trusts_finish(test_ctx);
+ test_ev_done(test_ctx->tctx, EOK);
}
static void test_ipa_server_create_oneway_kt_exists(void **state)
diff --git a/src/tests/cmocka/test_resolv_fake.c b/src/tests/cmocka/test_resolv_fake.c
index 2c846ce4c..a1e9ee4cb 100644
--- a/src/tests/cmocka/test_resolv_fake.c
+++ b/src/tests/cmocka/test_resolv_fake.c
@@ -293,8 +293,7 @@ void test_resolv_fake_srv_done(struct tevent_req *req)
assert_int_equal(ttl, 500);
talloc_free(tmp_ctx);
- test_ctx->ctx->error = EOK;
- test_ctx->ctx->done = true;
+ test_ev_done(test_ctx->ctx, EOK);
}
void test_resolv_fake_srv(void **state)
diff --git a/src/tests/cmocka/test_responder_common.c b/src/tests/cmocka/test_responder_common.c
index 0a4d4bb49..cb57c97fe 100644
--- a/src/tests/cmocka/test_responder_common.c
+++ b/src/tests/cmocka/test_responder_common.c
@@ -161,8 +161,9 @@ void parse_inp_simple_done(struct tevent_req *req)
char *domname = NULL;
ret = sss_parse_inp_recv(req, parse_inp_ctx, &name, &domname);
- parse_inp_ctx->tctx->done = true;
assert_int_equal(ret, EOK);
+
+ test_ev_done(parse_inp_ctx->tctx, EOK);
talloc_free(req);
assert_string_equal(name, NAME);
@@ -239,8 +240,8 @@ void parse_inp_neg_done(struct tevent_req *req)
char *domname = NULL;
ret = sss_parse_inp_recv(req, parse_inp_ctx, &name, &domname);
- parse_inp_ctx->tctx->done = true;
assert_int_equal(ret, ERR_INPUT_PARSE);
+ test_ev_done(parse_inp_ctx->tctx, EOK);
talloc_free(req);
assert_null(name);
@@ -273,8 +274,7 @@ struct sss_nc_ctx {
errno_t sss_ncache_reset_repopulate_permanent(struct resp_ctx *rctx,
struct sss_nc_ctx *dummy_ncache_ptr)
{
- dummy_ncache_ptr->pctx->tctx->error = EOK;
- dummy_ncache_ptr->pctx->tctx->done = true;
+ test_ev_done(dummy_ncache_ptr->pctx->tctx, EOK);
return EOK;
}
diff --git a/src/tests/common.h b/src/tests/common.h
index 714be6988..0b351f5d6 100644
--- a/src/tests/common.h
+++ b/src/tests/common.h
@@ -112,6 +112,9 @@ errno_t test_request_recv(struct tevent_req *req);
int test_ev_loop(struct sss_test_ctx *tctx);
+/* Mark the test as done with an error code */
+void test_ev_done(struct sss_test_ctx *tctx, errno_t ret);
+
bool ldb_modules_path_is_set(void);
DBusConnection *
diff --git a/src/tests/common_tev.c b/src/tests/common_tev.c
index 770f97d83..808efd459 100644
--- a/src/tests/common_tev.c
+++ b/src/tests/common_tev.c
@@ -83,3 +83,9 @@ int test_ev_loop(struct sss_test_ctx *tctx)
return tctx->error;
}
+
+void test_ev_done(struct sss_test_ctx *tctx, errno_t ret)
+{
+ tctx->error = ret;
+ tctx->done = true;
+}