diff options
Diffstat (limited to 'lib/tdb2/test')
69 files changed, 74 insertions, 2239 deletions
diff --git a/lib/tdb2/test/api-13-delete.c b/lib/tdb2/test/api-13-delete.c index c8ed580615..279b38645b 100644 --- a/lib/tdb2/test/api-13-delete.c +++ b/lib/tdb2/test/api-13-delete.c @@ -151,12 +151,7 @@ int main(int argc, char *argv[]) .data = &seed } }; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; /* These two values gave trouble before. */ int vals[] = { 755, 837 }; diff --git a/lib/tdb2/test/api-14-exists.c b/lib/tdb2/test/api-14-exists.c index 916e9b46f6..801c295893 100644 --- a/lib/tdb2/test/api-14-exists.c +++ b/lib/tdb2/test/api-14-exists.c @@ -38,12 +38,7 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; plan_tests(sizeof(flags) / sizeof(flags[0]) * 2 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { diff --git a/lib/tdb2/test/api-16-wipe_all.c b/lib/tdb2/test/api-16-wipe_all.c index f97dd0db42..3dfcc7a419 100644 --- a/lib/tdb2/test/api-16-wipe_all.c +++ b/lib/tdb2/test/api-16-wipe_all.c @@ -26,12 +26,7 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; plan_tests(sizeof(flags) / sizeof(flags[0]) * 4 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { diff --git a/lib/tdb2/test/api-21-parse_record.c b/lib/tdb2/test/api-21-parse_record.c index 6ac9543b52..150e1c9dd0 100644 --- a/lib/tdb2/test/api-21-parse_record.c +++ b/lib/tdb2/test/api-21-parse_record.c @@ -51,12 +51,7 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; plan_tests(sizeof(flags) / sizeof(flags[0]) * 2 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { diff --git a/lib/tdb2/test/api-55-transaction.c b/lib/tdb2/test/api-55-transaction.c index ece59d5cb5..c474c6abc3 100644 --- a/lib/tdb2/test/api-55-transaction.c +++ b/lib/tdb2/test/api-55-transaction.c @@ -13,10 +13,7 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; unsigned char *buffer; int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, - TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; struct tdb_data key = tdb_mkdata("key", 3); struct tdb_data data; diff --git a/lib/tdb2/test/api-80-tdb_fd.c b/lib/tdb2/test/api-80-tdb_fd.c index fea30979b9..63967b8aa6 100644 --- a/lib/tdb2/test/api-80-tdb_fd.c +++ b/lib/tdb2/test/api-80-tdb_fd.c @@ -12,12 +12,7 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; plan_tests(sizeof(flags) / sizeof(flags[0]) * 3); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { diff --git a/lib/tdb2/test/api-81-seqnum.c b/lib/tdb2/test/api-81-seqnum.c index 954b097b0f..8bf261d635 100644 --- a/lib/tdb2/test/api-81-seqnum.c +++ b/lib/tdb2/test/api-81-seqnum.c @@ -16,14 +16,9 @@ int main(int argc, char *argv[]) struct tdb_data data = tdb_mkdata("data", 4); int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; - plan_tests(sizeof(flags) / sizeof(flags[0]) * 15 + 8 * 13); + plan_tests(sizeof(flags) / sizeof(flags[0]) * 15 + 4 * 13); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { tdb = tdb_open("api-81-seqnum.tdb", flags[i]|TDB_SEQNUM, O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); @@ -39,9 +34,6 @@ int main(int argc, char *argv[]) free(d.dptr); ok1(tdb_get_seqnum(tdb) == seq); ok1(tdb_append(tdb, key, data) == TDB_SUCCESS); - /* Append in tdb1 (or store over value) bumps twice! */ - if (flags[i] & TDB_VERSION1) - seq++; ok1(tdb_get_seqnum(tdb) == ++seq); ok1(tdb_delete(tdb, key) == TDB_SUCCESS); @@ -57,9 +49,6 @@ int main(int argc, char *argv[]) ok1(tdb_transaction_start(tdb) == TDB_SUCCESS); ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0); ok1(tdb_get_seqnum(tdb) == ++seq); - /* Append in tdb1 (or store over value) bumps twice! */ - if (flags[i] & TDB_VERSION1) - seq++; ok1(tdb_append(tdb, key, data) == TDB_SUCCESS); ok1(tdb_get_seqnum(tdb) == ++seq); ok1(tdb_delete(tdb, key) == TDB_SUCCESS); diff --git a/lib/tdb2/test/api-82-lockattr.c b/lib/tdb2/test/api-82-lockattr.c index 8dc4e2fa4e..b229eab83c 100644 --- a/lib/tdb2/test/api-82-lockattr.c +++ b/lib/tdb2/test/api-82-lockattr.c @@ -46,10 +46,7 @@ int main(int argc, char *argv[]) unsigned int i; struct tdb_context *tdb; int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, - TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; union tdb_attribute lock_attr; struct tdb_data key = tdb_mkdata("key", 3); struct tdb_data data = tdb_mkdata("data", 4); @@ -65,14 +62,6 @@ int main(int argc, char *argv[]) for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { struct tdb_data d; - unsigned int num_oom_messages; - - /* TDB1 double logs here. */ - if (flags[i] & TDB_VERSION1) { - num_oom_messages = 2; - } else { - num_oom_messages = 1; - } /* Nonblocking open; expect no error message. */ lock_err = EAGAIN; @@ -114,7 +103,7 @@ int main(int argc, char *argv[]) ok1(tap_log_messages == 0); lock_err = ENOMEM; ok1(tdb_store(tdb, key, data, TDB_REPLACE) == TDB_ERR_LOCK); - ok1(tap_log_messages == num_oom_messages); + ok1(tap_log_messages == 1); tap_log_messages = 0; /* Nonblocking fetch. */ @@ -126,7 +115,7 @@ int main(int argc, char *argv[]) ok1(tap_log_messages == 0); lock_err = ENOMEM; ok1(!tdb_exists(tdb, key)); - ok1(tap_log_messages == num_oom_messages); + ok1(tap_log_messages == 1); tap_log_messages = 0; lock_err = EAGAIN; @@ -137,7 +126,7 @@ int main(int argc, char *argv[]) ok1(tap_log_messages == 0); lock_err = ENOMEM; ok1(tdb_fetch(tdb, key, &d) == TDB_ERR_LOCK); - ok1(tap_log_messages == num_oom_messages); + ok1(tap_log_messages == 1); tap_log_messages = 0; /* Nonblocking delete. */ @@ -149,7 +138,7 @@ int main(int argc, char *argv[]) ok1(tap_log_messages == 0); lock_err = ENOMEM; ok1(tdb_delete(tdb, key) == TDB_ERR_LOCK); - ok1(tap_log_messages == num_oom_messages); + ok1(tap_log_messages == 1); tap_log_messages = 0; /* Nonblocking locks. */ @@ -161,7 +150,7 @@ int main(int argc, char *argv[]) ok1(tap_log_messages == 0); lock_err = ENOMEM; ok1(tdb_chainlock(tdb, key) == TDB_ERR_LOCK); - ok1(tap_log_messages == num_oom_messages); + ok1(tap_log_messages == 1); tap_log_messages = 0; lock_err = EAGAIN; @@ -172,7 +161,7 @@ int main(int argc, char *argv[]) ok1(tap_log_messages == 0); lock_err = ENOMEM; ok1(tdb_chainlock_read(tdb, key) == TDB_ERR_LOCK); - ok1(tap_log_messages == num_oom_messages); + ok1(tap_log_messages == 1); tap_log_messages = 0; lock_err = EAGAIN; @@ -211,7 +200,7 @@ int main(int argc, char *argv[]) trav_err = ENOMEM; lock_err = 0; ok1(tdb_traverse(tdb, trav, &lock_err) == TDB_ERR_LOCK); - ok1(tap_log_messages == num_oom_messages); + ok1(tap_log_messages == 1); tap_log_messages = 0; /* Nonblocking transactions. */ diff --git a/lib/tdb2/test/api-83-openhook.c b/lib/tdb2/test/api-83-openhook.c index acafca78fa..191cf068c1 100644 --- a/lib/tdb2/test/api-83-openhook.c +++ b/lib/tdb2/test/api-83-openhook.c @@ -47,10 +47,7 @@ int main(int argc, char *argv[]) union tdb_attribute cif; struct tdb_data key = tdb_mkdata("key", 3); int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, - TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; cif.openhook.base.attr = TDB_ATTRIBUTE_OPENHOOK; cif.openhook.base.next = &tap_log_attr; diff --git a/lib/tdb2/test/api-91-get-stats.c b/lib/tdb2/test/api-91-get-stats.c index f7bc64524d..395db3fb18 100644 --- a/lib/tdb2/test/api-91-get-stats.c +++ b/lib/tdb2/test/api-91-get-stats.c @@ -13,10 +13,7 @@ int main(int argc, char *argv[]) unsigned int i; struct tdb_context *tdb; int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, - TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; plan_tests(sizeof(flags) / sizeof(flags[0]) * 11); diff --git a/lib/tdb2/test/api-92-get-set-readonly.c b/lib/tdb2/test/api-92-get-set-readonly.c index eddb0d4fe2..46aea7ae0d 100644 --- a/lib/tdb2/test/api-92-get-set-readonly.c +++ b/lib/tdb2/test/api-92-get-set-readonly.c @@ -8,15 +8,12 @@ int main(int argc, char *argv[]) { - unsigned int i, extra_msgs; + unsigned int i; struct tdb_context *tdb; struct tdb_data key = tdb_mkdata("key", 3); struct tdb_data data = tdb_mkdata("data", 4); int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, - TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; plan_tests(sizeof(flags) / sizeof(flags[0]) * 48); @@ -27,13 +24,6 @@ int main(int argc, char *argv[]) ok1(tdb); ok1(!(tdb_get_flags(tdb) & TDB_RDONLY)); - /* TDB1 complains multiple times. */ - if (flags[i] & TDB_VERSION1) { - extra_msgs = 1; - } else { - extra_msgs = 0; - } - ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); tdb_add_flag(tdb, TDB_RDONLY); @@ -43,17 +33,14 @@ int main(int argc, char *argv[]) ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_ERR_RDONLY); ok1(tap_log_messages == 1); ok1(tdb_append(tdb, key, data) == TDB_ERR_RDONLY); - tap_log_messages -= extra_msgs; ok1(tap_log_messages == 2); ok1(tdb_delete(tdb, key) == TDB_ERR_RDONLY); - tap_log_messages -= extra_msgs; ok1(tap_log_messages == 3); /* Can't start a transaction, or any write lock. */ ok1(tdb_transaction_start(tdb) == TDB_ERR_RDONLY); ok1(tap_log_messages == 4); ok1(tdb_chainlock(tdb, key) == TDB_ERR_RDONLY); - tap_log_messages -= extra_msgs; ok1(tap_log_messages == 5); ok1(tdb_lockall(tdb) == TDB_ERR_RDONLY); ok1(tap_log_messages == 6); @@ -91,17 +78,14 @@ int main(int argc, char *argv[]) ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_ERR_RDONLY); ok1(tap_log_messages == 8); ok1(tdb_append(tdb, key, data) == TDB_ERR_RDONLY); - tap_log_messages -= extra_msgs; ok1(tap_log_messages == 9); ok1(tdb_delete(tdb, key) == TDB_ERR_RDONLY); - tap_log_messages -= extra_msgs; ok1(tap_log_messages == 10); /* Can't start a transaction, or any write lock. */ ok1(tdb_transaction_start(tdb) == TDB_ERR_RDONLY); ok1(tap_log_messages == 11); ok1(tdb_chainlock(tdb, key) == TDB_ERR_RDONLY); - tap_log_messages -= extra_msgs; ok1(tap_log_messages == 12); ok1(tdb_lockall(tdb) == TDB_ERR_RDONLY); ok1(tap_log_messages == 13); diff --git a/lib/tdb2/test/api-93-repack.c b/lib/tdb2/test/api-93-repack.c index a1b5154524..910eb9b301 100644 --- a/lib/tdb2/test/api-93-repack.c +++ b/lib/tdb2/test/api-93-repack.c @@ -53,10 +53,7 @@ int main(int argc, char *argv[]) bool found[NUM_TESTS]; struct tdb_context *tdb; int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, - TDB_VERSION1, TDB_VERSION1|TDB_NOMMAP, - TDB_VERSION1|TDB_CONVERT, - TDB_VERSION1|TDB_NOMMAP|TDB_CONVERT + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; plan_tests(sizeof(flags) / sizeof(flags[0]) * 6 + 1); diff --git a/lib/tdb2/test/api-add-remove-flags.c b/lib/tdb2/test/api-add-remove-flags.c index 2526bf45b6..a72b609fcb 100644 --- a/lib/tdb2/test/api-add-remove-flags.c +++ b/lib/tdb2/test/api-add-remove-flags.c @@ -12,14 +12,9 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; - plan_tests(173); + plan_tests(87); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { tdb = tdb_open("run-add-remove-flags.tdb", flags[i], O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); diff --git a/lib/tdb2/test/api-check-callback.c b/lib/tdb2/test/api-check-callback.c index e49d00f904..96ef09f3bd 100644 --- a/lib/tdb2/test/api-check-callback.c +++ b/lib/tdb2/test/api-check-callback.c @@ -58,12 +58,7 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; plan_tests(sizeof(flags) / sizeof(flags[0]) * 4 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { diff --git a/lib/tdb2/test/api-firstkey-nextkey.c b/lib/tdb2/test/api-firstkey-nextkey.c index 56b3c25fb0..e5a7c5f8b5 100644 --- a/lib/tdb2/test/api-firstkey-nextkey.c +++ b/lib/tdb2/test/api-firstkey-nextkey.c @@ -56,12 +56,7 @@ int main(int argc, char *argv[]) enum TDB_ERROR ecode; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; seed_attr.base.attr = TDB_ATTRIBUTE_SEED; seed_attr.base.next = &tap_log_attr; @@ -72,7 +67,7 @@ int main(int argc, char *argv[]) for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { tdb = tdb_open("api-firstkey-nextkey.tdb", flags[i], O_RDWR|O_CREAT|O_TRUNC, 0600, - flags[i] & TDB_VERSION1 ? NULL : &seed_attr); + &seed_attr); ok1(tdb); if (!tdb) continue; diff --git a/lib/tdb2/test/api-fork-test.c b/lib/tdb2/test/api-fork-test.c index 988004e90a..934c71cbe8 100644 --- a/lib/tdb2/test/api-fork-test.c +++ b/lib/tdb2/test/api-fork-test.c @@ -25,24 +25,16 @@ static enum TDB_ERROR fork_in_parse(TDB_DATA key, TDB_DATA data, struct tdb_context *tdb) { - int status, extra_messages; - - if (tdb_get_flags(tdb) & TDB_VERSION1) { - extra_messages = 1; - } else { - extra_messages = 0; - } + int status; if (fork() == 0) { /* We expect this to fail. */ if (tdb_store(tdb, key, data, TDB_REPLACE) != TDB_ERR_LOCK) exit(1); - tap_log_messages -= extra_messages; if (tdb_fetch(tdb, key, &data) != TDB_ERR_LOCK) exit(1); - tap_log_messages -= extra_messages; if (tap_log_messages != 2) exit(2); @@ -61,22 +53,13 @@ int main(int argc, char *argv[]) unsigned int i; struct tdb_context *tdb; int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, - TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; struct tdb_data key = tdb_mkdata("key", 3); struct tdb_data data = tdb_mkdata("data", 4); plan_tests(sizeof(flags) / sizeof(flags[0]) * 14); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - int status, extra_messages; - - if (flags[i] & TDB_VERSION1) { - extra_messages = 1; - } else { - extra_messages = 0; - } + int status; tap_log_messages = 0; @@ -93,11 +76,9 @@ int main(int argc, char *argv[]) /* We expect this to fail. */ if (tdb_store(tdb, key, data, TDB_REPLACE) != TDB_ERR_LOCK) return 1; - tap_log_messages -= extra_messages; if (tdb_fetch(tdb, key, &data) != TDB_ERR_LOCK) return 1; - tap_log_messages -= extra_messages; if (tap_log_messages != 2) return 2; @@ -119,11 +100,9 @@ int main(int argc, char *argv[]) /* We expect this to fail. */ if (tdb_store(tdb, key, data, TDB_REPLACE) != TDB_ERR_LOCK) return 1; - tap_log_messages -= extra_messages; if (tdb_fetch(tdb, key, &data) != TDB_ERR_LOCK) return 1; - tap_log_messages -= extra_messages; if (tap_log_messages != 2) return 2; @@ -146,11 +125,9 @@ int main(int argc, char *argv[]) /* This would always fail anyway... */ if (tdb_store(tdb, key, data, TDB_REPLACE) != TDB_ERR_LOCK) return 1; - tap_log_messages -= extra_messages; if (tdb_fetch(tdb, key, &data) != TDB_ERR_LOCK) return 1; - tap_log_messages -= extra_messages; if (tap_log_messages != 2) return 2; @@ -174,18 +151,15 @@ int main(int argc, char *argv[]) /* We expect this to fail. */ if (tdb_store(tdb, key, data, TDB_REPLACE) != TDB_ERR_LOCK) return 1; - tap_log_messages -= extra_messages; if (tdb_fetch(tdb, key, &data) != TDB_ERR_LOCK) return 1; - tap_log_messages -= extra_messages; if (tap_log_messages != 2) return 2; if (tdb_transaction_commit(tdb) != TDB_ERR_LOCK) return 3; - tap_log_messages -= extra_messages; tdb_close(tdb); if (tap_log_messages < 3) diff --git a/lib/tdb2/test/api-locktimeout.c b/lib/tdb2/test/api-locktimeout.c index 2466817a13..dabe262f25 100644 --- a/lib/tdb2/test/api-locktimeout.c +++ b/lib/tdb2/test/api-locktimeout.c @@ -133,10 +133,7 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; TDB_DATA key = tdb_mkdata("hello", 5); int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, - TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; struct agent *agent; plan_tests(sizeof(flags) / sizeof(flags[0]) * 15); diff --git a/lib/tdb2/test/api-open-multiple-times.c b/lib/tdb2/test/api-open-multiple-times.c index f976c95403..38aea135ac 100644 --- a/lib/tdb2/test/api-open-multiple-times.c +++ b/lib/tdb2/test/api-open-multiple-times.c @@ -9,16 +9,13 @@ int main(int argc, char *argv[]) { - unsigned int i, extra_messages; + unsigned int i; 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_VERSION1, TDB_NOMMAP|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; plan_tests(sizeof(flags) / sizeof(flags[0]) * 28); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { @@ -28,11 +25,6 @@ int main(int argc, char *argv[]) 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); @@ -65,15 +57,12 @@ 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. */ diff --git a/lib/tdb2/test/api-record-expand.c b/lib/tdb2/test/api-record-expand.c index 686dcf3267..34799ebe5e 100644 --- a/lib/tdb2/test/api-record-expand.c +++ b/lib/tdb2/test/api-record-expand.c @@ -16,12 +16,7 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; struct tdb_data key = tdb_mkdata("key", 3); struct tdb_data data; diff --git a/lib/tdb2/test/api-simple-delete.c b/lib/tdb2/test/api-simple-delete.c index bd228d654e..48b077a6db 100644 --- a/lib/tdb2/test/api-simple-delete.c +++ b/lib/tdb2/test/api-simple-delete.c @@ -12,12 +12,7 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; struct tdb_data key = tdb_mkdata("key", 3); struct tdb_data data = tdb_mkdata("data", 4); diff --git a/lib/tdb2/test/api-summary.c b/lib/tdb2/test/api-summary.c index babccc7cf4..e9dfd270e9 100644 --- a/lib/tdb2/test/api-summary.c +++ b/lib/tdb2/test/api-summary.c @@ -13,12 +13,7 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; struct tdb_data key = { (unsigned char *)&j, sizeof(j) }; struct tdb_data data = { (unsigned char *)&j, sizeof(j) }; char *summary; @@ -46,8 +41,7 @@ int main(int argc, char *argv[]) ok1(strstr(summary, "Number of records: 500\n")); ok1(strstr(summary, "Smallest/average/largest keys: 4/4/4\n")); ok1(strstr(summary, "Smallest/average/largest data: 0/2/4\n")); - if (!(flags[i] & TDB_VERSION1) - && j == TDB_SUMMARY_HISTOGRAMS) { + if (j == TDB_SUMMARY_HISTOGRAMS) { ok1(strstr(summary, "|") && strstr(summary, "*")); } else { diff --git a/lib/tdb2/test/api-tdb1-flag-removal.c b/lib/tdb2/test/api-tdb1-flag-removal.c deleted file mode 100644 index 59994dfa5c..0000000000 --- a/lib/tdb2/test/api-tdb1-flag-removal.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "config.h" -#include "tdb2.h" -#include "tap-interface.h" -#include <ccan/hash/hash.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -#include "logging.h" - -int main(int argc, char *argv[]) -{ - unsigned int i; - struct tdb_context *tdb; - int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; - - plan_tests(sizeof(flags) / sizeof(flags[0]) * 3 + 1); - for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - tdb = tdb_open("run-12-store.tdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); - if (!ok1(tdb)) - continue; - - tdb_close(tdb); - - tdb = tdb_open("run-12-store.tdb", flags[i] | TDB_VERSION1, - O_RDWR, 0600, &tap_log_attr); - if (!ok1(tdb)) - continue; - /* It's not a version1 */ - ok1(!(tdb_get_flags(tdb) & TDB_VERSION1)); - - tdb_close(tdb); - } - - ok1(tap_log_messages == 0); - return exit_status(); -} diff --git a/lib/tdb2/test/failtest_helper.h b/lib/tdb2/test/failtest_helper.h index 4130aff1eb..3c509e7c38 100644 --- a/lib/tdb2/test/failtest_helper.h +++ b/lib/tdb2/test/failtest_helper.h @@ -4,7 +4,7 @@ #include <stdbool.h> /* FIXME: Check these! */ -#define INITIAL_TDB_MALLOC "open.c", 445, FAILTEST_MALLOC +#define INITIAL_TDB_MALLOC "open.c", 403, FAILTEST_MALLOC #define URANDOM_OPEN "open.c", 62, FAILTEST_OPEN #define URANDOM_READ "open.c", 42, FAILTEST_READ diff --git a/lib/tdb2/test/helpapi-external-agent.c b/lib/tdb2/test/helpapi-external-agent.c index 140ffaf116..59e1c6cbee 100644 --- a/lib/tdb2/test/helpapi-external-agent.c +++ b/lib/tdb2/test/helpapi-external-agent.c @@ -1,5 +1,4 @@ #include "external-agent.h" -#include "tdb1_private.h" /* This isn't possible with via the tdb2 API, but this makes it link. */ enum agent_return external_agent_needs_rec(struct tdb_context *tdb) diff --git a/lib/tdb2/test/helprun-external-agent.c b/lib/tdb2/test/helprun-external-agent.c index 469847be75..9f243824fd 100644 --- a/lib/tdb2/test/helprun-external-agent.c +++ b/lib/tdb2/test/helprun-external-agent.c @@ -1,10 +1,7 @@ #include "external-agent.h" -#include "tdb1_private.h" +#include "private.h" enum agent_return external_agent_needs_rec(struct tdb_context *tdb) { - if (tdb->flags & TDB_VERSION1) - return tdb1_needs_recovery(tdb) ? SUCCESS : FAILED; - else - return tdb_needs_recovery(tdb) ? SUCCESS : FAILED; + return tdb_needs_recovery(tdb) ? SUCCESS : FAILED; } diff --git a/lib/tdb2/test/jenkins-be-hash.tdb1 b/lib/tdb2/test/jenkins-be-hash.tdb1 Binary files differdeleted file mode 100644 index b652840414..0000000000 --- a/lib/tdb2/test/jenkins-be-hash.tdb1 +++ /dev/null diff --git a/lib/tdb2/test/jenkins-le-hash.tdb1 b/lib/tdb2/test/jenkins-le-hash.tdb1 Binary files differdeleted file mode 100644 index 007e0a3368..0000000000 --- a/lib/tdb2/test/jenkins-le-hash.tdb1 +++ /dev/null diff --git a/lib/tdb2/test/lock-tracking.c b/lib/tdb2/test/lock-tracking.c index 4a61f9c312..c7387ead99 100644 --- a/lib/tdb2/test/lock-tracking.c +++ b/lib/tdb2/test/lock-tracking.c @@ -1,5 +1,5 @@ /* We save the locks so we can reaquire them. */ -#include "tdb1_private.h" /* For TDB_HASH_LOCK_START, TDB1_FREELIST_TOP, etc. */ +#include "private.h" /* For TDB_HASH_LOCK_START, etc. */ #include <unistd.h> #include <fcntl.h> #include <stdarg.h> @@ -110,17 +110,6 @@ int fcntl_with_lockcheck(int fd, int cmd, ... /* arg */ ) i->type = F_WRLCK; goto done; } - /* allrecord upgrade for tdb1. */ - if (i->type == F_RDLCK && fl->l_type == F_WRLCK - && i->off == TDB1_FREELIST_TOP - && fl->l_start == TDB1_FREELIST_TOP - && i->len == 0 - && fl->l_len == 0) { - if (ret == 0) - i->type = F_WRLCK; - goto done; - } - if (!suppress_lockcheck) { diag("%s lock %u@%u overlaps %u@%u", fl->l_type == F_WRLCK ? "write" : "read", diff --git a/lib/tdb2/test/old-nohash-be.tdb1 b/lib/tdb2/test/old-nohash-be.tdb1 Binary files differdeleted file mode 100644 index 1c49116c1d..0000000000 --- a/lib/tdb2/test/old-nohash-be.tdb1 +++ /dev/null diff --git a/lib/tdb2/test/old-nohash-le.tdb1 b/lib/tdb2/test/old-nohash-le.tdb1 Binary files differdeleted file mode 100644 index 0655072d88..0000000000 --- a/lib/tdb2/test/old-nohash-le.tdb1 +++ /dev/null diff --git a/lib/tdb2/test/run-01-new_database.c b/lib/tdb2/test/run-01-new_database.c index 2876868842..00c15140df 100644 --- a/lib/tdb2/test/run-01-new_database.c +++ b/lib/tdb2/test/run-01-new_database.c @@ -11,12 +11,7 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; failtest_init(argc, argv); failtest_hook = block_repeat_failures; diff --git a/lib/tdb2/test/run-05-readonly-open.c b/lib/tdb2/test/run-05-readonly-open.c index 4827b425da..1046a8b47e 100644 --- a/lib/tdb2/test/run-05-readonly-open.c +++ b/lib/tdb2/test/run-05-readonly-open.c @@ -10,10 +10,7 @@ int main(int argc, char *argv[]) unsigned int i; struct tdb_context *tdb; int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, - TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; struct tdb_data key = tdb_mkdata("key", 3); struct tdb_data data = tdb_mkdata("data", 4), d; union tdb_attribute seed_attr; @@ -32,8 +29,7 @@ int main(int argc, char *argv[]) for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { tdb = tdb_open("run-05-readonly-open.tdb", flags[i], O_RDWR|O_CREAT|O_TRUNC, 0600, - flags[i] & TDB_VERSION1 - ? &tap_log_attr : &seed_attr); + &seed_attr); ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0); tdb_close(tdb); diff --git a/lib/tdb2/test/run-10-simple-store.c b/lib/tdb2/test/run-10-simple-store.c index 3fba81d22d..66bf6a6a51 100644 --- a/lib/tdb2/test/run-10-simple-store.c +++ b/lib/tdb2/test/run-10-simple-store.c @@ -11,12 +11,7 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; struct tdb_data key = tdb_mkdata("key", 3); struct tdb_data data = tdb_mkdata("data", 4); diff --git a/lib/tdb2/test/run-11-simple-fetch.c b/lib/tdb2/test/run-11-simple-fetch.c index 8cd63dedcd..4c41ceec6d 100644 --- a/lib/tdb2/test/run-11-simple-fetch.c +++ b/lib/tdb2/test/run-11-simple-fetch.c @@ -11,12 +11,7 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; struct tdb_data key = tdb_mkdata("key", 3); struct tdb_data data = tdb_mkdata("data", 4); diff --git a/lib/tdb2/test/run-12-check.c b/lib/tdb2/test/run-12-check.c index 4173fb05c8..cc57726f93 100644 --- a/lib/tdb2/test/run-12-check.c +++ b/lib/tdb2/test/run-12-check.c @@ -12,11 +12,7 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; int flags[] = { TDB_INTERNAL, TDB_INTERNAL|TDB_CONVERT, - TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, - TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT }; struct tdb_data key = tdb_mkdata("key", 3); struct tdb_data data = tdb_mkdata("data", 4); diff --git a/lib/tdb2/test/run-15-append.c b/lib/tdb2/test/run-15-append.c index 8102d3967d..6578b70734 100644 --- a/lib/tdb2/test/run-15-append.c +++ b/lib/tdb2/test/run-15-append.c @@ -12,12 +12,6 @@ static tdb_off_t tdb_offset(struct tdb_context *tdb, struct tdb_data key) struct tdb_used_record urec; struct hash_info h; - if (tdb_get_flags(tdb) & TDB_VERSION1) { - struct tdb1_record rec; - return tdb1_find(tdb, key, tdb_hash(tdb, key.dptr, key.dsize), - &rec); - } - off = find_and_lock(tdb, key, F_RDLCK, &h, &urec, NULL); if (TDB_OFF_IS_ERR(off)) return 0; @@ -33,12 +27,7 @@ int main(int argc, char *argv[]) tdb_off_t oldoff = 0, newoff; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, - TDB_NOMMAP|TDB_CONVERT, - TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1, - TDB_NOMMAP|TDB_VERSION1, - TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_NOMMAP|TDB_CONVERT }; struct tdb_data key = tdb_mkdata("key", 3); struct tdb_data data; @@ -75,15 +64,9 @@ int main(int argc, char *argv[]) } ok1(!tdb->file || (tdb->file->allrecord_lock.count == 0 && tdb->file->num_lockrecs == 0)); - if (flags[i] & TDB_VERSION1) { - /* TDB1 simply over-size by 25%. */ - ok(moves <= ilog64(j / SIZE_STEP)*4, - "Moved %u times", moves); - } else { - /* We should increase by 50% each time... */ - ok(moves <= ilog64(j / SIZE_STEP)*2, - "Moved %u times", moves); - } + /* We should increase by 50% each time... */ + ok(moves <= ilog64(j / SIZE_STEP)*2, + "Moved %u times", moves); tdb_close(tdb); } @@ -114,15 +97,9 @@ int main(int argc, char *argv[]) } ok1(!tdb->file || (tdb->file->allrecord_lock.count == 0 && tdb->file->num_lockrecs == 0)); - if (flags[i] & TDB_VERSION1) { - /* TDB1 simply over-size by 25%. */ - ok(moves <= ilog64(j / SIZE_STEP)*4, - "Moved %u times", moves); - } else { - /* We should increase by 50% each time... */ - ok(moves <= ilog64(j / SIZE_STEP)*2, - "Moved %u times", moves); - } + /* We should increase by 50% each time... */ + ok(moves <= ilog64(j / SIZE_STEP)*2, + "Moved %u times", moves); tdb_close(tdb); } diff --git a/lib/tdb2/test/run-35-convert.c b/lib/tdb2/test/run-35-convert.c index 0aee0ca625..ac7939591b 100644 --- a/lib/tdb2/test/run-35-convert.c +++ b/lib/tdb2/test/run-35-convert.c @@ -11,10 +11,7 @@ int main(int argc, char *argv[]) unsigned int i, messages = 0; struct tdb_context *tdb; int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, - TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; failtest_init(argc, argv); failtest_hook = block_repeat_failures; diff --git a/lib/tdb2/test/run-56-open-during-transaction.c b/lib/tdb2/test/run-56-open-during-transaction.c index f6fd36f6e3..c514caa92b 100644 --- a/lib/tdb2/test/run-56-open-during-transaction.c +++ b/lib/tdb2/test/run-56-open-during-transaction.c @@ -128,10 +128,7 @@ static int ftruncate_check(int fd, off_t length) int main(int argc, char *argv[]) { const int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, - TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; int i; struct tdb_context *tdb; TDB_DATA key, data; diff --git a/lib/tdb2/test/run-57-die-during-transaction.c b/lib/tdb2/test/run-57-die-during-transaction.c index 595d6ae23b..ee33a896ff 100644 --- a/lib/tdb2/test/run-57-die-during-transaction.c +++ b/lib/tdb2/test/run-57-die-during-transaction.c @@ -151,7 +151,7 @@ static int ftruncate_check(int fd, off_t length) return ret; } -static bool test_death(enum operation op, struct agent *agent, int flags) +static bool test_death(enum operation op, struct agent *agent) { struct tdb_context *tdb = NULL; TDB_DATA key; @@ -161,7 +161,7 @@ static bool test_death(enum operation op, struct agent *agent, int flags) current = target = 0; reset: unlink(TEST_DBNAME); - tdb = tdb_open(TEST_DBNAME, flags|TDB_NOMMAP, + tdb = tdb_open(TEST_DBNAME, TDB_NOMMAP, O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr); if (!tdb) { diag("Failed opening TDB: %s", strerror(errno)); @@ -273,9 +273,9 @@ int main(int argc, char *argv[]) { enum operation ops[] = { FETCH, STORE, TRANSACTION_START }; struct agent *agent; - int i, flags; + int i; - plan_tests(24); + plan_tests(12); unlock_callback = maybe_die; external_agent_free = free_noleak; @@ -283,11 +283,9 @@ int main(int argc, char *argv[]) if (!agent) err(1, "preparing agent"); - for (flags = TDB_DEFAULT; flags <= TDB_VERSION1; flags += TDB_VERSION1) { - for (i = 0; i < sizeof(ops)/sizeof(ops[0]); i++) { - diag("Testing %s after death", operation_name(ops[i])); - ok1(test_death(ops[i], agent, flags)); - } + for (i = 0; i < sizeof(ops)/sizeof(ops[0]); i++) { + diag("Testing %s after death", operation_name(ops[i])); + ok1(test_death(ops[i], agent)); } free_external_agent(agent); diff --git a/lib/tdb2/test/run-90-get-set-attributes.c b/lib/tdb2/test/run-90-get-set-attributes.c index b6a9075b6d..edf0735013 100644 --- a/lib/tdb2/test/run-90-get-set-attributes.c +++ b/lib/tdb2/test/run-90-get-set-attributes.c @@ -24,10 +24,7 @@ int main(int argc, char *argv[]) unsigned int i; struct tdb_context *tdb; int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, - TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; union tdb_attribute seed_attr; union tdb_attribute hash_attr; union tdb_attribute lock_attr; @@ -47,8 +44,7 @@ int main(int argc, char *argv[]) lock_attr.flock.unlock = myunlock; lock_attr.flock.data = &lock_attr; - plan_tests(sizeof(flags) / sizeof(flags[0]) * 49 - + sizeof(flags) / sizeof(flags[0]) / 2); + plan_tests(sizeof(flags) / sizeof(flags[0]) * 50); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { union tdb_attribute attr; @@ -65,26 +61,17 @@ int main(int argc, char *argv[]) attr.base.attr = TDB_ATTRIBUTE_HASH; ok1(tdb_get_attribute(tdb, &attr) == 0); ok1(attr.base.attr == TDB_ATTRIBUTE_HASH); - if (flags[i] & TDB_VERSION1) { - ok1(attr.hash.fn == tdb1_old_hash); - } else { - ok1(attr.hash.fn == tdb_jenkins_hash); - } + ok1(attr.hash.fn == tdb_jenkins_hash); attr.base.attr = TDB_ATTRIBUTE_FLOCK; ok1(tdb_get_attribute(tdb, &attr) == 0); ok1(attr.base.attr == TDB_ATTRIBUTE_FLOCK); ok1(attr.flock.lock == tdb_fcntl_lock); ok1(attr.flock.unlock == tdb_fcntl_unlock); attr.base.attr = TDB_ATTRIBUTE_SEED; - if (flags[i] & TDB_VERSION1) { - ok1(tdb_get_attribute(tdb, &attr) == TDB_ERR_EINVAL); - tap_log_messages = 0; - } else { - ok1(tdb_get_attribute(tdb, &attr) == 0); - ok1(attr.base.attr == TDB_ATTRIBUTE_SEED); - /* This is possible, just astronomically unlikely. */ - ok1(attr.seed.seed != 0); - } + ok1(tdb_get_attribute(tdb, &attr) == 0); + ok1(attr.base.attr == TDB_ATTRIBUTE_SEED); + /* This is possible, just astronomically unlikely. */ + ok1(attr.seed.seed != 0); /* Unset attributes. */ tdb_unset_attribute(tdb, TDB_ATTRIBUTE_LOG); @@ -128,14 +115,6 @@ int main(int argc, char *argv[]) O_RDWR|O_CREAT|O_TRUNC, 0600, &seed_attr); - if (flags[i] & TDB_VERSION1) { - ok1(!tdb); - ok1(tap_log_messages == 1); - tap_log_messages = 0; - tdb = tdb_open("run-90-get-set-attributes.tdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, - &hash_attr); - } ok1(tdb); /* Get will succeed */ @@ -159,15 +138,9 @@ int main(int argc, char *argv[]) ok1(attr.flock.data == &lock_attr); attr.base.attr = TDB_ATTRIBUTE_SEED; - if (flags[i] & TDB_VERSION1) { - ok1(tdb_get_attribute(tdb, &attr) == TDB_ERR_EINVAL); - ok1(tap_log_messages == 1); - tap_log_messages = 0; - } else { - ok1(tdb_get_attribute(tdb, &attr) == 0); - ok1(attr.base.attr == TDB_ATTRIBUTE_SEED); - ok1(attr.seed.seed == seed_attr.seed.seed); - } + ok1(tdb_get_attribute(tdb, &attr) == 0); + ok1(attr.base.attr == TDB_ATTRIBUTE_SEED); + ok1(attr.seed.seed == seed_attr.seed.seed); /* Unset attributes. */ tdb_unset_attribute(tdb, TDB_ATTRIBUTE_HASH); diff --git a/lib/tdb2/test/run-expand-in-transaction.c b/lib/tdb2/test/run-expand-in-transaction.c index 2e9919c0f1..6b22d2ef46 100644 --- a/lib/tdb2/test/run-expand-in-transaction.c +++ b/lib/tdb2/test/run-expand-in-transaction.c @@ -7,10 +7,7 @@ int main(int argc, char *argv[]) unsigned int i; struct tdb_context *tdb; int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, - TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; struct tdb_data key = tdb_mkdata("key", 3); struct tdb_data data = tdb_mkdata("data", 4); diff --git a/lib/tdb2/test/run-lockall.c b/lib/tdb2/test/run-lockall.c index 23273135bc..3ae0d14f65 100644 --- a/lib/tdb2/test/run-lockall.c +++ b/lib/tdb2/test/run-lockall.c @@ -21,10 +21,7 @@ int main(int argc, char *argv[]) { struct agent *agent; int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, - TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, - TDB_CONVERT|TDB_VERSION1, - TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; + TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; int i; plan_tests(13 * sizeof(flags)/sizeof(flags[0]) + 1); diff --git a/lib/tdb2/test/run-tdb1-3G-file.c b/lib/tdb2/test/run-tdb1-3G-file.c deleted file mode 100644 index a278561c77..0000000000 --- a/lib/tdb2/test/run-tdb1-3G-file.c +++ /dev/null @@ -1,139 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> -#include "logging.h" - -static int tdb1_expand_file_sparse(struct tdb_context *tdb, - tdb1_off_t size, - tdb1_off_t addition) -{ - if ((tdb->flags & TDB_RDONLY) || tdb->tdb1.traverse_read) { - tdb->last_error = TDB_ERR_RDONLY; - return -1; - } - - if (ftruncate(tdb->file->fd, size+addition) == -1) { - char b = 0; - ssize_t written = pwrite(tdb->file->fd, &b, 1, (size+addition) - 1); - if (written == 0) { - /* try once more, potentially revealing errno */ - written = pwrite(tdb->file->fd, &b, 1, (size+addition) - 1); - } - if (written == 0) { - /* again - give up, guessing errno */ - errno = ENOSPC; - } - if (written != 1) { - tdb->last_error = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR, - "expand_file to %d failed (%s)", - size+addition, - strerror(errno)); - return -1; - } - } - - return 0; -} - -static const struct tdb1_methods large_io_methods = { - tdb1_read, - tdb1_write, - tdb1_next_hash_chain, - tdb1_oob, - tdb1_expand_file_sparse -}; - -static int test_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, - void *_data) -{ - TDB_DATA *expect = _data; - ok1(key.dsize == strlen("hi")); - ok1(memcmp(key.dptr, "hi", strlen("hi")) == 0); - ok1(data.dsize == expect->dsize); - ok1(memcmp(data.dptr, expect->dptr, data.dsize) == 0); - return 0; -} - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - TDB_DATA key, orig_data, data; - uint32_t hash; - tdb1_off_t rec_ptr; - struct tdb1_record rec; - union tdb_attribute hsize; - int ret; - - hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - hsize.base.next = &tap_log_attr; - hsize.tdb1_hashsize.hsize = 1024; - - plan_tests(26); - tdb = tdb_open("run-36-file.tdb1", TDB_VERSION1, - O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); - - ok1(tdb); - tdb->tdb1.io = &large_io_methods; - - key = tdb_mkdata("hi", strlen("hi")); - orig_data = tdb_mkdata("world", strlen("world")); - - /* Enlarge the file (internally multiplies by 2). */ - ret = tdb1_expand(tdb, 1500000000); - -#ifdef HAVE_INCOHERENT_MMAP - /* This can fail due to mmap failure on 32 bit systems. */ - if (ret == -1) { - /* These should now fail. */ - ok1(tdb_store(tdb, key, orig_data, TDB_INSERT) == TDB_ERR_IO); - ok1(tdb_fetch(tdb, key, &data) == TDB_ERR_IO); - ok1(tdb_traverse(tdb, test_traverse, &orig_data) == TDB_ERR_IO); - ok1(tdb_delete(tdb, key) == TDB_ERR_IO); - ok1(tdb_traverse(tdb, test_traverse, NULL) == TDB_ERR_IO); - /* Skip the rest... */ - for (ret = 0; ret < 26 - 6; ret++) - ok1(1); - tdb_close(tdb); - return exit_status(); - } -#endif - ok1(ret == 0); - - /* Put an entry in, and check it. */ - ok1(tdb_store(tdb, key, orig_data, TDB_INSERT) == TDB_SUCCESS); - - ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS); - ok1(data.dsize == strlen("world")); - ok1(memcmp(data.dptr, "world", strlen("world")) == 0); - free(data.dptr); - - /* That currently fills at the end, make sure that's true. */ - hash = tdb_hash(tdb, key.dptr, key.dsize); - rec_ptr = tdb1_find_lock_hash(tdb, key, hash, F_RDLCK, &rec); - ok1(rec_ptr); - ok1(rec_ptr > 2U*1024*1024*1024); - tdb1_unlock(tdb, TDB1_BUCKET(rec.full_hash), F_RDLCK); - - /* Traverse must work. */ - ok1(tdb_traverse(tdb, test_traverse, &orig_data) == 1); - - /* Delete should work. */ - ok1(tdb_delete(tdb, key) == TDB_SUCCESS); - - ok1(tdb_traverse(tdb, test_traverse, NULL) == 0); - - /* Transactions should work. */ - ok1(tdb_transaction_start(tdb) == TDB_SUCCESS); - ok1(tdb_store(tdb, key, orig_data, TDB_INSERT) == TDB_SUCCESS); - - ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS); - ok1(data.dsize == strlen("world")); - ok1(memcmp(data.dptr, "world", strlen("world")) == 0); - free(data.dptr); - ok1(tdb_transaction_commit(tdb) == TDB_SUCCESS); - - ok1(tdb_traverse(tdb, test_traverse, &orig_data) == 1); - tdb_close(tdb); - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-bad-tdb-header.c b/lib/tdb2/test/run-tdb1-bad-tdb-header.c deleted file mode 100644 index ed1b0085c7..0000000000 --- a/lib/tdb2/test/run-tdb1-bad-tdb-header.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> -#include "logging.h" - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - struct tdb1_header hdr; - int fd; - union tdb_attribute hsize; - - hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - hsize.base.next = &tap_log_attr; - hsize.tdb1_hashsize.hsize = 1024; - - plan_tests(11); - /* Cannot open fine if complete crap, even with O_CREAT. */ - fd = open("run-bad-tdb-header.tdb1", O_RDWR|O_CREAT|O_TRUNC, 0600); - ok1(fd >= 0); - ok1(write(fd, "hello world", 11) == 11); - close(fd); - tdb = tdb_open("run-bad-tdb-header.tdb1", 0, O_RDWR, 0, &tap_log_attr); - ok1(!tdb); - tdb = tdb_open("run-bad-tdb-header.tdb1", 0, O_CREAT|O_RDWR, - 0600, &hsize); - ok1(!tdb); - - /* With truncate, will be fine. */ - tdb = tdb_open("run-bad-tdb-header.tdb1", TDB_VERSION1, - O_RDWR|O_CREAT|O_TRUNC, 0600, &hsize); - ok1(tdb); - tdb_close(tdb); - - /* Now, with wrong version it should *not* overwrite. */ - fd = open("run-bad-tdb-header.tdb1", O_RDWR); - ok1(fd >= 0); - ok1(read(fd, &hdr, sizeof(hdr)) == sizeof(hdr)); - ok1(hdr.version == TDB1_VERSION); - hdr.version++; - lseek(fd, 0, SEEK_SET); - ok1(write(fd, &hdr, sizeof(hdr)) == sizeof(hdr)); - close(fd); - - tdb = tdb_open("run-bad-tdb-header.tdb1", TDB_VERSION1, O_RDWR|O_CREAT, - 0600, &hsize); - ok1(errno == EIO); - ok1(!tdb); - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-check.c b/lib/tdb2/test/run-tdb1-check.c deleted file mode 100644 index 45bcbc4a9d..0000000000 --- a/lib/tdb2/test/run-tdb1-check.c +++ /dev/null @@ -1,56 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> -#include "logging.h" - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - TDB_DATA key, data; - union tdb_attribute hsize; - - hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - hsize.base.next = &tap_log_attr; - hsize.tdb1_hashsize.hsize = 1; - - plan_tests(13); - tdb = tdb_open("run-check.tdb1", TDB_VERSION1, - O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); - - ok1(tdb); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - - key = tdb_mkdata("hi", strlen("hi")); - data = tdb_mkdata("world", strlen("world")); - - ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - tdb = tdb_open("run-check.tdb1", TDB_VERSION1, O_RDWR, 0, &tap_log_attr); - ok1(tdb); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - tdb = tdb_open("test/tdb1.corrupt", TDB_VERSION1, O_RDWR, 0, - &tap_log_attr); - ok1(tdb); - ok1(tdb_check(tdb, NULL, NULL) == TDB_ERR_CORRUPT); - ok1(tdb_error(tdb) == TDB_ERR_CORRUPT); - tdb_close(tdb); - - /* Big and little endian should work! */ - tdb = tdb_open("test/old-nohash-le.tdb1", TDB_VERSION1, O_RDWR, 0, - &tap_log_attr); - ok1(tdb); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - tdb = tdb_open("test/old-nohash-be.tdb1", TDB_VERSION1, O_RDWR, 0, - &tap_log_attr); - ok1(tdb); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-corrupt.c b/lib/tdb2/test/run-tdb1-corrupt.c deleted file mode 100644 index 99f5578db7..0000000000 --- a/lib/tdb2/test/run-tdb1-corrupt.c +++ /dev/null @@ -1,121 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> -#include "logging.h" - -static int check(TDB_DATA key, TDB_DATA data, void *private) -{ - unsigned int *sizes = private; - - if (key.dsize > strlen("hello")) - return -1; - if (memcmp(key.dptr, "hello", key.dsize) != 0) - return -1; - - if (data.dsize != strlen("world")) - return -1; - if (memcmp(data.dptr, "world", data.dsize) != 0) - return -1; - - sizes[0] += key.dsize; - sizes[1] += data.dsize; - return 0; -} - -static void tdb1_flip_bit(struct tdb_context *tdb, unsigned int bit) -{ - unsigned int off = bit / CHAR_BIT; - unsigned char mask = (1 << (bit % CHAR_BIT)); - - if (tdb->file->map_ptr) - ((unsigned char *)tdb->file->map_ptr)[off] ^= mask; - else { - unsigned char c; - if (pread(tdb->file->fd, &c, 1, off) != 1) - err(1, "pread"); - c ^= mask; - if (pwrite(tdb->file->fd, &c, 1, off) != 1) - err(1, "pwrite"); - } -} - -static void check_test(struct tdb_context *tdb) -{ - TDB_DATA key, data; - unsigned int i, verifiable, corrupt, sizes[2], dsize, ksize; - - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - - key = tdb_mkdata("hello", strlen("hello")); - data = tdb_mkdata("world", strlen("world")); - - /* Key and data size respectively. */ - dsize = ksize = 0; - - /* 5 keys in hash size 2 means we'll have multichains. */ - for (key.dsize = 1; key.dsize <= 5; key.dsize++) { - ksize += key.dsize; - dsize += data.dsize; - if (tdb_store(tdb, key, data, TDB_INSERT) != TDB_SUCCESS) - abort(); - } - - /* This is how many bytes we expect to be verifiable. */ - /* From the file header. */ - verifiable = strlen(TDB_MAGIC_FOOD) + 1 - + 2 * sizeof(uint32_t) + 2 * sizeof(tdb1_off_t) - + 2 * sizeof(uint32_t); - /* From the free list chain and hash chains. */ - verifiable += 3 * sizeof(tdb1_off_t); - /* From the record headers & tailer */ - verifiable += 5 * (sizeof(struct tdb1_record) + sizeof(uint32_t)); - /* The free block: we ignore datalen, keylen, full_hash. */ - verifiable += sizeof(struct tdb1_record) - 3*sizeof(uint32_t) + - sizeof(uint32_t); - /* Our check function verifies the key and data. */ - verifiable += ksize + dsize; - - /* Flip one bit at a time, make sure it detects verifiable bytes. */ - for (i = 0, corrupt = 0; i < tdb->file->map_size * CHAR_BIT; i++) { - tdb1_flip_bit(tdb, i); - memset(sizes, 0, sizeof(sizes)); - if (tdb_check(tdb, check, sizes) == TDB_ERR_CORRUPT) - corrupt++; - else if (sizes[0] != ksize || sizes[1] != dsize) - corrupt++; - tdb1_flip_bit(tdb, i); - } - ok(corrupt == verifiable * CHAR_BIT, "corrupt %u should be %u", - corrupt, verifiable * CHAR_BIT); -} - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - union tdb_attribute hsize; - - hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - hsize.base.next = &tap_log_attr; - hsize.tdb1_hashsize.hsize = 2; - - plan_tests(4); - /* This should use mmap. */ - tdb = tdb_open("run-corrupt.tdb1", TDB_VERSION1, - O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); - - if (!tdb) - abort(); - check_test(tdb); - tdb_close(tdb); - - /* This should not. */ - tdb = tdb_open("run-corrupt.tdb1", TDB_VERSION1|TDB_NOMMAP, - O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); - - if (!tdb) - abort(); - check_test(tdb); - tdb_close(tdb); - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-endian.c b/lib/tdb2/test/run-tdb1-endian.c deleted file mode 100644 index 43f9d5fe5e..0000000000 --- a/lib/tdb2/test/run-tdb1-endian.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> -#include "logging.h" - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - TDB_DATA key, data; - union tdb_attribute hsize; - - hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - hsize.base.next = &tap_log_attr; - hsize.tdb1_hashsize.hsize = 1024; - - plan_tests(14); - tdb = tdb_open("run-endian.tdb1", - TDB_VERSION1|TDB_CONVERT, - O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); - - ok1(tdb); - key = tdb_mkdata("hi", strlen("hi")); - data = tdb_mkdata("world", strlen("world")); - - ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_ERR_NOEXIST); - ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); - ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_ERR_EXISTS); - ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_SUCCESS); - - ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS); - ok1(data.dsize == strlen("world")); - ok1(memcmp(data.dptr, "world", strlen("world")) == 0); - free(data.dptr); - - key.dsize++; - ok1(tdb_fetch(tdb, key, &data) == TDB_ERR_NOEXIST); - ok1(data.dptr == NULL); - tdb_close(tdb); - - /* Reopen: should read it */ - tdb = tdb_open("run-endian.tdb1", 0, O_RDWR, 0, NULL); - ok1(tdb); - - key = tdb_mkdata("hi", strlen("hi")); - ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS); - ok1(data.dsize == strlen("world")); - ok1(memcmp(data.dptr, "world", strlen("world")) == 0); - free(data.dptr); - tdb_close(tdb); - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-hashsize.c b/lib/tdb2/test/run-tdb1-hashsize.c deleted file mode 100644 index 4f37b72be6..0000000000 --- a/lib/tdb2/test/run-tdb1-hashsize.c +++ /dev/null @@ -1,60 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> -#include "logging.h" - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - union tdb_attribute hsize, h2; - - hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - hsize.base.next = &tap_log_attr; - hsize.tdb1_hashsize.hsize = 1024; - - plan_tests(14); - tdb = tdb_open("run-tdb1-hashsize.tdb1", TDB_VERSION1, - O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); - ok1(tdb); - h2.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - ok1(tdb_get_attribute(tdb, &h2) == TDB_SUCCESS); - ok1(h2.tdb1_hashsize.hsize == hsize.tdb1_hashsize.hsize); - tdb_close(tdb); - - /* Can't specify TDB_ATTRIBUTE_TDB1_HASHSIZE without O_CREAT */ - tdb = tdb_open("run-tdb1-hashsize.tdb1", TDB_VERSION1, - O_RDWR, 0600, &hsize); - ok1(!tdb); - ok1(tap_log_messages == 1); - - /* Can't specify TDB_ATTRIBUTE_TDB1_HASHSIZE for version2. */ - tdb = tdb_open("run-tdb1-hashsize.tdb", TDB_DEFAULT, - O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); - ok1(!tdb); - ok1(tap_log_messages == 2); - - /* We can get attribute even if we didn't set it though. */ - tdb = tdb_open("run-tdb1-hashsize.tdb1", TDB_DEFAULT, - O_RDWR, 0600, &tap_log_attr); - - ok1(tdb); - memset(&h2, 0, sizeof(h2)); - h2.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - ok1(tdb_get_attribute(tdb, &h2) == TDB_SUCCESS); - ok1(h2.tdb1_hashsize.hsize == hsize.tdb1_hashsize.hsize); - tdb_close(tdb); - - /* Check for default hash size. */ - tdb = tdb_open("run-tdb1-hashsize.tdb1", TDB_VERSION1, - O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr); - - ok1(tdb); - memset(&h2, 0, sizeof(h2)); - h2.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - ok1(tdb_get_attribute(tdb, &h2) == TDB_SUCCESS); - ok1(h2.tdb1_hashsize.hsize == TDB1_DEFAULT_HASH_SIZE); - tdb_close(tdb); - ok1(tap_log_messages == 2); - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-incompatible.c b/lib/tdb2/test/run-tdb1-incompatible.c deleted file mode 100644 index 4a7581609a..0000000000 --- a/lib/tdb2/test/run-tdb1-incompatible.c +++ /dev/null @@ -1,208 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> - -static uint64_t tdb1_dumb_hash(const void *key, size_t len, uint64_t seed, - void *unused) -{ - return len; -} - -static void log_fn(struct tdb_context *tdb, enum tdb_log_level level, - enum TDB_ERROR ecode, const char *message, void *priv) -{ - unsigned int *count = priv; - if (strstr(message, "hash")) - (*count)++; -} - -static unsigned int hdr_rwlocks(const char *fname) -{ - struct tdb1_header hdr; - - int fd = open(fname, O_RDONLY); - if (fd == -1) - return -1; - - if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) - return -1; - - close(fd); - return hdr.rwlocks; -} - -static uint64_t jenkins_hashfn(const void *key, size_t len, uint64_t seed, - void *unused) -{ - return hashlittle(key, len); -} - -static uint64_t old_hash(const void *key, size_t len, uint64_t seed, - void *unused) -{ - return tdb1_old_hash(key, len, seed, unused); -} - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - unsigned int log_count, flags; - TDB_DATA d; - union tdb_attribute log_attr, jhash_attr, ohash_attr, - incompat_hash_attr, dumbhash_attr; - - log_attr.base.attr = TDB_ATTRIBUTE_LOG; - log_attr.base.next = NULL; - log_attr.log.fn = log_fn; - log_attr.log.data = &log_count; - - jhash_attr.base.attr = TDB_ATTRIBUTE_HASH; - jhash_attr.base.next = &log_attr; - jhash_attr.hash.fn = jenkins_hashfn; - - ohash_attr.base.attr = TDB_ATTRIBUTE_HASH; - ohash_attr.base.next = &log_attr; - ohash_attr.hash.fn = old_hash; - - incompat_hash_attr.base.attr = TDB_ATTRIBUTE_HASH; - incompat_hash_attr.base.next = &log_attr; - incompat_hash_attr.hash.fn = tdb1_incompatible_hash; - - dumbhash_attr.base.attr = TDB_ATTRIBUTE_HASH; - dumbhash_attr.base.next = &log_attr; - dumbhash_attr.hash.fn = tdb1_dumb_hash; - - plan_tests(42 * 2); - - for (flags = 0; flags <= TDB_CONVERT; flags += TDB_CONVERT) { - unsigned int rwmagic = TDB1_HASH_RWLOCK_MAGIC; - - if (flags & TDB_CONVERT) - tdb1_convert(&rwmagic, sizeof(rwmagic)); - - /* Create an old-style hash. */ - log_count = 0; - tdb = tdb_open("run-incompatible.tdb1", flags|TDB_VERSION1, - O_CREAT|O_RDWR|O_TRUNC, 0600, &log_attr); - ok1(tdb); - ok1(log_count == 0); - d = tdb_mkdata("Hello", strlen("Hello")); - ok1(tdb_store(tdb, d, d, TDB_INSERT) == TDB_SUCCESS); - tdb_close(tdb); - - /* Should not have marked rwlocks field. */ - ok1(hdr_rwlocks("run-incompatible.tdb1") == 0); - - /* We can still open any old-style with incompat hash. */ - log_count = 0; - tdb = tdb_open("run-incompatible.tdb1", - TDB_VERSION1, - O_RDWR, 0600, &incompat_hash_attr); - ok1(tdb); - ok1(log_count == 0); - ok1(tdb_fetch(tdb, d, &d) == TDB_SUCCESS); - ok1(d.dsize == 5); - free(d.dptr); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - log_count = 0; - tdb = tdb_open("test/jenkins-le-hash.tdb1", - TDB_VERSION1, O_RDONLY, 0, &jhash_attr); - ok1(tdb); - ok1(log_count == 0); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - log_count = 0; - tdb = tdb_open("test/jenkins-be-hash.tdb1", - TDB_VERSION1, O_RDONLY, 0, &jhash_attr); - ok1(tdb); - ok1(log_count == 0); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - /* OK, now create with incompatible hash. */ - log_count = 0; - tdb = tdb_open("run-incompatible.tdb1", - flags|TDB_VERSION1, - O_CREAT|O_RDWR|O_TRUNC, 0600, - &incompat_hash_attr); - ok1(tdb); - ok1(log_count == 0); - d = tdb_mkdata("Hello", strlen("Hello")); - ok1(tdb_store(tdb, d, d, TDB_INSERT) == TDB_SUCCESS); - tdb_close(tdb); - - /* Should have marked rwlocks field. */ - ok1(hdr_rwlocks("run-incompatible.tdb1") == rwmagic); - - /* Cannot open with old hash. */ - log_count = 0; - tdb = tdb_open("run-incompatible.tdb1", TDB_VERSION1, - O_RDWR, 0600, &ohash_attr); - ok1(!tdb); - ok1(log_count == 1); - - /* Can open with jenkins hash. */ - log_count = 0; - tdb = tdb_open("run-incompatible.tdb1", TDB_VERSION1, - O_RDWR, 0600, &jhash_attr); - ok1(tdb); - ok1(log_count == 0); - ok1(tdb_fetch(tdb, d, &d) == TDB_SUCCESS); - ok1(d.dsize == 5); - free(d.dptr); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - /* Can open by letting it figure it out itself. */ - log_count = 0; - tdb = tdb_open("run-incompatible.tdb1", TDB_VERSION1, - O_RDWR, 0600, &log_attr); - ok1(tdb); - ok1(log_count == 0); - d = tdb_mkdata("Hello", strlen("Hello")); - ok1(tdb_fetch(tdb, d, &d) == TDB_SUCCESS); - ok1(d.dsize == 5); - free(d.dptr); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - /* FIXME: Not possible with TDB2 :( */ - /* We can also use incompatible hash with other hashes. */ - log_count = 0; - tdb = tdb_open("run-incompatible.tdb1", - flags|TDB_VERSION1, - O_CREAT|O_RDWR|O_TRUNC, 0600, &dumbhash_attr); - ok1(tdb); - ok1(log_count == 0); - d = tdb_mkdata("Hello", strlen("Hello")); - ok1(tdb_store(tdb, d, d, TDB_INSERT) == TDB_SUCCESS); - tdb_close(tdb); - - /* FIXME: Should have marked rwlocks field. */ - ok1(hdr_rwlocks("run-incompatible.tdb1") != rwmagic); - - /* It should not open if we don't specify. */ - log_count = 0; - tdb = tdb_open("run-incompatible.tdb1", TDB_VERSION1, O_RDWR, 0, - &log_attr); - ok1(!tdb); - ok1(log_count == 1); - - /* Should reopen with correct hash. */ - log_count = 0; - tdb = tdb_open("run-incompatible.tdb1", TDB_VERSION1, O_RDWR, 0, - &dumbhash_attr); - ok1(tdb); - ok1(log_count == 0); - ok1(tdb_fetch(tdb, d, &d) == TDB_SUCCESS); - ok1(d.dsize == 5); - free(d.dptr); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - } - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-nested-transactions.c b/lib/tdb2/test/run-tdb1-nested-transactions.c deleted file mode 100644 index 938ab486e7..0000000000 --- a/lib/tdb2/test/run-tdb1-nested-transactions.c +++ /dev/null @@ -1,70 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> -#include <stdbool.h> -#include "logging.h" - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - TDB_DATA key, data; - union tdb_attribute hsize; - - hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - hsize.base.next = &tap_log_attr; - hsize.tdb1_hashsize.hsize = 1024; - - plan_tests(30); - key = tdb_mkdata("hi", strlen("hi")); - - tdb = tdb_open("run-nested-transactions.tdb1", - TDB_VERSION1, O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); - ok1(tdb); - - /* No nesting by default. */ - ok1(tdb_transaction_start(tdb) == TDB_SUCCESS); - data = tdb_mkdata("world", strlen("world")); - ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); - ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS); - ok1(data.dsize == strlen("world")); - ok1(memcmp(data.dptr, "world", strlen("world")) == 0); - free(data.dptr); - ok1(tdb_transaction_start(tdb) == TDB_ERR_EINVAL); - ok1(tap_log_messages == 1); - - ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS); - ok1(data.dsize == strlen("world")); - ok1(memcmp(data.dptr, "world", strlen("world")) == 0); - free(data.dptr); - ok1(tdb_transaction_commit(tdb) == TDB_SUCCESS); - ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS); - ok1(data.dsize == strlen("world")); - ok1(memcmp(data.dptr, "world", strlen("world")) == 0); - free(data.dptr); - tdb_close(tdb); - - tdb = tdb_open("run-nested-transactions.tdb1", - TDB_ALLOW_NESTING, O_RDWR, 0, &tap_log_attr); - ok1(tdb); - - ok1(tdb_transaction_start(tdb) == TDB_SUCCESS); - ok1(tdb_transaction_start(tdb) == TDB_SUCCESS); - ok1(tdb_delete(tdb, key) == TDB_SUCCESS); - ok1(tdb_transaction_commit(tdb) == TDB_SUCCESS); - ok1(!tdb_exists(tdb, key)); - tdb_transaction_cancel(tdb); - ok1(tap_log_messages == 1); - /* Surprise! Kills inner "committed" transaction. */ - ok1(tdb_exists(tdb, key)); - - ok1(tdb_transaction_start(tdb) == TDB_SUCCESS); - ok1(tdb_transaction_start(tdb) == TDB_SUCCESS); - ok1(tdb_delete(tdb, key) == TDB_SUCCESS); - ok1(tdb_transaction_commit(tdb) == TDB_SUCCESS); - ok1(!tdb_exists(tdb, key)); - ok1(tdb_transaction_commit(tdb) == TDB_SUCCESS); - ok1(!tdb_exists(tdb, key)); - 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 deleted file mode 100644 index 30f9922f16..0000000000 --- a/lib/tdb2/test/run-tdb1-nested-traverse.c +++ /dev/null @@ -1,84 +0,0 @@ -#include "tdb1-lock-tracking.h" -#define fcntl fcntl_with_lockcheck1 -#include "tdb2-source.h" -#include "tap-interface.h" -#undef fcntl -#include <stdlib.h> -#include <stdbool.h> -#include "tdb1-external-agent.h" -#include "logging.h" - -static struct agent *agent; - -static bool correct_key(TDB_DATA key) -{ - return key.dsize == strlen("hi") - && memcmp(key.dptr, "hi", key.dsize) == 0; -} - -static bool correct_data(TDB_DATA data) -{ - return data.dsize == strlen("world") - && memcmp(data.dptr, "world", data.dsize) == 0; -} - -static int traverse2(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, - void *p) -{ - ok1(correct_key(key)); - ok1(correct_data(data)); - return 0; -} - -static int traverse1(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, - void *p) -{ - ok1(correct_key(key)); - ok1(correct_data(data)); - ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name) - == WOULD_HAVE_BLOCKED); - tdb_traverse(tdb, traverse2, NULL); - - /* That should *not* release the transaction lock! */ - ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name) - == WOULD_HAVE_BLOCKED); - return 0; -} - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - TDB_DATA key, data; - union tdb_attribute hsize; - - hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - hsize.base.next = &tap_log_attr; - hsize.tdb1_hashsize.hsize = 1024; - - plan_tests(17); - agent = prepare_external_agent1(); - if (!agent) - err(1, "preparing agent"); - - tdb = tdb_open("run-nested-traverse.tdb1", TDB_VERSION1, - O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); - ok1(tdb); - - ok1(external_agent_operation1(agent, OPEN, tdb->name) == SUCCESS); - ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name) - == SUCCESS); - ok1(external_agent_operation1(agent, TRANSACTION_COMMIT, tdb->name) - == SUCCESS); - - key = tdb_mkdata("hi", strlen("hi")); - data = tdb_mkdata("world", strlen("world")); - - ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); - 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 deleted file mode 100644 index 79106c58cb..0000000000 --- a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c +++ /dev/null @@ -1,109 +0,0 @@ -#include "private.h" -#include <unistd.h> -#include "tdb1-lock-tracking.h" - -#define fcntl fcntl_with_lockcheck1 - -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> -#include "logging.h" - -#undef fcntl - -#define NUM_ENTRIES 10 - -static bool prepare_entries(struct tdb_context *tdb) -{ - unsigned int i; - TDB_DATA key, data; - - for (i = 0; i < NUM_ENTRIES; i++) { - key.dsize = sizeof(i); - key.dptr = (void *)&i; - data = tdb_mkdata("world", strlen("world")); - - if (tdb_store(tdb, key, data, 0) != TDB_SUCCESS) - return false; - } - return true; -} - -static void delete_entries(struct tdb_context *tdb) -{ - unsigned int i; - TDB_DATA key; - - for (i = 0; i < NUM_ENTRIES; i++) { - key.dsize = sizeof(i); - key.dptr = (void *)&i; - - ok1(tdb_delete(tdb, key) == TDB_SUCCESS); - } -} - -/* We don't know how many times this will run. */ -static int delete_other(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, - void *private_data) -{ - unsigned int i; - memcpy(&i, key.dptr, 4); - i = (i + 1) % NUM_ENTRIES; - key.dptr = (void *)&i; - if (tdb_delete(tdb, key) != TDB_SUCCESS) - (*(int *)private_data)++; - return 0; -} - -static int delete_self(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, - void *private_data) -{ - ok1(tdb_delete(tdb, key) == TDB_SUCCESS); - return 0; -} - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - int errors = 0; - union tdb_attribute hsize; - - hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - hsize.base.next = &tap_log_attr; - hsize.tdb1_hashsize.hsize = 1024; - - plan_tests(40); - tdb = tdb_open("run-no-lock-during-traverse.tdb1", - TDB_VERSION1, O_CREAT|O_TRUNC|O_RDWR, - 0600, &hsize); - - ok1(tdb); - ok1(prepare_entries(tdb)); - ok1(locking_errors1 == 0); - ok1(tdb_lockall(tdb) == 0); - ok1(locking_errors1 == 0); - ok1(tdb_traverse(tdb, delete_other, &errors) >= 0); - ok1(errors == 0); - ok1(locking_errors1 == 0); - tdb_unlockall(tdb); - - ok1(prepare_entries(tdb)); - ok1(locking_errors1 == 0); - ok1(tdb_lockall(tdb) == 0); - ok1(locking_errors1 == 0); - ok1(tdb_traverse(tdb, delete_self, NULL) == NUM_ENTRIES); - ok1(locking_errors1 == 0); - tdb_unlockall(tdb); - - ok1(prepare_entries(tdb)); - ok1(locking_errors1 == 0); - ok1(tdb_lockall(tdb) == 0); - ok1(locking_errors1 == 0); - delete_entries(tdb); - ok1(locking_errors1 == 0); - tdb_unlockall(tdb); - - ok1(tdb_close(tdb) == 0); - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-oldhash.c b/lib/tdb2/test/run-tdb1-oldhash.c deleted file mode 100644 index 629ff50634..0000000000 --- a/lib/tdb2/test/run-tdb1-oldhash.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> -#include "logging.h" - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - union tdb_attribute incompat_hash_attr; - - incompat_hash_attr.base.attr = TDB_ATTRIBUTE_HASH; - incompat_hash_attr.base.next = &tap_log_attr; - incompat_hash_attr.hash.fn = tdb1_incompatible_hash; - - plan_tests(8); - - /* Old format (with zeroes in the hash magic fields) should - * open with any hash (since we don't know what hash they used). */ - tdb = tdb_open("test/old-nohash-le.tdb1", TDB_VERSION1, O_RDWR, 0, - &tap_log_attr); - ok1(tdb); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - tdb = tdb_open("test/old-nohash-be.tdb1", TDB_VERSION1, O_RDWR, 0, - &tap_log_attr); - ok1(tdb); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - tdb = tdb_open("test/old-nohash-le.tdb1", TDB_VERSION1, O_RDWR, 0, - &incompat_hash_attr); - ok1(tdb); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - tdb = tdb_open("test/old-nohash-be.tdb1", TDB_VERSION1, O_RDWR, 0, - &incompat_hash_attr); - ok1(tdb); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-readonly-check.c b/lib/tdb2/test/run-tdb1-readonly-check.c deleted file mode 100644 index 078b9d6148..0000000000 --- a/lib/tdb2/test/run-tdb1-readonly-check.c +++ /dev/null @@ -1,44 +0,0 @@ -/* We should be able to tdb_check a O_RDONLY tdb, and we were previously allowed - * to tdb_check() inside a transaction (though that's paranoia!). */ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> -#include "logging.h" - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - TDB_DATA key, data; - union tdb_attribute hsize; - - hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - hsize.base.next = &tap_log_attr; - hsize.tdb1_hashsize.hsize = 1024; - - plan_tests(10); - tdb = tdb_open("run-readonly-check.tdb1", - TDB_VERSION1, - O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); - - ok1(tdb); - key = tdb_mkdata("hi", strlen("hi")); - data = tdb_mkdata("world", strlen("world")); - - ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - - /* We are also allowed to do a check inside a transaction. */ - ok1(tdb_transaction_start(tdb) == TDB_SUCCESS); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - ok1(tdb_close(tdb) == 0); - - tdb = tdb_open("run-readonly-check.tdb1", - TDB_DEFAULT, O_RDONLY, 0, &tap_log_attr); - - ok1(tdb); - ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_ERR_RDONLY); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - ok1(tdb_close(tdb) == 0); - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-rwlock-check.c b/lib/tdb2/test/run-tdb1-rwlock-check.c deleted file mode 100644 index 08a082ff5c..0000000000 --- a/lib/tdb2/test/run-tdb1-rwlock-check.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> - -static void log_fn(struct tdb_context *tdb, enum tdb_log_level level, - enum TDB_ERROR ecode, const char *message, void *priv) -{ - unsigned int *count = priv; - if (strstr(message, "spinlocks")) - (*count)++; -} - -/* The code should barf on TDBs created with rwlocks. */ -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - unsigned int log_count; - union tdb_attribute log_attr; - - log_attr.base.attr = TDB_ATTRIBUTE_LOG; - log_attr.base.next = NULL; - log_attr.log.fn = log_fn; - log_attr.log.data = &log_count; - - plan_tests(4); - - /* We should fail to open rwlock-using tdbs of either endian. */ - log_count = 0; - tdb = tdb_open("test/rwlock-le.tdb1", TDB_VERSION1, O_RDWR, 0, - &log_attr); - ok1(!tdb); - ok1(log_count == 1); - - log_count = 0; - tdb = tdb_open("test/rwlock-be.tdb1", TDB_VERSION1, O_RDWR, 0, - &log_attr); - ok1(!tdb); - ok1(log_count == 1); - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-seqnum-wrap.c b/lib/tdb2/test/run-tdb1-seqnum-wrap.c deleted file mode 100644 index 01cfaefb90..0000000000 --- a/lib/tdb2/test/run-tdb1-seqnum-wrap.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> -#include "logging.h" - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - unsigned int i; - struct tdb1_header hdr; - struct tdb_data key = { (unsigned char *)&hdr, sizeof(hdr) }; - struct tdb_data data = { (unsigned char *)&hdr, sizeof(hdr) }; - int flags[] = { TDB_DEFAULT, TDB_NOMMAP, - TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; - - plan_tests(sizeof(flags) / sizeof(flags[0]) * 7); - for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - tdb = tdb_open("run-tdb1-seqnum-wrap.tdb1", - flags[i]|TDB_VERSION1|TDB_SEQNUM, - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); - ok1(tdb); - if (!tdb) - break; - ok1(pread(tdb->file->fd, &hdr, sizeof(hdr), 0) == sizeof(hdr)); - hdr.sequence_number = 0xFFFFFFFF; - ok1(pwrite(tdb->file->fd, &hdr, sizeof(hdr), 0) == sizeof(hdr)); - - /* Must not be negative: that would mean an error! */ - ok1(tdb_get_seqnum(tdb) == 0xFFFFFFFF); - - ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); - ok1(tdb_get_seqnum(tdb) == 0); - tdb_close(tdb); - ok1(tap_log_messages == 0); - } - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-summary.c b/lib/tdb2/test/run-tdb1-summary.c deleted file mode 100644 index a031a10519..0000000000 --- a/lib/tdb2/test/run-tdb1-summary.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> - -int main(int argc, char *argv[]) -{ - unsigned int i, j; - struct tdb_context *tdb; - 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; - - plan_tests(sizeof(flags) / sizeof(flags[0]) * 14); - for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - tdb = tdb_open("run-summary.tdb1", flags[i]|TDB_VERSION1, - O_RDWR|O_CREAT|O_TRUNC, 0600, NULL); - ok1(tdb); - if (!tdb) - continue; - - /* Put some stuff in there. */ - for (j = 0; j < 500; j++) { - /* Make sure padding varies to we get some graphs! */ - data.dsize = j % (sizeof(j) + 1); - if (tdb_store(tdb, key, data, TDB_REPLACE) - != TDB_SUCCESS) { - fail("Storing in tdb"); - } - } - - summary = tdb1_summary(tdb); - diag("%s", summary); - ok1(strstr(summary, "Size of file/data: ")); - ok1(strstr(summary, "Number of records: 500\n")); - ok1(strstr(summary, "Smallest/average/largest keys: 4/4/4\n")); - ok1(strstr(summary, "Smallest/average/largest data: 0/2/4\n")); - ok1(strstr(summary, "Smallest/average/largest padding: ")); - ok1(strstr(summary, "Number of dead records: 0\n")); - ok1(strstr(summary, "Number of free records: 1\n")); - ok1(strstr(summary, "Smallest/average/largest free records: ")); - ok1(strstr(summary, "Number of hash chains: 131\n")); - ok1(strstr(summary, "Smallest/average/largest hash chains: ")); - ok1(strstr(summary, "Number of uncoalesced records: 0\n")); - ok1(strstr(summary, "Smallest/average/largest uncoalesced runs: 0/0/0\n")); - ok1(strstr(summary, "Percentage keys/data/padding/free/dead/rechdrs&tailers/hashes: ")); - - free(summary); - tdb_close(tdb); - } - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c deleted file mode 100644 index 6f209d9578..0000000000 --- a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c +++ /dev/null @@ -1,82 +0,0 @@ -#include "config.h" -#include "tdb1-lock-tracking.h" -#define fcntl fcntl_with_lockcheck1 -#include "tdb2-source.h" -#include "tap-interface.h" -#undef fcntl_with_lockcheck -#include <stdlib.h> -#include <stdbool.h> -#include "tdb1-external-agent.h" -#include "logging.h" - -static struct agent *agent; - -static bool correct_key(TDB_DATA key) -{ - return key.dsize == strlen("hi") - && memcmp(key.dptr, "hi", key.dsize) == 0; -} - -static bool correct_data(TDB_DATA data) -{ - return data.dsize == strlen("world") - && memcmp(data.dptr, "world", data.dsize) == 0; -} - -static int traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, - void *p) -{ - ok1(correct_key(key)); - ok1(correct_data(data)); - return 0; -} - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - TDB_DATA key, data; - union tdb_attribute hsize; - - hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - hsize.base.next = &tap_log_attr; - hsize.tdb1_hashsize.hsize = 1024; - - plan_tests(13); - agent = prepare_external_agent1(); - if (!agent) - err(1, "preparing agent"); - - tdb = tdb_open("run-traverse-in-transaction.tdb1", - TDB_VERSION1, O_CREAT|O_TRUNC|O_RDWR, - 0600, &hsize); - ok1(tdb); - - key = tdb_mkdata("hi", strlen("hi")); - data = tdb_mkdata("world", strlen("world")); - - ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); - - ok1(external_agent_operation1(agent, OPEN, tdb->name) == SUCCESS); - - ok1(tdb_transaction_start(tdb) == TDB_SUCCESS); - ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name) - == WOULD_HAVE_BLOCKED); - tdb_traverse(tdb, traverse, NULL); - - /* That should *not* release the transaction lock! */ - ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name) - == WOULD_HAVE_BLOCKED); - tdb_traverse(tdb, traverse, NULL); - - /* That should *not* release the transaction lock! */ - ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name) - == WOULD_HAVE_BLOCKED); - ok1(tdb_transaction_commit(tdb) == TDB_SUCCESS); - /* Now we should be fine. */ - ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name) - == SUCCESS); - - tdb_close(tdb); - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-wronghash-fail.c b/lib/tdb2/test/run-tdb1-wronghash-fail.c deleted file mode 100644 index 725b4d2d00..0000000000 --- a/lib/tdb2/test/run-tdb1-wronghash-fail.c +++ /dev/null @@ -1,141 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> - -static void log_fn(struct tdb_context *tdb, enum tdb_log_level level, - enum TDB_ERROR ecode, const char *message, void *priv) -{ - unsigned int *count = priv; - if (strstr(message, "hash")) - (*count)++; -} - -static uint64_t jenkins_hashfn(const void *key, size_t len, uint64_t seed, - void *unused) -{ - return hashlittle(key, len); -} - -/* the tdb1_old_hash function is "magic" as it automatically makes us test the - * tdb1_incompatible_hash as well, so use this wrapper. */ -static uint64_t old_hash(const void *key, size_t len, uint64_t seed, - void *unused) -{ - return tdb1_old_hash(key, len, seed, unused); -} - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - unsigned int log_count; - TDB_DATA d; - union tdb_attribute log_attr, jhash_attr, ohash_attr, - incompat_hash_attr; - - log_attr.base.attr = TDB_ATTRIBUTE_LOG; - log_attr.base.next = NULL; - log_attr.log.fn = log_fn; - log_attr.log.data = &log_count; - - jhash_attr.base.attr = TDB_ATTRIBUTE_HASH; - jhash_attr.base.next = &log_attr; - jhash_attr.hash.fn = jenkins_hashfn; - - ohash_attr.base.attr = TDB_ATTRIBUTE_HASH; - ohash_attr.base.next = &log_attr; - ohash_attr.hash.fn = old_hash; - - incompat_hash_attr.base.attr = TDB_ATTRIBUTE_HASH; - incompat_hash_attr.base.next = &log_attr; - incompat_hash_attr.hash.fn = tdb1_incompatible_hash; - - plan_tests(28); - - /* Create with default hash. */ - log_count = 0; - tdb = tdb_open("run-wronghash-fail.tdb1", TDB_VERSION1, - O_CREAT|O_RDWR|O_TRUNC, 0600, &log_attr); - ok1(tdb); - ok1(log_count == 0); - d = tdb_mkdata("Hello", strlen("Hello")); - ok1(tdb_store(tdb, d, d, TDB_INSERT) == TDB_SUCCESS); - tdb_close(tdb); - - /* Fail to open with different hash. */ - tdb = tdb_open("run-wronghash-fail.tdb1", TDB_VERSION1, O_RDWR, 0, - &jhash_attr); - ok1(!tdb); - ok1(log_count == 1); - - /* Create with different hash. */ - log_count = 0; - tdb = tdb_open("run-wronghash-fail.tdb1", TDB_VERSION1, - O_CREAT|O_RDWR|O_TRUNC, 0600, &jhash_attr); - ok1(tdb); - ok1(log_count == 0); - tdb_close(tdb); - - /* Endian should be no problem. */ - log_count = 0; - tdb = tdb_open("test/jenkins-le-hash.tdb1", TDB_VERSION1, O_RDWR, 0, - &ohash_attr); - ok1(!tdb); - ok1(log_count == 1); - - log_count = 0; - tdb = tdb_open("test/jenkins-be-hash.tdb1", TDB_VERSION1, O_RDWR, 0, - &ohash_attr); - ok1(!tdb); - ok1(log_count == 1); - - log_count = 0; - /* Fail to open with old default hash. */ - tdb = tdb_open("run-wronghash-fail.tdb1", TDB_VERSION1, O_RDWR, 0, - &ohash_attr); - ok1(!tdb); - ok1(log_count == 1); - - log_count = 0; - tdb = tdb_open("test/jenkins-le-hash.tdb1", TDB_VERSION1, O_RDONLY, - 0, &incompat_hash_attr); - ok1(tdb); - ok1(log_count == 0); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - log_count = 0; - tdb = tdb_open("test/jenkins-be-hash.tdb1", TDB_VERSION1, O_RDONLY, - 0, &incompat_hash_attr); - ok1(tdb); - ok1(log_count == 0); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - /* It should open with jenkins hash if we don't specify. */ - log_count = 0; - tdb = tdb_open("test/jenkins-le-hash.tdb1", TDB_VERSION1, O_RDWR, 0, - &log_attr); - ok1(tdb); - ok1(log_count == 0); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - log_count = 0; - tdb = tdb_open("test/jenkins-be-hash.tdb1", TDB_VERSION1, O_RDWR, 0, - &log_attr); - ok1(tdb); - ok1(log_count == 0); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - log_count = 0; - tdb = tdb_open("run-wronghash-fail.tdb1", TDB_VERSION1, O_RDONLY, - 0, &log_attr); - ok1(tdb); - ok1(log_count == 0); - ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - tdb_close(tdb); - - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1-zero-append.c b/lib/tdb2/test/run-tdb1-zero-append.c deleted file mode 100644 index 2d8be6123b..0000000000 --- a/lib/tdb2/test/run-tdb1-zero-append.c +++ /dev/null @@ -1,33 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> -#include "logging.h" - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - TDB_DATA key, data; - union tdb_attribute hsize; - - hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - hsize.base.next = &tap_log_attr; - hsize.tdb1_hashsize.hsize = 1024; - - plan_tests(5); - tdb = tdb_open(NULL, TDB_INTERNAL|TDB_VERSION1, O_CREAT|O_TRUNC|O_RDWR, - 0600, &hsize); - ok1(tdb); - - /* Tickle bug on appending zero length buffer to zero length buffer. */ - key = tdb_mkdata("hi", strlen("hi")); - data = tdb_mkdata("world", 0); - - ok1(tdb_append(tdb, key, data) == TDB_SUCCESS); - ok1(tdb_append(tdb, key, data) == TDB_SUCCESS); - ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS); - ok1(data.dsize == 0); - free(data.dptr); - tdb_close(tdb); - - return exit_status(); -} diff --git a/lib/tdb2/test/run-tdb1.c b/lib/tdb2/test/run-tdb1.c deleted file mode 100644 index d5b05b0bd6..0000000000 --- a/lib/tdb2/test/run-tdb1.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "tdb2-source.h" -#include "tap-interface.h" -#include <stdlib.h> -#include "logging.h" - -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - TDB_DATA key, data; - union tdb_attribute hsize; - - hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE; - hsize.base.next = &tap_log_attr; - hsize.tdb1_hashsize.hsize = 1024; - - plan_tests(9); - tdb = tdb_open("run.tdb1", TDB_VERSION1, - O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); - - ok1(tdb); - key = tdb_mkdata("hi", strlen("hi")); - data = tdb_mkdata("world", strlen("world")); - - ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_ERR_NOEXIST); - ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); - ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_ERR_EXISTS); - ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_SUCCESS); - - ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS); - ok1(data.dsize == strlen("world")); - ok1(memcmp(data.dptr, "world", strlen("world")) == 0); - free(data.dptr); - - key.dsize++; - ok1(tdb_fetch(tdb, key, &data) == TDB_ERR_NOEXIST); - tdb_close(tdb); - - return exit_status(); -} diff --git a/lib/tdb2/test/rwlock-be.tdb1 b/lib/tdb2/test/rwlock-be.tdb1 Binary files differdeleted file mode 100644 index 45b5f09a1b..0000000000 --- a/lib/tdb2/test/rwlock-be.tdb1 +++ /dev/null diff --git a/lib/tdb2/test/rwlock-le.tdb1 b/lib/tdb2/test/rwlock-le.tdb1 Binary files differdeleted file mode 100644 index 45b5f09a1b..0000000000 --- a/lib/tdb2/test/rwlock-le.tdb1 +++ /dev/null diff --git a/lib/tdb2/test/tdb1-external-agent.c b/lib/tdb2/test/tdb1-external-agent.c deleted file mode 100644 index 7242e22300..0000000000 --- a/lib/tdb2/test/tdb1-external-agent.c +++ /dev/null @@ -1,186 +0,0 @@ -#include "tdb1-external-agent.h" -#include "tdb1-lock-tracking.h" -#include "logging.h" -#include <sys/types.h> -#include <sys/wait.h> -#include <unistd.h> -#include <fcntl.h> -#include <stdlib.h> -#include <limits.h> -#include <string.h> -#include <errno.h> -#include "tdb1_private.h" -#include "tap-interface.h" -#include <stdio.h> -#include <stdarg.h> - -static struct tdb_context *tdb; - -static enum agent_return do_operation(enum operation op, const char *name) -{ - TDB_DATA k; - enum agent_return ret; - TDB_DATA data; - - if (op != OPEN && !tdb) { - diag("external: No tdb open!"); - return OTHER_FAILURE; - } - - k = tdb_mkdata(name, strlen(name)); - - locking_would_block1 = 0; - switch (op) { - case OPEN: - if (tdb) { - diag("Already have tdb %s open", tdb->name); - return OTHER_FAILURE; - } - tdb = tdb_open(name, TDB_VERSION1, O_RDWR, 0, &tap_log_attr); - if (!tdb) { - if (!locking_would_block1) - diag("Opening tdb gave %s", strerror(errno)); - ret = OTHER_FAILURE; - } else - ret = SUCCESS; - break; - case TRANSACTION_START: - ret = tdb_transaction_start(tdb) == TDB_SUCCESS ? SUCCESS : OTHER_FAILURE; - break; - case FETCH: - if (tdb_fetch(tdb, k, &data) != TDB_SUCCESS) { - if (tdb->last_error == TDB_ERR_NOEXIST) - ret = FAILED; - else - ret = OTHER_FAILURE; - } else if (data.dsize != k.dsize - || memcmp(data.dptr, k.dptr, k.dsize) != 0) { - ret = OTHER_FAILURE; - } else { - ret = SUCCESS; - } - free(data.dptr); - break; - case STORE: - if (tdb_store(tdb, k, k, 0) == TDB_SUCCESS) - ret = SUCCESS; - else - ret = OTHER_FAILURE; - break; - case TRANSACTION_COMMIT: - ret = tdb_transaction_commit(tdb) == TDB_SUCCESS ? SUCCESS : OTHER_FAILURE; - break; - case CHECK: - ret = tdb_check(tdb, NULL, NULL) == TDB_SUCCESS ? SUCCESS : OTHER_FAILURE; - break; - case NEEDS_RECOVERY: - ret = external_agent_needs_rec(tdb); - break; - case CLOSE: - ret = tdb_close(tdb) == 0 ? SUCCESS : OTHER_FAILURE; - tdb = NULL; - break; - default: - ret = OTHER_FAILURE; - } - - if (locking_would_block1) - ret = WOULD_HAVE_BLOCKED; - - return ret; -} - -struct agent { - int cmdfd, responsefd; -}; - -/* Do this before doing any tdb stuff. Return handle, or NULL. */ -struct agent *prepare_external_agent1(void) -{ - int pid, ret; - int command[2], response[2]; - char name[1+PATH_MAX]; - - if (pipe(command) != 0 || pipe(response) != 0) - return NULL; - - pid = fork(); - if (pid < 0) - return NULL; - - if (pid != 0) { - struct agent *agent = malloc(sizeof(*agent)); - - close(command[0]); - close(response[1]); - agent->cmdfd = command[1]; - agent->responsefd = response[0]; - return agent; - } - - close(command[1]); - close(response[0]); - - /* We want to fail, not block. */ - nonblocking_locks1 = true; - log_prefix = "external: "; - while ((ret = read(command[0], name, sizeof(name))) > 0) { - enum agent_return result; - - result = do_operation(name[0], name+1); - if (write(response[1], &result, sizeof(result)) - != sizeof(result)) - err(1, "Writing response"); - } - exit(0); -} - -/* Ask the external agent to try to do an operation. */ -enum agent_return external_agent_operation1(struct agent *agent, - enum operation op, - const char *name) -{ - enum agent_return res; - unsigned int len; - char *string; - - if (!name) - name = ""; - len = 1 + strlen(name) + 1; - string = malloc(len); - - string[0] = op; - strcpy(string+1, name); - - if (write(agent->cmdfd, string, len) != len - || read(agent->responsefd, &res, sizeof(res)) != sizeof(res)) - res = AGENT_DIED; - - free(string); - return res; -} - -const char *agent_return_name1(enum agent_return ret) -{ - return ret == SUCCESS ? "SUCCESS" - : ret == WOULD_HAVE_BLOCKED ? "WOULD_HAVE_BLOCKED" - : ret == AGENT_DIED ? "AGENT_DIED" - : ret == FAILED ? "FAILED" - : ret == OTHER_FAILURE ? "OTHER_FAILURE" - : "**INVALID**"; -} - -const char *operation_name1(enum operation op) -{ - switch (op) { - case OPEN: return "OPEN"; - case TRANSACTION_START: return "TRANSACTION_START"; - case FETCH: return "FETCH"; - case STORE: return "STORE"; - case TRANSACTION_COMMIT: return "TRANSACTION_COMMIT"; - case CHECK: return "CHECK"; - case NEEDS_RECOVERY: return "NEEDS_RECOVERY"; - case CLOSE: return "CLOSE"; - } - return "**INVALID**"; -} diff --git a/lib/tdb2/test/tdb1-external-agent.h b/lib/tdb2/test/tdb1-external-agent.h deleted file mode 100644 index 19ad8d2c12..0000000000 --- a/lib/tdb2/test/tdb1-external-agent.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef TDB_TEST_EXTERNAL_AGENT_H -#define TDB_TEST_EXTERNAL_AGENT_H - -/* For locking tests, we need a different process to try things at - * various times. */ -enum operation { - OPEN, - TRANSACTION_START, - FETCH, - STORE, - TRANSACTION_COMMIT, - CHECK, - NEEDS_RECOVERY, - CLOSE, -}; - -/* Do this before doing any tdb stuff. Return handle, or -1. */ -struct agent *prepare_external_agent1(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_operation1(struct agent *handle, - enum operation op, - const char *name); - -/* Mapping enum -> string. */ -const char *agent_return_name1(enum agent_return ret); -const char *operation_name1(enum operation op); - -/* Internal use: */ -struct tdb_context; -enum agent_return external_agent_needs_rec(struct tdb_context *tdb); -#endif /* TDB_TEST_EXTERNAL_AGENT_H */ diff --git a/lib/tdb2/test/tdb1-lock-tracking.c b/lib/tdb2/test/tdb1-lock-tracking.c deleted file mode 100644 index 9701157b81..0000000000 --- a/lib/tdb2/test/tdb1-lock-tracking.c +++ /dev/null @@ -1,146 +0,0 @@ -/* We save the locks so we can reaquire them. */ -#include "tdb1_private.h" -#include <unistd.h> -#include <fcntl.h> -#include <stdarg.h> -#include <stdlib.h> -#include "tap-interface.h" -#include "tdb1-lock-tracking.h" - -struct lock { - struct lock *next; - unsigned int off; - unsigned int len; - int type; -}; -static struct lock *locks; -int locking_errors1 = 0; -bool suppress_lockcheck1 = false; -bool nonblocking_locks1; -int locking_would_block1 = 0; -void (*unlock_callback1)(int fd); - -int fcntl_with_lockcheck1(int fd, int cmd, ... /* arg */ ) -{ - va_list ap; - int ret, arg3; - struct flock *fl; - bool may_block = false; - - if (cmd != F_SETLK && cmd != F_SETLKW) { - /* This may be totally bogus, but we don't know in general. */ - va_start(ap, cmd); - arg3 = va_arg(ap, int); - va_end(ap); - - return fcntl(fd, cmd, arg3); - } - - va_start(ap, cmd); - fl = va_arg(ap, struct flock *); - va_end(ap); - - if (cmd == F_SETLKW && nonblocking_locks1) { - cmd = F_SETLK; - may_block = true; - } - ret = fcntl(fd, cmd, fl); - - /* Detect when we failed, but might have been OK if we waited. */ - if (may_block && ret == -1 && (errno == EAGAIN || errno == EACCES)) { - locking_would_block1++; - } - - if (fl->l_type == F_UNLCK) { - struct lock **l; - struct lock *old = NULL; - - for (l = &locks; *l; l = &(*l)->next) { - if ((*l)->off == fl->l_start - && (*l)->len == fl->l_len) { - if (ret == 0) { - old = *l; - *l = (*l)->next; - free(old); - } - break; - } - } - if (!old && !suppress_lockcheck1) { - diag("Unknown unlock %u@%u - %i", - (int)fl->l_len, (int)fl->l_start, ret); - locking_errors1++; - } - } else { - struct lock *new, *i; - unsigned int fl_end = fl->l_start + fl->l_len; - if (fl->l_len == 0) - fl_end = (unsigned int)-1; - - /* Check for overlaps: we shouldn't do this. */ - for (i = locks; i; i = i->next) { - unsigned int i_end = i->off + i->len; - if (i->len == 0) - i_end = (unsigned int)-1; - - if (fl->l_start >= i->off && fl->l_start < i_end) - break; - if (fl_end >= i->off && fl_end < i_end) - break; - - /* tdb_allrecord_lock does this, handle adjacent: */ - if (fl->l_start == i_end && fl->l_type == i->type) { - if (ret == 0) { - i->len = fl->l_len - ? i->len + fl->l_len - : 0; - } - goto done; - } - } - if (i) { - /* Special case: upgrade of allrecord lock. */ - if (i->type == F_RDLCK && fl->l_type == F_WRLCK - && i->off == TDB1_FREELIST_TOP - && fl->l_start == TDB1_FREELIST_TOP - && i->len == 0 - && fl->l_len == 0) { - if (ret == 0) - i->type = F_WRLCK; - goto done; - } - if (!suppress_lockcheck1) { - diag("%s lock %u@%u overlaps %u@%u", - fl->l_type == F_WRLCK ? "write" : "read", - (int)fl->l_len, (int)fl->l_start, - i->len, (int)i->off); - locking_errors1++; - } - } - - if (ret == 0) { - new = malloc(sizeof *new); - new->off = fl->l_start; - new->len = fl->l_len; - new->type = fl->l_type; - new->next = locks; - locks = new; - } - } -done: - if (ret == 0 && fl->l_type == F_UNLCK && unlock_callback1) - unlock_callback1(fd); - return ret; -} - -unsigned int forget_locking1(void) -{ - unsigned int num = 0; - while (locks) { - struct lock *next = locks->next; - free(locks); - locks = next; - num++; - } - return num; -} diff --git a/lib/tdb2/test/tdb1-lock-tracking.h b/lib/tdb2/test/tdb1-lock-tracking.h deleted file mode 100644 index b59e7d805d..0000000000 --- a/lib/tdb2/test/tdb1-lock-tracking.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef TDB1_LOCK_TRACKING_H -#define TDB1_LOCK_TRACKING_H -#include "private.h" -#include <stdbool.h> - -/* Set this if you want a callback after fnctl unlock. */ -extern void (*unlock_callback1)(int fd); - -/* Replacement fcntl. */ -int fcntl_with_lockcheck1(int fd, int cmd, ... /* arg */ ); - -/* Discard locking info: returns number of locks outstanding. */ -unsigned int forget_locking1(void); - -/* Number of errors in locking. */ -extern int locking_errors1; - -/* Suppress lock checking. */ -extern bool suppress_lockcheck1; - -/* Make all locks non-blocking. */ -extern bool nonblocking_locks1; - -/* Number of times we failed a lock because we made it non-blocking. */ -extern int locking_would_block1; -#endif /* LOCK_TRACKING_H */ diff --git a/lib/tdb2/test/tdb1.corrupt b/lib/tdb2/test/tdb1.corrupt Binary files differdeleted file mode 100644 index 83d6677454..0000000000 --- a/lib/tdb2/test/tdb1.corrupt +++ /dev/null diff --git a/lib/tdb2/test/tdb2-source.h b/lib/tdb2/test/tdb2-source.h index fabf6ac33d..d13d8b868c 100644 --- a/lib/tdb2/test/tdb2-source.h +++ b/lib/tdb2/test/tdb2-source.h @@ -9,13 +9,3 @@ #include "tdb.c" #include "transaction.c" #include "traverse.c" -#include "tdb1_check.c" -#include "tdb1_freelist.c" -#include "tdb1_hash.c" -#include "tdb1_io.c" -#include "tdb1_lock.c" -#include "tdb1_open.c" -#include "tdb1_summary.c" -#include "tdb1_tdb.c" -#include "tdb1_transaction.c" -#include "tdb1_traverse.c" |