X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb%2Ftest%2Frun-nested-transactions.c;fp=ccan%2Ftdb%2Ftest%2Frun-nested-transactions.c;h=0000000000000000000000000000000000000000;hp=d13977ca8ae7bc1addb7a439aa575f6a95c9274b;hb=7581be1b694700155dbb0edb91a772babf160545;hpb=98b8ada203137a324f1712c042f7f6f3a5ef9ea0 diff --git a/ccan/tdb/test/run-nested-transactions.c b/ccan/tdb/test/run-nested-transactions.c deleted file mode 100644 index d13977ca..00000000 --- a/ccan/tdb/test/run-nested-transactions.c +++ /dev/null @@ -1,79 +0,0 @@ -#define _XOPEN_SOURCE 500 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "logging.h" - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - TDB_DATA key, data; - - plan_tests(27); - key.dsize = strlen("hi"); - key.dptr = (void *)"hi"; - - tdb = tdb_open_ex("run-nested-transactions.tdb", - 1024, TDB_CLEAR_IF_FIRST, - O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); - ok1(tdb); - - /* No nesting by default. */ - ok1(tdb_transaction_start(tdb) == 0); - data.dptr = (void *)"world"; - data.dsize = strlen("world"); - ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0); - data = tdb_fetch(tdb, key); - ok1(data.dsize == strlen("world")); - ok1(memcmp(data.dptr, "world", strlen("world")) == 0); - free(data.dptr); - ok1(tdb_transaction_start(tdb) != 0); - ok1(tdb_error(tdb) == TDB_ERR_NESTING); - - data = tdb_fetch(tdb, key); - ok1(data.dsize == strlen("world")); - ok1(memcmp(data.dptr, "world", strlen("world")) == 0); - free(data.dptr); - ok1(tdb_transaction_commit(tdb) == 0); - data = tdb_fetch(tdb, key); - ok1(data.dsize == strlen("world")); - ok1(memcmp(data.dptr, "world", strlen("world")) == 0); - free(data.dptr); - tdb_close(tdb); - - tdb = tdb_open_ex("run-nested-transactions.tdb", - 1024, TDB_ALLOW_NESTING, O_RDWR, 0, &taplogctx, NULL); - ok1(tdb); - - ok1(tdb_transaction_start(tdb) == 0); - ok1(tdb_transaction_start(tdb) == 0); - ok1(tdb_delete(tdb, key) == 0); - ok1(tdb_transaction_commit(tdb) == 0); - ok1(!tdb_exists(tdb, key)); - ok1(tdb_transaction_cancel(tdb) == 0); - /* Surprise! Kills inner "committed" transaction. */ - ok1(tdb_exists(tdb, key)); - - ok1(tdb_transaction_start(tdb) == 0); - ok1(tdb_transaction_start(tdb) == 0); - ok1(tdb_delete(tdb, key) == 0); - ok1(tdb_transaction_commit(tdb) == 0); - ok1(!tdb_exists(tdb, key)); - ok1(tdb_transaction_commit(tdb) == 0); - ok1(!tdb_exists(tdb, key)); - tdb_close(tdb); - - return exit_status(); -}