X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Ftest%2Frun-03-coalesce.c;h=0b544f8c1f758f286b0e7a5fd90862e7e47d94a8;hb=156e5eb92f1d986957cb081b58320579c6e366dd;hp=7325a4498c81e5d8c1b1497f8cc64c8b770e7b7b;hpb=7d6312518bd3a8e4cbad69b1f6b1800f7bcdf68c;p=ccan diff --git a/ccan/tdb2/test/run-03-coalesce.c b/ccan/tdb2/test/run-03-coalesce.c index 7325a449..0b544f8c 100644 --- a/ccan/tdb2/test/run-03-coalesce.c +++ b/ccan/tdb2/test/run-03-coalesce.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -33,13 +34,11 @@ int main(int argc, char *argv[]) /* FIXME: Test TDB_CONVERT */ plan_tests(38); - data.dptr = (void *)"world"; - data.dsize = 5; - key.dptr = (void *)"hello"; - key.dsize = 5; + data = tdb_mkdata("world", 5); + key = tdb_mkdata("hello", 5); /* No coalescing can be done due to EOF */ - layout = new_tdb_layout(NULL); + layout = new_tdb_layout("run-03-coalesce.tdb"); tdb_layout_add_freetable(layout); len = 1024; tdb_layout_add_free(layout, len, 0); @@ -59,7 +58,7 @@ int main(int argc, char *argv[]) tdb_layout_free(layout); /* No coalescing can be done due to used record */ - layout = new_tdb_layout(NULL); + layout = new_tdb_layout("run-03-coalesce.tdb"); tdb_layout_add_freetable(layout); tdb_layout_add_free(layout, 1024, 0); tdb_layout_add_used(layout, key, data, 6); @@ -79,7 +78,7 @@ int main(int argc, char *argv[]) tdb_layout_free(layout); /* Coalescing can be done due to two free records, then EOF */ - layout = new_tdb_layout(NULL); + layout = new_tdb_layout("run-03-coalesce.tdb"); tdb_layout_add_freetable(layout); tdb_layout_add_free(layout, 1024, 0); tdb_layout_add_free(layout, 2048, 0); @@ -93,7 +92,7 @@ int main(int argc, char *argv[]) /* Lock and coalesce. */ ok1(tdb_lock_free_bucket(tdb, b_off, TDB_LOCK_WAIT) == 0); ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024) == 1); - ok1(tdb->allrecord_lock.count == 0 && tdb->num_lockrecs == 0); + ok1(tdb->file->allrecord_lock.count == 0 && tdb->file->num_lockrecs == 0); ok1(free_record_length(tdb, layout->elem[1].base.off) == 1024 + sizeof(struct tdb_used_record) + 2048); ok1(tdb_check(tdb, NULL, NULL) == 0); @@ -101,7 +100,7 @@ int main(int argc, char *argv[]) tdb_layout_free(layout); /* Coalescing can be done due to two free records, then data */ - layout = new_tdb_layout(NULL); + layout = new_tdb_layout("run-03-coalesce.tdb"); tdb_layout_add_freetable(layout); tdb_layout_add_free(layout, 1024, 0); tdb_layout_add_free(layout, 512, 0); @@ -116,7 +115,7 @@ int main(int argc, char *argv[]) /* Lock and coalesce. */ ok1(tdb_lock_free_bucket(tdb, b_off, TDB_LOCK_WAIT) == 0); ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024) == 1); - ok1(tdb->allrecord_lock.count == 0 && tdb->num_lockrecs == 0); + ok1(tdb->file->allrecord_lock.count == 0 && tdb->file->num_lockrecs == 0); ok1(free_record_length(tdb, layout->elem[1].base.off) == 1024 + sizeof(struct tdb_used_record) + 512); ok1(tdb_check(tdb, NULL, NULL) == 0); @@ -124,7 +123,7 @@ int main(int argc, char *argv[]) tdb_layout_free(layout); /* Coalescing can be done due to three free records, then EOF */ - layout = new_tdb_layout(NULL); + layout = new_tdb_layout("run-03-coalesce.tdb"); tdb_layout_add_freetable(layout); tdb_layout_add_free(layout, 1024, 0); tdb_layout_add_free(layout, 512, 0); @@ -140,7 +139,8 @@ int main(int argc, char *argv[]) /* Lock and coalesce. */ ok1(tdb_lock_free_bucket(tdb, b_off, TDB_LOCK_WAIT) == 0); ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024) == 1); - ok1(tdb->allrecord_lock.count == 0 && tdb->num_lockrecs == 0); + ok1(tdb->file->allrecord_lock.count == 0 + && tdb->file->num_lockrecs == 0); ok1(free_record_length(tdb, layout->elem[1].base.off) == 1024 + sizeof(struct tdb_used_record) + 512 + sizeof(struct tdb_used_record) + 256);