]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/test/run-20-growhash.c
tdb2: open hook for implementing TDB_CLEAR_IF_FIRST
[ccan] / ccan / tdb2 / test / run-20-growhash.c
index 6bcfd7d3baee007dbb29633068ef0c6010160113..22a88c450438b06bf94e8f29d554ea5f1e71d595 100644 (file)
@@ -1,15 +1,17 @@
 #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/transaction.c>
 #include <ccan/tdb2/check.c>
 #include <ccan/tap/tap.h>
 #include "logging.h"
 
 static uint64_t myhash(const void *key, size_t len, uint64_t seed, void *priv)
 {
-       return *(uint64_t *)key;
+       return *(const uint64_t *)key;
 }
 
 static void add_bits(uint64_t *val, unsigned new, unsigned new_bits,
@@ -47,7 +49,7 @@ int main(int argc, char *argv[])
        struct tdb_data key = { (unsigned char *)&kdata, sizeof(kdata) };
        struct tdb_data dbuf = { (unsigned char *)&kdata, sizeof(kdata) };
        union tdb_attribute hattr = { .hash = { .base = { TDB_ATTRIBUTE_HASH },
-                                               .hash_fn = myhash } };
+                                               .fn = myhash } };
        int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
                        TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
                        TDB_NOMMAP|TDB_CONVERT,
@@ -76,7 +78,7 @@ int main(int argc, char *argv[])
 
                /* Check first still exists. */
                kdata = make_key(0, 0, 0, 0, 0, 0);
-               ok1(find_and_lock(tdb, key, F_RDLCK, &h, &rec) != 0);
+               ok1(find_and_lock(tdb, key, F_RDLCK, &h, &rec, NULL) != 0);
                /* Should have created correct hash. */
                ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
                /* Should have located space in group 0, bucket 0. */
@@ -98,7 +100,7 @@ int main(int argc, char *argv[])
                        ok1(tdb_store(tdb, key, dbuf, TDB_INSERT) == 0);
                        ok1(tdb_check(tdb, NULL, NULL) == 0);
 
-                       ok1(find_and_lock(tdb, key, F_RDLCK, &h, &rec) != 0);
+                       ok1(find_and_lock(tdb, key, F_RDLCK, &h, &rec, NULL));
                        /* Should have created correct hash. */
                        ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
                        /* Should have moved to subhash */
@@ -122,7 +124,7 @@ int main(int argc, char *argv[])
                        ok1(tdb_store(tdb, key, dbuf, TDB_INSERT) == 0);
                        ok1(tdb_check(tdb, NULL, NULL) == 0);
 
-                       ok1(find_and_lock(tdb, key, F_RDLCK, &h, &rec) != 0);
+                       ok1(find_and_lock(tdb, key, F_RDLCK, &h, &rec, NULL));
                        /* Should have created correct hash. */
                        ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
                        /* Should have moved to subhash */