summaryrefslogtreecommitdiff
path: root/lib/tdb2/test
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-09-14 07:47:13 +0930
committerRusty Russell <rusty@rustcorp.com.au>2011-09-14 07:47:13 +0930
commit6e16e29d532d7542c210fd725bf61df1e7a97795 (patch)
tree463f4867fe4ff441d924672b564f508632e57c02 /lib/tdb2/test
parentf8dbfad23c9cab9d52b366d56e8491666a90f714 (diff)
downloadsamba-6e16e29d532d7542c210fd725bf61df1e7a97795.tar.gz
samba-6e16e29d532d7542c210fd725bf61df1e7a97795.tar.bz2
samba-6e16e29d532d7542c210fd725bf61df1e7a97795.zip
tdb2: add TDB_ATTRIBUTE_TDB1_HASHSIZE
This replaces the tdb1_open "hash_size" argument. It will only be valid when you call tdb_open() with O_CREAT in open_flags, and TDB_VERSION1 in tdb_flags. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 49475d68deecd0b31597ed6094229171d2699b11)
Diffstat (limited to 'lib/tdb2/test')
-rw-r--r--lib/tdb2/test/failtest_helper.h2
-rw-r--r--lib/tdb2/test/run-tdb1-3G-file.c9
-rw-r--r--lib/tdb2/test/run-tdb1-bad-tdb-header.c20
-rw-r--r--lib/tdb2/test/run-tdb1-check.c17
-rw-r--r--lib/tdb2/test/run-tdb1-corrupt.c13
-rw-r--r--lib/tdb2/test/run-tdb1-die-during-transaction.c9
-rw-r--r--lib/tdb2/test/run-tdb1-endian.c12
-rw-r--r--lib/tdb2/test/run-tdb1-hashsize.c61
-rw-r--r--lib/tdb2/test/run-tdb1-incompatible.c22
-rw-r--r--lib/tdb2/test/run-tdb1-nested-transactions.c11
-rw-r--r--lib/tdb2/test/run-tdb1-nested-traverse.c9
-rw-r--r--lib/tdb2/test/run-tdb1-no-lock-during-traverse.c9
-rw-r--r--lib/tdb2/test/run-tdb1-oldhash.c8
-rw-r--r--lib/tdb2/test/run-tdb1-open-during-transaction.c9
-rw-r--r--lib/tdb2/test/run-tdb1-readonly-check.c11
-rw-r--r--lib/tdb2/test/run-tdb1-rwlock-check.c4
-rw-r--r--lib/tdb2/test/run-tdb1-summary.c2
-rw-r--r--lib/tdb2/test/run-tdb1-traverse-in-transaction.c9
-rw-r--r--lib/tdb2/test/run-tdb1-wronghash-fail.c22
-rw-r--r--lib/tdb2/test/run-tdb1-zero-append.c9
-rw-r--r--lib/tdb2/test/run-tdb1.c9
-rw-r--r--lib/tdb2/test/tdb1-external-agent.c2
22 files changed, 204 insertions, 75 deletions
diff --git a/lib/tdb2/test/failtest_helper.h b/lib/tdb2/test/failtest_helper.h
index a585dc2b65..37acbdd832 100644
--- a/lib/tdb2/test/failtest_helper.h
+++ b/lib/tdb2/test/failtest_helper.h
@@ -4,7 +4,7 @@
#include <stdbool.h>
/* FIXME: Check these! */
-#define INITIAL_TDB_MALLOC "open.c", 343, FAILTEST_MALLOC
+#define INITIAL_TDB_MALLOC "open.c", 360, FAILTEST_MALLOC
#define URANDOM_OPEN "open.c", 61, FAILTEST_OPEN
#define URANDOM_READ "open.c", 41, FAILTEST_READ
diff --git a/lib/tdb2/test/run-tdb1-3G-file.c b/lib/tdb2/test/run-tdb1-3G-file.c
index 1eab447671..4edaa5d464 100644
--- a/lib/tdb2/test/run-tdb1-3G-file.c
+++ b/lib/tdb2/test/run-tdb1-3G-file.c
@@ -64,10 +64,15 @@ int main(int argc, char *argv[])
uint32_t hash;
tdb1_off_t rec_ptr;
struct tdb1_record rec;
+ union tdb_attribute hsize;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ hsize.tdb1_hashsize.hsize = 1024;
plan_tests(24);
- tdb = tdb1_open("run-36-file.tdb", 1024, TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
+ tdb = tdb1_open("run-36-file.tdb", TDB_DEFAULT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
tdb->tdb1.io = &large_io_methods;
diff --git a/lib/tdb2/test/run-tdb1-bad-tdb-header.c b/lib/tdb2/test/run-tdb1-bad-tdb-header.c
index a32b817c1d..f8bee0b45c 100644
--- a/lib/tdb2/test/run-tdb1-bad-tdb-header.c
+++ b/lib/tdb2/test/run-tdb1-bad-tdb-header.c
@@ -9,6 +9,11 @@ int main(int argc, char *argv[])
struct tdb_context *tdb;
struct tdb1_header hdr;
int fd;
+ union tdb_attribute hsize;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ hsize.tdb1_hashsize.hsize = 1024;
plan_tests(11);
/* Can open fine if complete crap, as long as O_CREAT. */
@@ -16,11 +21,10 @@ int main(int argc, char *argv[])
ok1(fd >= 0);
ok1(write(fd, "hello world", 11) == 11);
close(fd);
- tdb = tdb1_open("run-bad-tdb-header.tdb", 1024, 0, O_RDWR, 0,
- &tap_log_attr);
+ tdb = tdb1_open("run-bad-tdb-header.tdb", 0, O_RDWR, 0, &tap_log_attr);
ok1(!tdb);
- tdb = tdb1_open("run-bad-tdb-header.tdb", 1024, 0, O_CREAT|O_RDWR,
- 0600, &tap_log_attr);
+ tdb = tdb1_open("run-bad-tdb-header.tdb", 0, O_CREAT|O_RDWR,
+ 0600, &hsize);
ok1(tdb);
tdb1_close(tdb);
@@ -34,14 +38,14 @@ int main(int argc, char *argv[])
ok1(write(fd, &hdr, sizeof(hdr)) == sizeof(hdr));
close(fd);
- tdb = tdb1_open("run-bad-tdb-header.tdb", 1024, 0, O_RDWR|O_CREAT,
- 0600, &tap_log_attr);
+ tdb = tdb1_open("run-bad-tdb-header.tdb", 0, O_RDWR|O_CREAT,
+ 0600, &hsize);
ok1(errno == EIO);
ok1(!tdb);
/* With truncate, will be fine. */
- tdb = tdb1_open("run-bad-tdb-header.tdb", 1024, 0,
- O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
+ tdb = tdb1_open("run-bad-tdb-header.tdb", 0,
+ O_RDWR|O_CREAT|O_TRUNC, 0600, &hsize);
ok1(tdb);
tdb1_close(tdb);
diff --git a/lib/tdb2/test/run-tdb1-check.c b/lib/tdb2/test/run-tdb1-check.c
index 017eb8328a..f188dc928e 100644
--- a/lib/tdb2/test/run-tdb1-check.c
+++ b/lib/tdb2/test/run-tdb1-check.c
@@ -8,10 +8,15 @@ int main(int argc, char *argv[])
{
struct tdb_context *tdb;
TDB_DATA key, data;
+ union tdb_attribute hsize;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ hsize.tdb1_hashsize.hsize = 1;
plan_tests(13);
- tdb = tdb1_open("run-check.tdb", 1, TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
+ tdb = tdb1_open("run-check.tdb", TDB_DEFAULT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
@@ -25,13 +30,13 @@ int main(int argc, char *argv[])
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
- tdb = tdb1_open("run-check.tdb", 1024, 0, O_RDWR, 0,
+ tdb = tdb1_open("run-check.tdb", 0, O_RDWR, 0,
&tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
- tdb = tdb1_open("test/tdb1.corrupt", 1024, 0, O_RDWR, 0,
+ tdb = tdb1_open("test/tdb1.corrupt", 0, O_RDWR, 0,
&tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == -1);
@@ -39,13 +44,13 @@ int main(int argc, char *argv[])
tdb1_close(tdb);
/* Big and little endian should work! */
- tdb = tdb1_open("test/old-nohash-le.tdb1", 1024, 0, O_RDWR, 0,
+ tdb = tdb1_open("test/old-nohash-le.tdb1", 0, O_RDWR, 0,
&tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
- tdb = tdb1_open("test/old-nohash-be.tdb1", 1024, 0, O_RDWR, 0,
+ tdb = tdb1_open("test/old-nohash-be.tdb1", 0, O_RDWR, 0,
&tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
diff --git a/lib/tdb2/test/run-tdb1-corrupt.c b/lib/tdb2/test/run-tdb1-corrupt.c
index 833e9c1ee1..8647ecccba 100644
--- a/lib/tdb2/test/run-tdb1-corrupt.c
+++ b/lib/tdb2/test/run-tdb1-corrupt.c
@@ -94,11 +94,16 @@ static void check_test(struct tdb_context *tdb)
int main(int argc, char *argv[])
{
struct tdb_context *tdb;
+ union tdb_attribute hsize;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ hsize.tdb1_hashsize.hsize = 2;
plan_tests(4);
/* This should use mmap. */
- tdb = tdb1_open("run-corrupt.tdb", 2, TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
+ tdb = tdb1_open("run-corrupt.tdb", TDB_DEFAULT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
if (!tdb)
abort();
@@ -106,8 +111,8 @@ int main(int argc, char *argv[])
tdb1_close(tdb);
/* This should not. */
- tdb = tdb1_open("run-corrupt.tdb", 2, TDB_NOMMAP,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
+ tdb = tdb1_open("run-corrupt.tdb", TDB_NOMMAP,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
if (!tdb)
abort();
diff --git a/lib/tdb2/test/run-tdb1-die-during-transaction.c b/lib/tdb2/test/run-tdb1-die-during-transaction.c
index 9ff75d1020..933d748686 100644
--- a/lib/tdb2/test/run-tdb1-die-during-transaction.c
+++ b/lib/tdb2/test/run-tdb1-die-during-transaction.c
@@ -85,12 +85,17 @@ static bool test_death(enum operation op, struct agent *agent)
TDB_DATA key;
enum agent_return ret;
int needed_recovery = 0;
+ union tdb_attribute hsize;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ hsize.tdb1_hashsize.hsize = 1024;
current = target = 0;
reset:
unlink(TEST_DBNAME);
- tdb = tdb1_open(TEST_DBNAME, 1024, TDB_NOMMAP,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
+ tdb = tdb1_open(TEST_DBNAME, TDB_NOMMAP,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
if (setjmp(jmpbuf) != 0) {
/* We're partway through. Simulate our death. */
diff --git a/lib/tdb2/test/run-tdb1-endian.c b/lib/tdb2/test/run-tdb1-endian.c
index a06bfb6e99..e1b92eeace 100644
--- a/lib/tdb2/test/run-tdb1-endian.c
+++ b/lib/tdb2/test/run-tdb1-endian.c
@@ -8,11 +8,16 @@ int main(int argc, char *argv[])
{
struct tdb_context *tdb;
TDB_DATA key, data;
+ union tdb_attribute hsize;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ hsize.tdb1_hashsize.hsize = 1024;
plan_tests(13);
- tdb = tdb1_open("run-endian.tdb", 1024,
+ tdb = tdb1_open("run-endian.tdb",
TDB_CONVERT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
key.dsize = strlen("hi");
@@ -38,8 +43,7 @@ int main(int argc, char *argv[])
tdb1_close(tdb);
/* Reopen: should read it */
- tdb = tdb1_open("run-endian.tdb", 1024, 0, O_RDWR, 0,
- &tap_log_attr);
+ tdb = tdb1_open("run-endian.tdb", 0, O_RDWR, 0, NULL);
ok1(tdb);
key.dsize = strlen("hi");
diff --git a/lib/tdb2/test/run-tdb1-hashsize.c b/lib/tdb2/test/run-tdb1-hashsize.c
new file mode 100644
index 0000000000..fc48c23076
--- /dev/null
+++ b/lib/tdb2/test/run-tdb1-hashsize.c
@@ -0,0 +1,61 @@
+#include "tdb2-source.h"
+#include <ccan/tap/tap.h>
+#include <stdlib.h>
+#include <err.h>
+#include "logging.h"
+
+int main(int argc, char *argv[])
+{
+ struct tdb_context *tdb;
+ union tdb_attribute hsize, h2;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ 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);
+ ok1(tdb);
+ h2.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ ok1(tdb_get_attribute(tdb, &h2) == TDB_SUCCESS);
+ ok1(h2.tdb1_hashsize.hsize == hsize.tdb1_hashsize.hsize);
+ 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);
+ ok1(!tdb);
+ ok1(tap_log_messages == 1);
+
+ /* Can't specify TDB_ATTRIBUTE_TDB1_HASHSIZE for version2. */
+ tdb = tdb_open("run-tdb1-hashsize.tdb", TDB_DEFAULT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
+ ok1(!tdb);
+ 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);
+
+ ok1(tdb);
+ memset(&h2, 0, sizeof(h2));
+ h2.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ ok1(tdb_get_attribute(tdb, &h2) == TDB_SUCCESS);
+ ok1(h2.tdb1_hashsize.hsize == hsize.tdb1_hashsize.hsize);
+ 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);
+
+ ok1(tdb);
+ memset(&h2, 0, sizeof(h2));
+ h2.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ ok1(tdb_get_attribute(tdb, &h2) == TDB_SUCCESS);
+ ok1(h2.tdb1_hashsize.hsize == TDB1_DEFAULT_HASH_SIZE);
+ tdb_close(tdb);
+ ok1(tap_log_messages == 2);
+
+ return exit_status();
+}
diff --git a/lib/tdb2/test/run-tdb1-incompatible.c b/lib/tdb2/test/run-tdb1-incompatible.c
index baf40ed4e6..48f796dbf4 100644
--- a/lib/tdb2/test/run-tdb1-incompatible.c
+++ b/lib/tdb2/test/run-tdb1-incompatible.c
@@ -83,7 +83,7 @@ int main(int argc, char *argv[])
/* Create an old-style hash. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb", 0, flags,
+ tdb = tdb1_open("run-incompatible.tdb", flags,
O_CREAT|O_RDWR|O_TRUNC, 0600, &log_attr);
ok1(tdb);
ok1(log_count == 0);
@@ -97,7 +97,7 @@ int main(int argc, char *argv[])
/* We can still open any old-style with incompat hash. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb", 0,
+ tdb = tdb1_open("run-incompatible.tdb",
TDB_DEFAULT,
O_RDWR, 0600, &incompat_hash_attr);
ok1(tdb);
@@ -109,7 +109,7 @@ int main(int argc, char *argv[])
tdb1_close(tdb);
log_count = 0;
- tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, 0, O_RDONLY,
+ tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, O_RDONLY,
0, &jhash_attr);
ok1(tdb);
ok1(log_count == 0);
@@ -117,7 +117,7 @@ int main(int argc, char *argv[])
tdb1_close(tdb);
log_count = 0;
- tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, 0, O_RDONLY,
+ tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, O_RDONLY,
0, &jhash_attr);
ok1(tdb);
ok1(log_count == 0);
@@ -126,7 +126,7 @@ int main(int argc, char *argv[])
/* OK, now create with incompatible hash. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb", 0,
+ tdb = tdb1_open("run-incompatible.tdb",
flags,
O_CREAT|O_RDWR|O_TRUNC, 0600,
&incompat_hash_attr);
@@ -142,14 +142,14 @@ int main(int argc, char *argv[])
/* Cannot open with old hash. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb", 0, 0,
+ tdb = tdb1_open("run-incompatible.tdb", 0,
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, 0,
+ tdb = tdb1_open("run-incompatible.tdb", 0,
O_RDWR, 0600, &jhash_attr);
ok1(tdb);
ok1(log_count == 0);
@@ -161,7 +161,7 @@ int main(int argc, char *argv[])
/* Can open by letting it figure it out itself. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb", 0, 0,
+ tdb = tdb1_open("run-incompatible.tdb", 0,
O_RDWR, 0600, &log_attr);
ok1(tdb);
ok1(log_count == 0);
@@ -176,7 +176,7 @@ int main(int argc, char *argv[])
/* FIXME: Not possible with TDB2 :( */
/* We can also use incompatible hash with other hashes. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb", 0,
+ tdb = tdb1_open("run-incompatible.tdb",
flags,
O_CREAT|O_RDWR|O_TRUNC, 0600, &dumbhash_attr);
ok1(tdb);
@@ -191,14 +191,14 @@ int main(int argc, char *argv[])
/* It should not open if we don't specify. */
log_count = 0;
- tdb = tdb1_open("run-incompatible.tdb", 0, 0, O_RDWR, 0,
+ tdb = tdb1_open("run-incompatible.tdb", 0, 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, 0, O_RDWR, 0,
+ tdb = tdb1_open("run-incompatible.tdb", 0, O_RDWR, 0,
&dumbhash_attr);
ok1(tdb);
ok1(log_count == 0);
diff --git a/lib/tdb2/test/run-tdb1-nested-transactions.c b/lib/tdb2/test/run-tdb1-nested-transactions.c
index d5886123ea..79b9b5683b 100644
--- a/lib/tdb2/test/run-tdb1-nested-transactions.c
+++ b/lib/tdb2/test/run-tdb1-nested-transactions.c
@@ -9,14 +9,19 @@ int main(int argc, char *argv[])
{
struct tdb_context *tdb;
TDB_DATA key, data;
+ union tdb_attribute hsize;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ hsize.tdb1_hashsize.hsize = 1024;
plan_tests(27);
key.dsize = strlen("hi");
key.dptr = (void *)"hi";
tdb = tdb1_open("run-nested-transactions.tdb",
- 1024, TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
+ TDB_DEFAULT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
/* No nesting by default. */
@@ -43,7 +48,7 @@ int main(int argc, char *argv[])
tdb1_close(tdb);
tdb = tdb1_open("run-nested-transactions.tdb",
- 1024, TDB_ALLOW_NESTING, O_RDWR, 0, &tap_log_attr);
+ TDB_ALLOW_NESTING, O_RDWR, 0, &tap_log_attr);
ok1(tdb);
ok1(tdb1_transaction_start(tdb) == 0);
diff --git a/lib/tdb2/test/run-tdb1-nested-traverse.c b/lib/tdb2/test/run-tdb1-nested-traverse.c
index 1fc8d09277..0d58a569ac 100644
--- a/lib/tdb2/test/run-tdb1-nested-traverse.c
+++ b/lib/tdb2/test/run-tdb1-nested-traverse.c
@@ -50,14 +50,19 @@ int main(int argc, char *argv[])
{
struct tdb_context *tdb;
TDB_DATA key, data;
+ union tdb_attribute hsize;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ hsize.tdb1_hashsize.hsize = 1024;
plan_tests(17);
agent = prepare_external_agent1();
if (!agent)
err(1, "preparing agent");
- tdb = tdb1_open("run-nested-traverse.tdb", 1024, TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
+ tdb = tdb1_open("run-nested-traverse.tdb", TDB_DEFAULT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
ok1(external_agent_operation1(agent, OPEN, tdb->name) == SUCCESS);
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 cb1c23606b..91926cf889 100644
--- a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
+++ b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
@@ -68,11 +68,16 @@ int main(int argc, char *argv[])
{
struct tdb_context *tdb;
int errors = 0;
+ union tdb_attribute hsize;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ hsize.tdb1_hashsize.hsize = 1024;
plan_tests(41);
tdb = tdb1_open("run-no-lock-during-traverse.tdb",
- 1024, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR,
- 0600, &tap_log_attr);
+ TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR,
+ 0600, &hsize);
ok1(tdb);
ok1(prepare_entries(tdb));
diff --git a/lib/tdb2/test/run-tdb1-oldhash.c b/lib/tdb2/test/run-tdb1-oldhash.c
index 5219d5c30a..4cc973c0e3 100644
--- a/lib/tdb2/test/run-tdb1-oldhash.c
+++ b/lib/tdb2/test/run-tdb1-oldhash.c
@@ -17,25 +17,25 @@ 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, 0, O_RDWR, 0,
+ tdb = tdb1_open("test/old-nohash-le.tdb1", 0, O_RDWR, 0,
&tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
- tdb = tdb1_open("test/old-nohash-be.tdb1", 0, 0, O_RDWR, 0,
+ tdb = tdb1_open("test/old-nohash-be.tdb1", 0, O_RDWR, 0,
&tap_log_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
- tdb = tdb1_open("test/old-nohash-le.tdb1", 0, 0, O_RDWR, 0,
+ tdb = tdb1_open("test/old-nohash-le.tdb1", 0, O_RDWR, 0,
&incompat_hash_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb1_close(tdb);
- tdb = tdb1_open("test/old-nohash-be.tdb1", 0, 0, O_RDWR, 0,
+ tdb = tdb1_open("test/old-nohash-be.tdb1", 0, O_RDWR, 0,
&incompat_hash_attr);
ok1(tdb);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
diff --git a/lib/tdb2/test/run-tdb1-open-during-transaction.c b/lib/tdb2/test/run-tdb1-open-during-transaction.c
index e0b28a536e..fbd539a436 100644
--- a/lib/tdb2/test/run-tdb1-open-during-transaction.c
+++ b/lib/tdb2/test/run-tdb1-open-during-transaction.c
@@ -133,6 +133,11 @@ int main(int argc, char *argv[])
int i;
struct tdb_context *tdb;
TDB_DATA key, data;
+ union tdb_attribute hsize;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ hsize.tdb1_hashsize.hsize = 1024;
plan_tests(10);
agent = prepare_external_agent1();
@@ -145,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, 1024, flags[i],
+ tdb = tdb1_open(TEST_DBNAME, flags[i],
O_CREAT|O_TRUNC|O_RDWR, 0600,
- &tap_log_attr);
+ &hsize);
ok1(tdb);
opened = true;
diff --git a/lib/tdb2/test/run-tdb1-readonly-check.c b/lib/tdb2/test/run-tdb1-readonly-check.c
index 762c576f92..b712e48aa3 100644
--- a/lib/tdb2/test/run-tdb1-readonly-check.c
+++ b/lib/tdb2/test/run-tdb1-readonly-check.c
@@ -10,11 +10,16 @@ int main(int argc, char *argv[])
{
struct tdb_context *tdb;
TDB_DATA key, data;
+ union tdb_attribute hsize;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ hsize.tdb1_hashsize.hsize = 1024;
plan_tests(11);
- tdb = tdb1_open("run-readonly-check.tdb", 1024,
+ tdb = tdb1_open("run-readonly-check.tdb",
TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
key.dsize = strlen("hi");
@@ -30,7 +35,7 @@ int main(int argc, char *argv[])
ok1(tdb1_check(tdb, NULL, NULL) == 0);
ok1(tdb1_close(tdb) == 0);
- tdb = tdb1_open("run-readonly-check.tdb", 1024,
+ tdb = tdb1_open("run-readonly-check.tdb",
TDB_DEFAULT, O_RDONLY, 0, &tap_log_attr);
ok1(tdb);
diff --git a/lib/tdb2/test/run-tdb1-rwlock-check.c b/lib/tdb2/test/run-tdb1-rwlock-check.c
index 6f4406c026..76355e848f 100644
--- a/lib/tdb2/test/run-tdb1-rwlock-check.c
+++ b/lib/tdb2/test/run-tdb1-rwlock-check.c
@@ -27,13 +27,13 @@ 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, 0, O_RDWR, 0,
+ tdb = tdb1_open("test/rwlock-le.tdb1", 0, O_RDWR, 0,
&log_attr);
ok1(!tdb);
ok1(log_count == 1);
log_count = 0;
- tdb = tdb1_open("test/rwlock-be.tdb1", 0, 0, O_RDWR, 0,
+ tdb = tdb1_open("test/rwlock-be.tdb1", 0, 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 8b9b74ffe7..85194c8a88 100644
--- a/lib/tdb2/test/run-tdb1-summary.c
+++ b/lib/tdb2/test/run-tdb1-summary.c
@@ -16,7 +16,7 @@ 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", 131, flags[i],
+ tdb = tdb1_open("run-summary.tdb", flags[i],
O_RDWR|O_CREAT|O_TRUNC, 0600, NULL);
ok1(tdb);
if (!tdb)
diff --git a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
index 0395bff7ce..3865289a6d 100644
--- a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
+++ b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
@@ -36,6 +36,11 @@ int main(int argc, char *argv[])
{
struct tdb_context *tdb;
TDB_DATA key, data;
+ union tdb_attribute hsize;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ hsize.tdb1_hashsize.hsize = 1024;
plan_tests(13);
agent = prepare_external_agent1();
@@ -43,8 +48,8 @@ int main(int argc, char *argv[])
err(1, "preparing agent");
tdb = tdb1_open("run-traverse-in-transaction.tdb",
- 1024, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR,
- 0600, &tap_log_attr);
+ TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR,
+ 0600, &hsize);
ok1(tdb);
key.dsize = strlen("hi");
diff --git a/lib/tdb2/test/run-tdb1-wronghash-fail.c b/lib/tdb2/test/run-tdb1-wronghash-fail.c
index 54524fc1ff..f87ebd7cab 100644
--- a/lib/tdb2/test/run-tdb1-wronghash-fail.c
+++ b/lib/tdb2/test/run-tdb1-wronghash-fail.c
@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
/* Create with default hash. */
log_count = 0;
- tdb = tdb1_open("run-wronghash-fail.tdb", 0, 0,
+ tdb = tdb1_open("run-wronghash-fail.tdb", 0,
O_CREAT|O_RDWR|O_TRUNC, 0600, &log_attr);
ok1(tdb);
ok1(log_count == 0);
@@ -64,14 +64,14 @@ int main(int argc, char *argv[])
tdb1_close(tdb);
/* Fail to open with different hash. */
- tdb = tdb1_open("run-wronghash-fail.tdb", 0, 0, O_RDWR, 0,
+ tdb = tdb1_open("run-wronghash-fail.tdb", 0, 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, 0,
+ tdb = tdb1_open("run-wronghash-fail.tdb", 0,
O_CREAT|O_RDWR|O_TRUNC,
0600, &jhash_attr);
ok1(tdb);
@@ -80,26 +80,26 @@ int main(int argc, char *argv[])
/* Endian should be no problem. */
log_count = 0;
- tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, 0, O_RDWR, 0,
+ tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, O_RDWR, 0,
&ohash_attr);
ok1(!tdb);
ok1(log_count == 1);
log_count = 0;
- tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, 0, O_RDWR, 0,
+ tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, 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, 0, O_RDWR, 0,
+ tdb = tdb1_open("run-wronghash-fail.tdb", 0, O_RDWR, 0,
&ohash_attr);
ok1(!tdb);
ok1(log_count == 1);
log_count = 0;
- tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, 0, O_RDONLY,
+ tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, O_RDONLY,
0, &incompat_hash_attr);
ok1(tdb);
ok1(log_count == 0);
@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
tdb1_close(tdb);
log_count = 0;
- tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, 0, O_RDONLY,
+ tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, O_RDONLY,
0, &incompat_hash_attr);
ok1(tdb);
ok1(log_count == 0);
@@ -116,7 +116,7 @@ int main(int argc, char *argv[])
/* It should open with jenkins hash if we don't specify. */
log_count = 0;
- tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, 0, O_RDWR, 0,
+ tdb = tdb1_open("test/jenkins-le-hash.tdb1", 0, O_RDWR, 0,
&log_attr);
ok1(tdb);
ok1(log_count == 0);
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
tdb1_close(tdb);
log_count = 0;
- tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, 0, O_RDWR, 0,
+ tdb = tdb1_open("test/jenkins-be-hash.tdb1", 0, O_RDWR, 0,
&log_attr);
ok1(tdb);
ok1(log_count == 0);
@@ -132,7 +132,7 @@ int main(int argc, char *argv[])
tdb1_close(tdb);
log_count = 0;
- tdb = tdb1_open("run-wronghash-fail.tdb", 0, 0, O_RDONLY,
+ tdb = tdb1_open("run-wronghash-fail.tdb", 0, O_RDONLY,
0, &log_attr);
ok1(tdb);
ok1(log_count == 0);
diff --git a/lib/tdb2/test/run-tdb1-zero-append.c b/lib/tdb2/test/run-tdb1-zero-append.c
index 3541fe08c8..9b5c8bc0f3 100644
--- a/lib/tdb2/test/run-tdb1-zero-append.c
+++ b/lib/tdb2/test/run-tdb1-zero-append.c
@@ -8,10 +8,15 @@ int main(int argc, char *argv[])
{
struct tdb_context *tdb;
TDB_DATA key, data;
+ union tdb_attribute hsize;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ hsize.tdb1_hashsize.hsize = 1024;
plan_tests(4);
- tdb = tdb1_open(NULL, 1024, TDB_INTERNAL, O_CREAT|O_TRUNC|O_RDWR,
- 0600, &tap_log_attr);
+ tdb = tdb1_open(NULL, TDB_INTERNAL, O_CREAT|O_TRUNC|O_RDWR,
+ 0600, &hsize);
ok1(tdb);
/* Tickle bug on appending zero length buffer to zero length buffer. */
diff --git a/lib/tdb2/test/run-tdb1.c b/lib/tdb2/test/run-tdb1.c
index d206545c68..913b66c109 100644
--- a/lib/tdb2/test/run-tdb1.c
+++ b/lib/tdb2/test/run-tdb1.c
@@ -8,10 +8,15 @@ int main(int argc, char *argv[])
{
struct tdb_context *tdb;
TDB_DATA key, data;
+ union tdb_attribute hsize;
+
+ hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+ hsize.base.next = &tap_log_attr;
+ hsize.tdb1_hashsize.hsize = 1024;
plan_tests(10);
- tdb = tdb1_open("run.tdb", 1024, TDB_DEFAULT,
- O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
+ tdb = tdb1_open("run.tdb", TDB_DEFAULT,
+ O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
ok1(tdb);
key.dsize = strlen("hi");
diff --git a/lib/tdb2/test/tdb1-external-agent.c b/lib/tdb2/test/tdb1-external-agent.c
index dcd825dc82..44bdeceaad 100644
--- a/lib/tdb2/test/tdb1-external-agent.c
+++ b/lib/tdb2/test/tdb1-external-agent.c
@@ -39,7 +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, 0, TDB_DEFAULT, O_RDWR, 0,
+ tdb = tdb1_open(name, TDB_DEFAULT, O_RDWR, 0,
&tap_log_attr);
if (!tdb) {
if (!locking_would_block1)