]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb/test/run-nested-traverse.c
tdb: enforce hashing, via example hash in old rwlocks entry in header.
[ccan] / ccan / tdb / test / run-nested-traverse.c
index df4c7da13374d8befdcc37aa1a79590717e9d739..156946af1fb82ce61a0856afbeee23554459125f 100644 (file)
@@ -1,20 +1,21 @@
 #define _XOPEN_SOURCE 500
-#include "tdb/tdb.h"
-#include "tdb/io.c"
-#include "tdb/tdb.c"
-#include "tdb/lock.c"
-#include "tdb/freelist.c"
-#include "tdb/traverse.c"
-#include "tdb/transaction.c"
-#include "tdb/error.c"
-#include "tdb/open.c"
-#include "tap/tap.h"
+#include <ccan/tdb/tdb.h>
+#include <ccan/tdb/io.c>
+#include <ccan/tdb/tdb.c>
+#include <ccan/tdb/lock.c>
+#include <ccan/tdb/freelist.c>
+#include <ccan/tdb/traverse.c>
+#include <ccan/tdb/transaction.c>
+#include <ccan/tdb/error.c>
+#include <ccan/tdb/open.c>
+#include <ccan/tdb/check.c>
+#include <ccan/tap/tap.h>
 #include <stdlib.h>
 #include <stdbool.h>
 #include <err.h>
 #include "external-transaction.h"
 
-static int agent;
+static struct agent *agent;
 
 static bool correct_key(TDB_DATA key)
 {
@@ -41,11 +42,11 @@ static int traverse1(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data,
 {
        ok1(correct_key(key));
        ok1(correct_data(data));
-       ok1(!external_agent_transaction(agent, tdb_name(tdb)));
+       ok1(!external_agent_operation(agent, TRANSACTION, tdb_name(tdb)));
        tdb_traverse(tdb, traverse2, NULL);
 
        /* That should *not* release the transaction lock! */
-       ok1(!external_agent_transaction(agent, tdb_name(tdb)));
+       ok1(!external_agent_operation(agent, TRANSACTION, tdb_name(tdb)));
        return 0;
 }
 
@@ -56,14 +57,14 @@ int main(int argc, char *argv[])
 
        plan_tests(15);
        agent = prepare_external_agent();
-       if (agent < 0)
+       if (!agent)
                err(1, "preparing agent");
 
-       tdb = tdb_open("/tmp/test3.tdb", 1024, TDB_CLEAR_IF_FIRST,
+       tdb = tdb_open("run-nested-traverse.tdb", 1024, TDB_CLEAR_IF_FIRST,
                       O_CREAT|O_TRUNC|O_RDWR, 0600);
        ok1(tdb);
 
-       ok1(external_agent_transaction(agent, tdb_name(tdb)));
+       ok1(external_agent_operation(agent, TRANSACTION, tdb_name(tdb)));
 
        key.dsize = strlen("hi");
        key.dptr = (void *)"hi";