From aa5378602d8da09cccc9a435a6457245b13c2677 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 22 Mar 2012 10:47:26 +1030 Subject: lib/tdb2: fix OpenBSD incoherent mmap (tdb1 version) This is a direct port of the previous patch, to the TDB2 codebase. Signed-off-by: Rusty Russell --- lib/tdb2/test/run-tdb1-3G-file.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'lib/tdb2/test/run-tdb1-3G-file.c') diff --git a/lib/tdb2/test/run-tdb1-3G-file.c b/lib/tdb2/test/run-tdb1-3G-file.c index e75122ada9..148611753f 100644 --- a/lib/tdb2/test/run-tdb1-3G-file.c +++ b/lib/tdb2/test/run-tdb1-3G-file.c @@ -63,6 +63,7 @@ int main(int argc, char *argv[]) tdb1_off_t rec_ptr; struct tdb1_record rec; union tdb_attribute hsize; + int ret; hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; hsize.base.next = &tap_log_attr; @@ -75,15 +76,33 @@ int main(int argc, char *argv[]) ok1(tdb); tdb->tdb1.io = &large_io_methods; - /* Enlarge the file (internally multiplies by 2). */ - ok1(tdb1_expand(tdb, 1500000000) == 0); - - /* Put an entry in, and check it. */ key.dsize = strlen("hi"); key.dptr = (void *)"hi"; orig_data.dsize = strlen("world"); orig_data.dptr = (void *)"world"; + /* Enlarge the file (internally multiplies by 2). */ + ret = tdb1_expand(tdb, 1500000000); + +#ifdef HAVE_INCOHERENT_MMAP + /* This can fail due to mmap failure on 32 bit systems. */ + if (ret == -1) { + /* These should now fail. */ + ok1(tdb_store(tdb, key, orig_data, TDB_INSERT) == TDB_ERR_IO); + ok1(tdb_fetch(tdb, key, &data) == TDB_ERR_IO); + ok1(tdb_traverse(tdb, test_traverse, &orig_data) == TDB_ERR_IO); + ok1(tdb_delete(tdb, key) == TDB_ERR_IO); + ok1(tdb_traverse(tdb, test_traverse, NULL) == TDB_ERR_IO); + /* Skip the rest... */ + for (ret = 0; ret < 26 - 6; ret++) + ok1(1); + tdb_close(tdb); + return exit_status(); + } +#endif + ok1(ret == 0); + + /* Put an entry in, and check it. */ ok1(tdb_store(tdb, key, orig_data, TDB_INSERT) == TDB_SUCCESS); ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS); -- cgit