]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/test/run-55-transaction.c
tdb2: Make tdb1 share tdb_store flags, struct tdb_data and TDB_MAGIC_FOOD.
[ccan] / ccan / tdb2 / test / run-55-transaction.c
index d1224a7fdad6b61567d15edf60055773d9ac9c62..a6607d11dbd3b97575f5f3788b01c87b83706702 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"
 
@@ -16,7 +9,7 @@ int main(int argc, char *argv[])
        unsigned char *buffer;
        int flags[] = { TDB_DEFAULT, TDB_NOMMAP,
                        TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT };
-       struct tdb_data key = { (unsigned char *)"key", 3 };
+       struct tdb_data key = tdb_mkdata("key", 3);
        struct tdb_data data;
 
        buffer = malloc(1000);
@@ -43,7 +36,8 @@ int main(int argc, char *argv[])
 
                /* Cancelling a transaction means no store */
                tdb_transaction_cancel(tdb);
-               ok1(tdb->allrecord_lock.count == 0 && tdb->num_lockrecs == 0);
+               ok1(tdb->file->allrecord_lock.count == 0
+                   && tdb->file->num_lockrecs == 0);
                ok1(tdb_check(tdb, NULL, NULL) == 0);
                ok1(tdb_fetch(tdb, key, &data) == TDB_ERR_NOEXIST);
 
@@ -57,7 +51,8 @@ int main(int argc, char *argv[])
                ok1(memcmp(data.dptr, buffer, data.dsize) == 0);
                free(data.dptr);
                ok1(tdb_transaction_commit(tdb) == 0);
-               ok1(tdb->allrecord_lock.count == 0 && tdb->num_lockrecs == 0);
+               ok1(tdb->file->allrecord_lock.count == 0
+                   && tdb->file->num_lockrecs == 0);
                ok1(tdb_check(tdb, NULL, NULL) == 0);
                ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS);
                ok1(data.dsize == 1000);