summaryrefslogtreecommitdiff
path: root/lib/tdb2/test
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-09-14 07:49:13 +0930
committerRusty Russell <rusty@rustcorp.com.au>2011-09-14 07:49:13 +0930
commitcbad6e2c140e59a6ec653bcfe773599a57a5042f (patch)
tree84e7605464b76c0fabb18b89c7395f41d7514e5a /lib/tdb2/test
parent333a23fa995faf1735e5234272f56b792d91a877 (diff)
downloadsamba-cbad6e2c140e59a6ec653bcfe773599a57a5042f.tar.gz
samba-cbad6e2c140e59a6ec653bcfe773599a57a5042f.tar.bz2
samba-cbad6e2c140e59a6ec653bcfe773599a57a5042f.zip
tdb2: unify tdb1_open into tdb_open
Finally, we gut tdb1_open() to the tdb1-specific parts, and call it from tdb_open if they specify the TDB_VERSION1 flag or the version is a TDB1. We also unify tdb_close(), based on the TDB_VERSION1 flag. Note that tdb_open(TDB_VERSION1) will fail on an existing tdb if it's a TDB2. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit c8c3b3568677e8b0105f84e4ab068c580faf4591)
Diffstat (limited to 'lib/tdb2/test')
-rw-r--r--lib/tdb2/test/failtest_helper.h6
-rw-r--r--lib/tdb2/test/run-tdb1-3G-file.c6
-rw-r--r--lib/tdb2/test/run-tdb1-bad-tdb-header.c27
-rw-r--r--lib/tdb2/test/run-tdb1-check.c25
-rw-r--r--lib/tdb2/test/run-tdb1-corrupt.c12
-rw-r--r--lib/tdb2/test/run-tdb1-die-during-transaction.c10
-rw-r--r--lib/tdb2/test/run-tdb1-endian.c12
-rw-r--r--lib/tdb2/test/run-tdb1-hashsize.c16
-rw-r--r--lib/tdb2/test/run-tdb1-incompatible.c76
-rw-r--r--lib/tdb2/test/run-tdb1-nested-transactions.c13
-rw-r--r--lib/tdb2/test/run-tdb1-nested-traverse.c6
-rw-r--r--lib/tdb2/test/run-tdb1-no-lock-during-traverse.c8
-rw-r--r--lib/tdb2/test/run-tdb1-oldhash.c24
-rw-r--r--lib/tdb2/test/run-tdb1-open-during-transaction.c10
-rw-r--r--lib/tdb2/test/run-tdb1-readonly-check.c14
-rw-r--r--lib/tdb2/test/run-tdb1-rwlock-check.c8
-rw-r--r--lib/tdb2/test/run-tdb1-summary.c6
-rw-r--r--lib/tdb2/test/run-tdb1-traverse-in-transaction.c8
-rw-r--r--lib/tdb2/test/run-tdb1-wronghash-fail.c59
-rw-r--r--lib/tdb2/test/run-tdb1-zero-append.c6
-rw-r--r--lib/tdb2/test/run-tdb1.c6
-rw-r--r--lib/tdb2/test/tdb1-external-agent.c5
22 files changed, 179 insertions, 184 deletions
diff --git a/lib/tdb2/test/failtest_helper.h b/lib/tdb2/test/failtest_helper.h
index 403ff64758..54529fe893 100644
--- a/lib/tdb2/test/failtest_helper.h
+++ b/lib/tdb2/test/failtest_helper.h
@@ -4,9 +4,9 @@
#include <stdbool.h>
/* FIXME: Check these! */
-#define INITIAL_TDB_MALLOC "open.c", 367, FAILTEST_MALLOC
-#define URANDOM_OPEN "open.c", 61, FAILTEST_OPEN
-#define URANDOM_READ "open.c", 41, FAILTEST_READ
+#define INITIAL_TDB_MALLOC "open.c", 395, FAILTEST_MALLOC
+#define URANDOM_OPEN "open.c", 62, FAILTEST_OPEN
+#define URANDOM_READ "open.c", 42, FAILTEST_READ
bool exit_check_log(struct failtest_call *history, unsigned num);
bool failmatch(const struct failtest_call *call,
diff --git a/lib/tdb2/test/run-tdb1-3G-file.c b/lib/tdb2/test/run-tdb1-3G-file.c
index 4edaa5d464..9194d3a319 100644
--- a/lib/tdb2/test/run-tdb1-3G-file.c
+++ b/lib/tdb2/test/run-tdb1-3G-file.c
@@ -71,8 +71,8 @@ int main(int argc, char *argv[])
hsize.tdb1_hashsize.hsize = 1024;
plan_tests(24);
- tdb = tdb1_open("run-36-file.tdb", TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
+ tdb = tdb_open("run-36-file.tdb1", TDB_VERSION1,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
tdb->tdb1.io = &large_io_methods;
@@ -119,7 +119,7 @@ int main(int argc, char *argv[])
ok1(tdb1_transaction_commit(tdb) == 0);
ok1(tdb1_traverse(tdb, test_traverse, &orig_data) == 1);
- tdb1_close(tdb);
+ tdb_close(tdb);
return exit_status();
}
diff --git a/lib/tdb2/test/run-tdb1-bad-tdb-header.c b/lib/tdb2/test/run-tdb1-bad-tdb-header.c
index f8bee0b45c..c1d76740cc 100644
--- a/lib/tdb2/test/run-tdb1-bad-tdb-header.c
+++ b/lib/tdb2/test/run-tdb1-bad-tdb-header.c
@@ -16,20 +16,25 @@ int main(int argc, char *argv[])
hsize.tdb1_hashsize.hsize = 1024;
plan_tests(11);
- /* Can open fine if complete crap, as long as O_CREAT. */
- fd = open("run-bad-tdb-header.tdb", O_RDWR|O_CREAT|O_TRUNC, 0600);
+ /* Cannot open fine if complete crap, even with O_CREAT. */
+ fd = open("run-bad-tdb-header.tdb1", O_RDWR|O_CREAT|O_TRUNC, 0600);
ok1(fd >= 0);
ok1(write(fd, "hello world", 11) == 11);
close(fd);
- tdb = tdb1_open("run-bad-tdb-header.tdb", 0, O_RDWR, 0, &tap_log_attr);
+ tdb = tdb_open("run-bad-tdb-header.tdb1", 0, O_RDWR, 0, &tap_log_attr);
ok1(!tdb);
- tdb = tdb1_open("run-bad-tdb-header.tdb", 0, O_CREAT|O_RDWR,
+ tdb = tdb_open("run-bad-tdb-header.tdb1", 0, O_CREAT|O_RDWR,
0600, &hsize);
+ ok1(!tdb);
+
+ /* With truncate, will be fine. */
+ tdb = tdb_open("run-bad-tdb-header.tdb1", TDB_VERSION1,
+ O_RDWR|O_CREAT|O_TRUNC, 0600, &hsize);
ok1(tdb);
- tdb1_close(tdb);
+ tdb_close(tdb);
/* Now, with wrong version it should *not* overwrite. */
- fd = open("run-bad-tdb-header.tdb", O_RDWR);
+ fd = open("run-bad-tdb-header.tdb1", O_RDWR);
ok1(fd >= 0);
ok1(read(fd, &hdr, sizeof(hdr)) == sizeof(hdr));
ok1(hdr.version == TDB1_VERSION);
@@ -38,16 +43,10 @@ int main(int argc, char *argv[])
ok1(write(fd, &hdr, sizeof(hdr)) == sizeof(hdr));
close(fd);
- tdb = tdb1_open("run-bad-tdb-header.tdb", 0, O_RDWR|O_CREAT,
- 0600, &hsize);
+ tdb = tdb_open("run-bad-tdb-header.tdb1", TDB_VERSION1, O_RDWR|O_CREAT,
+ 0600, &hsize);
ok1(errno == EIO);
ok1(!tdb);
- /* With truncate, will be fine. */
- tdb = tdb1_open("run-bad-tdb-header.tdb", 0,
- O_RDWR|O_CREAT|O_TRUNC, 0600, &hsize);
- ok1(tdb);
- tdb1_close(tdb);
-
return exit_status();
}
diff --git a/lib/tdb2/test/run-tdb1-check.c b/lib/tdb2/test/run-tdb1-check.c
index f188dc928e..8a0532c4be 100644
--- a/lib/tdb2/test/run-tdb1-check.c
+++ b/lib/tdb2/test/run-tdb1-check.c
@@ -15,8 +15,8 @@ int main(int argc, char *argv[])
hsize.tdb1_hashsize.hsize = 1;
plan_tests(13);
- tdb = tdb1_open("run-check.tdb", TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
+ tdb = tdb_open("run-check.tdb1", TDB_VERSION1,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
@@ -28,33 +28,32 @@ int main(int argc, char *argv[])
ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
- tdb = tdb1_open("run-check.tdb", 0, O_RDWR, 0,
- &tap_log_attr);
+ tdb = tdb_open("run-check.tdb1", TDB_VERSION1, O_RDWR, 0, &tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
- tdb = tdb1_open("test/tdb1.corrupt", 0, O_RDWR, 0,
+ tdb = tdb_open("test/tdb1.corrupt", TDB_VERSION1, O_RDWR, 0,
&tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == -1);
ok1(tdb_error(tdb) == TDB_ERR_CORRUPT);
- tdb1_close(tdb);
+ tdb_close(tdb);
/* Big and little endian should work! */
- tdb = tdb1_open("test/old-nohash-le.tdb1", 0, O_RDWR, 0,
- &tap_log_attr);
+ tdb = tdb_open("test/old-nohash-le.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
- tdb = tdb1_open("test/old-nohash-be.tdb1", 0, O_RDWR, 0,
+ tdb = tdb_open("test/old-nohash-be.tdb1", TDB_VERSION1, O_RDWR, 0,
&tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
return exit_status();
}
diff --git a/lib/tdb2/test/run-tdb1-corrupt.c b/lib/tdb2/test/run-tdb1-corrupt.c
index 8647ecccba..f87afd8a6a 100644
--- a/lib/tdb2/test/run-tdb1-corrupt.c
+++ b/lib/tdb2/test/run-tdb1-corrupt.c
@@ -102,22 +102,22 @@ int main(int argc, char *argv[])
plan_tests(4);
/* This should use mmap. */
- tdb = tdb1_open("run-corrupt.tdb", TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
+ tdb = tdb_open("run-corrupt.tdb1", TDB_VERSION1,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
if (!tdb)
abort();
check_test(tdb);
- tdb1_close(tdb);
+ tdb_close(tdb);
/* This should not. */
- tdb = tdb1_open("run-corrupt.tdb", TDB_NOMMAP,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
+ tdb = tdb_open("run-corrupt.tdb1", TDB_VERSION1|TDB_NOMMAP,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
if (!tdb)
abort();
check_test(tdb);
- tdb1_close(tdb);
+ tdb_close(tdb);
return exit_status();
}
diff --git a/lib/tdb2/test/run-tdb1-die-during-transaction.c b/lib/tdb2/test/run-tdb1-die-during-transaction.c
index 933d748686..4f54f6cbc6 100644
--- a/lib/tdb2/test/run-tdb1-die-during-transaction.c
+++ b/lib/tdb2/test/run-tdb1-die-during-transaction.c
@@ -28,7 +28,7 @@ static int ftruncate_check(int fd, off_t length);
static bool in_transaction;
static int target, current;
static jmp_buf jmpbuf;
-#define TEST_DBNAME "run-die-during-transaction.tdb"
+#define TEST_DBNAME "run-die-during-transaction.tdb1"
#define KEY_STRING "helloworld"
static void maybe_die(int fd)
@@ -94,8 +94,8 @@ static bool test_death(enum operation op, struct agent *agent)
current = target = 0;
reset:
unlink(TEST_DBNAME);
- tdb = tdb1_open(TEST_DBNAME, TDB_NOMMAP,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
+ tdb = tdb_open(TEST_DBNAME, TDB_VERSION1|TDB_NOMMAP,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
if (setjmp(jmpbuf) != 0) {
/* We're partway through. Simulate our death. */
@@ -144,7 +144,7 @@ reset:
/* Suppress logging as this tries to use closed fd. */
suppress_logging = true;
suppress_lockcheck1 = true;
- tdb1_close(tdb);
+ tdb_close(tdb);
suppress_logging = false;
suppress_lockcheck1 = false;
target++;
@@ -183,7 +183,7 @@ reset:
/* We made it! */
diag("Completed %u runs", current);
- tdb1_close(tdb);
+ tdb_close(tdb);
ret = external_agent_operation1(agent, CLOSE, "");
if (ret != SUCCESS) {
diag("Step %u close failed = %s", current,
diff --git a/lib/tdb2/test/run-tdb1-endian.c b/lib/tdb2/test/run-tdb1-endian.c
index e1b92eeace..5e529ce2d0 100644
--- a/lib/tdb2/test/run-tdb1-endian.c
+++ b/lib/tdb2/test/run-tdb1-endian.c
@@ -15,9 +15,9 @@ int main(int argc, char *argv[])
hsize.tdb1_hashsize.hsize = 1024;
plan_tests(13);
- tdb = tdb1_open("run-endian.tdb",
- TDB_CONVERT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
+ tdb = tdb_open("run-endian.tdb1",
+ TDB_VERSION1|TDB_CONVERT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
key.dsize = strlen("hi");
@@ -40,10 +40,10 @@ int main(int argc, char *argv[])
key.dsize++;
data = tdb1_fetch(tdb, key);
ok1(data.dptr == NULL);
- tdb1_close(tdb);
+ tdb_close(tdb);
/* Reopen: should read it */
- tdb = tdb1_open("run-endian.tdb", 0, O_RDWR, 0, NULL);
+ tdb = tdb_open("run-endian.tdb1", 0, O_RDWR, 0, NULL);
ok1(tdb);
key.dsize = strlen("hi");
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
ok1(data.dsize == strlen("world"));
ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
free(data.dptr);
- tdb1_close(tdb);
+ tdb_close(tdb);
return exit_status();
}
diff --git a/lib/tdb2/test/run-tdb1-hashsize.c b/lib/tdb2/test/run-tdb1-hashsize.c
index fc48c23076..8a78196c82 100644
--- a/lib/tdb2/test/run-tdb1-hashsize.c
+++ b/lib/tdb2/test/run-tdb1-hashsize.c
@@ -14,8 +14,8 @@ int main(int argc, char *argv[])
hsize.tdb1_hashsize.hsize = 1024;
plan_tests(14);
- tdb = tdb1_open("run-tdb1-hashsize.tdb1", TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
+ tdb = tdb_open("run-tdb1-hashsize.tdb1", TDB_VERSION1,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
h2.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
ok1(tdb_get_attribute(tdb, &h2) == TDB_SUCCESS);
@@ -23,8 +23,8 @@ int main(int argc, char *argv[])
tdb_close(tdb);
/* Can't specify TDB_ATTRIBUTE_TDB1_HASHSIZE without O_CREAT */
- tdb = tdb1_open("run-tdb1-hashsize.tdb1", TDB_DEFAULT,
- O_RDWR, 0600, &hsize);
+ tdb = tdb_open("run-tdb1-hashsize.tdb1", TDB_VERSION1,
+ O_RDWR, 0600, &hsize);
ok1(!tdb);
ok1(tap_log_messages == 1);
@@ -35,8 +35,8 @@ int main(int argc, char *argv[])
ok1(tap_log_messages == 2);
/* We can get attribute even if we didn't set it though. */
- tdb = tdb1_open("run-tdb1-hashsize.tdb1", TDB_DEFAULT,
- O_RDWR, 0600, &tap_log_attr);
+ tdb = tdb_open("run-tdb1-hashsize.tdb1", TDB_DEFAULT,
+ O_RDWR, 0600, &tap_log_attr);
ok1(tdb);
memset(&h2, 0, sizeof(h2));
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
tdb_close(tdb);
/* Check for default hash size. */
- tdb = tdb1_open("run-tdb1-hashsize.tdb1", TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
+ tdb = tdb_open("run-tdb1-hashsize.tdb1", TDB_VERSION1,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
ok1(tdb);
memset(&h2, 0, sizeof(h2));
diff --git a/lib/tdb2/test/run-tdb1-incompatible.c b/lib/tdb2/test/run-tdb1-incompatible.c
index 48f796dbf4..350c78b2b4 100644
--- a/lib/tdb2/test/run-tdb1-incompatible.c
+++ b/lib/tdb2/test/run-tdb1-incompatible.c
@@ -83,86 +83,86 @@ int main(int argc, char *argv[])
/* Create an old-style hash. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb", flags,
- O_CREAT|O_RDWR|O_TRUNC, 0600, &log_attr);
+ tdb = tdb_open("run-incompatible.tdb1", flags|TDB_VERSION1,
+ O_CREAT|O_RDWR|O_TRUNC, 0600, &log_attr);
ok1(tdb);
ok1(log_count == 0);
d.dptr = (void *)"Hello";
d.dsize = 5;
ok1(tdb1_store(tdb, d, d, TDB_INSERT) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
/* Should not have marked rwlocks field. */
- ok1(hdr_rwlocks("run-incompatible.tdb") == 0);
+ ok1(hdr_rwlocks("run-incompatible.tdb1") == 0);
/* We can still open any old-style with incompat hash. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb",
- TDB_DEFAULT,
- O_RDWR, 0600, &incompat_hash_attr);
+ tdb = tdb_open("run-incompatible.tdb1",
+ TDB_VERSION1,
+ O_RDWR, 0600, &incompat_hash_attr);
ok1(tdb);
ok1(log_count == 0);
d = tdb1_fetch(tdb, d);
ok1(d.dsize == 5);
free(d.dptr);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
log_count = 0;
- tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, O_RDONLY,
- 0, &jhash_attr);
+ tdb = tdb_open("test/jenkins-le-hash.tdb1",
+ TDB_VERSION1, O_RDONLY, 0, &jhash_attr);
ok1(tdb);
ok1(log_count == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
log_count = 0;
- tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, O_RDONLY,
- 0, &jhash_attr);
+ tdb = tdb_open("test/jenkins-be-hash.tdb1",
+ TDB_VERSION1, O_RDONLY, 0, &jhash_attr);
ok1(tdb);
ok1(log_count == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
/* OK, now create with incompatible hash. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb",
- flags,
- O_CREAT|O_RDWR|O_TRUNC, 0600,
- &incompat_hash_attr);
+ tdb = tdb_open("run-incompatible.tdb1",
+ flags|TDB_VERSION1,
+ O_CREAT|O_RDWR|O_TRUNC, 0600,
+ &incompat_hash_attr);
ok1(tdb);
ok1(log_count == 0);
d.dptr = (void *)"Hello";
d.dsize = 5;
ok1(tdb1_store(tdb, d, d, TDB_INSERT) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
/* Should have marked rwlocks field. */
- ok1(hdr_rwlocks("run-incompatible.tdb") == rwmagic);
+ ok1(hdr_rwlocks("run-incompatible.tdb1") == rwmagic);
/* Cannot open with old hash. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb", 0,
- O_RDWR, 0600, &ohash_attr);
+ tdb = tdb_open("run-incompatible.tdb1", TDB_VERSION1,
+ O_RDWR, 0600, &ohash_attr);
ok1(!tdb);
ok1(log_count == 1);
/* Can open with jenkins hash. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb", 0,
- O_RDWR, 0600, &jhash_attr);
+ tdb = tdb_open("run-incompatible.tdb1", TDB_VERSION1,
+ O_RDWR, 0600, &jhash_attr);
ok1(tdb);
ok1(log_count == 0);
d = tdb1_fetch(tdb, d);
ok1(d.dsize == 5);
free(d.dptr);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
/* Can open by letting it figure it out itself. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb", 0,
- O_RDWR, 0600, &log_attr);
+ tdb = tdb_open("run-incompatible.tdb1", TDB_VERSION1,
+ O_RDWR, 0600, &log_attr);
ok1(tdb);
ok1(log_count == 0);
d.dptr = (void *)"Hello";
@@ -171,42 +171,42 @@ int main(int argc, char *argv[])
ok1(d.dsize == 5);
free(d.dptr);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
/* FIXME: Not possible with TDB2 :( */
/* We can also use incompatible hash with other hashes. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb",
- flags,
- O_CREAT|O_RDWR|O_TRUNC, 0600, &dumbhash_attr);
+ tdb = tdb_open("run-incompatible.tdb1",
+ flags|TDB_VERSION1,
+ O_CREAT|O_RDWR|O_TRUNC, 0600, &dumbhash_attr);
ok1(tdb);
ok1(log_count == 0);
d.dptr = (void *)"Hello";
d.dsize = 5;
ok1(tdb1_store(tdb, d, d, TDB_INSERT) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
/* FIXME: Should have marked rwlocks field. */
- ok1(hdr_rwlocks("run-incompatible.tdb") != rwmagic);
+ ok1(hdr_rwlocks("run-incompatible.tdb1") != rwmagic);
/* It should not open if we don't specify. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb", 0, O_RDWR, 0,
- &log_attr);
+ tdb = tdb_open("run-incompatible.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &log_attr);
ok1(!tdb);
ok1(log_count == 1);
/* Should reopen with correct hash. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb", 0, O_RDWR, 0,
- &dumbhash_attr);
+ tdb = tdb_open("run-incompatible.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &dumbhash_attr);
ok1(tdb);
ok1(log_count == 0);
d = tdb1_fetch(tdb, d);
ok1(d.dsize == 5);
free(d.dptr);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
}
return exit_status();
diff --git a/lib/tdb2/test/run-tdb1-nested-transactions.c b/lib/tdb2/test/run-tdb1-nested-transactions.c
index 79b9b5683b..63fa1de79f 100644
--- a/lib/tdb2/test/run-tdb1-nested-transactions.c
+++ b/lib/tdb2/test/run-tdb1-nested-transactions.c
@@ -19,9 +19,8 @@ int main(int argc, char *argv[])
key.dsize = strlen("hi");
key.dptr = (void *)"hi";
- tdb = tdb1_open("run-nested-transactions.tdb",
- TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
+ tdb = tdb_open("run-nested-transactions.tdb1",
+ TDB_VERSION1, O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
/* No nesting by default. */
@@ -45,10 +44,10 @@ int main(int argc, char *argv[])
ok1(data.dsize == strlen("world"));
ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
free(data.dptr);
- tdb1_close(tdb);
+ tdb_close(tdb);
- tdb = tdb1_open("run-nested-transactions.tdb",
- TDB_ALLOW_NESTING, O_RDWR, 0, &tap_log_attr);
+ tdb = tdb_open("run-nested-transactions.tdb1",
+ TDB_ALLOW_NESTING, O_RDWR, 0, &tap_log_attr);
ok1(tdb);
ok1(tdb1_transaction_start(tdb) == 0);
@@ -67,7 +66,7 @@ int main(int argc, char *argv[])
ok1(!tdb1_exists(tdb, key));
ok1(tdb1_transaction_commit(tdb) == 0);
ok1(!tdb1_exists(tdb, key));
- tdb1_close(tdb);
+ tdb_close(tdb);
return exit_status();
}
diff --git a/lib/tdb2/test/run-tdb1-nested-traverse.c b/lib/tdb2/test/run-tdb1-nested-traverse.c
index 0d58a569ac..0225620083 100644
--- a/lib/tdb2/test/run-tdb1-nested-traverse.c
+++ b/lib/tdb2/test/run-tdb1-nested-traverse.c
@@ -61,8 +61,8 @@ int main(int argc, char *argv[])
if (!agent)
err(1, "preparing agent");
- tdb = tdb1_open("run-nested-traverse.tdb", TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
+ tdb = tdb_open("run-nested-traverse.tdb1", TDB_VERSION1,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
ok1(external_agent_operation1(agent, OPEN, tdb->name) == SUCCESS);
@@ -79,7 +79,7 @@ int main(int argc, char *argv[])
ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
tdb1_traverse(tdb, traverse1, NULL);
tdb1_traverse_read(tdb, traverse1, NULL);
- tdb1_close(tdb);
+ tdb_close(tdb);
return exit_status();
}
diff --git a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
index 91926cf889..a418556d19 100644
--- a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
+++ b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
@@ -75,9 +75,9 @@ int main(int argc, char *argv[])
hsize.tdb1_hashsize.hsize = 1024;
plan_tests(41);
- tdb = tdb1_open("run-no-lock-during-traverse.tdb",
- TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR,
- 0600, &hsize);
+ tdb = tdb_open("run-no-lock-during-traverse.tdb1",
+ TDB_VERSION1, O_CREAT|O_TRUNC|O_RDWR,
+ 0600, &hsize);
ok1(tdb);
ok1(prepare_entries(tdb));
@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
ok1(locking_errors1 == 0);
ok1(tdb1_unlockall(tdb) == 0);
- ok1(tdb1_close(tdb) == 0);
+ ok1(tdb_close(tdb) == 0);
return exit_status();
}
diff --git a/lib/tdb2/test/run-tdb1-oldhash.c b/lib/tdb2/test/run-tdb1-oldhash.c
index 4cc973c0e3..185001db74 100644
--- a/lib/tdb2/test/run-tdb1-oldhash.c
+++ b/lib/tdb2/test/run-tdb1-oldhash.c
@@ -17,29 +17,29 @@ int main(int argc, char *argv[])
/* Old format (with zeroes in the hash magic fields) should
* open with any hash (since we don't know what hash they used). */
- tdb = tdb1_open("test/old-nohash-le.tdb1", 0, O_RDWR, 0,
- &tap_log_attr);
+ tdb = tdb_open("test/old-nohash-le.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
- tdb = tdb1_open("test/old-nohash-be.tdb1", 0, O_RDWR, 0,
- &tap_log_attr);
+ tdb = tdb_open("test/old-nohash-be.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
- tdb = tdb1_open("test/old-nohash-le.tdb1", 0, O_RDWR, 0,
- &incompat_hash_attr);
+ tdb = tdb_open("test/old-nohash-le.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &incompat_hash_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
- tdb = tdb1_open("test/old-nohash-be.tdb1", 0, O_RDWR, 0,
- &incompat_hash_attr);
+ tdb = tdb_open("test/old-nohash-be.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &incompat_hash_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
return exit_status();
}
diff --git a/lib/tdb2/test/run-tdb1-open-during-transaction.c b/lib/tdb2/test/run-tdb1-open-during-transaction.c
index fbd539a436..fd3a48086c 100644
--- a/lib/tdb2/test/run-tdb1-open-during-transaction.c
+++ b/lib/tdb2/test/run-tdb1-open-during-transaction.c
@@ -23,7 +23,7 @@ static int ftruncate_check(int fd, off_t length);
static struct agent *agent;
static bool opened;
static int errors = 0;
-#define TEST_DBNAME "run-open-during-transaction.tdb"
+#define TEST_DBNAME "run-open-during-transaction.tdb1"
#undef write
#undef pwrite
@@ -150,9 +150,9 @@ int main(int argc, char *argv[])
"DEFAULT",
(flags[i] & TDB_NOMMAP) ? "no mmap" : "mmap");
unlink(TEST_DBNAME);
- tdb = tdb1_open(TEST_DBNAME, flags[i],
- O_CREAT|O_TRUNC|O_RDWR, 0600,
- &hsize);
+ tdb = tdb_open(TEST_DBNAME, flags[i]|TDB_VERSION1,
+ O_CREAT|O_TRUNC|O_RDWR, 0600,
+ &hsize);
ok1(tdb);
opened = true;
@@ -167,7 +167,7 @@ int main(int argc, char *argv[])
ok(!errors, "We had %u open errors", errors);
opened = false;
- tdb1_close(tdb);
+ tdb_close(tdb);
}
return exit_status();
diff --git a/lib/tdb2/test/run-tdb1-readonly-check.c b/lib/tdb2/test/run-tdb1-readonly-check.c
index b712e48aa3..9bc9a93a7f 100644
--- a/lib/tdb2/test/run-tdb1-readonly-check.c
+++ b/lib/tdb2/test/run-tdb1-readonly-check.c
@@ -17,9 +17,9 @@ int main(int argc, char *argv[])
hsize.tdb1_hashsize.hsize = 1024;
plan_tests(11);
- tdb = tdb1_open("run-readonly-check.tdb",
- TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
+ tdb = tdb_open("run-readonly-check.tdb1",
+ TDB_VERSION1,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
key.dsize = strlen("hi");
@@ -33,16 +33,16 @@ int main(int argc, char *argv[])
/* We are also allowed to do a check inside a transaction. */
ok1(tdb1_transaction_start(tdb) == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- ok1(tdb1_close(tdb) == 0);
+ ok1(tdb_close(tdb) == 0);
- tdb = tdb1_open("run-readonly-check.tdb",
- TDB_DEFAULT, O_RDONLY, 0, &tap_log_attr);
+ tdb = tdb_open("run-readonly-check.tdb1",
+ TDB_DEFAULT, O_RDONLY, 0, &tap_log_attr);
ok1(tdb);
ok1(tdb1_store(tdb, key, data, TDB_MODIFY) == -1);
ok1(tdb_error(tdb) == TDB_ERR_RDONLY);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- ok1(tdb1_close(tdb) == 0);
+ ok1(tdb_close(tdb) == 0);
return exit_status();
}
diff --git a/lib/tdb2/test/run-tdb1-rwlock-check.c b/lib/tdb2/test/run-tdb1-rwlock-check.c
index 76355e848f..44a2eeb8c7 100644
--- a/lib/tdb2/test/run-tdb1-rwlock-check.c
+++ b/lib/tdb2/test/run-tdb1-rwlock-check.c
@@ -27,14 +27,14 @@ int main(int argc, char *argv[])
/* We should fail to open rwlock-using tdbs of either endian. */
log_count = 0;
- tdb = tdb1_open("test/rwlock-le.tdb1", 0, O_RDWR, 0,
- &log_attr);
+ tdb = tdb_open("test/rwlock-le.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &log_attr);
ok1(!tdb);
ok1(log_count == 1);
log_count = 0;
- tdb = tdb1_open("test/rwlock-be.tdb1", 0, O_RDWR, 0,
- &log_attr);
+ tdb = tdb_open("test/rwlock-be.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &log_attr);
ok1(!tdb);
ok1(log_count == 1);
diff --git a/lib/tdb2/test/run-tdb1-summary.c b/lib/tdb2/test/run-tdb1-summary.c
index 85194c8a88..45b4737286 100644
--- a/lib/tdb2/test/run-tdb1-summary.c
+++ b/lib/tdb2/test/run-tdb1-summary.c
@@ -16,8 +16,8 @@ int main(int argc, char *argv[])
plan_tests(sizeof(flags) / sizeof(flags[0]) * 14);
for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
- tdb = tdb1_open("run-summary.tdb", flags[i],
- O_RDWR|O_CREAT|O_TRUNC, 0600, NULL);
+ tdb = tdb_open("run-summary.tdb1", flags[i]|TDB_VERSION1,
+ O_RDWR|O_CREAT|O_TRUNC, 0600, NULL);
ok1(tdb);
if (!tdb)
continue;
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
ok1(strstr(summary, "Percentage keys/data/padding/free/dead/rechdrs&tailers/hashes: "));
free(summary);
- tdb1_close(tdb);
+ tdb_close(tdb);
}
return exit_status();
diff --git a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
index 3865289a6d..27df05ebb3 100644
--- a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
+++ b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
@@ -47,9 +47,9 @@ int main(int argc, char *argv[])
if (!agent)
err(1, "preparing agent");
- tdb = tdb1_open("run-traverse-in-transaction.tdb",
- TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR,
- 0600, &hsize);
+ tdb = tdb_open("run-traverse-in-transaction.tdb1",
+ TDB_VERSION1, O_CREAT|O_TRUNC|O_RDWR,
+ 0600, &hsize);
ok1(tdb);
key.dsize = strlen("hi");
@@ -79,7 +79,7 @@ int main(int argc, char *argv[])
ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name)
== SUCCESS);
- tdb1_close(tdb);
+ tdb_close(tdb);
return exit_status();
}
diff --git a/lib/tdb2/test/run-tdb1-wronghash-fail.c b/lib/tdb2/test/run-tdb1-wronghash-fail.c
index f87ebd7cab..61d56d6c8a 100644
--- a/lib/tdb2/test/run-tdb1-wronghash-fail.c
+++ b/lib/tdb2/test/run-tdb1-wronghash-fail.c
@@ -54,90 +54,89 @@ int main(int argc, char *argv[])
/* Create with default hash. */
log_count = 0;
- tdb = tdb1_open("run-wronghash-fail.tdb", 0,
- O_CREAT|O_RDWR|O_TRUNC, 0600, &log_attr);
+ tdb = tdb_open("run-wronghash-fail.tdb1", TDB_VERSION1,
+ O_CREAT|O_RDWR|O_TRUNC, 0600, &log_attr);
ok1(tdb);
ok1(log_count == 0);
d.dptr = (void *)"Hello";
d.dsize = 5;
ok1(tdb1_store(tdb, d, d, TDB_INSERT) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
/* Fail to open with different hash. */
- tdb = tdb1_open("run-wronghash-fail.tdb", 0, O_RDWR, 0,
- &jhash_attr);
+ tdb = tdb_open("run-wronghash-fail.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &jhash_attr);
ok1(!tdb);
ok1(log_count == 1);
/* Create with different hash. */
log_count = 0;
- tdb = tdb1_open("run-wronghash-fail.tdb", 0,
- O_CREAT|O_RDWR|O_TRUNC,
- 0600, &jhash_attr);
+ tdb = tdb_open("run-wronghash-fail.tdb1", TDB_VERSION1,
+ O_CREAT|O_RDWR|O_TRUNC, 0600, &jhash_attr);
ok1(tdb);
ok1(log_count == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
/* Endian should be no problem. */
log_count = 0;
- tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, O_RDWR, 0,
- &ohash_attr);
+ tdb = tdb_open("test/jenkins-le-hash.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &ohash_attr);
ok1(!tdb);
ok1(log_count == 1);
log_count = 0;
- tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, O_RDWR, 0,
- &ohash_attr);
+ tdb = tdb_open("test/jenkins-be-hash.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &ohash_attr);
ok1(!tdb);
ok1(log_count == 1);
log_count = 0;
/* Fail to open with old default hash. */
- tdb = tdb1_open("run-wronghash-fail.tdb", 0, O_RDWR, 0,
- &ohash_attr);
+ tdb = tdb_open("run-wronghash-fail.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &ohash_attr);
ok1(!tdb);
ok1(log_count == 1);
log_count = 0;
- tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, O_RDONLY,
- 0, &incompat_hash_attr);
+ tdb = tdb_open("test/jenkins-le-hash.tdb1", TDB_VERSION1, O_RDONLY,
+ 0, &incompat_hash_attr);
ok1(tdb);
ok1(log_count == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
log_count = 0;
- tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, O_RDONLY,
- 0, &incompat_hash_attr);
+ tdb = tdb_open("test/jenkins-be-hash.tdb1", TDB_VERSION1, O_RDONLY,
+ 0, &incompat_hash_attr);
ok1(tdb);
ok1(log_count == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
/* It should open with jenkins hash if we don't specify. */
log_count = 0;
- tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, O_RDWR, 0,
- &log_attr);
+ tdb = tdb_open("test/jenkins-le-hash.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &log_attr);
ok1(tdb);
ok1(log_count == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
log_count = 0;
- tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, O_RDWR, 0,
- &log_attr);
+ tdb = tdb_open("test/jenkins-be-hash.tdb1", TDB_VERSION1, O_RDWR, 0,
+ &log_attr);
ok1(tdb);
ok1(log_count == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
log_count = 0;
- tdb = tdb1_open("run-wronghash-fail.tdb", 0, O_RDONLY,
- 0, &log_attr);
+ tdb = tdb_open("run-wronghash-fail.tdb1", TDB_VERSION1, O_RDONLY,
+ 0, &log_attr);
ok1(tdb);
ok1(log_count == 0);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
- tdb1_close(tdb);
+ tdb_close(tdb);
return exit_status();
diff --git a/lib/tdb2/test/run-tdb1-zero-append.c b/lib/tdb2/test/run-tdb1-zero-append.c
index 9b5c8bc0f3..64169087e3 100644
--- a/lib/tdb2/test/run-tdb1-zero-append.c
+++ b/lib/tdb2/test/run-tdb1-zero-append.c
@@ -15,8 +15,8 @@ int main(int argc, char *argv[])
hsize.tdb1_hashsize.hsize = 1024;
plan_tests(4);
- tdb = tdb1_open(NULL, TDB_INTERNAL, O_CREAT|O_TRUNC|O_RDWR,
- 0600, &hsize);
+ tdb = tdb_open(NULL, TDB_INTERNAL|TDB_VERSION1, O_CREAT|O_TRUNC|O_RDWR,
+ 0600, &hsize);
ok1(tdb);
/* Tickle bug on appending zero length buffer to zero length buffer. */
@@ -30,7 +30,7 @@ int main(int argc, char *argv[])
data = tdb1_fetch(tdb, key);
ok1(data.dsize == 0);
free(data.dptr);
- tdb1_close(tdb);
+ tdb_close(tdb);
return exit_status();
}
diff --git a/lib/tdb2/test/run-tdb1.c b/lib/tdb2/test/run-tdb1.c
index 913b66c109..2d551dc538 100644
--- a/lib/tdb2/test/run-tdb1.c
+++ b/lib/tdb2/test/run-tdb1.c
@@ -15,8 +15,8 @@ int main(int argc, char *argv[])
hsize.tdb1_hashsize.hsize = 1024;
plan_tests(10);
- tdb = tdb1_open("run.tdb", TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
+ tdb = tdb_open("run.tdb1", TDB_VERSION1,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
key.dsize = strlen("hi");
@@ -39,7 +39,7 @@ int main(int argc, char *argv[])
key.dsize++;
data = tdb1_fetch(tdb, key);
ok1(data.dptr == NULL);
- tdb1_close(tdb);
+ tdb_close(tdb);
return exit_status();
}
diff --git a/lib/tdb2/test/tdb1-external-agent.c b/lib/tdb2/test/tdb1-external-agent.c
index 44bdeceaad..eb52e55f62 100644
--- a/lib/tdb2/test/tdb1-external-agent.c
+++ b/lib/tdb2/test/tdb1-external-agent.c
@@ -39,8 +39,7 @@ static enum agent_return do_operation(enum operation op, const char *name)
diag("Already have tdb %s open", tdb->name);
return OTHER_FAILURE;
}
- tdb = tdb1_open(name, TDB_DEFAULT, O_RDWR, 0,
- &tap_log_attr);
+ tdb = tdb_open(name, TDB_VERSION1, O_RDWR, 0, &tap_log_attr);
if (!tdb) {
if (!locking_would_block1)
diag("Opening tdb gave %s", strerror(errno));
@@ -79,7 +78,7 @@ static enum agent_return do_operation(enum operation op, const char *name)
ret = tdb1_needs_recovery(tdb) ? SUCCESS : FAILED;
break;
case CLOSE:
- ret = tdb1_close(tdb) == 0 ? SUCCESS : OTHER_FAILURE;
+ ret = tdb_close(tdb) == 0 ? SUCCESS : OTHER_FAILURE;
tdb = NULL;
break;
default: