summaryrefslogtreecommitdiff
path: root/lib/ntdb/test/run-64-bit-tdb.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2012-06-18 22:30:29 +0930
committerRusty Russell <rusty@rustcorp.com.au>2012-06-19 05:38:06 +0200
commitdb2508840d55842ebaf0c0d7a2fa3c855498e75f (patch)
tree6123390e0616ed98eb173422e94e8c5c0e862459 /lib/ntdb/test/run-64-bit-tdb.c
parent9396757676c304398a3e94ad01f2657e667b113c (diff)
downloadsamba-db2508840d55842ebaf0c0d7a2fa3c855498e75f.tar.gz
ntdb: create initial database to be multiple of NTDB_PGSIZE.
As copied from tdb1, there is logic in the transaction code to handle a non-PGSIZE multiple db, but in fact this only happens for a completely unused database: as soon as we add anything to it, it is expanded to a NTDB_PGSIZE multiple. If we create the database with a free record which pads it out to NTDB_PGSIZE, we can remove this last-page-is-different logic. Of course, the fake ntdbs we create in our tests now also need to be multiples of NTDB_PGSIZE, so we change some numbers there too. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/ntdb/test/run-64-bit-tdb.c')
-rw-r--r--lib/ntdb/test/run-64-bit-tdb.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/ntdb/test/run-64-bit-tdb.c b/lib/ntdb/test/run-64-bit-tdb.c
index b36f422a972..a85a4af56c9 100644
--- a/lib/ntdb/test/run-64-bit-tdb.c
+++ b/lib/ntdb/test/run-64-bit-tdb.c
@@ -21,7 +21,7 @@ int main(int argc, char *argv[])
return exit_status();
}
- plan_tests(sizeof(flags) / sizeof(flags[0]) * 14);
+ plan_tests(sizeof(flags) / sizeof(flags[0]) * 16);
for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
off_t old_size;
NTDB_DATA k, d;
@@ -37,6 +37,15 @@ int main(int argc, char *argv[])
old_size = ntdb->file->map_size;
+ /* Add a fake record to chew up the existing free space. */
+ k = ntdb_mkdata("fake", 4);
+ d.dsize = ntdb->file->map_size - sizeof(struct new_database)- 8;
+ d.dptr = malloc(d.dsize);
+ memset(d.dptr, 0, d.dsize);
+ ok1(ntdb_store(ntdb, k, d, NTDB_INSERT) == 0);
+ ok1(ntdb->file->map_size == old_size);
+ free(d.dptr);
+
/* This makes a sparse file */
ok1(ftruncate(ntdb->file->fd, ALMOST_4G) == 0);
ok1(add_free_record(ntdb, old_size, ALMOST_4G - old_size,