summaryrefslogtreecommitdiff
path: root/lib/tdb2/test
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-09-14 07:55:13 +0930
committerRusty Russell <rusty@rustcorp.com.au>2011-09-14 07:55:13 +0930
commit30294c7b91456dd49b89a9b26eb0b1066087815c (patch)
tree8bf72d6834fafb9e030d120e7f6c881068cdb3af /lib/tdb2/test
parente6cbc0f00ec9ecb4c014ee484746d565382d5f67 (diff)
downloadsamba-30294c7b91456dd49b89a9b26eb0b1066087815c.tar.gz
samba-30294c7b91456dd49b89a9b26eb0b1066087815c.tar.bz2
samba-30294c7b91456dd49b89a9b26eb0b1066087815c.zip
tdb2: unify tdb1_traverse into tdb_traverse
Switch on the TDB_VERSION1 flag; we now only do a tdb1_traverse_read on a read-only database, as there is no tdb2 equivalent. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit cc2d609dfca7192305ad477b8c2b52cfdc1aa9be)
Diffstat (limited to 'lib/tdb2/test')
-rw-r--r--lib/tdb2/test/run-tdb1-3G-file.c6
-rw-r--r--lib/tdb2/test/run-tdb1-nested-traverse.c8
-rw-r--r--lib/tdb2/test/run-tdb1-no-lock-during-traverse.c6
-rw-r--r--lib/tdb2/test/run-tdb1-traverse-in-transaction.c4
4 files changed, 13 insertions, 11 deletions
diff --git a/lib/tdb2/test/run-tdb1-3G-file.c b/lib/tdb2/test/run-tdb1-3G-file.c
index 116c655438..074901857f 100644
--- a/lib/tdb2/test/run-tdb1-3G-file.c
+++ b/lib/tdb2/test/run-tdb1-3G-file.c
@@ -101,12 +101,12 @@ int main(int argc, char *argv[])
tdb1_unlock(tdb, TDB1_BUCKET(rec.full_hash), F_RDLCK);
/* Traverse must work. */
- ok1(tdb1_traverse(tdb, test_traverse, &orig_data) == 1);
+ ok1(tdb_traverse(tdb, test_traverse, &orig_data) == 1);
/* Delete should work. */
ok1(tdb_delete(tdb, key) == TDB_SUCCESS);
- ok1(tdb1_traverse(tdb, test_traverse, NULL) == 0);
+ ok1(tdb_traverse(tdb, test_traverse, NULL) == 0);
/* Transactions should work. */
ok1(tdb1_transaction_start(tdb) == 0);
@@ -118,7 +118,7 @@ int main(int argc, char *argv[])
free(data.dptr);
ok1(tdb1_transaction_commit(tdb) == 0);
- ok1(tdb1_traverse(tdb, test_traverse, &orig_data) == 1);
+ ok1(tdb_traverse(tdb, test_traverse, &orig_data) == 1);
tdb_close(tdb);
return exit_status();
diff --git a/lib/tdb2/test/run-tdb1-nested-traverse.c b/lib/tdb2/test/run-tdb1-nested-traverse.c
index ef19911d14..cf5aa4a2f4 100644
--- a/lib/tdb2/test/run-tdb1-nested-traverse.c
+++ b/lib/tdb2/test/run-tdb1-nested-traverse.c
@@ -38,7 +38,7 @@ static int traverse1(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data,
ok1(correct_data(data));
ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name)
== WOULD_HAVE_BLOCKED);
- tdb1_traverse(tdb, traverse2, NULL);
+ tdb_traverse(tdb, traverse2, NULL);
/* That should *not* release the transaction lock! */
ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name)
@@ -77,8 +77,10 @@ int main(int argc, char *argv[])
data.dsize = strlen("world");
ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS);
- tdb1_traverse(tdb, traverse1, NULL);
- tdb1_traverse_read(tdb, traverse1, NULL);
+ tdb_traverse(tdb, traverse1, NULL);
+ tdb_add_flag(tdb, TDB_RDONLY);
+ tdb_traverse(tdb, traverse1, NULL);
+ tdb_remove_flag(tdb, TDB_RDONLY);
tdb_close(tdb);
return exit_status();
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 383b74cb87..71404c2d75 100644
--- a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
+++ b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
hsize.base.next = &tap_log_attr;
hsize.tdb1_hashsize.hsize = 1024;
- plan_tests(41);
+ plan_tests(43);
tdb = tdb_open("run-no-lock-during-traverse.tdb1",
TDB_VERSION1, O_CREAT|O_TRUNC|O_RDWR,
0600, &hsize);
@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
ok1(locking_errors1 == 0);
ok1(tdb1_lockall(tdb) == 0);
ok1(locking_errors1 == 0);
- tdb1_traverse(tdb, delete_other, &errors);
+ ok1(tdb_traverse(tdb, delete_other, &errors) >= 0);
ok1(errors == 0);
ok1(locking_errors1 == 0);
ok1(tdb1_unlockall(tdb) == 0);
@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
ok1(locking_errors1 == 0);
ok1(tdb1_lockall(tdb) == 0);
ok1(locking_errors1 == 0);
- tdb1_traverse(tdb, delete_self, NULL);
+ ok1(tdb_traverse(tdb, delete_self, NULL) == NUM_ENTRIES);
ok1(locking_errors1 == 0);
ok1(tdb1_unlockall(tdb) == 0);
diff --git a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
index 90783198d9..c4fd89dfe4 100644
--- a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
+++ b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
@@ -64,12 +64,12 @@ int main(int argc, char *argv[])
ok1(tdb1_transaction_start(tdb) == 0);
ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name)
== WOULD_HAVE_BLOCKED);
- tdb1_traverse(tdb, traverse, NULL);
+ tdb_traverse(tdb, traverse, NULL);
/* That should *not* release the transaction lock! */
ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name)
== WOULD_HAVE_BLOCKED);
- tdb1_traverse_read(tdb, traverse, NULL);
+ tdb_traverse(tdb, traverse, NULL);
/* That should *not* release the transaction lock! */
ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name)