Skip to content
Snippets Groups Projects
Commit 8c7d28fb authored by Daniel Salzman's avatar Daniel Salzman
Browse files

tests: remove temporary database

parent 6bfc0840
Branches
Tags
No related merge requests found
......@@ -14,6 +14,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <dirent.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
......@@ -172,7 +173,22 @@ int main(int argc, char *argv[])
namedb_test_set(nkeys, keys, dbid, namedb_lmdb_api(), &pool);
namedb_test_set(nkeys, keys, NULL, namedb_trie_api(), &pool);
/* Cleanup */
/* Cleanup. */
mp_delete(pool.ctx);
/* Cleanup temporary DB. */
DIR *dir = opendir(dbid);
struct dirent *dp;
while ((dp = readdir(dir)) != NULL) {
if (dp->d_name[0] == '.') {
continue;
}
char *file = sprintf_alloc("%s/%s", dbid, dp->d_name);
remove(file);
free(file);
}
closedir(dir);
remove(dbid);
return 0;
}
......@@ -14,11 +14,13 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <dirent.h>
#include <stdlib.h>
#include <time.h>
#include <tap/basic.h>
#include "libknot/common.h"
#include "common/mem.h"
#include "common/namedb/namedb.h"
#include "common/namedb/namedb_lmdb.h"
#include "knot/zone/timers.h"
......@@ -119,6 +121,23 @@ int main(int argc, char *argv[])
zone_free(&zone_2);
close_timers_db(db);
// Cleanup temporary DB.
char *timers_dir = sprintf_alloc("%s/timers", dbid);
DIR *dir = opendir(timers_dir);
struct dirent *dp;
while ((dp = readdir(dir)) != NULL) {
if (dp->d_name[0] == '.') {
continue;
}
char *file = sprintf_alloc("%s/%s", timers_dir, dp->d_name);
remove(file);
free(file);
}
closedir(dir);
remove(timers_dir);
free(timers_dir);
remove(dbid);
return EXIT_SUCCESS;
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment