diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2011-09-14 07:35:13 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-09-14 07:35:13 +0930 |
commit | 9b98acbba304f2c1c1fba5bda672e1005151e526 (patch) | |
tree | 64dfb0b094bd57aa403a96be95097b6db9732553 /lib/tdb2/test | |
parent | 61b1bd1dca145a0417907793579352c66b016c23 (diff) | |
download | samba-9b98acbba304f2c1c1fba5bda672e1005151e526.tar.gz samba-9b98acbba304f2c1c1fba5bda672e1005151e526.tar.bz2 samba-9b98acbba304f2c1c1fba5bda672e1005151e526.zip |
tdb2: Make TDB1 code use TDB2's open flags.
This means getting rid of TDB_VOLATILE (perhaps we should use an
attribute for that?), TDB_INCOMPATIBLE_HASH (use the
tdb_attribute_hash for that) and TDB_CLEAR_IF_FIRST (use the
tdb_attribute_openhook for that).
We also get rid of TDB_DISALLOW_NESTING: that's the default for TDB2.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 22d0e0dc59fc9d7e0046fec6971ef478c2d604fd)
Diffstat (limited to 'lib/tdb2/test')
-rw-r--r-- | lib/tdb2/test/run-tdb1-3G-file.c | 2 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-check.c | 2 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-corrupt.c | 4 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-die-during-transaction.c | 2 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-endian.c | 2 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-incompatible.c | 4 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-nested-transactions.c | 6 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-nested-traverse.c | 2 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-no-lock-during-traverse.c | 2 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-open-during-transaction.c | 19 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-readonly-check.c | 4 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-summary.c | 6 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-traverse-in-transaction.c | 2 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-zero-append.c | 2 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1.c | 2 | ||||
-rw-r--r-- | lib/tdb2/test/tdb1-external-agent.c | 12 | ||||
-rw-r--r-- | lib/tdb2/test/tdb1-external-agent.h | 1 |
17 files changed, 29 insertions, 45 deletions
diff --git a/lib/tdb2/test/run-tdb1-3G-file.c b/lib/tdb2/test/run-tdb1-3G-file.c index 6121b4de48..98e3a3006c 100644 --- a/lib/tdb2/test/run-tdb1-3G-file.c +++ b/lib/tdb2/test/run-tdb1-3G-file.c @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) struct tdb1_record rec; plan_tests(24); - tdb = tdb1_open_ex("run-36-file.tdb", 1024, TDB1_CLEAR_IF_FIRST, + tdb = tdb1_open_ex("run-36-file.tdb", 1024, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); ok1(tdb); diff --git a/lib/tdb2/test/run-tdb1-check.c b/lib/tdb2/test/run-tdb1-check.c index fb49b64e48..f05608feaa 100644 --- a/lib/tdb2/test/run-tdb1-check.c +++ b/lib/tdb2/test/run-tdb1-check.c @@ -10,7 +10,7 @@ int main(int argc, char *argv[]) TDB_DATA key, data; plan_tests(13); - tdb = tdb1_open_ex("run-check.tdb", 1, TDB1_CLEAR_IF_FIRST, + tdb = tdb1_open_ex("run-check.tdb", 1, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); ok1(tdb); diff --git a/lib/tdb2/test/run-tdb1-corrupt.c b/lib/tdb2/test/run-tdb1-corrupt.c index bfc25a5711..2a8d31bf66 100644 --- a/lib/tdb2/test/run-tdb1-corrupt.c +++ b/lib/tdb2/test/run-tdb1-corrupt.c @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) plan_tests(4); /* This should use mmap. */ - tdb = tdb1_open_ex("run-corrupt.tdb", 2, TDB1_CLEAR_IF_FIRST, + tdb = tdb1_open_ex("run-corrupt.tdb", 2, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); if (!tdb) @@ -106,7 +106,7 @@ int main(int argc, char *argv[]) tdb1_close(tdb); /* This should not. */ - tdb = tdb1_open_ex("run-corrupt.tdb", 2, TDB1_CLEAR_IF_FIRST|TDB1_NOMMAP, + tdb = tdb1_open_ex("run-corrupt.tdb", 2, TDB_NOMMAP, O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); if (!tdb) diff --git a/lib/tdb2/test/run-tdb1-die-during-transaction.c b/lib/tdb2/test/run-tdb1-die-during-transaction.c index 3097e13a33..592f75731f 100644 --- a/lib/tdb2/test/run-tdb1-die-during-transaction.c +++ b/lib/tdb2/test/run-tdb1-die-during-transaction.c @@ -89,7 +89,7 @@ static bool test_death(enum operation op, struct agent *agent) current = target = 0; reset: unlink(TEST_DBNAME); - tdb = tdb1_open_ex(TEST_DBNAME, 1024, TDB1_NOMMAP, + tdb = tdb1_open_ex(TEST_DBNAME, 1024, TDB_NOMMAP, O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); if (setjmp(jmpbuf) != 0) { diff --git a/lib/tdb2/test/run-tdb1-endian.c b/lib/tdb2/test/run-tdb1-endian.c index 35067d7182..9813050d1e 100644 --- a/lib/tdb2/test/run-tdb1-endian.c +++ b/lib/tdb2/test/run-tdb1-endian.c @@ -11,7 +11,7 @@ int main(int argc, char *argv[]) plan_tests(13); tdb = tdb1_open_ex("run-endian.tdb", 1024, - TDB1_CLEAR_IF_FIRST|TDB1_CONVERT, + TDB_CONVERT, O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); ok1(tdb); diff --git a/lib/tdb2/test/run-tdb1-incompatible.c b/lib/tdb2/test/run-tdb1-incompatible.c index 6f3aee0336..a2754461e2 100644 --- a/lib/tdb2/test/run-tdb1-incompatible.c +++ b/lib/tdb2/test/run-tdb1-incompatible.c @@ -50,10 +50,10 @@ int main(int argc, char *argv[]) plan_tests(38 * 2); - for (flags = 0; flags <= TDB1_CONVERT; flags += TDB1_CONVERT) { + for (flags = 0; flags <= TDB_CONVERT; flags += TDB_CONVERT) { unsigned int rwmagic = TDB1_HASH_RWLOCK_MAGIC; - if (flags & TDB1_CONVERT) + if (flags & TDB_CONVERT) tdb1_convert(&rwmagic, sizeof(rwmagic)); /* Create an old-style hash. */ diff --git a/lib/tdb2/test/run-tdb1-nested-transactions.c b/lib/tdb2/test/run-tdb1-nested-transactions.c index f9891fe70d..6a13c13ded 100644 --- a/lib/tdb2/test/run-tdb1-nested-transactions.c +++ b/lib/tdb2/test/run-tdb1-nested-transactions.c @@ -15,10 +15,11 @@ int main(int argc, char *argv[]) key.dptr = (void *)"hi"; tdb = tdb1_open_ex("run-nested-transactions.tdb", - 1024, TDB1_CLEAR_IF_FIRST|TDB1_DISALLOW_NESTING, + 1024, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); ok1(tdb); + /* No nesting by default. */ ok1(tdb1_transaction_start(tdb) == 0); data.dptr = (void *)"world"; data.dsize = strlen("world"); @@ -41,9 +42,8 @@ int main(int argc, char *argv[]) free(data.dptr); tdb1_close(tdb); - /* Allow nesting by default. */ tdb = tdb1_open_ex("run-nested-transactions.tdb", - 1024, TDB1_DEFAULT, O_RDWR, 0, &taplogctx, NULL); + 1024, TDB_ALLOW_NESTING, O_RDWR, 0, &taplogctx, NULL); ok1(tdb); ok1(tdb1_transaction_start(tdb) == 0); diff --git a/lib/tdb2/test/run-tdb1-nested-traverse.c b/lib/tdb2/test/run-tdb1-nested-traverse.c index a33efec735..5eadc184ff 100644 --- a/lib/tdb2/test/run-tdb1-nested-traverse.c +++ b/lib/tdb2/test/run-tdb1-nested-traverse.c @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) if (!agent) err(1, "preparing agent"); - tdb = tdb1_open_ex("run-nested-traverse.tdb", 1024, TDB1_CLEAR_IF_FIRST, + tdb = tdb1_open_ex("run-nested-traverse.tdb", 1024, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); ok1(tdb); diff --git a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c index 4035c78c73..c1cb40a49e 100644 --- a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c +++ b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) plan_tests(41); tdb = tdb1_open_ex("run-no-lock-during-traverse.tdb", - 1024, TDB1_CLEAR_IF_FIRST, O_CREAT|O_TRUNC|O_RDWR, + 1024, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); ok1(tdb); diff --git a/lib/tdb2/test/run-tdb1-open-during-transaction.c b/lib/tdb2/test/run-tdb1-open-during-transaction.c index ad6c6d6074..875fc3ca9e 100644 --- a/lib/tdb2/test/run-tdb1-open-during-transaction.c +++ b/lib/tdb2/test/run-tdb1-open-during-transaction.c @@ -23,7 +23,6 @@ static int ftruncate_check(int fd, off_t length); static struct agent *agent; static bool opened; static int errors = 0; -static bool clear_if_first; #define TEST_DBNAME "run-open-during-transaction.tdb" #undef write @@ -70,10 +69,7 @@ static void check_file_intact(int fd) } /* Ask agent to open file. */ - ret = external_agent_operation1(agent, clear_if_first ? - OPEN_WITH_CLEAR_IF_FIRST : - OPEN, - TEST_DBNAME); + ret = external_agent_operation1(agent, OPEN, TEST_DBNAME); /* It's OK to open it, but it must not have changed! */ if (!compare_file(fd, contents, st.st_size)) { @@ -132,25 +128,22 @@ static int ftruncate_check(int fd, off_t length) int main(int argc, char *argv[]) { - const int flags[] = { TDB1_DEFAULT, - TDB1_CLEAR_IF_FIRST, - TDB1_NOMMAP, - TDB1_CLEAR_IF_FIRST | TDB1_NOMMAP }; + const int flags[] = { TDB_DEFAULT, + TDB_NOMMAP }; int i; struct tdb1_context *tdb; TDB_DATA key, data; - plan_tests(20); + plan_tests(10); agent = prepare_external_agent1(); if (!agent) err(1, "preparing agent"); unlock_callback1 = after_unlock; for (i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) { - clear_if_first = (flags[i] & TDB1_CLEAR_IF_FIRST); diag("Test with %s and %s\n", - clear_if_first ? "CLEAR" : "DEFAULT", - (flags[i] & TDB1_NOMMAP) ? "no mmap" : "mmap"); + "DEFAULT", + (flags[i] & TDB_NOMMAP) ? "no mmap" : "mmap"); unlink(TEST_DBNAME); tdb = tdb1_open_ex(TEST_DBNAME, 1024, flags[i], O_CREAT|O_TRUNC|O_RDWR, 0600, diff --git a/lib/tdb2/test/run-tdb1-readonly-check.c b/lib/tdb2/test/run-tdb1-readonly-check.c index a764f2da42..ae47aa747d 100644 --- a/lib/tdb2/test/run-tdb1-readonly-check.c +++ b/lib/tdb2/test/run-tdb1-readonly-check.c @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) plan_tests(11); tdb = tdb1_open_ex("run-readonly-check.tdb", 1024, - TDB1_DEFAULT, + TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); ok1(tdb); @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) ok1(tdb1_close(tdb) == 0); tdb = tdb1_open_ex("run-readonly-check.tdb", 1024, - TDB1_DEFAULT, O_RDONLY, 0, &taplogctx, NULL); + TDB_DEFAULT, O_RDONLY, 0, &taplogctx, NULL); ok1(tdb); ok1(tdb1_store(tdb, key, data, TDB_MODIFY) == -1); diff --git a/lib/tdb2/test/run-tdb1-summary.c b/lib/tdb2/test/run-tdb1-summary.c index 616c522507..b563b18730 100644 --- a/lib/tdb2/test/run-tdb1-summary.c +++ b/lib/tdb2/test/run-tdb1-summary.c @@ -7,9 +7,9 @@ int main(int argc, char *argv[]) { unsigned int i, j; struct tdb1_context *tdb; - int flags[] = { TDB1_INTERNAL, TDB1_DEFAULT, TDB1_NOMMAP, - TDB1_INTERNAL|TDB1_CONVERT, TDB1_CONVERT, - TDB1_NOMMAP|TDB1_CONVERT }; + int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, + TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, + TDB_NOMMAP|TDB_CONVERT }; TDB_DATA key = { (unsigned char *)&j, sizeof(j) }; TDB_DATA data = { (unsigned char *)&j, sizeof(j) }; char *summary; diff --git a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c index 4d3a81f19e..922f73caa7 100644 --- a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c +++ b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) err(1, "preparing agent"); tdb = tdb1_open_ex("run-traverse-in-transaction.tdb", - 1024, TDB1_CLEAR_IF_FIRST, O_CREAT|O_TRUNC|O_RDWR, + 1024, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); ok1(tdb); diff --git a/lib/tdb2/test/run-tdb1-zero-append.c b/lib/tdb2/test/run-tdb1-zero-append.c index 1ecab54ce4..1304bebdbd 100644 --- a/lib/tdb2/test/run-tdb1-zero-append.c +++ b/lib/tdb2/test/run-tdb1-zero-append.c @@ -10,7 +10,7 @@ int main(int argc, char *argv[]) TDB_DATA key, data; plan_tests(4); - tdb = tdb1_open_ex(NULL, 1024, TDB1_INTERNAL, O_CREAT|O_TRUNC|O_RDWR, + tdb = tdb1_open_ex(NULL, 1024, TDB_INTERNAL, O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); ok1(tdb); diff --git a/lib/tdb2/test/run-tdb1.c b/lib/tdb2/test/run-tdb1.c index 1f234b12e3..84eea75ce2 100644 --- a/lib/tdb2/test/run-tdb1.c +++ b/lib/tdb2/test/run-tdb1.c @@ -10,7 +10,7 @@ int main(int argc, char *argv[]) TDB_DATA key, data; plan_tests(10); - tdb = tdb1_open_ex("run.tdb", 1024, TDB1_CLEAR_IF_FIRST, + tdb = tdb1_open_ex("run.tdb", 1024, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); ok1(tdb); diff --git a/lib/tdb2/test/tdb1-external-agent.c b/lib/tdb2/test/tdb1-external-agent.c index f60df5b702..18c76f1124 100644 --- a/lib/tdb2/test/tdb1-external-agent.c +++ b/lib/tdb2/test/tdb1-external-agent.c @@ -24,7 +24,7 @@ static enum agent_return do_operation(enum operation op, const char *name) enum agent_return ret; TDB_DATA data; - if (op != OPEN && op != OPEN_WITH_CLEAR_IF_FIRST && !tdb) { + if (op != OPEN && !tdb) { diag("external: No tdb open!"); return OTHER_FAILURE; } @@ -39,7 +39,7 @@ static enum agent_return do_operation(enum operation op, const char *name) diag("Already have tdb %s open", tdb->name); return OTHER_FAILURE; } - tdb = tdb1_open_ex(name, 0, TDB1_DEFAULT, O_RDWR, 0, + tdb = tdb1_open_ex(name, 0, TDB_DEFAULT, O_RDWR, 0, &taplogctx, NULL); if (!tdb) { if (!locking_would_block1) @@ -48,13 +48,6 @@ static enum agent_return do_operation(enum operation op, const char *name) } else ret = SUCCESS; break; - case OPEN_WITH_CLEAR_IF_FIRST: - if (tdb) - return OTHER_FAILURE; - tdb = tdb1_open_ex(name, 0, TDB1_CLEAR_IF_FIRST, O_RDWR, 0, - &taplogctx, NULL); - ret = tdb ? SUCCESS : OTHER_FAILURE; - break; case TRANSACTION_START: ret = tdb1_transaction_start(tdb) == 0 ? SUCCESS : OTHER_FAILURE; break; @@ -183,7 +176,6 @@ const char *operation_name1(enum operation op) { switch (op) { case OPEN: return "OPEN"; - case OPEN_WITH_CLEAR_IF_FIRST: return "OPEN_WITH_CLEAR_IF_FIRST"; case TRANSACTION_START: return "TRANSACTION_START"; case FETCH: return "FETCH"; case STORE: return "STORE"; diff --git a/lib/tdb2/test/tdb1-external-agent.h b/lib/tdb2/test/tdb1-external-agent.h index 8b0c1548a7..ee903b65c5 100644 --- a/lib/tdb2/test/tdb1-external-agent.h +++ b/lib/tdb2/test/tdb1-external-agent.h @@ -5,7 +5,6 @@ * various times. */ enum operation { OPEN, - OPEN_WITH_CLEAR_IF_FIRST, TRANSACTION_START, FETCH, STORE, |