diff options
author | Lukas Slebodnik <lslebodn@redhat.com> | 2013-05-22 09:02:24 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-05-30 13:37:55 +0200 |
commit | b36153ce4c3eeb19274ce32e82949da446184406 (patch) | |
tree | e12b73e3421bb334ddea05fedab9572fe1178dfe /src | |
parent | d65f692d7b7639ed8ba0f5cffa4f88b68056739a (diff) | |
download | sssd-b36153ce4c3eeb19274ce32e82949da446184406.tar.gz sssd-b36153ce4c3eeb19274ce32e82949da446184406.tar.bz2 sssd-b36153ce4c3eeb19274ce32e82949da446184406.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/tests/common_dom.c | 8 | ||||
-rw-r--r-- | src/tests/simple_access-tests.c | 14 | ||||
-rw-r--r-- | 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 00e7f5ae..661271d3 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 4c784002..48ebea6f 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 b30f2ed4..db2d903d 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); } |