From f79c4a947759e6760a6f4f7c8bafd2856bca9938 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 3 Oct 2014 16:11:08 +0200 Subject: TESTS: unit tests can use confdb without using sysdb --- src/tests/common_dom.c | 52 +++++++++++++++++++++++++++----------------------- 1 file 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; -- cgit