summaryrefslogtreecommitdiff
path: root/src/tests/common.h
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-02-12 13:18:00 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-03-08 22:19:26 +0100
commitda33a9d7742d45975bd97d33dd8ad04a843e7656 (patch)
tree15658387462574430ab72281c0a0759ae1060e1c /src/tests/common.h
parenta5077712fc8c24e8cad08207b7b5a6603bde6a7c (diff)
downloadsssd-da33a9d7742d45975bd97d33dd8ad04a843e7656.tar.gz
sssd-da33a9d7742d45975bd97d33dd8ad04a843e7656.tar.bz2
sssd-da33a9d7742d45975bd97d33dd8ad04a843e7656.zip
Add utility functions for tests that use sysdb or tevent.
There was shared code for several unit tests that connected to their own sysdb instance. This patch adds common code to run a generic request to completion or connect to a test sysdb.
Diffstat (limited to 'src/tests/common.h')
-rw-r--r--src/tests/common.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/tests/common.h b/src/tests/common.h
index f13181b7..b7eee46e 100644
--- a/src/tests/common.h
+++ b/src/tests/common.h
@@ -55,4 +55,44 @@ errno_t
compare_sdap_attr_maps(struct sdap_attr_map *map1, size_t size1,
struct sdap_attr_map *map2);
+/* A common test structure for tests that require a domain to be set up. */
+struct sss_test_ctx {
+ struct sysdb_ctx *sysdb;
+ struct confdb_ctx *confdb;
+ struct tevent_context *ev;
+ struct sss_domain_info *dom;
+
+ bool done;
+ int error;
+};
+
+struct sss_test_conf_param {
+ const char *key;
+ const char *value;
+};
+
+struct sss_test_ctx *
+create_dom_test_ctx(TALLOC_CTX *mem_ctx,
+ const char *tests_path,
+ const char *confdb_path,
+ const char *sysdb_path,
+ const char *domain_name,
+ const char *id_provider,
+ struct sss_test_conf_param *params);
+
+void test_dom_suite_setup(const char *tests_path);
+
+void test_dom_suite_cleanup(const char *tests_path,
+ const char *confdb_path,
+ const char *sysdb_path);
+
+struct tevent_req *
+test_request_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, errno_t err);
+
+#define test_req_succeed_send(mem_ctx, ev) test_request_send(mem_ctx, ev, 0)
+
+errno_t test_request_recv(struct tevent_req *req);
+
+int test_ev_loop(struct sss_test_ctx *tctx);
+
#endif /* !__TESTS_COMMON_H__ */