summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-12-24 11:54:03 +0100
committerStefan Metzmacher <metze@samba.org>2010-12-24 17:31:06 +0100
commitd81ceeb9833ec80d7ab21b34e4b3af3d79aeb845 (patch)
treeac2ce053040afd55df60b8c43de36c9e947ec200
parent769425662e51e561f2a8f20f3ae264ba38467817 (diff)
downloadsamba-d81ceeb9833ec80d7ab21b34e4b3af3d79aeb845.tar.gz
samba-d81ceeb9833ec80d7ab21b34e4b3af3d79aeb845.tar.bz2
samba-d81ceeb9833ec80d7ab21b34e4b3af3d79aeb845.zip
tdb:tdbtest: use TEST_DATA_PREFIX for files
metze
-rw-r--r--lib/tdb/tools/tdbtest.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/lib/tdb/tools/tdbtest.c b/lib/tdb/tools/tdbtest.c
index 416bc50a5b..44c78efda5 100644
--- a/lib/tdb/tools/tdbtest.c
+++ b/lib/tdb/tools/tdbtest.c
@@ -215,16 +215,38 @@ static void merge_test(void)
tdb_delete(db, key);
}
+static char *test_path(const char *filename)
+{
+ const char *prefix = getenv("TEST_DATA_PREFIX");
+
+ if (prefix) {
+ char *path = NULL;
+ int ret;
+
+ ret = asprintf(&path, "%s/%s", prefix, filename);
+ if (ret == -1) {
+ return NULL;
+ }
+ return path;
+ }
+
+ return strdup(filename);
+}
+
int main(int argc, const char *argv[])
{
int i, seed=0;
int loops = 10000;
int num_entries;
- char test_gdbm[] = "test.gdbm";
+ char test_gdbm[1] = "test.gdbm";
+ char *test_tdb;
- unlink("test.gdbm");
+ test_gdbm[0] = test_path("test.gdbm");
+ test_tdb = test_path("test.tdb");
- db = tdb_open("test.tdb", 0, TDB_CLEAR_IF_FIRST,
+ unlink(test_gdbm[0]);
+
+ db = tdb_open(test_tdb, 0, TDB_CLEAR_IF_FIRST,
O_RDWR | O_CREAT | O_TRUNC, 0600);
gdbm = gdbm_open(test_gdbm, 512, GDBM_WRITER|GDBM_NEWDB|GDBM_FAST,
0600, NULL);
@@ -261,5 +283,8 @@ static void merge_test(void)
tdb_close(db);
gdbm_close(gdbm);
+ free(test_gdbm[0]);
+ free(test_tdb);
+
return 0;
}