From 01b2214a1893db5071addf1fdf17e9ac06ed63a0 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 14 Sep 2011 08:13:26 +0930 Subject: tdb2: test: try (almost) all tests with TDB_VERSION1 flag. There are some minor changes required, in particular: 1) Make sure lockcheck understands tdb1 allrecord lock upgrades. 2) Handle tdb1 sequence number jumps: various operations increment the sequence number twice, especually tdb_append. 3) Don't test fail on unlock, since it gets triggered with traversal on the tdb1 backend (we didn't actually ever test this case for tdb2). 4) Move clear_if_first to offset 4, to match tdb1. Signed-off-by: Rusty Russell (Imported from CCAN commit 818ed29730b030ce79855fc35c212b51adff3180) --- lib/tdb2/test/run-open-multiple-times.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib/tdb2/test/run-open-multiple-times.c') diff --git a/lib/tdb2/test/run-open-multiple-times.c b/lib/tdb2/test/run-open-multiple-times.c index f49e65d8b6..4d60b20279 100644 --- a/lib/tdb2/test/run-open-multiple-times.c +++ b/lib/tdb2/test/run-open-multiple-times.c @@ -4,13 +4,16 @@ int main(int argc, char *argv[]) { - unsigned int i; + unsigned int i, extra_messages; struct tdb_context *tdb, *tdb2; struct tdb_data key = { (unsigned char *)&i, sizeof(i) }; struct tdb_data data = { (unsigned char *)&i, sizeof(i) }; struct tdb_data d = { NULL, 0 }; /* Bogus GCC warning */ int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, + TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, + TDB_CONVERT|TDB_VERSION1, + TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; plan_tests(sizeof(flags) / sizeof(flags[0]) * 28); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { @@ -19,6 +22,12 @@ int main(int argc, char *argv[]) ok1(tdb); if (!tdb) continue; + + if (flags[i] & TDB_VERSION1) { + extra_messages = 1; + } else { + extra_messages = 0; + } tdb2 = tdb_open("run-open-multiple-times.tdb", flags[i], O_RDWR|O_CREAT, 0600, &tap_log_attr); ok1(tdb_check(tdb, NULL, NULL) == 0); @@ -51,12 +60,15 @@ int main(int argc, char *argv[]) /* Anything in the other one should fail. */ ok1(tdb_fetch(tdb, key, &d) == TDB_ERR_LOCK); + tap_log_messages -= extra_messages; ok1(tap_log_messages == 1); ok1(tdb_store(tdb, key, data, TDB_REPLACE) == TDB_ERR_LOCK); + tap_log_messages -= extra_messages; ok1(tap_log_messages == 2); ok1(tdb_transaction_start(tdb) == TDB_ERR_LOCK); ok1(tap_log_messages == 3); ok1(tdb_chainlock(tdb, key) == TDB_ERR_LOCK); + tap_log_messages -= extra_messages; ok1(tap_log_messages == 4); /* Transaciton should work as normal. */ -- cgit