]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/test/run-56-open-during-transaction.c
tdb2: test: convert (non-invasive) run tests to api tests.
[ccan] / ccan / tdb2 / test / run-56-open-during-transaction.c
index 8a6a0e52720ee2e3ba91da78519fe28adc86f4db..9262c0528eb8a2f4bcf3b6691b30854751d7e4b0 100644 (file)
@@ -1,4 +1,4 @@
-#include "config.h"
+#include <ccan/tdb2/private.h>
 #include <unistd.h>
 #include "lock-tracking.h"
 
@@ -11,13 +11,7 @@ static int ftruncate_check(int fd, off_t length);
 #define fcntl fcntl_with_lockcheck
 #define ftruncate ftruncate_check
 
-#include <ccan/tdb2/tdb.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 <stdlib.h>
 #include <stdbool.h>
@@ -134,15 +128,16 @@ static int ftruncate_check(int fd, off_t length)
 
 int main(int argc, char *argv[])
 {
-       const int flags[] = { TDB_DEFAULT,
-                             TDB_NOMMAP,
-                             TDB_CONVERT,
-                             TDB_CONVERT | TDB_NOMMAP };
+       const int flags[] = { TDB_DEFAULT, TDB_NOMMAP,
+                       TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT,
+                       TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1,
+                       TDB_CONVERT|TDB_VERSION1,
+                       TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 };
        int i;
        struct tdb_context *tdb;
        TDB_DATA key, data;
 
-       plan_tests(20);
+       plan_tests(sizeof(flags)/sizeof(flags[0]) * 5);
        agent = prepare_external_agent();
        if (!agent)
                err(1, "preparing agent");
@@ -159,10 +154,8 @@ int main(int argc, char *argv[])
 
                opened = true;
                ok1(tdb_transaction_start(tdb) == 0);
-               key.dsize = strlen("hi");
-               key.dptr = (void *)"hi";
-               data.dptr = (void *)"world";
-               data.dsize = strlen("world");
+               key = tdb_mkdata("hi", strlen("hi"));
+               data = tdb_mkdata("world", strlen("world"));
 
                ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0);
                ok1(tdb_transaction_commit(tdb) == 0);