From 9d897b0951e73a4717ae133d5b6b2493334fbf22 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 22 Feb 2012 15:03:37 +1030 Subject: lib/tdb2: adapt unit tests to SAMBA environment. This means changing headers, implementing a simple tap-like wrapper, and also splitting out the helpers into those which are linked with the api* tests (which can't use non-public tdb2 functions) and those linked with the run* tests (which can). Signed-off-by: Rusty Russell --- lib/tdb2/test/api-12-store.c | 5 +- lib/tdb2/test/api-13-delete.c | 6 +- lib/tdb2/test/api-14-exists.c | 5 +- lib/tdb2/test/api-16-wipe_all.c | 5 +- lib/tdb2/test/api-21-parse_record.c | 5 +- lib/tdb2/test/api-55-transaction.c | 6 +- lib/tdb2/test/api-80-tdb_fd.c | 5 +- lib/tdb2/test/api-81-seqnum.c | 5 +- lib/tdb2/test/api-82-lockattr.c | 6 +- lib/tdb2/test/api-83-openhook.c | 5 +- lib/tdb2/test/api-91-get-stats.c | 5 +- lib/tdb2/test/api-92-get-set-readonly.c | 5 +- lib/tdb2/test/api-93-repack.c | 5 +- lib/tdb2/test/api-add-remove-flags.c | 6 +- lib/tdb2/test/api-check-callback.c | 5 +- lib/tdb2/test/api-firstkey-nextkey.c | 5 +- lib/tdb2/test/api-fork-test.c | 5 +- lib/tdb2/test/api-locktimeout.c | 6 +- lib/tdb2/test/api-missing-entries.c | 5 +- lib/tdb2/test/api-open-multiple-times.c | 5 +- lib/tdb2/test/api-record-expand.c | 5 +- lib/tdb2/test/api-simple-delete.c | 5 +- lib/tdb2/test/api-summary.c | 5 +- lib/tdb2/test/api-tdb1-flag-removal.c | 5 +- lib/tdb2/test/external-agent.c | 12 +- lib/tdb2/test/external-agent.h | 7 +- lib/tdb2/test/failtest_helper.c | 2 +- lib/tdb2/test/helpapi-external-agent.c | 8 + lib/tdb2/test/helprun-external-agent.c | 10 + lib/tdb2/test/helprun-layout.c | 402 +++++++++++++++++++++++ lib/tdb2/test/layout.c | 402 ----------------------- lib/tdb2/test/layout.h | 2 +- lib/tdb2/test/lock-tracking.c | 4 +- lib/tdb2/test/logging.c | 2 +- lib/tdb2/test/logging.h | 2 +- lib/tdb2/test/run-001-encode.c | 2 +- lib/tdb2/test/run-001-fls.c | 2 +- lib/tdb2/test/run-01-new_database.c | 2 +- lib/tdb2/test/run-02-expand.c | 2 +- lib/tdb2/test/run-03-coalesce.c | 2 +- lib/tdb2/test/run-04-basichash.c | 2 +- lib/tdb2/test/run-05-readonly-open.c | 2 +- lib/tdb2/test/run-10-simple-store.c | 2 +- lib/tdb2/test/run-11-simple-fetch.c | 2 +- lib/tdb2/test/run-12-check.c | 4 +- lib/tdb2/test/run-15-append.c | 2 +- lib/tdb2/test/run-20-growhash.c | 2 +- lib/tdb2/test/run-25-hashoverload.c | 2 +- lib/tdb2/test/run-30-exhaust-before-expand.c | 2 +- lib/tdb2/test/run-35-convert.c | 4 +- lib/tdb2/test/run-50-multiple-freelists.c | 2 +- lib/tdb2/test/run-56-open-during-transaction.c | 4 +- lib/tdb2/test/run-57-die-during-transaction.c | 4 +- lib/tdb2/test/run-64-bit-tdb.c | 2 +- lib/tdb2/test/run-90-get-set-attributes.c | 2 +- lib/tdb2/test/run-capabilities.c | 2 +- lib/tdb2/test/run-expand-in-transaction.c | 2 +- lib/tdb2/test/run-features.c | 2 +- lib/tdb2/test/run-lockall.c | 4 +- lib/tdb2/test/run-remap-in-read_traverse.c | 2 +- lib/tdb2/test/run-seed.c | 2 +- lib/tdb2/test/run-tdb1-3G-file.c | 2 +- lib/tdb2/test/run-tdb1-bad-tdb-header.c | 2 +- lib/tdb2/test/run-tdb1-check.c | 2 +- lib/tdb2/test/run-tdb1-corrupt.c | 2 +- lib/tdb2/test/run-tdb1-endian.c | 2 +- lib/tdb2/test/run-tdb1-hashsize.c | 2 +- lib/tdb2/test/run-tdb1-incompatible.c | 2 +- lib/tdb2/test/run-tdb1-nested-transactions.c | 2 +- lib/tdb2/test/run-tdb1-nested-traverse.c | 2 +- lib/tdb2/test/run-tdb1-no-lock-during-traverse.c | 4 +- lib/tdb2/test/run-tdb1-oldhash.c | 2 +- lib/tdb2/test/run-tdb1-readonly-check.c | 2 +- lib/tdb2/test/run-tdb1-rwlock-check.c | 2 +- lib/tdb2/test/run-tdb1-seqnum-wrap.c | 2 +- lib/tdb2/test/run-tdb1-summary.c | 2 +- lib/tdb2/test/run-tdb1-traverse-in-transaction.c | 2 +- lib/tdb2/test/run-tdb1-wronghash-fail.c | 2 +- lib/tdb2/test/run-tdb1-zero-append.c | 2 +- lib/tdb2/test/run-tdb1.c | 2 +- lib/tdb2/test/run-tdb_errorstr.c | 2 +- lib/tdb2/test/run-tdb_foreach.c | 2 +- lib/tdb2/test/run-traverse.c | 2 +- lib/tdb2/test/tap-interface.c | 3 + lib/tdb2/test/tap-interface.h | 41 +++ lib/tdb2/test/tdb1-external-agent.c | 6 +- lib/tdb2/test/tdb1-external-agent.h | 3 + lib/tdb2/test/tdb1-lock-tracking.c | 4 +- lib/tdb2/test/tdb1-lock-tracking.h | 2 +- lib/tdb2/test/tdb2-source.h | 40 +-- 90 files changed, 636 insertions(+), 549 deletions(-) create mode 100644 lib/tdb2/test/helpapi-external-agent.c create mode 100644 lib/tdb2/test/helprun-external-agent.c create mode 100644 lib/tdb2/test/helprun-layout.c delete mode 100644 lib/tdb2/test/layout.c create mode 100644 lib/tdb2/test/tap-interface.c create mode 100644 lib/tdb2/test/tap-interface.h diff --git a/lib/tdb2/test/api-12-store.c b/lib/tdb2/test/api-12-store.c index ccec53e029..6a9dd95f5f 100644 --- a/lib/tdb2/test/api-12-store.c +++ b/lib/tdb2/test/api-12-store.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-13-delete.c b/lib/tdb2/test/api-13-delete.c index 0287a6abf9..c8ed580615 100644 --- a/lib/tdb2/test/api-13-delete.c +++ b/lib/tdb2/test/api-13-delete.c @@ -1,10 +1,10 @@ -#include // For TDB_TOPLEVEL_HASH_BITS +#include "private.h" // For TDB_TOPLEVEL_HASH_BITS #include #include #include #include -#include -#include +#include "tdb2.h" +#include "tap-interface.h" #include "logging.h" /* We rig the hash so adjacent-numbered records always clash. */ diff --git a/lib/tdb2/test/api-14-exists.c b/lib/tdb2/test/api-14-exists.c index 698006faf4..916e9b46f6 100644 --- a/lib/tdb2/test/api-14-exists.c +++ b/lib/tdb2/test/api-14-exists.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-16-wipe_all.c b/lib/tdb2/test/api-16-wipe_all.c index d17eff8e6a..f97dd0db42 100644 --- a/lib/tdb2/test/api-16-wipe_all.c +++ b/lib/tdb2/test/api-16-wipe_all.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-21-parse_record.c b/lib/tdb2/test/api-21-parse_record.c index def4f456ff..6ac9543b52 100644 --- a/lib/tdb2/test/api-21-parse_record.c +++ b/lib/tdb2/test/api-21-parse_record.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-55-transaction.c b/lib/tdb2/test/api-55-transaction.c index 9c1044b4e1..ece59d5cb5 100644 --- a/lib/tdb2/test/api-55-transaction.c +++ b/lib/tdb2/test/api-55-transaction.c @@ -1,6 +1,6 @@ -#include // struct tdb_context -#include -#include +#include "private.h" // struct tdb_context +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-80-tdb_fd.c b/lib/tdb2/test/api-80-tdb_fd.c index 0088f9b74d..fea30979b9 100644 --- a/lib/tdb2/test/api-80-tdb_fd.c +++ b/lib/tdb2/test/api-80-tdb_fd.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-81-seqnum.c b/lib/tdb2/test/api-81-seqnum.c index c1eb75170b..954b097b0f 100644 --- a/lib/tdb2/test/api-81-seqnum.c +++ b/lib/tdb2/test/api-81-seqnum.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-82-lockattr.c b/lib/tdb2/test/api-82-lockattr.c index 048feacfa5..4a68702fe1 100644 --- a/lib/tdb2/test/api-82-lockattr.c +++ b/lib/tdb2/test/api-82-lockattr.c @@ -1,6 +1,6 @@ -#include // for tdb_fcntl_unlock -#include -#include +#include "private.h" // for tdb_fcntl_unlock +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-83-openhook.c b/lib/tdb2/test/api-83-openhook.c index e7e94738de..1ee745f992 100644 --- a/lib/tdb2/test/api-83-openhook.c +++ b/lib/tdb2/test/api-83-openhook.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-91-get-stats.c b/lib/tdb2/test/api-91-get-stats.c index d9a22ca444..f7bc64524d 100644 --- a/lib/tdb2/test/api-91-get-stats.c +++ b/lib/tdb2/test/api-91-get-stats.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-92-get-set-readonly.c b/lib/tdb2/test/api-92-get-set-readonly.c index 483b50d7fd..eddb0d4fe2 100644 --- a/lib/tdb2/test/api-92-get-set-readonly.c +++ b/lib/tdb2/test/api-92-get-set-readonly.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-93-repack.c b/lib/tdb2/test/api-93-repack.c index 74a8b5eda2..a1b5154524 100644 --- a/lib/tdb2/test/api-93-repack.c +++ b/lib/tdb2/test/api-93-repack.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-add-remove-flags.c b/lib/tdb2/test/api-add-remove-flags.c index 231b9f6cfe..2526bf45b6 100644 --- a/lib/tdb2/test/api-add-remove-flags.c +++ b/lib/tdb2/test/api-add-remove-flags.c @@ -1,6 +1,6 @@ -#include // for tdb_context -#include -#include +#include "private.h" // for tdb_context +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-check-callback.c b/lib/tdb2/test/api-check-callback.c index fb980f2276..e49d00f904 100644 --- a/lib/tdb2/test/api-check-callback.c +++ b/lib/tdb2/test/api-check-callback.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-firstkey-nextkey.c b/lib/tdb2/test/api-firstkey-nextkey.c index e0374d8680..56b3c25fb0 100644 --- a/lib/tdb2/test/api-firstkey-nextkey.c +++ b/lib/tdb2/test/api-firstkey-nextkey.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-fork-test.c b/lib/tdb2/test/api-fork-test.c index 6feb618c72..988004e90a 100644 --- a/lib/tdb2/test/api-fork-test.c +++ b/lib/tdb2/test/api-fork-test.c @@ -10,8 +10,9 @@ * Note that we don't hold a lock across tdb_traverse callbacks, so * that doesn't matter. */ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-locktimeout.c b/lib/tdb2/test/api-locktimeout.c index 21a26c46fe..2466817a13 100644 --- a/lib/tdb2/test/api-locktimeout.c +++ b/lib/tdb2/test/api-locktimeout.c @@ -1,5 +1,7 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" +#include "system/wait.h" #include #include #include diff --git a/lib/tdb2/test/api-missing-entries.c b/lib/tdb2/test/api-missing-entries.c index 0b21e1ee0f..c81839bc05 100644 --- a/lib/tdb2/test/api-missing-entries.c +++ b/lib/tdb2/test/api-missing-entries.c @@ -1,7 +1,8 @@ /* Another test revealed that we lost an entry. This reproduces it. */ -#include +#include "config.h" +#include "tdb2.h" #include -#include +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-open-multiple-times.c b/lib/tdb2/test/api-open-multiple-times.c index 16562069dc..f976c95403 100644 --- a/lib/tdb2/test/api-open-multiple-times.c +++ b/lib/tdb2/test/api-open-multiple-times.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-record-expand.c b/lib/tdb2/test/api-record-expand.c index 48ad1cdf22..686dcf3267 100644 --- a/lib/tdb2/test/api-record-expand.c +++ b/lib/tdb2/test/api-record-expand.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-simple-delete.c b/lib/tdb2/test/api-simple-delete.c index a5b65d605e..bd228d654e 100644 --- a/lib/tdb2/test/api-simple-delete.c +++ b/lib/tdb2/test/api-simple-delete.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-summary.c b/lib/tdb2/test/api-summary.c index e0e292ea39..babccc7cf4 100644 --- a/lib/tdb2/test/api-summary.c +++ b/lib/tdb2/test/api-summary.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/api-tdb1-flag-removal.c b/lib/tdb2/test/api-tdb1-flag-removal.c index 28f24e6388..59994dfa5c 100644 --- a/lib/tdb2/test/api-tdb1-flag-removal.c +++ b/lib/tdb2/test/api-tdb1-flag-removal.c @@ -1,5 +1,6 @@ -#include -#include +#include "config.h" +#include "tdb2.h" +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/external-agent.c b/lib/tdb2/test/external-agent.c index 01c7106fba..9d50e8fa85 100644 --- a/lib/tdb2/test/external-agent.c +++ b/lib/tdb2/test/external-agent.c @@ -10,8 +10,7 @@ #include #include #include -#include -#include +#include "tap-interface.h" #include #include @@ -65,7 +64,7 @@ static enum agent_return do_operation(enum operation op, const char *name) switch (op) { case OPEN: if (tdb) { - diag("Already have tdb %s open", tdb->name); + diag("Already have tdb %s open", tdb_name(tdb)); return OTHER_FAILURE; } tdb = tdb_open(name, TDB_DEFAULT, O_RDWR, 0, &tap_log_attr); @@ -79,7 +78,7 @@ static enum agent_return do_operation(enum operation op, const char *name) break; case OPEN_WITH_HOOK: if (tdb) { - diag("Already have tdb %s open", tdb->name); + diag("Already have tdb %s open", tdb_name(tdb)); return OTHER_FAILURE; } cif.openhook.base.attr = TDB_ATTRIBUTE_OPENHOOK; @@ -118,10 +117,7 @@ static enum agent_return do_operation(enum operation op, const char *name) ret = tdb_transaction_commit(tdb)==0 ? SUCCESS : OTHER_FAILURE; break; case NEEDS_RECOVERY: - if (tdb->flags & TDB_VERSION1) - ret = tdb1_needs_recovery(tdb) ? SUCCESS : FAILED; - else - ret = tdb_needs_recovery(tdb) ? SUCCESS : FAILED; + ret = external_agent_needs_rec(tdb); break; case CHECK: ret = tdb_check(tdb, NULL, NULL) == 0 ? SUCCESS : OTHER_FAILURE; diff --git a/lib/tdb2/test/external-agent.h b/lib/tdb2/test/external-agent.h index cf9789b669..c4cd2b148d 100644 --- a/lib/tdb2/test/external-agent.h +++ b/lib/tdb2/test/external-agent.h @@ -36,11 +36,16 @@ enum agent_return external_agent_operation(struct agent *handle, const char *name); /* Hook into free() on tdb_data in external agent. */ -void (*external_agent_free)(void *); +extern void (*external_agent_free)(void *); /* Mapping enum -> string. */ const char *agent_return_name(enum agent_return ret); const char *operation_name(enum operation op); void free_external_agent(struct agent *agent); + +/* Internal use: */ +struct tdb_context; +enum agent_return external_agent_needs_rec(struct tdb_context *tdb); + #endif /* TDB2_TEST_EXTERNAL_AGENT_H */ diff --git a/lib/tdb2/test/failtest_helper.c b/lib/tdb2/test/failtest_helper.c index ab79de1978..386f1c2379 100644 --- a/lib/tdb2/test/failtest_helper.c +++ b/lib/tdb2/test/failtest_helper.c @@ -1,7 +1,7 @@ #include "failtest_helper.h" #include "logging.h" #include -#include +#include "tap-interface.h" bool failtest_suppress = false; diff --git a/lib/tdb2/test/helpapi-external-agent.c b/lib/tdb2/test/helpapi-external-agent.c new file mode 100644 index 0000000000..140ffaf116 --- /dev/null +++ b/lib/tdb2/test/helpapi-external-agent.c @@ -0,0 +1,8 @@ +#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) +{ + return FAILED; +} diff --git a/lib/tdb2/test/helprun-external-agent.c b/lib/tdb2/test/helprun-external-agent.c new file mode 100644 index 0000000000..469847be75 --- /dev/null +++ b/lib/tdb2/test/helprun-external-agent.c @@ -0,0 +1,10 @@ +#include "external-agent.h" +#include "tdb1_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; +} diff --git a/lib/tdb2/test/helprun-layout.c b/lib/tdb2/test/helprun-layout.c new file mode 100644 index 0000000000..0bce5dd89e --- /dev/null +++ b/lib/tdb2/test/helprun-layout.c @@ -0,0 +1,402 @@ +/* TDB tools to create various canned database layouts. */ +#include "layout.h" +#include +#include +#include +#include +#include "logging.h" + +struct tdb_layout *new_tdb_layout(void) +{ + struct tdb_layout *layout = malloc(sizeof(*layout)); + layout->num_elems = 0; + layout->elem = NULL; + return layout; +} + +static void add(struct tdb_layout *layout, union tdb_layout_elem elem) +{ + layout->elem = realloc(layout->elem, + sizeof(layout->elem[0]) + * (layout->num_elems+1)); + layout->elem[layout->num_elems++] = elem; +} + +void tdb_layout_add_freetable(struct tdb_layout *layout) +{ + union tdb_layout_elem elem; + elem.base.type = FREETABLE; + add(layout, elem); +} + +void tdb_layout_add_free(struct tdb_layout *layout, tdb_len_t len, + unsigned ftable) +{ + union tdb_layout_elem elem; + elem.base.type = FREE; + elem.free.len = len; + elem.free.ftable_num = ftable; + add(layout, elem); +} + +void tdb_layout_add_capability(struct tdb_layout *layout, + uint64_t type, + bool write_breaks, + bool check_breaks, + bool open_breaks, + tdb_len_t extra) +{ + union tdb_layout_elem elem; + elem.base.type = CAPABILITY; + elem.capability.type = type; + if (write_breaks) + elem.capability.type |= TDB_CAP_NOWRITE; + if (open_breaks) + elem.capability.type |= TDB_CAP_NOOPEN; + if (check_breaks) + elem.capability.type |= TDB_CAP_NOCHECK; + elem.capability.extra = extra; + add(layout, elem); +} + +static struct tdb_data dup_key(struct tdb_data key) +{ + struct tdb_data ret; + ret.dsize = key.dsize; + ret.dptr = malloc(ret.dsize); + memcpy(ret.dptr, key.dptr, ret.dsize); + return ret; +} + +void tdb_layout_add_used(struct tdb_layout *layout, + TDB_DATA key, TDB_DATA data, + tdb_len_t extra) +{ + union tdb_layout_elem elem; + elem.base.type = DATA; + elem.used.key = dup_key(key); + elem.used.data = dup_key(data); + elem.used.extra = extra; + add(layout, elem); +} + +static tdb_len_t free_record_len(tdb_len_t len) +{ + return sizeof(struct tdb_used_record) + len; +} + +static tdb_len_t data_record_len(struct tle_used *used) +{ + tdb_len_t len; + len = sizeof(struct tdb_used_record) + + used->key.dsize + used->data.dsize + used->extra; + assert(len >= sizeof(struct tdb_free_record)); + return len; +} + +static tdb_len_t hashtable_len(struct tle_hashtable *htable) +{ + return sizeof(struct tdb_used_record) + + (sizeof(tdb_off_t) << TDB_SUBLEVEL_HASH_BITS) + + htable->extra; +} + +static tdb_len_t capability_len(struct tle_capability *cap) +{ + return sizeof(struct tdb_capability) + cap->extra; +} + +static tdb_len_t freetable_len(struct tle_freetable *ftable) +{ + return sizeof(struct tdb_freetable); +} + +static void set_free_record(void *mem, tdb_len_t len) +{ + /* We do all the work in add_to_freetable */ +} + +static void add_zero_pad(struct tdb_used_record *u, size_t len, size_t extra) +{ + if (extra) + ((char *)(u + 1))[len] = '\0'; +} + +static void set_data_record(void *mem, struct tdb_context *tdb, + struct tle_used *used) +{ + struct tdb_used_record *u = mem; + + set_header(tdb, u, TDB_USED_MAGIC, used->key.dsize, used->data.dsize, + used->key.dsize + used->data.dsize + used->extra, + tdb_hash(tdb, used->key.dptr, used->key.dsize)); + memcpy(u + 1, used->key.dptr, used->key.dsize); + memcpy((char *)(u + 1) + used->key.dsize, + used->data.dptr, used->data.dsize); + add_zero_pad(u, used->key.dsize + used->data.dsize, used->extra); +} + +static void set_hashtable(void *mem, struct tdb_context *tdb, + struct tle_hashtable *htable) +{ + struct tdb_used_record *u = mem; + tdb_len_t len = sizeof(tdb_off_t) << TDB_SUBLEVEL_HASH_BITS; + + set_header(tdb, u, TDB_HTABLE_MAGIC, 0, len, len + htable->extra, 0); + memset(u + 1, 0, len); + add_zero_pad(u, len, htable->extra); +} + +static void set_capability(void *mem, struct tdb_context *tdb, + struct tle_capability *cap, struct tdb_header *hdr, + tdb_off_t last_cap) +{ + struct tdb_capability *c = mem; + tdb_len_t len = sizeof(*c) - sizeof(struct tdb_used_record) + cap->extra; + + c->type = cap->type; + c->next = 0; + set_header(tdb, &c->hdr, TDB_CAP_MAGIC, 0, len, len, 0); + + /* Append to capability list. */ + if (!last_cap) { + hdr->capabilities = cap->base.off; + } else { + c = (struct tdb_capability *)((char *)hdr + last_cap); + c->next = cap->base.off; + } +} + +static void set_freetable(void *mem, struct tdb_context *tdb, + struct tle_freetable *freetable, struct tdb_header *hdr, + tdb_off_t last_ftable) +{ + struct tdb_freetable *ftable = mem; + memset(ftable, 0, sizeof(*ftable)); + set_header(tdb, &ftable->hdr, TDB_FTABLE_MAGIC, 0, + sizeof(*ftable) - sizeof(ftable->hdr), + sizeof(*ftable) - sizeof(ftable->hdr), 0); + + if (last_ftable) { + ftable = (struct tdb_freetable *)((char *)hdr + last_ftable); + ftable->next = freetable->base.off; + } else { + hdr->free_table = freetable->base.off; + } +} + +static void add_to_freetable(struct tdb_context *tdb, + tdb_off_t eoff, + tdb_off_t elen, + unsigned ftable, + struct tle_freetable *freetable) +{ + tdb->tdb2.ftable_off = freetable->base.off; + tdb->tdb2.ftable = ftable; + add_free_record(tdb, eoff, sizeof(struct tdb_used_record) + elen, + TDB_LOCK_WAIT, false); +} + +static tdb_off_t hbucket_off(tdb_off_t group_start, unsigned ingroup) +{ + return group_start + + (ingroup % (1 << TDB_HASH_GROUP_BITS)) * sizeof(tdb_off_t); +} + +/* Get bits from a value. */ +static uint32_t bits(uint64_t val, unsigned start, unsigned num) +{ + assert(num <= 32); + return (val >> start) & ((1U << num) - 1); +} + +/* We take bits from the top: that way we can lock whole sections of the hash + * by using lock ranges. */ +static uint32_t use_bits(uint64_t h, unsigned num, unsigned *used) +{ + *used += num; + return bits(h, 64 - *used, num); +} + +static tdb_off_t encode_offset(tdb_off_t new_off, unsigned bucket, + uint64_t h) +{ + return bucket + | new_off + | ((uint64_t)bits(h, 64 - TDB_OFF_UPPER_STEAL_EXTRA, + TDB_OFF_UPPER_STEAL_EXTRA) + << TDB_OFF_HASH_EXTRA_BIT); +} + +/* FIXME: Our hash table handling here is primitive: we don't expand! */ +static void add_to_hashtable(struct tdb_context *tdb, + tdb_off_t eoff, + struct tdb_data key) +{ + uint64_t h = tdb_hash(tdb, key.dptr, key.dsize); + tdb_off_t b_off, group_start; + unsigned i, group, in_group; + unsigned used = 0; + + group = use_bits(h, TDB_TOPLEVEL_HASH_BITS-TDB_HASH_GROUP_BITS, &used); + in_group = use_bits(h, TDB_HASH_GROUP_BITS, &used); + + group_start = offsetof(struct tdb_header, hashtable) + + group * (sizeof(tdb_off_t) << TDB_HASH_GROUP_BITS); + + for (i = 0; i < (1 << TDB_HASH_GROUP_BITS); i++) { + unsigned bucket = (in_group + i) % (1 << TDB_HASH_GROUP_BITS); + + b_off = hbucket_off(group_start, bucket); + if (tdb_read_off(tdb, b_off) == 0) { + tdb_write_off(tdb, b_off, + encode_offset(eoff, in_group, h)); + return; + } + } + abort(); +} + +static struct tle_freetable *find_ftable(struct tdb_layout *layout, unsigned num) +{ + unsigned i; + + for (i = 0; i < layout->num_elems; i++) { + if (layout->elem[i].base.type != FREETABLE) + continue; + if (num == 0) + return &layout->elem[i].ftable; + num--; + } + abort(); +} + +/* FIXME: Support TDB_CONVERT */ +struct tdb_context *tdb_layout_get(struct tdb_layout *layout, + void (*freefn)(void *), + union tdb_attribute *attr) +{ + unsigned int i; + tdb_off_t off, len, last_ftable, last_cap; + char *mem; + struct tdb_context *tdb; + + off = sizeof(struct tdb_header); + + /* First pass of layout: calc lengths */ + for (i = 0; i < layout->num_elems; i++) { + union tdb_layout_elem *e = &layout->elem[i]; + e->base.off = off; + switch (e->base.type) { + case FREETABLE: + len = freetable_len(&e->ftable); + break; + case FREE: + len = free_record_len(e->free.len); + break; + case DATA: + len = data_record_len(&e->used); + break; + case HASHTABLE: + len = hashtable_len(&e->hashtable); + break; + case CAPABILITY: + len = capability_len(&e->capability); + break; + default: + abort(); + } + off += len; + } + + mem = malloc(off); + /* Fill with some weird pattern. */ + memset(mem, 0x99, off); + /* Now populate our header, cribbing from a real TDB header. */ + tdb = tdb_open(NULL, TDB_INTERNAL, O_RDWR, 0, attr); + memcpy(mem, tdb->file->map_ptr, sizeof(struct tdb_header)); + + /* Mug the tdb we have to make it use this. */ + freefn(tdb->file->map_ptr); + tdb->file->map_ptr = mem; + tdb->file->map_size = off; + + last_ftable = 0; + last_cap = 0; + for (i = 0; i < layout->num_elems; i++) { + union tdb_layout_elem *e = &layout->elem[i]; + switch (e->base.type) { + case FREETABLE: + set_freetable(mem + e->base.off, tdb, &e->ftable, + (struct tdb_header *)mem, last_ftable); + last_ftable = e->base.off; + break; + case FREE: + set_free_record(mem + e->base.off, e->free.len); + break; + case DATA: + set_data_record(mem + e->base.off, tdb, &e->used); + break; + case HASHTABLE: + set_hashtable(mem + e->base.off, tdb, &e->hashtable); + break; + case CAPABILITY: + set_capability(mem + e->base.off, tdb, &e->capability, + (struct tdb_header *)mem, last_cap); + last_cap = e->base.off; + break; + } + } + /* Must have a free table! */ + assert(last_ftable); + + /* Now fill the free and hash tables. */ + for (i = 0; i < layout->num_elems; i++) { + union tdb_layout_elem *e = &layout->elem[i]; + switch (e->base.type) { + case FREE: + add_to_freetable(tdb, e->base.off, e->free.len, + e->free.ftable_num, + find_ftable(layout, e->free.ftable_num)); + break; + case DATA: + add_to_hashtable(tdb, e->base.off, e->used.key); + break; + default: + break; + } + } + + tdb->tdb2.ftable_off = find_ftable(layout, 0)->base.off; + return tdb; +} + +void tdb_layout_write(struct tdb_layout *layout, void (*freefn)(void *), + union tdb_attribute *attr, const char *filename) +{ + struct tdb_context *tdb = tdb_layout_get(layout, freefn, attr); + int fd; + + fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0600); + if (fd < 0) + err(1, "opening %s for writing", filename); + if (write(fd, tdb->file->map_ptr, tdb->file->map_size) + != tdb->file->map_size) + err(1, "writing %s", filename); + close(fd); + tdb_close(tdb); +} + +void tdb_layout_free(struct tdb_layout *layout) +{ + unsigned int i; + + for (i = 0; i < layout->num_elems; i++) { + if (layout->elem[i].base.type == DATA) { + free(layout->elem[i].used.key.dptr); + free(layout->elem[i].used.data.dptr); + } + } + free(layout->elem); + free(layout); +} diff --git a/lib/tdb2/test/layout.c b/lib/tdb2/test/layout.c deleted file mode 100644 index 0bce5dd89e..0000000000 --- a/lib/tdb2/test/layout.c +++ /dev/null @@ -1,402 +0,0 @@ -/* TDB tools to create various canned database layouts. */ -#include "layout.h" -#include -#include -#include -#include -#include "logging.h" - -struct tdb_layout *new_tdb_layout(void) -{ - struct tdb_layout *layout = malloc(sizeof(*layout)); - layout->num_elems = 0; - layout->elem = NULL; - return layout; -} - -static void add(struct tdb_layout *layout, union tdb_layout_elem elem) -{ - layout->elem = realloc(layout->elem, - sizeof(layout->elem[0]) - * (layout->num_elems+1)); - layout->elem[layout->num_elems++] = elem; -} - -void tdb_layout_add_freetable(struct tdb_layout *layout) -{ - union tdb_layout_elem elem; - elem.base.type = FREETABLE; - add(layout, elem); -} - -void tdb_layout_add_free(struct tdb_layout *layout, tdb_len_t len, - unsigned ftable) -{ - union tdb_layout_elem elem; - elem.base.type = FREE; - elem.free.len = len; - elem.free.ftable_num = ftable; - add(layout, elem); -} - -void tdb_layout_add_capability(struct tdb_layout *layout, - uint64_t type, - bool write_breaks, - bool check_breaks, - bool open_breaks, - tdb_len_t extra) -{ - union tdb_layout_elem elem; - elem.base.type = CAPABILITY; - elem.capability.type = type; - if (write_breaks) - elem.capability.type |= TDB_CAP_NOWRITE; - if (open_breaks) - elem.capability.type |= TDB_CAP_NOOPEN; - if (check_breaks) - elem.capability.type |= TDB_CAP_NOCHECK; - elem.capability.extra = extra; - add(layout, elem); -} - -static struct tdb_data dup_key(struct tdb_data key) -{ - struct tdb_data ret; - ret.dsize = key.dsize; - ret.dptr = malloc(ret.dsize); - memcpy(ret.dptr, key.dptr, ret.dsize); - return ret; -} - -void tdb_layout_add_used(struct tdb_layout *layout, - TDB_DATA key, TDB_DATA data, - tdb_len_t extra) -{ - union tdb_layout_elem elem; - elem.base.type = DATA; - elem.used.key = dup_key(key); - elem.used.data = dup_key(data); - elem.used.extra = extra; - add(layout, elem); -} - -static tdb_len_t free_record_len(tdb_len_t len) -{ - return sizeof(struct tdb_used_record) + len; -} - -static tdb_len_t data_record_len(struct tle_used *used) -{ - tdb_len_t len; - len = sizeof(struct tdb_used_record) - + used->key.dsize + used->data.dsize + used->extra; - assert(len >= sizeof(struct tdb_free_record)); - return len; -} - -static tdb_len_t hashtable_len(struct tle_hashtable *htable) -{ - return sizeof(struct tdb_used_record) - + (sizeof(tdb_off_t) << TDB_SUBLEVEL_HASH_BITS) - + htable->extra; -} - -static tdb_len_t capability_len(struct tle_capability *cap) -{ - return sizeof(struct tdb_capability) + cap->extra; -} - -static tdb_len_t freetable_len(struct tle_freetable *ftable) -{ - return sizeof(struct tdb_freetable); -} - -static void set_free_record(void *mem, tdb_len_t len) -{ - /* We do all the work in add_to_freetable */ -} - -static void add_zero_pad(struct tdb_used_record *u, size_t len, size_t extra) -{ - if (extra) - ((char *)(u + 1))[len] = '\0'; -} - -static void set_data_record(void *mem, struct tdb_context *tdb, - struct tle_used *used) -{ - struct tdb_used_record *u = mem; - - set_header(tdb, u, TDB_USED_MAGIC, used->key.dsize, used->data.dsize, - used->key.dsize + used->data.dsize + used->extra, - tdb_hash(tdb, used->key.dptr, used->key.dsize)); - memcpy(u + 1, used->key.dptr, used->key.dsize); - memcpy((char *)(u + 1) + used->key.dsize, - used->data.dptr, used->data.dsize); - add_zero_pad(u, used->key.dsize + used->data.dsize, used->extra); -} - -static void set_hashtable(void *mem, struct tdb_context *tdb, - struct tle_hashtable *htable) -{ - struct tdb_used_record *u = mem; - tdb_len_t len = sizeof(tdb_off_t) << TDB_SUBLEVEL_HASH_BITS; - - set_header(tdb, u, TDB_HTABLE_MAGIC, 0, len, len + htable->extra, 0); - memset(u + 1, 0, len); - add_zero_pad(u, len, htable->extra); -} - -static void set_capability(void *mem, struct tdb_context *tdb, - struct tle_capability *cap, struct tdb_header *hdr, - tdb_off_t last_cap) -{ - struct tdb_capability *c = mem; - tdb_len_t len = sizeof(*c) - sizeof(struct tdb_used_record) + cap->extra; - - c->type = cap->type; - c->next = 0; - set_header(tdb, &c->hdr, TDB_CAP_MAGIC, 0, len, len, 0); - - /* Append to capability list. */ - if (!last_cap) { - hdr->capabilities = cap->base.off; - } else { - c = (struct tdb_capability *)((char *)hdr + last_cap); - c->next = cap->base.off; - } -} - -static void set_freetable(void *mem, struct tdb_context *tdb, - struct tle_freetable *freetable, struct tdb_header *hdr, - tdb_off_t last_ftable) -{ - struct tdb_freetable *ftable = mem; - memset(ftable, 0, sizeof(*ftable)); - set_header(tdb, &ftable->hdr, TDB_FTABLE_MAGIC, 0, - sizeof(*ftable) - sizeof(ftable->hdr), - sizeof(*ftable) - sizeof(ftable->hdr), 0); - - if (last_ftable) { - ftable = (struct tdb_freetable *)((char *)hdr + last_ftable); - ftable->next = freetable->base.off; - } else { - hdr->free_table = freetable->base.off; - } -} - -static void add_to_freetable(struct tdb_context *tdb, - tdb_off_t eoff, - tdb_off_t elen, - unsigned ftable, - struct tle_freetable *freetable) -{ - tdb->tdb2.ftable_off = freetable->base.off; - tdb->tdb2.ftable = ftable; - add_free_record(tdb, eoff, sizeof(struct tdb_used_record) + elen, - TDB_LOCK_WAIT, false); -} - -static tdb_off_t hbucket_off(tdb_off_t group_start, unsigned ingroup) -{ - return group_start - + (ingroup % (1 << TDB_HASH_GROUP_BITS)) * sizeof(tdb_off_t); -} - -/* Get bits from a value. */ -static uint32_t bits(uint64_t val, unsigned start, unsigned num) -{ - assert(num <= 32); - return (val >> start) & ((1U << num) - 1); -} - -/* We take bits from the top: that way we can lock whole sections of the hash - * by using lock ranges. */ -static uint32_t use_bits(uint64_t h, unsigned num, unsigned *used) -{ - *used += num; - return bits(h, 64 - *used, num); -} - -static tdb_off_t encode_offset(tdb_off_t new_off, unsigned bucket, - uint64_t h) -{ - return bucket - | new_off - | ((uint64_t)bits(h, 64 - TDB_OFF_UPPER_STEAL_EXTRA, - TDB_OFF_UPPER_STEAL_EXTRA) - << TDB_OFF_HASH_EXTRA_BIT); -} - -/* FIXME: Our hash table handling here is primitive: we don't expand! */ -static void add_to_hashtable(struct tdb_context *tdb, - tdb_off_t eoff, - struct tdb_data key) -{ - uint64_t h = tdb_hash(tdb, key.dptr, key.dsize); - tdb_off_t b_off, group_start; - unsigned i, group, in_group; - unsigned used = 0; - - group = use_bits(h, TDB_TOPLEVEL_HASH_BITS-TDB_HASH_GROUP_BITS, &used); - in_group = use_bits(h, TDB_HASH_GROUP_BITS, &used); - - group_start = offsetof(struct tdb_header, hashtable) - + group * (sizeof(tdb_off_t) << TDB_HASH_GROUP_BITS); - - for (i = 0; i < (1 << TDB_HASH_GROUP_BITS); i++) { - unsigned bucket = (in_group + i) % (1 << TDB_HASH_GROUP_BITS); - - b_off = hbucket_off(group_start, bucket); - if (tdb_read_off(tdb, b_off) == 0) { - tdb_write_off(tdb, b_off, - encode_offset(eoff, in_group, h)); - return; - } - } - abort(); -} - -static struct tle_freetable *find_ftable(struct tdb_layout *layout, unsigned num) -{ - unsigned i; - - for (i = 0; i < layout->num_elems; i++) { - if (layout->elem[i].base.type != FREETABLE) - continue; - if (num == 0) - return &layout->elem[i].ftable; - num--; - } - abort(); -} - -/* FIXME: Support TDB_CONVERT */ -struct tdb_context *tdb_layout_get(struct tdb_layout *layout, - void (*freefn)(void *), - union tdb_attribute *attr) -{ - unsigned int i; - tdb_off_t off, len, last_ftable, last_cap; - char *mem; - struct tdb_context *tdb; - - off = sizeof(struct tdb_header); - - /* First pass of layout: calc lengths */ - for (i = 0; i < layout->num_elems; i++) { - union tdb_layout_elem *e = &layout->elem[i]; - e->base.off = off; - switch (e->base.type) { - case FREETABLE: - len = freetable_len(&e->ftable); - break; - case FREE: - len = free_record_len(e->free.len); - break; - case DATA: - len = data_record_len(&e->used); - break; - case HASHTABLE: - len = hashtable_len(&e->hashtable); - break; - case CAPABILITY: - len = capability_len(&e->capability); - break; - default: - abort(); - } - off += len; - } - - mem = malloc(off); - /* Fill with some weird pattern. */ - memset(mem, 0x99, off); - /* Now populate our header, cribbing from a real TDB header. */ - tdb = tdb_open(NULL, TDB_INTERNAL, O_RDWR, 0, attr); - memcpy(mem, tdb->file->map_ptr, sizeof(struct tdb_header)); - - /* Mug the tdb we have to make it use this. */ - freefn(tdb->file->map_ptr); - tdb->file->map_ptr = mem; - tdb->file->map_size = off; - - last_ftable = 0; - last_cap = 0; - for (i = 0; i < layout->num_elems; i++) { - union tdb_layout_elem *e = &layout->elem[i]; - switch (e->base.type) { - case FREETABLE: - set_freetable(mem + e->base.off, tdb, &e->ftable, - (struct tdb_header *)mem, last_ftable); - last_ftable = e->base.off; - break; - case FREE: - set_free_record(mem + e->base.off, e->free.len); - break; - case DATA: - set_data_record(mem + e->base.off, tdb, &e->used); - break; - case HASHTABLE: - set_hashtable(mem + e->base.off, tdb, &e->hashtable); - break; - case CAPABILITY: - set_capability(mem + e->base.off, tdb, &e->capability, - (struct tdb_header *)mem, last_cap); - last_cap = e->base.off; - break; - } - } - /* Must have a free table! */ - assert(last_ftable); - - /* Now fill the free and hash tables. */ - for (i = 0; i < layout->num_elems; i++) { - union tdb_layout_elem *e = &layout->elem[i]; - switch (e->base.type) { - case FREE: - add_to_freetable(tdb, e->base.off, e->free.len, - e->free.ftable_num, - find_ftable(layout, e->free.ftable_num)); - break; - case DATA: - add_to_hashtable(tdb, e->base.off, e->used.key); - break; - default: - break; - } - } - - tdb->tdb2.ftable_off = find_ftable(layout, 0)->base.off; - return tdb; -} - -void tdb_layout_write(struct tdb_layout *layout, void (*freefn)(void *), - union tdb_attribute *attr, const char *filename) -{ - struct tdb_context *tdb = tdb_layout_get(layout, freefn, attr); - int fd; - - fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0600); - if (fd < 0) - err(1, "opening %s for writing", filename); - if (write(fd, tdb->file->map_ptr, tdb->file->map_size) - != tdb->file->map_size) - err(1, "writing %s", filename); - close(fd); - tdb_close(tdb); -} - -void tdb_layout_free(struct tdb_layout *layout) -{ - unsigned int i; - - for (i = 0; i < layout->num_elems; i++) { - if (layout->elem[i].base.type == DATA) { - free(layout->elem[i].used.key.dptr); - free(layout->elem[i].used.data.dptr); - } - } - free(layout->elem); - free(layout); -} diff --git a/lib/tdb2/test/layout.h b/lib/tdb2/test/layout.h index 9a71484601..3aadf20ee2 100644 --- a/lib/tdb2/test/layout.h +++ b/lib/tdb2/test/layout.h @@ -1,6 +1,6 @@ #ifndef TDB2_TEST_LAYOUT_H #define TDB2_TEST_LAYOUT_H -#include +#include "private.h" struct tdb_layout *new_tdb_layout(void); void tdb_layout_add_freetable(struct tdb_layout *layout); diff --git a/lib/tdb2/test/lock-tracking.c b/lib/tdb2/test/lock-tracking.c index e253db9f71..4a61f9c312 100644 --- a/lib/tdb2/test/lock-tracking.c +++ b/lib/tdb2/test/lock-tracking.c @@ -1,10 +1,10 @@ /* We save the locks so we can reaquire them. */ -#include +#include "tdb1_private.h" /* For TDB_HASH_LOCK_START, TDB1_FREELIST_TOP, etc. */ #include #include #include #include -#include +#include "tap-interface.h" #include "lock-tracking.h" struct lock { diff --git a/lib/tdb2/test/logging.c b/lib/tdb2/test/logging.c index 6927592b8a..86fc152bab 100644 --- a/lib/tdb2/test/logging.c +++ b/lib/tdb2/test/logging.c @@ -1,6 +1,6 @@ #include #include -#include +#include "tap-interface.h" #include "logging.h" unsigned tap_log_messages; diff --git a/lib/tdb2/test/logging.h b/lib/tdb2/test/logging.h index 2dfea145c3..5f517dc592 100644 --- a/lib/tdb2/test/logging.h +++ b/lib/tdb2/test/logging.h @@ -1,6 +1,6 @@ #ifndef TDB2_TEST_LOGGING_H #define TDB2_TEST_LOGGING_H -#include +#include "tdb2.h" #include #include diff --git a/lib/tdb2/test/run-001-encode.c b/lib/tdb2/test/run-001-encode.c index 67616fcd9f..9657eb79d0 100644 --- a/lib/tdb2/test/run-001-encode.c +++ b/lib/tdb2/test/run-001-encode.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include "logging.h" int main(int argc, char *argv[]) diff --git a/lib/tdb2/test/run-001-fls.c b/lib/tdb2/test/run-001-fls.c index 4449f69d85..792adbf655 100644 --- a/lib/tdb2/test/run-001-fls.c +++ b/lib/tdb2/test/run-001-fls.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" static unsigned int dumb_fls(uint64_t num) { diff --git a/lib/tdb2/test/run-01-new_database.c b/lib/tdb2/test/run-01-new_database.c index e08e3201e6..2876868842 100644 --- a/lib/tdb2/test/run-01-new_database.c +++ b/lib/tdb2/test/run-01-new_database.c @@ -1,6 +1,6 @@ #include #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include "logging.h" #include "failtest_helper.h" diff --git a/lib/tdb2/test/run-02-expand.c b/lib/tdb2/test/run-02-expand.c index dacf5f2194..fd1ae4be34 100644 --- a/lib/tdb2/test/run-02-expand.c +++ b/lib/tdb2/test/run-02-expand.c @@ -1,6 +1,6 @@ #include #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include "logging.h" #include "failtest_helper.h" diff --git a/lib/tdb2/test/run-03-coalesce.c b/lib/tdb2/test/run-03-coalesce.c index 99f94fe16d..ad39719bcb 100644 --- a/lib/tdb2/test/run-03-coalesce.c +++ b/lib/tdb2/test/run-03-coalesce.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include "logging.h" #include "layout.h" diff --git a/lib/tdb2/test/run-04-basichash.c b/lib/tdb2/test/run-04-basichash.c index 3bf66c720f..9ab45ad978 100644 --- a/lib/tdb2/test/run-04-basichash.c +++ b/lib/tdb2/test/run-04-basichash.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include "logging.h" /* We rig the hash so adjacent-numbered records always clash. */ diff --git a/lib/tdb2/test/run-05-readonly-open.c b/lib/tdb2/test/run-05-readonly-open.c index 80eb56759b..4827b425da 100644 --- a/lib/tdb2/test/run-05-readonly-open.c +++ b/lib/tdb2/test/run-05-readonly-open.c @@ -1,6 +1,6 @@ #include #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include "logging.h" #include "failtest_helper.h" diff --git a/lib/tdb2/test/run-10-simple-store.c b/lib/tdb2/test/run-10-simple-store.c index b195d80ab1..3fba81d22d 100644 --- a/lib/tdb2/test/run-10-simple-store.c +++ b/lib/tdb2/test/run-10-simple-store.c @@ -1,6 +1,6 @@ #include #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include "logging.h" #include "failtest_helper.h" diff --git a/lib/tdb2/test/run-11-simple-fetch.c b/lib/tdb2/test/run-11-simple-fetch.c index fd77332016..8cd63dedcd 100644 --- a/lib/tdb2/test/run-11-simple-fetch.c +++ b/lib/tdb2/test/run-11-simple-fetch.c @@ -1,6 +1,6 @@ #include #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include "logging.h" #include "failtest_helper.h" diff --git a/lib/tdb2/test/run-12-check.c b/lib/tdb2/test/run-12-check.c index b55bfe7d46..4173fb05c8 100644 --- a/lib/tdb2/test/run-12-check.c +++ b/lib/tdb2/test/run-12-check.c @@ -1,7 +1,7 @@ -#include +#include "private.h" #include #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include "logging.h" #include "failtest_helper.h" diff --git a/lib/tdb2/test/run-15-append.c b/lib/tdb2/test/run-15-append.c index 46a77ff976..53fe66bcf7 100644 --- a/lib/tdb2/test/run-15-append.c +++ b/lib/tdb2/test/run-15-append.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include "logging.h" diff --git a/lib/tdb2/test/run-20-growhash.c b/lib/tdb2/test/run-20-growhash.c index 65cead0358..2f634a27c0 100644 --- a/lib/tdb2/test/run-20-growhash.c +++ b/lib/tdb2/test/run-20-growhash.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include "logging.h" static uint64_t myhash(const void *key, size_t len, uint64_t seed, void *priv) diff --git a/lib/tdb2/test/run-25-hashoverload.c b/lib/tdb2/test/run-25-hashoverload.c index 0e1430265c..850321554a 100644 --- a/lib/tdb2/test/run-25-hashoverload.c +++ b/lib/tdb2/test/run-25-hashoverload.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include "logging.h" static uint64_t badhash(const void *key, size_t len, uint64_t seed, void *priv) diff --git a/lib/tdb2/test/run-30-exhaust-before-expand.c b/lib/tdb2/test/run-30-exhaust-before-expand.c index db391e7e59..12449a1fe6 100644 --- a/lib/tdb2/test/run-30-exhaust-before-expand.c +++ b/lib/tdb2/test/run-30-exhaust-before-expand.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include "logging.h" diff --git a/lib/tdb2/test/run-35-convert.c b/lib/tdb2/test/run-35-convert.c index b7b1e6e562..0aee0ca625 100644 --- a/lib/tdb2/test/run-35-convert.c +++ b/lib/tdb2/test/run-35-convert.c @@ -1,7 +1,7 @@ -#include +#include "private.h" #include #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include "logging.h" #include "failtest_helper.h" diff --git a/lib/tdb2/test/run-50-multiple-freelists.c b/lib/tdb2/test/run-50-multiple-freelists.c index 44fee941cf..617b1e4dd4 100644 --- a/lib/tdb2/test/run-50-multiple-freelists.c +++ b/lib/tdb2/test/run-50-multiple-freelists.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include "logging.h" #include "layout.h" diff --git a/lib/tdb2/test/run-56-open-during-transaction.c b/lib/tdb2/test/run-56-open-during-transaction.c index 9262c0528e..d2115f63cb 100644 --- a/lib/tdb2/test/run-56-open-during-transaction.c +++ b/lib/tdb2/test/run-56-open-during-transaction.c @@ -1,4 +1,4 @@ -#include +#include "private.h" #include #include "lock-tracking.h" @@ -12,7 +12,7 @@ static int ftruncate_check(int fd, off_t length); #define ftruncate ftruncate_check #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/run-57-die-during-transaction.c b/lib/tdb2/test/run-57-die-during-transaction.c index 42102ae732..9790e92dfd 100644 --- a/lib/tdb2/test/run-57-die-during-transaction.c +++ b/lib/tdb2/test/run-57-die-during-transaction.c @@ -1,7 +1,7 @@ -#include +#include "private.h" #include #include "lock-tracking.h" -#include +#include "tap-interface.h" #include #include static ssize_t pwrite_check(int fd, const void *buf, size_t count, off_t offset); diff --git a/lib/tdb2/test/run-64-bit-tdb.c b/lib/tdb2/test/run-64-bit-tdb.c index 1201bba619..ef6e243a05 100644 --- a/lib/tdb2/test/run-64-bit-tdb.c +++ b/lib/tdb2/test/run-64-bit-tdb.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include "logging.h" int main(int argc, char *argv[]) diff --git a/lib/tdb2/test/run-90-get-set-attributes.c b/lib/tdb2/test/run-90-get-set-attributes.c index 4cbbda03c7..b6a9075b6d 100644 --- a/lib/tdb2/test/run-90-get-set-attributes.c +++ b/lib/tdb2/test/run-90-get-set-attributes.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include "logging.h" static int mylock(int fd, int rw, off_t off, off_t len, bool waitflag, diff --git a/lib/tdb2/test/run-capabilities.c b/lib/tdb2/test/run-capabilities.c index 4b25f9c5c9..e59f5009ab 100644 --- a/lib/tdb2/test/run-capabilities.c +++ b/lib/tdb2/test/run-capabilities.c @@ -1,6 +1,6 @@ #include #include "tdb2-source.h" -#include +#include "tap-interface.h" #include "logging.h" #include "layout.h" #include "failtest_helper.h" diff --git a/lib/tdb2/test/run-expand-in-transaction.c b/lib/tdb2/test/run-expand-in-transaction.c index 0fa2a57f4d..2e9919c0f1 100644 --- a/lib/tdb2/test/run-expand-in-transaction.c +++ b/lib/tdb2/test/run-expand-in-transaction.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include "logging.h" int main(int argc, char *argv[]) diff --git a/lib/tdb2/test/run-features.c b/lib/tdb2/test/run-features.c index a304833ce3..f552fcfb58 100644 --- a/lib/tdb2/test/run-features.c +++ b/lib/tdb2/test/run-features.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include "logging.h" int main(int argc, char *argv[]) diff --git a/lib/tdb2/test/run-lockall.c b/lib/tdb2/test/run-lockall.c index 7cd9b849ef..c3e03dea7d 100644 --- a/lib/tdb2/test/run-lockall.c +++ b/lib/tdb2/test/run-lockall.c @@ -1,11 +1,11 @@ -#include +#include "private.h" #include #include "lock-tracking.h" #define fcntl fcntl_with_lockcheck #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/run-remap-in-read_traverse.c b/lib/tdb2/test/run-remap-in-read_traverse.c index b70a841aaf..16a1baab46 100644 --- a/lib/tdb2/test/run-remap-in-read_traverse.c +++ b/lib/tdb2/test/run-remap-in-read_traverse.c @@ -1,7 +1,7 @@ #include "tdb2-source.h" /* We had a bug where we marked the tdb read-only for a tdb_traverse_read. * If we then expanded the tdb, we would remap read-only, and later SEGV. */ -#include +#include "tap-interface.h" #include "external-agent.h" #include "logging.h" diff --git a/lib/tdb2/test/run-seed.c b/lib/tdb2/test/run-seed.c index 129666299c..9c90833001 100644 --- a/lib/tdb2/test/run-seed.c +++ b/lib/tdb2/test/run-seed.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include "logging.h" static int log_count = 0; diff --git a/lib/tdb2/test/run-tdb1-3G-file.c b/lib/tdb2/test/run-tdb1-3G-file.c index f3403dd1b8..2a5e48b105 100644 --- a/lib/tdb2/test/run-tdb1-3G-file.c +++ b/lib/tdb2/test/run-tdb1-3G-file.c @@ -1,7 +1,7 @@ /* We need this otherwise fcntl locking fails. */ #define _FILE_OFFSET_BITS 64 #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include #include "logging.h" diff --git a/lib/tdb2/test/run-tdb1-bad-tdb-header.c b/lib/tdb2/test/run-tdb1-bad-tdb-header.c index c1d76740cc..cedf6b6057 100644 --- a/lib/tdb2/test/run-tdb1-bad-tdb-header.c +++ b/lib/tdb2/test/run-tdb1-bad-tdb-header.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include #include "logging.h" diff --git a/lib/tdb2/test/run-tdb1-check.c b/lib/tdb2/test/run-tdb1-check.c index e939d04036..b8f0889b35 100644 --- a/lib/tdb2/test/run-tdb1-check.c +++ b/lib/tdb2/test/run-tdb1-check.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include #include "logging.h" diff --git a/lib/tdb2/test/run-tdb1-corrupt.c b/lib/tdb2/test/run-tdb1-corrupt.c index 35bc4c3f22..6403acb1ea 100644 --- a/lib/tdb2/test/run-tdb1-corrupt.c +++ b/lib/tdb2/test/run-tdb1-corrupt.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include #include "logging.h" diff --git a/lib/tdb2/test/run-tdb1-endian.c b/lib/tdb2/test/run-tdb1-endian.c index 3b91d45bdf..a31908009c 100644 --- a/lib/tdb2/test/run-tdb1-endian.c +++ b/lib/tdb2/test/run-tdb1-endian.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include #include "logging.h" diff --git a/lib/tdb2/test/run-tdb1-hashsize.c b/lib/tdb2/test/run-tdb1-hashsize.c index 8a78196c82..e6a46775f1 100644 --- a/lib/tdb2/test/run-tdb1-hashsize.c +++ b/lib/tdb2/test/run-tdb1-hashsize.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include #include "logging.h" diff --git a/lib/tdb2/test/run-tdb1-incompatible.c b/lib/tdb2/test/run-tdb1-incompatible.c index 46ab566920..84acf1bccd 100644 --- a/lib/tdb2/test/run-tdb1-incompatible.c +++ b/lib/tdb2/test/run-tdb1-incompatible.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include diff --git a/lib/tdb2/test/run-tdb1-nested-transactions.c b/lib/tdb2/test/run-tdb1-nested-transactions.c index 149e5318a0..23ab740d9f 100644 --- a/lib/tdb2/test/run-tdb1-nested-transactions.c +++ b/lib/tdb2/test/run-tdb1-nested-transactions.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include #include diff --git a/lib/tdb2/test/run-tdb1-nested-traverse.c b/lib/tdb2/test/run-tdb1-nested-traverse.c index cf5aa4a2f4..8fa36bd88a 100644 --- a/lib/tdb2/test/run-tdb1-nested-traverse.c +++ b/lib/tdb2/test/run-tdb1-nested-traverse.c @@ -1,7 +1,7 @@ #include "tdb1-lock-tracking.h" #define fcntl fcntl_with_lockcheck1 #include "tdb2-source.h" -#include +#include "tap-interface.h" #undef fcntl #include #include diff --git a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c index b2b7a781db..7392d14875 100644 --- a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c +++ b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c @@ -1,11 +1,11 @@ -#include +#include "private.h" #include #include "tdb1-lock-tracking.h" #define fcntl fcntl_with_lockcheck1 #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include #include "logging.h" diff --git a/lib/tdb2/test/run-tdb1-oldhash.c b/lib/tdb2/test/run-tdb1-oldhash.c index f9cffa25a6..2b7f6adde8 100644 --- a/lib/tdb2/test/run-tdb1-oldhash.c +++ b/lib/tdb2/test/run-tdb1-oldhash.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include #include "logging.h" diff --git a/lib/tdb2/test/run-tdb1-readonly-check.c b/lib/tdb2/test/run-tdb1-readonly-check.c index f42a8f5e27..c15c06ab92 100644 --- a/lib/tdb2/test/run-tdb1-readonly-check.c +++ b/lib/tdb2/test/run-tdb1-readonly-check.c @@ -1,7 +1,7 @@ /* 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 +#include "tap-interface.h" #include #include #include "logging.h" diff --git a/lib/tdb2/test/run-tdb1-rwlock-check.c b/lib/tdb2/test/run-tdb1-rwlock-check.c index 44a2eeb8c7..a56f3ba356 100644 --- a/lib/tdb2/test/run-tdb1-rwlock-check.c +++ b/lib/tdb2/test/run-tdb1-rwlock-check.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include diff --git a/lib/tdb2/test/run-tdb1-seqnum-wrap.c b/lib/tdb2/test/run-tdb1-seqnum-wrap.c index c3eb278e1a..aa5398f242 100644 --- a/lib/tdb2/test/run-tdb1-seqnum-wrap.c +++ b/lib/tdb2/test/run-tdb1-seqnum-wrap.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include #include "logging.h" diff --git a/lib/tdb2/test/run-tdb1-summary.c b/lib/tdb2/test/run-tdb1-summary.c index 5107b8e436..34fb381b5b 100644 --- a/lib/tdb2/test/run-tdb1-summary.c +++ b/lib/tdb2/test/run-tdb1-summary.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include diff --git a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c index 691aaf9444..7732d54cf7 100644 --- a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c +++ b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c @@ -2,7 +2,7 @@ #include "tdb1-lock-tracking.h" #define fcntl fcntl_with_lockcheck1 #include "tdb2-source.h" -#include +#include "tap-interface.h" #undef fcntl_with_lockcheck #include #include diff --git a/lib/tdb2/test/run-tdb1-wronghash-fail.c b/lib/tdb2/test/run-tdb1-wronghash-fail.c index 63c1bdf1e4..19f926c787 100644 --- a/lib/tdb2/test/run-tdb1-wronghash-fail.c +++ b/lib/tdb2/test/run-tdb1-wronghash-fail.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include diff --git a/lib/tdb2/test/run-tdb1-zero-append.c b/lib/tdb2/test/run-tdb1-zero-append.c index fdc9cdce35..16a097ce30 100644 --- a/lib/tdb2/test/run-tdb1-zero-append.c +++ b/lib/tdb2/test/run-tdb1-zero-append.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include #include "logging.h" diff --git a/lib/tdb2/test/run-tdb1.c b/lib/tdb2/test/run-tdb1.c index dca6473b1c..eebdcdb212 100644 --- a/lib/tdb2/test/run-tdb1.c +++ b/lib/tdb2/test/run-tdb1.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include #include #include "logging.h" diff --git a/lib/tdb2/test/run-tdb_errorstr.c b/lib/tdb2/test/run-tdb_errorstr.c index 742fb89113..94aab89d32 100644 --- a/lib/tdb2/test/run-tdb_errorstr.c +++ b/lib/tdb2/test/run-tdb_errorstr.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" int main(int argc, char *argv[]) { diff --git a/lib/tdb2/test/run-tdb_foreach.c b/lib/tdb2/test/run-tdb_foreach.c index b17f078074..b1eb2de217 100644 --- a/lib/tdb2/test/run-tdb_foreach.c +++ b/lib/tdb2/test/run-tdb_foreach.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include "logging.h" static int drop_count(struct tdb_context *tdb, unsigned int *count) diff --git a/lib/tdb2/test/run-traverse.c b/lib/tdb2/test/run-traverse.c index 610f02a516..20d610fe66 100644 --- a/lib/tdb2/test/run-traverse.c +++ b/lib/tdb2/test/run-traverse.c @@ -1,5 +1,5 @@ #include "tdb2-source.h" -#include +#include "tap-interface.h" #include "logging.h" #define NUM_RECORDS 1000 diff --git a/lib/tdb2/test/tap-interface.c b/lib/tdb2/test/tap-interface.c new file mode 100644 index 0000000000..077ec2cd9a --- /dev/null +++ b/lib/tdb2/test/tap-interface.c @@ -0,0 +1,3 @@ +#include "tap-interface.h" + +unsigned tap_ok_count, tap_ok_target = -1U; diff --git a/lib/tdb2/test/tap-interface.h b/lib/tdb2/test/tap-interface.h new file mode 100644 index 0000000000..9ee84aaaba --- /dev/null +++ b/lib/tdb2/test/tap-interface.h @@ -0,0 +1,41 @@ +/* + Unix SMB/CIFS implementation. + Simplistic implementation of tap interface. + + Copyright (C) Rusty Russell 2012 + + ** NOTE! The following LGPL license applies to the talloc + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, see . +*/ +#include +#include + +#ifndef __location__ +#define __TAP_STRING_LINE1__(s) #s +#define __TAP_STRING_LINE2__(s) __TAP_STRING_LINE1__(s) +#define __TAP_STRING_LINE3__ __TAP_STRING_LINE2__(__LINE__) +#define __location__ __FILE__ ":" __TAP_STRING_LINE3__ +#endif + +extern unsigned tap_ok_count, tap_ok_target; +#define plan_tests(num) do { tap_ok_target = (num); } while(0) +#define ok(e, ...) ((e) ? (printf("."), tap_ok_count++, true) : (warnx(__VA_ARGS__), false)) +#define ok1(e) ok((e), "%s:%s", __location__, #e) +#define pass(...) (printf("."), tap_ok_count++) +#define fail(...) warnx(__VA_ARGS__) +#define diag printf +#define exit_status() (tap_ok_count == tap_ok_target ? 0 : 1) diff --git a/lib/tdb2/test/tdb1-external-agent.c b/lib/tdb2/test/tdb1-external-agent.c index ffde077025..dff7012a40 100644 --- a/lib/tdb2/test/tdb1-external-agent.c +++ b/lib/tdb2/test/tdb1-external-agent.c @@ -10,8 +10,8 @@ #include #include #include -#include -#include +#include "tdb1_private.h" +#include "tap-interface.h" #include #include @@ -76,7 +76,7 @@ static enum agent_return do_operation(enum operation op, const char *name) ret = tdb_check(tdb, NULL, NULL) == TDB_SUCCESS ? SUCCESS : OTHER_FAILURE; break; case NEEDS_RECOVERY: - ret = tdb1_needs_recovery(tdb) ? SUCCESS : FAILED; + ret = external_agent_needs_rec(tdb); break; case CLOSE: ret = tdb_close(tdb) == 0 ? SUCCESS : OTHER_FAILURE; diff --git a/lib/tdb2/test/tdb1-external-agent.h b/lib/tdb2/test/tdb1-external-agent.h index ee903b65c5..19ad8d2c12 100644 --- a/lib/tdb2/test/tdb1-external-agent.h +++ b/lib/tdb2/test/tdb1-external-agent.h @@ -37,4 +37,7 @@ enum agent_return external_agent_operation1(struct agent *handle, 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 index 197b1f0706..9701157b81 100644 --- a/lib/tdb2/test/tdb1-lock-tracking.c +++ b/lib/tdb2/test/tdb1-lock-tracking.c @@ -1,10 +1,10 @@ /* We save the locks so we can reaquire them. */ -#include +#include "tdb1_private.h" #include #include #include #include -#include +#include "tap-interface.h" #include "tdb1-lock-tracking.h" struct lock { diff --git a/lib/tdb2/test/tdb1-lock-tracking.h b/lib/tdb2/test/tdb1-lock-tracking.h index cb8c2f1278..b59e7d805d 100644 --- a/lib/tdb2/test/tdb1-lock-tracking.h +++ b/lib/tdb2/test/tdb1-lock-tracking.h @@ -1,6 +1,6 @@ #ifndef TDB1_LOCK_TRACKING_H #define TDB1_LOCK_TRACKING_H -#include +#include "private.h" #include /* Set this if you want a callback after fnctl unlock. */ diff --git a/lib/tdb2/test/tdb2-source.h b/lib/tdb2/test/tdb2-source.h index 28ab35135c..fabf6ac33d 100644 --- a/lib/tdb2/test/tdb2-source.h +++ b/lib/tdb2/test/tdb2-source.h @@ -1,21 +1,21 @@ #include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "check.c" +#include "free.c" +#include "hash.c" +#include "io.c" +#include "lock.c" +#include "open.c" +#include "summary.c" +#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" -- cgit