X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Ftest%2Frun-tdb1-3G-file.c;h=0f299a32fe1427d2ed7b598f1dff4b068d594865;hp=43e9f2ad9bd831f847acfe954ab3e6305315b207;hb=98c754ffe65bc335f66161d6cc8705d4ea2710ec;hpb=60210a73ec08a7b34ba637ad19e6749cf6dc1952 diff --git a/ccan/tdb2/test/run-tdb1-3G-file.c b/ccan/tdb2/test/run-tdb1-3G-file.c index 43e9f2ad..0f299a32 100644 --- a/ccan/tdb2/test/run-tdb1-3G-file.c +++ b/ccan/tdb2/test/run-tdb1-3G-file.c @@ -4,13 +4,13 @@ #include #include #include -#include "tdb1-logging.h" +#include "logging.h" -static int tdb1_expand_file_sparse(struct tdb1_context *tdb, +static int tdb1_expand_file_sparse(struct tdb_context *tdb, tdb1_off_t size, tdb1_off_t addition) { - if (tdb->read_only || tdb->traverse_read) { + if ((tdb->flags & TDB_RDONLY) || tdb->tdb1.traverse_read) { tdb->last_error = TDB_ERR_RDONLY; return -1; } @@ -46,7 +46,7 @@ static const struct tdb1_methods large_io_methods = { tdb1_expand_file_sparse }; -static int test_traverse(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA data, +static int test_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *_data) { TDB_DATA *expect = _data; @@ -59,18 +59,23 @@ static int test_traverse(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA data, int main(int argc, char *argv[]) { - struct tdb1_context *tdb; + struct tdb_context *tdb; TDB_DATA key, orig_data, data; 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_ex("run-36-file.tdb", 1024, TDB_DEFAULT, - O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); + tdb = tdb_open("run-36-file.tdb1", TDB_VERSION1, + O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); ok1(tdb); - tdb->methods = &large_io_methods; + tdb->tdb1.io = &large_io_methods; /* Enlarge the file (internally multiplies by 2). */ ok1(tdb1_expand(tdb, 1500000000) == 0); @@ -81,7 +86,7 @@ int main(int argc, char *argv[]) orig_data.dsize = strlen("world"); orig_data.dptr = (void *)"world"; - ok1(tdb1_store(tdb, key, orig_data, TDB_INSERT) == 0); + ok1(tdb_store(tdb, key, orig_data, TDB_INSERT) == TDB_SUCCESS); data = tdb1_fetch(tdb, key); ok1(data.dsize == strlen("world")); @@ -89,7 +94,7 @@ int main(int argc, char *argv[]) free(data.dptr); /* That currently fills at the end, make sure that's true. */ - hash = tdb->hash_fn(&key); + hash = tdb_hash(tdb, key.dptr, key.dsize); rec_ptr = tdb1_find_lock_hash(tdb, key, hash, F_RDLCK, &rec); ok1(rec_ptr); ok1(rec_ptr > 2U*1024*1024*1024); @@ -105,7 +110,7 @@ int main(int argc, char *argv[]) /* Transactions should work. */ ok1(tdb1_transaction_start(tdb) == 0); - ok1(tdb1_store(tdb, key, orig_data, TDB_INSERT) == 0); + ok1(tdb_store(tdb, key, orig_data, TDB_INSERT) == TDB_SUCCESS); data = tdb1_fetch(tdb, key); ok1(data.dsize == strlen("world")); @@ -114,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(); }