[SSSD] [PATCH] Cleanup db files after test run

Sumit Bose sbose at redhat.com
Tue Dec 15 16:36:21 UTC 2009


Ok this new version deletes the files only if there were no errors and
adds a missing dependency when sysdb-tests is build individually in a
clean tree.

bye,
Sumit
On Tue, Dec 15, 2009 at 06:41:48AM -0500, Stephen Gallagher wrote:
> Nack. Please make this conditional on success of all tests. If any
> tests fail, it can be useful to examine the contents of the DB files.
> 
> On Dec 15, 2009, at 6:38 AM, Sumit Bose <sbose at redhat.com> wrote:
> 
> > Hi,
> >
> > with this patch the two ldb files created by the sysdb test are
> > deleted
> > at the end of the test run. With this and the other two distcheck
> > patches applied 'make distcheck' should run flawlessly (again?).
> >
> > bye,
> > Sumit
> > <0001-Cleanup-db-files-after-test-run.patch>
> > _______________________________________________
> > sssd-devel mailing list
> > sssd-devel at lists.fedorahosted.org
> > https://fedorahosted.org/mailman/listinfo/sssd-devel
> _______________________________________________
> sssd-devel mailing list
> sssd-devel at lists.fedorahosted.org
> https://fedorahosted.org/mailman/listinfo/sssd-devel
-------------- next part --------------
From d669f4435d14cceaaba1616e12b96daf63b3c289 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose at redhat.com>
Date: Tue, 15 Dec 2009 10:37:27 +0100
Subject: [PATCH] Cleanup db files after test run

---
 server/Makefile.am         |    2 ++
 server/tests/sysdb-tests.c |   21 +++++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/server/Makefile.am b/server/Makefile.am
index 95d78ef..a7fd8c4 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -417,6 +417,8 @@ sss_groupmod_LDADD = \
 # Feature Tests #
 #################
 if HAVE_CHECK
+sysdb_tests_DEPENDENCIES = \
+    $(ldblib_LTLIBRARIES)
 sysdb_tests_SOURCES = \
     tests/sysdb-tests.c \
     $(SSSD_UTIL_OBJ)
diff --git a/server/tests/sysdb-tests.c b/server/tests/sysdb-tests.c
index 70972ca..ace0343 100644
--- a/server/tests/sysdb-tests.c
+++ b/server/tests/sysdb-tests.c
@@ -31,6 +31,7 @@
 #include "db/sysdb_private.h"
 
 #define TESTS_PATH "tests_sysdb"
+#define TEST_CONF_FILE "tests_conf.ldb"
 
 #define TEST_ATTR_NAME "test_attr_name"
 #define TEST_ATTR_VALUE "test_attr_value"
@@ -86,7 +87,7 @@ static int setup_sysdb_tests(struct sysdb_test_ctx **ctx)
         return EIO;
     }
 
-    conf_db = talloc_asprintf(test_ctx, "%s/tests_conf.ldb", TESTS_PATH);
+    conf_db = talloc_asprintf(test_ctx, "%s/%s", TESTS_PATH, TEST_CONF_FILE);
     if (conf_db == NULL) {
         fail("Out of memory, aborting!");
         talloc_free(test_ctx);
@@ -3066,5 +3067,21 @@ int main(int argc, const char *argv[]) {
     srunner_run_all(sr, CK_ENV);
     failure_count = srunner_ntests_failed(sr);
     srunner_free(sr);
-    return (failure_count==0 ? EXIT_SUCCESS : EXIT_FAILURE);
+    if (failure_count == 0) {
+        ret = unlink(TESTS_PATH"/"TEST_CONF_FILE);
+        if (ret != EOK) {
+            fprintf(stderr, "Could not delete the test config ldb file (%d) (%s)\n",
+                    errno, strerror(errno));
+            return EXIT_FAILURE;
+        }
+        ret = unlink(TESTS_PATH"/"LOCAL_SYSDB_FILE);
+        if (ret != EOK) {
+            fprintf(stderr, "Could not delete the test config ldb file (%d) (%s)\n",
+                    errno, strerror(errno));
+            return EXIT_FAILURE;
+        }
+
+        return EXIT_SUCCESS;
+    }
+    return  EXIT_FAILURE;
 }
-- 
1.6.5.2



More information about the sssd-devel mailing list