From b36153ce4c3eeb19274ce32e82949da446184406 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Wed, 22 May 2013 09:02:24 +0200 Subject: Remove empty directories after tests run. Empty directory tests_path is removed in function test_dom_suite_cleanup. Function test_dom_suite_cleanup is reused in other tests. --- src/tests/common_dom.c | 8 ++++++++ src/tests/simple_access-tests.c | 14 ++------------ src/tests/sysdb-tests.c | 17 ++--------------- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/src/tests/common_dom.c b/src/tests/common_dom.c index 00e7f5ae2..661271d3b 100644 --- a/src/tests/common_dom.c +++ b/src/tests/common_dom.c @@ -156,6 +156,14 @@ void test_dom_suite_cleanup(const char *tests_path, errno, strerror(errno))); } + errno = 0; + ret = rmdir(tests_path); + if (ret != 0) { + DEBUG(SSSDBG_CRIT_FAILURE, + ("Could not delete the test dir (%d) (%s)\n", + errno, strerror(errno))); + } + talloc_free(conf_db); talloc_free(sys_db); } diff --git a/src/tests/simple_access-tests.c b/src/tests/simple_access-tests.c index 4c7840026..48ebea6f7 100644 --- a/src/tests/simple_access-tests.c +++ b/src/tests/simple_access-tests.c @@ -540,7 +540,6 @@ int main(int argc, const char *argv[]) int opt; poptContext pc; int number_failed; - int ret; struct poptOption long_options[] = { POPT_AUTOHELP @@ -573,17 +572,8 @@ int main(int argc, const char *argv[]) number_failed = srunner_ntests_failed(sr); srunner_free(sr); - 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; + if (number_failed == 0) { + test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_FILE, LOCAL_SYSDB_FILE); } return (number_failed==0 ? EXIT_SUCCESS : EXIT_FAILURE); diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c index b30f2ed4c..db2d903dd 100644 --- a/src/tests/sysdb-tests.c +++ b/src/tests/sysdb-tests.c @@ -5293,20 +5293,7 @@ int main(int argc, const char *argv[]) { failure_count = srunner_ntests_failed(sr); srunner_free(sr); if (failure_count == 0 && !no_cleanup) { - 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; + test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_FILE, LOCAL_SYSDB_FILE); } - return EXIT_FAILURE; + return (failure_count==0 ? EXIT_SUCCESS : EXIT_FAILURE); } -- cgit