]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/test/run-03-coalesce.c
tdb2: make jenkins_hash function non-static, rename to tdb_jenkins_hash.
[ccan] / ccan / tdb2 / test / run-03-coalesce.c
index e60e341eca46d9fe359a98602f144184f41271bc..93b817284467c03361859065d8016bc6206899b9 100644 (file)
@@ -1,11 +1,4 @@
-#include <ccan/tdb2/tdb.c>
-#include <ccan/tdb2/open.c>
-#include <ccan/tdb2/free.c>
-#include <ccan/tdb2/lock.c>
-#include <ccan/tdb2/io.c>
-#include <ccan/tdb2/hash.c>
-#include <ccan/tdb2/check.c>
-#include <ccan/tdb2/transaction.c>
+#include "tdb2-source.h"
 #include <ccan/tap/tap.h>
 #include "logging.h"
 #include "layout.h"
@@ -43,16 +36,16 @@ int main(int argc, char *argv[])
        tdb_layout_add_freetable(layout);
        len = 1024;
        tdb_layout_add_free(layout, len, 0);
-       tdb = tdb_layout_get(layout);
+       tdb = tdb_layout_get(layout, &tap_log_attr);
        ok1(tdb_check(tdb, NULL, NULL) == 0);
        ok1(free_record_length(tdb, layout->elem[1].base.off) == len);
 
        /* Figure out which bucket free entry is. */
-       b_off = bucket_off(tdb->ftable_off, size_to_bucket(len));
+       b_off = bucket_off(tdb->tdb2.ftable_off, size_to_bucket(len));
        /* Lock and fail to coalesce. */
        ok1(tdb_lock_free_bucket(tdb, b_off, TDB_LOCK_WAIT) == 0);
        test = layout->elem[1].base.off;
-       ok1(coalesce(tdb, layout->elem[1].base.off, b_off, len, &test, &test)
+       ok1(coalesce(tdb, layout->elem[1].base.off, b_off, len, &test)
            == 0);
        tdb_unlock_free_bucket(tdb, b_off);
        ok1(free_record_length(tdb, layout->elem[1].base.off) == len);
@@ -66,16 +59,16 @@ int main(int argc, char *argv[])
        tdb_layout_add_freetable(layout);
        tdb_layout_add_free(layout, 1024, 0);
        tdb_layout_add_used(layout, key, data, 6);
-       tdb = tdb_layout_get(layout);
+       tdb = tdb_layout_get(layout, &tap_log_attr);
        ok1(free_record_length(tdb, layout->elem[1].base.off) == 1024);
        ok1(tdb_check(tdb, NULL, NULL) == 0);
 
        /* Figure out which bucket free entry is. */
-       b_off = bucket_off(tdb->ftable_off, size_to_bucket(1024));
+       b_off = bucket_off(tdb->tdb2.ftable_off, size_to_bucket(1024));
        /* Lock and fail to coalesce. */
        ok1(tdb_lock_free_bucket(tdb, b_off, TDB_LOCK_WAIT) == 0);
        test = layout->elem[1].base.off;
-       ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024, &test, &test)
+       ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024, &test)
            == 0);
        tdb_unlock_free_bucket(tdb, b_off);
        ok1(free_record_length(tdb, layout->elem[1].base.off) == 1024);
@@ -89,17 +82,17 @@ int main(int argc, char *argv[])
        tdb_layout_add_freetable(layout);
        tdb_layout_add_free(layout, 1024, 0);
        tdb_layout_add_free(layout, 2048, 0);
-       tdb = tdb_layout_get(layout);
+       tdb = tdb_layout_get(layout, &tap_log_attr);
        ok1(free_record_length(tdb, layout->elem[1].base.off) == 1024);
        ok1(free_record_length(tdb, layout->elem[2].base.off) == 2048);
        ok1(tdb_check(tdb, NULL, NULL) == 0);
 
        /* Figure out which bucket (first) free entry is. */
-       b_off = bucket_off(tdb->ftable_off, size_to_bucket(1024));
+       b_off = bucket_off(tdb->tdb2.ftable_off, size_to_bucket(1024));
        /* Lock and coalesce. */
        ok1(tdb_lock_free_bucket(tdb, b_off, TDB_LOCK_WAIT) == 0);
        test = layout->elem[2].base.off;
-       ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024, &test, &test)
+       ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024, &test)
            == 1024 + sizeof(struct tdb_used_record) + 2048);
        /* Should tell us it's erased this one... */
        ok1(test == TDB_ERR_NOEXIST);
@@ -116,17 +109,17 @@ int main(int argc, char *argv[])
        tdb_layout_add_free(layout, 1024, 0);
        tdb_layout_add_free(layout, 512, 0);
        tdb_layout_add_used(layout, key, data, 6);
-       tdb = tdb_layout_get(layout);
+       tdb = tdb_layout_get(layout, &tap_log_attr);
        ok1(free_record_length(tdb, layout->elem[1].base.off) == 1024);
        ok1(free_record_length(tdb, layout->elem[2].base.off) == 512);
        ok1(tdb_check(tdb, NULL, NULL) == 0);
 
        /* Figure out which bucket free entry is. */
-       b_off = bucket_off(tdb->ftable_off, size_to_bucket(1024));
+       b_off = bucket_off(tdb->tdb2.ftable_off, size_to_bucket(1024));
        /* Lock and coalesce. */
        ok1(tdb_lock_free_bucket(tdb, b_off, TDB_LOCK_WAIT) == 0);
        test = layout->elem[2].base.off;
-       ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024, &test, &test)
+       ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024, &test)
            == 1024 + sizeof(struct tdb_used_record) + 512);
        ok1(tdb->file->allrecord_lock.count == 0 && tdb->file->num_lockrecs == 0);
        ok1(free_record_length(tdb, layout->elem[1].base.off)
@@ -142,18 +135,18 @@ int main(int argc, char *argv[])
        tdb_layout_add_free(layout, 1024, 0);
        tdb_layout_add_free(layout, 512, 0);
        tdb_layout_add_free(layout, 256, 0);
-       tdb = tdb_layout_get(layout);
+       tdb = tdb_layout_get(layout, &tap_log_attr);
        ok1(free_record_length(tdb, layout->elem[1].base.off) == 1024);
        ok1(free_record_length(tdb, layout->elem[2].base.off) == 512);
        ok1(free_record_length(tdb, layout->elem[3].base.off) == 256);
        ok1(tdb_check(tdb, NULL, NULL) == 0);
 
        /* Figure out which bucket free entry is. */
-       b_off = bucket_off(tdb->ftable_off, size_to_bucket(1024));
+       b_off = bucket_off(tdb->tdb2.ftable_off, size_to_bucket(1024));
        /* Lock and coalesce. */
        ok1(tdb_lock_free_bucket(tdb, b_off, TDB_LOCK_WAIT) == 0);
        test = layout->elem[2].base.off;
-       ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024, &test, &test)
+       ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024, &test)
            == 1024 + sizeof(struct tdb_used_record) + 512
            + sizeof(struct tdb_used_record) + 256);
        ok1(tdb->file->allrecord_lock.count == 0