summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2014-10-03 16:11:08 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-10-22 23:31:07 +0200
commit9dd73e9ad92b2905271cd5466ac237c829f1a608 (patch)
tree4e95dc63d82969d2fce61b0b7fd7350bec8109a2 /src/tests
parenta2fbe2b9de23e91835c10153d048c1b0c5ec7fee (diff)
downloadsssd-9dd73e9ad92b2905271cd5466ac237c829f1a608.tar.gz
sssd-9dd73e9ad92b2905271cd5466ac237c829f1a608.tar.xz
sssd-9dd73e9ad92b2905271cd5466ac237c829f1a608.zip
TESTS: Unit tests can use confdb without using sysdb
Previously, if a test used the utility functions for setting up a test, it had to use both sysdb and confdb. Some unit tests only need to use of of them, for example the unit tests for the server module only need confdb. Reviewed-by: Pavel Reichl <preichl@redhat.com>
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/common_dom.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/src/tests/common_dom.c b/src/tests/common_dom.c
index b96db8d90..bc69c5a09 100644
--- a/src/tests/common_dom.c
+++ b/src/tests/common_dom.c
@@ -159,34 +159,38 @@ void test_dom_suite_cleanup(const char *tests_path,
return;
}
- conf_db = talloc_asprintf(tmp_ctx, "%s/%s", tests_path, confdb_path);
- if (!conf_db) {
- DEBUG(SSSDBG_CRIT_FAILURE,
- "Could not construct conf_db path\n");
- goto done;
- }
+ if (confdb_path != NULL) {
+ conf_db = talloc_asprintf(tmp_ctx, "%s/%s", tests_path, confdb_path);
+ if (!conf_db) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Could not construct conf_db path\n");
+ goto done;
+ }
- errno = 0;
- ret = unlink(conf_db);
- if (ret != 0 && errno != ENOENT) {
- DEBUG(SSSDBG_CRIT_FAILURE,
- "Could not delete the test config ldb file (%d) (%s)\n",
- errno, strerror(errno));
+ errno = 0;
+ ret = unlink(conf_db);
+ if (ret != 0 && errno != ENOENT) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Could not delete the test config ldb file (%d) (%s)\n",
+ errno, strerror(errno));
+ }
}
- sys_db = talloc_asprintf(tmp_ctx, "%s/%s", tests_path, sysdb_path);
- if (!sys_db) {
- DEBUG(SSSDBG_CRIT_FAILURE,
- "Could not construct sys_db path\n");
- goto done;
- }
+ if (sysdb_path != NULL) {
+ sys_db = talloc_asprintf(tmp_ctx, "%s/%s", tests_path, sysdb_path);
+ if (!sys_db) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Could not construct sys_db path\n");
+ goto done;
+ }
- errno = 0;
- ret = unlink(sys_db);
- if (ret != 0 && errno != ENOENT) {
- DEBUG(SSSDBG_CRIT_FAILURE,
- "Could not delete the test ldb file (%d) (%s)\n",
- errno, strerror(errno));
+ errno = 0;
+ ret = unlink(sys_db);
+ if (ret != 0 && errno != ENOENT) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Could not delete the test ldb file (%d) (%s)\n",
+ errno, strerror(errno));
+ }
}
errno = 0;