]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/test/run-04-basichash.c
tdb2: add write flag to tdb_direct
[ccan] / ccan / tdb2 / test / run-04-basichash.c
index ba70cc37143b90a57800bf331665a66774a24ea9..491c853fce27fb58b5778edc05f5d22aaa9570cb 100644 (file)
@@ -3,6 +3,7 @@
 #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"
@@ -45,7 +46,7 @@ int main(int argc, char *argv[])
 
                v = 0;
                /* Should not find it. */
-               ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec) == 0);
+               ok1(find_and_lock(tdb, key, F_WRLCK, &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. */
@@ -84,7 +85,8 @@ int main(int argc, char *argv[])
                ok1(tdb_check(tdb, NULL, NULL) == 0);
 
                /* Now, this should give a successful lookup. */
-               ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec) == new_off);
+               ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec, NULL)
+                   == new_off);
                /* Should have created correct hash. */
                ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
                /* Should have located space in group 0, bucket 0. */
@@ -110,7 +112,7 @@ int main(int argc, char *argv[])
 
                /* Test expansion. */
                v = 1;
-               ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec) == 0);
+               ok1(find_and_lock(tdb, key, F_WRLCK, &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 1. */
@@ -146,7 +148,8 @@ int main(int argc, char *argv[])
 
                /* Should be able to find it. */
                v = 0;
-               ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec) == new_off);
+               ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec, NULL)
+                   == new_off);
                /* Should have created correct hash. */
                ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
                /* Should have located space in expanded group 0, bucket 0. */
@@ -167,7 +170,7 @@ int main(int argc, char *argv[])
 
                /* Simple delete should work. */
                ok1(delete_from_hash(tdb, &h) == 0);
-               ok1(add_free_record(tdb, rec_zone_bits(&rec), new_off,
+               ok1(add_free_record(tdb, new_off,
                                    sizeof(struct tdb_used_record)
                                    + rec_key_length(&rec)
                                    + rec_data_length(&rec)
@@ -178,7 +181,7 @@ int main(int argc, char *argv[])
 
                /* Test second-level expansion: should expand 0th bucket. */
                v = 0;
-               ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec) == 0);
+               ok1(find_and_lock(tdb, key, F_WRLCK, &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. */
@@ -210,7 +213,7 @@ int main(int argc, char *argv[])
                /* Should be happy with expansion. */
                ok1(tdb_check(tdb, NULL, NULL) == 0);
 
-               ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec) == 0);
+               ok1(find_and_lock(tdb, key, F_WRLCK, &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. */
@@ -241,7 +244,8 @@ int main(int argc, char *argv[])
 
                /* Should be able to find it. */
                v = 0;
-               ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec) == new_off);
+               ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec, NULL)
+                   == new_off);
                /* Should have created correct hash. */
                ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
                /* Should have located space in expanded group 0, bucket 0. */