X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Ftest%2Fexternal-agent.h;fp=ccan%2Ftdb2%2Ftest%2Fexternal-agent.h;h=6d5c5306251a188dbdd13fefe51bbaafaf21397c;hb=0455668028cfe8f0417037975bc3d7dd742974db;hp=0000000000000000000000000000000000000000;hpb=cbe5094e85d08d19393c1b66abd59aecce7c8408;p=ccan diff --git a/ccan/tdb2/test/external-agent.h b/ccan/tdb2/test/external-agent.h new file mode 100644 index 00000000..6d5c5306 --- /dev/null +++ b/ccan/tdb2/test/external-agent.h @@ -0,0 +1,42 @@ +#ifndef TDB2_TEST_EXTERNAL_AGENT_H +#define TDB2_TEST_EXTERNAL_AGENT_H + +/* For locking tests, we need a different process to try things at + * various times. */ +enum operation { + OPEN, + FETCH, + STORE, +#if 0 + TRANSACTION_START, + TRANSACTION_COMMIT, + NEEDS_RECOVERY, +#endif + CHECK, + CLOSE, +}; + +/* Do this before doing any tdb stuff. Return handle, or -1. */ +struct agent *prepare_external_agent(void); + +enum agent_return { + SUCCESS, + WOULD_HAVE_BLOCKED, + AGENT_DIED, + FAILED, /* For fetch, or NEEDS_RECOVERY */ + OTHER_FAILURE, +}; + +/* Ask the external agent to try to do an operation. + * name == tdb name for OPEN/OPEN_WITH_CLEAR_IF_FIRST, + * record name for FETCH/STORE (store stores name as data too) + */ +enum agent_return external_agent_operation(struct agent *handle, + enum operation op, + const char *name); + +/* Mapping enum -> string. */ +const char *agent_return_name(enum agent_return ret); +const char *operation_name(enum operation op); + +#endif /* TDB2_TEST_EXTERNAL_AGENT_H */