]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/test/run-03-coalesce.c
tdb2: allow multiple chain locks.
[ccan] / ccan / tdb2 / test / run-03-coalesce.c
index d40096515a1ba5c245c2af1f452fb926b89cb471..0b544f8c1f758f286b0e7a5fd90862e7e47d94a8 100644 (file)
@@ -34,10 +34,8 @@ 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("run-03-coalesce.tdb");
@@ -94,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);
@@ -117,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);
@@ -141,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);