|
|
905b4d |
From 9dd73e9ad92b2905271cd5466ac237c829f1a608 Mon Sep 17 00:00:00 2001
|
|
|
905b4d |
From: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
905b4d |
Date: Fri, 3 Oct 2014 16:11:08 +0200
|
|
|
905b4d |
Subject: [PATCH 07/22] TESTS: Unit tests can use confdb without using sysdb
|
|
|
905b4d |
|
|
|
905b4d |
Previously, if a test used the utility functions for setting up a test,
|
|
|
905b4d |
it had to use both sysdb and confdb. Some unit tests only need to use of
|
|
|
905b4d |
of them, for example the unit tests for the server module only need
|
|
|
905b4d |
confdb.
|
|
|
905b4d |
|
|
|
905b4d |
Reviewed-by: Pavel Reichl <preichl@redhat.com>
|
|
|
905b4d |
---
|
|
|
905b4d |
src/tests/common_dom.c | 52 +++++++++++++++++++++++++++-----------------------
|
|
|
905b4d |
1 file changed, 28 insertions(+), 24 deletions(-)
|
|
|
905b4d |
|
|
|
905b4d |
diff --git a/src/tests/common_dom.c b/src/tests/common_dom.c
|
|
|
905b4d |
index b96db8d9084fea9ec07be88d9c5f72c6885d8f09..bc69c5a093e17fc56e42ccedd998ab6434d85003 100644
|
|
|
905b4d |
--- a/src/tests/common_dom.c
|
|
|
905b4d |
+++ b/src/tests/common_dom.c
|
|
|
905b4d |
@@ -159,34 +159,38 @@ void test_dom_suite_cleanup(const char *tests_path,
|
|
|
905b4d |
return;
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
- conf_db = talloc_asprintf(tmp_ctx, "%s/%s", tests_path, confdb_path);
|
|
|
905b4d |
- if (!conf_db) {
|
|
|
905b4d |
- DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
- "Could not construct conf_db path\n");
|
|
|
905b4d |
- goto done;
|
|
|
905b4d |
- }
|
|
|
905b4d |
+ if (confdb_path != NULL) {
|
|
|
905b4d |
+ conf_db = talloc_asprintf(tmp_ctx, "%s/%s", tests_path, confdb_path);
|
|
|
905b4d |
+ if (!conf_db) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
+ "Could not construct conf_db path\n");
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
|
|
|
905b4d |
- errno = 0;
|
|
|
905b4d |
- ret = unlink(conf_db);
|
|
|
905b4d |
- if (ret != 0 && errno != ENOENT) {
|
|
|
905b4d |
- DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
- "Could not delete the test config ldb file (%d) (%s)\n",
|
|
|
905b4d |
- errno, strerror(errno));
|
|
|
905b4d |
+ errno = 0;
|
|
|
905b4d |
+ ret = unlink(conf_db);
|
|
|
905b4d |
+ if (ret != 0 && errno != ENOENT) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
+ "Could not delete the test config ldb file (%d) (%s)\n",
|
|
|
905b4d |
+ errno, strerror(errno));
|
|
|
905b4d |
+ }
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
- sys_db = talloc_asprintf(tmp_ctx, "%s/%s", tests_path, sysdb_path);
|
|
|
905b4d |
- if (!sys_db) {
|
|
|
905b4d |
- DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
- "Could not construct sys_db path\n");
|
|
|
905b4d |
- goto done;
|
|
|
905b4d |
- }
|
|
|
905b4d |
+ if (sysdb_path != NULL) {
|
|
|
905b4d |
+ sys_db = talloc_asprintf(tmp_ctx, "%s/%s", tests_path, sysdb_path);
|
|
|
905b4d |
+ if (!sys_db) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
+ "Could not construct sys_db path\n");
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
|
|
|
905b4d |
- errno = 0;
|
|
|
905b4d |
- ret = unlink(sys_db);
|
|
|
905b4d |
- if (ret != 0 && errno != ENOENT) {
|
|
|
905b4d |
- DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
- "Could not delete the test ldb file (%d) (%s)\n",
|
|
|
905b4d |
- errno, strerror(errno));
|
|
|
905b4d |
+ errno = 0;
|
|
|
905b4d |
+ ret = unlink(sys_db);
|
|
|
905b4d |
+ if (ret != 0 && errno != ENOENT) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
+ "Could not delete the test ldb file (%d) (%s)\n",
|
|
|
905b4d |
+ errno, strerror(errno));
|
|
|
905b4d |
+ }
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
errno = 0;
|
|
|
905b4d |
--
|
|
|
905b4d |
1.9.3
|
|
|
905b4d |
|