X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb%2Ftest%2Frun-traverse-in-transaction.c;h=61cb13155bb102dc0a345de2950f189b9f3b2772;hp=37a4f6d3ffd9ee760fef70de4746fc922f66285b;hb=ab3df365ce9bcd76379cda8d3a7c188baa3e0a05;hpb=02b364ae6c3a120101aa1fd6eb0919994ca8ffb1 diff --git a/ccan/tdb/test/run-traverse-in-transaction.c b/ccan/tdb/test/run-traverse-in-transaction.c index 37a4f6d3..61cb1315 100644 --- a/ccan/tdb/test/run-traverse-in-transaction.c +++ b/ccan/tdb/test/run-traverse-in-transaction.c @@ -1,4 +1,6 @@ #define _XOPEN_SOURCE 500 +#include "lock-tracking.h" +#define fcntl fcntl_with_lockcheck #include #include #include @@ -8,11 +10,15 @@ #include #include #include +#include +#include #include +#undef fcntl_with_lockcheck #include #include #include -#include "external-transaction.h" +#include "external-agent.h" +#include "logging.h" static struct agent *agent; @@ -46,8 +52,9 @@ int main(int argc, char *argv[]) if (!agent) err(1, "preparing agent"); - tdb = tdb_open("/tmp/test2.tdb", 1024, TDB_CLEAR_IF_FIRST, - O_CREAT|O_TRUNC|O_RDWR, 0600); + tdb = tdb_open_ex("run-traverse-in-transaction.tdb", + 1024, TDB_CLEAR_IF_FIRST, O_CREAT|O_TRUNC|O_RDWR, + 0600, &taplogctx, NULL); ok1(tdb); key.dsize = strlen("hi"); @@ -57,21 +64,25 @@ int main(int argc, char *argv[]) ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0); - ok1(external_agent_operation(agent, TRANSACTION, tdb_name(tdb))); + ok1(external_agent_operation(agent, OPEN, tdb_name(tdb)) == SUCCESS); ok1(tdb_transaction_start(tdb) == 0); - ok1(!external_agent_operation(agent, TRANSACTION, tdb_name(tdb))); + ok1(external_agent_operation(agent, TRANSACTION_START, tdb_name(tdb)) + == WOULD_HAVE_BLOCKED); tdb_traverse(tdb, traverse, NULL); /* That should *not* release the transaction lock! */ - ok1(!external_agent_operation(agent, TRANSACTION, tdb_name(tdb))); + ok1(external_agent_operation(agent, TRANSACTION_START, tdb_name(tdb)) + == WOULD_HAVE_BLOCKED); tdb_traverse_read(tdb, traverse, NULL); /* That should *not* release the transaction lock! */ - ok1(!external_agent_operation(agent, TRANSACTION, tdb_name(tdb))); + ok1(external_agent_operation(agent, TRANSACTION_START, tdb_name(tdb)) + == WOULD_HAVE_BLOCKED); ok1(tdb_transaction_commit(tdb) == 0); /* Now we should be fine. */ - ok1(external_agent_operation(agent, TRANSACTION, tdb_name(tdb))); + ok1(external_agent_operation(agent, TRANSACTION_START, tdb_name(tdb)) + == SUCCESS); tdb_close(tdb);