X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb%2Ftest%2Frun-nested-traverse.c;h=c58b24c0fafe8a6f3110d138377a2ed467c3fd94;hp=f4a36b6217020ad0c24f7c5b38ddad6c2765bb87;hb=100444225380d3f5ca29424ea54703d308c7c651;hpb=2cad878947b3abd9d30841d6b80a5146479ac709 diff --git a/ccan/tdb/test/run-nested-traverse.c b/ccan/tdb/test/run-nested-traverse.c index f4a36b62..c58b24c0 100644 --- a/ccan/tdb/test/run-nested-traverse.c +++ b/ccan/tdb/test/run-nested-traverse.c @@ -1,17 +1,26 @@ #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 "lock-tracking.h" +#define fcntl fcntl_with_lockcheck +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#undef fcntl #include #include #include +#include "external-agent.h" +#include "logging.h" + +static struct agent *agent; static bool correct_key(TDB_DATA key) { @@ -38,11 +47,13 @@ static int traverse1(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, { ok1(correct_key(key)); ok1(correct_data(data)); - ok1(tdb->have_transaction_lock); + ok1(external_agent_operation(agent, TRANSACTION_START, tdb_name(tdb)) + == WOULD_HAVE_BLOCKED); tdb_traverse(tdb, traverse2, NULL); /* That should *not* release the transaction lock! */ - ok1(tdb->have_transaction_lock); + ok1(external_agent_operation(agent, TRANSACTION_START, tdb_name(tdb)) + == WOULD_HAVE_BLOCKED); return 0; } @@ -51,12 +62,21 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; TDB_DATA key, data; - plan_tests(14); - tdb = tdb_open("/tmp/test.tdb", 1024, TDB_CLEAR_IF_FIRST, - O_CREAT|O_TRUNC|O_RDWR, 0600); + plan_tests(17); + agent = prepare_external_agent(); + if (!agent) + err(1, "preparing agent"); + + tdb = tdb_open_ex("run-nested-traverse.tdb", 1024, TDB_CLEAR_IF_FIRST, + O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); ok1(tdb); - /* Tickle bug on appending zero length buffer to zero length buffer. */ + ok1(external_agent_operation(agent, OPEN, tdb_name(tdb)) == SUCCESS); + ok1(external_agent_operation(agent, TRANSACTION_START, tdb_name(tdb)) + == SUCCESS); + ok1(external_agent_operation(agent, TRANSACTION_COMMIT, tdb_name(tdb)) + == SUCCESS); + key.dsize = strlen("hi"); key.dptr = (void *)"hi"; data.dptr = (void *)"world";