From: Rusty Russell Date: Fri, 20 Mar 2015 01:06:52 +0000 (+1030) Subject: ntdb: fix up tests. X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=8ccb14db10cfedc5c97c9222a7955cee8246b741 ntdb: fix up tests. Mainly include path fixes. Also Samba's unit tests were enhanced to detect the prefixes helpapi and helprun to indicate an object was to be linked against only api/run tests. We hack around that by #including the helper code instead. Signed-off-by: Rusty Russell --- diff --git a/ccan/ntdb/test/api-12-store.c b/ccan/ntdb/test/api-12-store.c index 532a8ee5..f5b3b72a 100644 --- a/ccan/ntdb/test/api-12-store.c +++ b/ccan/ntdb/test/api-12-store.c @@ -1,10 +1,10 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include - #include "logging.h" +#include "helpapi-external-agent.h" /* We use the same seed which we saw a failure on. */ static uint32_t fixedhash(const void *key, size_t len, uint32_t seed, void *p) diff --git a/ccan/ntdb/test/api-13-delete.c b/ccan/ntdb/test/api-13-delete.c index 730ade5a..44820ff1 100644 --- a/ccan/ntdb/test/api-13-delete.c +++ b/ccan/ntdb/test/api-13-delete.c @@ -1,8 +1,9 @@ -#include "private.h" // For NTDB_TOPLEVEL_HASH_BITS +#include "../private.h" // For NTDB_TOPLEVEL_HASH_BITS #include -#include "ntdb.h" +#include "../ntdb.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" /* We rig the hash so adjacent-numbered records always clash. */ static uint32_t clash(const void *key, size_t len, uint32_t seed, void *priv) diff --git a/ccan/ntdb/test/api-14-exists.c b/ccan/ntdb/test/api-14-exists.c index c40d9016..37f40b00 100644 --- a/ccan/ntdb/test/api-14-exists.c +++ b/ccan/ntdb/test/api-14-exists.c @@ -1,8 +1,9 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" static bool test_records(struct ntdb_context *ntdb) { diff --git a/ccan/ntdb/test/api-16-wipe_all.c b/ccan/ntdb/test/api-16-wipe_all.c index 4eea151e..fb70523f 100644 --- a/ccan/ntdb/test/api-16-wipe_all.c +++ b/ccan/ntdb/test/api-16-wipe_all.c @@ -1,8 +1,9 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" static bool add_records(struct ntdb_context *ntdb) { diff --git a/ccan/ntdb/test/api-20-alloc-attr.c b/ccan/ntdb/test/api-20-alloc-attr.c index 3df5003a..1abdcf6a 100644 --- a/ccan/ntdb/test/api-20-alloc-attr.c +++ b/ccan/ntdb/test/api-20-alloc-attr.c @@ -1,11 +1,12 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include #include #include "logging.h" +#include "helpapi-external-agent.h" static const struct ntdb_context *curr_ntdb; static const struct ntdb_file *curr_file; diff --git a/ccan/ntdb/test/api-21-parse_record.c b/ccan/ntdb/test/api-21-parse_record.c index 5af9abe0..a841a1a7 100644 --- a/ccan/ntdb/test/api-21-parse_record.c +++ b/ccan/ntdb/test/api-21-parse_record.c @@ -1,8 +1,9 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" static enum NTDB_ERROR parse(NTDB_DATA key, NTDB_DATA data, NTDB_DATA *expected) { diff --git a/ccan/ntdb/test/api-55-transaction.c b/ccan/ntdb/test/api-55-transaction.c index 3d3e5399..21dd1c46 100644 --- a/ccan/ntdb/test/api-55-transaction.c +++ b/ccan/ntdb/test/api-55-transaction.c @@ -1,8 +1,9 @@ -#include "private.h" // struct ntdb_context -#include "ntdb.h" +#include "../private.h" // struct ntdb_context +#include "../ntdb.h" #include "tap-interface.h" #include #include "logging.h" +#include "helpapi-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/api-60-noop-transaction.c b/ccan/ntdb/test/api-60-noop-transaction.c index 5e56dbc5..53a4ade6 100644 --- a/ccan/ntdb/test/api-60-noop-transaction.c +++ b/ccan/ntdb/test/api-60-noop-transaction.c @@ -1,8 +1,9 @@ -#include "private.h" // struct ntdb_context -#include "ntdb.h" +#include "../private.h" // struct ntdb_context +#include "../ntdb.h" #include "tap-interface.h" #include #include "logging.h" +#include "helpapi-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/api-80-tdb_fd.c b/ccan/ntdb/test/api-80-tdb_fd.c index ca520a99..0d37754e 100644 --- a/ccan/ntdb/test/api-80-tdb_fd.c +++ b/ccan/ntdb/test/api-80-tdb_fd.c @@ -1,8 +1,9 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/api-81-seqnum.c b/ccan/ntdb/test/api-81-seqnum.c index 45963ff5..33ced82c 100644 --- a/ccan/ntdb/test/api-81-seqnum.c +++ b/ccan/ntdb/test/api-81-seqnum.c @@ -1,9 +1,10 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include #include "logging.h" +#include "helpapi-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/api-82-lockattr.c b/ccan/ntdb/test/api-82-lockattr.c index f71600c1..3b7ba8c8 100644 --- a/ccan/ntdb/test/api-82-lockattr.c +++ b/ccan/ntdb/test/api-82-lockattr.c @@ -1,8 +1,9 @@ -#include "private.h" // for ntdb_fcntl_unlock -#include "ntdb.h" +#include "../private.h" // for ntdb_fcntl_unlock +#include "../ntdb.h" #include "tap-interface.h" #include #include "logging.h" +#include "helpapi-external-agent.h" static int mylock(int fd, int rw, off_t off, off_t len, bool waitflag, void *_err) diff --git a/ccan/ntdb/test/api-83-openhook.c b/ccan/ntdb/test/api-83-openhook.c index d2930acf..cdd015a5 100644 --- a/ccan/ntdb/test/api-83-openhook.c +++ b/ccan/ntdb/test/api-83-openhook.c @@ -1,9 +1,10 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "external-agent.h" #include "logging.h" +#include "helpapi-external-agent.h" #define KEY_STR "key" diff --git a/ccan/ntdb/test/api-91-get-stats.c b/ccan/ntdb/test/api-91-get-stats.c index 1041cba5..120b62ed 100644 --- a/ccan/ntdb/test/api-91-get-stats.c +++ b/ccan/ntdb/test/api-91-get-stats.c @@ -1,8 +1,9 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/api-92-get-set-readonly.c b/ccan/ntdb/test/api-92-get-set-readonly.c index c557f34c..dda5acb9 100644 --- a/ccan/ntdb/test/api-92-get-set-readonly.c +++ b/ccan/ntdb/test/api-92-get-set-readonly.c @@ -1,8 +1,9 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/api-93-repack.c b/ccan/ntdb/test/api-93-repack.c index 0fade082..437c0f85 100644 --- a/ccan/ntdb/test/api-93-repack.c +++ b/ccan/ntdb/test/api-93-repack.c @@ -1,8 +1,9 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" #define NUM_TESTS 1000 diff --git a/ccan/ntdb/test/api-94-expand-during-parse.c b/ccan/ntdb/test/api-94-expand-during-parse.c index 3aca88bd..39b19988 100644 --- a/ccan/ntdb/test/api-94-expand-during-parse.c +++ b/ccan/ntdb/test/api-94-expand-during-parse.c @@ -1,9 +1,10 @@ /* We use direct access to hand to the parse function: what if db expands? */ #include "config.h" -#include "ntdb.h" +#include "../ntdb.h" #include "tap-interface.h" #include "logging.h" #include "../private.h" /* To establish size, esp. for NTDB_INTERNAL dbs */ +#include "helpapi-external-agent.h" static struct ntdb_context *ntdb; diff --git a/ccan/ntdb/test/api-95-read-only-during-parse.c b/ccan/ntdb/test/api-95-read-only-during-parse.c index 53adbc3c..0b0eb69f 100644 --- a/ccan/ntdb/test/api-95-read-only-during-parse.c +++ b/ccan/ntdb/test/api-95-read-only-during-parse.c @@ -1,9 +1,10 @@ /* Make sure write operations fail during ntdb_parse(). */ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" static struct ntdb_context *ntdb; diff --git a/ccan/ntdb/test/api-add-remove-flags.c b/ccan/ntdb/test/api-add-remove-flags.c index c16ceeb2..a09046e2 100644 --- a/ccan/ntdb/test/api-add-remove-flags.c +++ b/ccan/ntdb/test/api-add-remove-flags.c @@ -1,7 +1,8 @@ -#include "private.h" // for ntdb_context -#include "ntdb.h" +#include "../private.h" // for ntdb_context +#include "../ntdb.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/api-check-callback.c b/ccan/ntdb/test/api-check-callback.c index 20c88e71..eaf60d48 100644 --- a/ccan/ntdb/test/api-check-callback.c +++ b/ccan/ntdb/test/api-check-callback.c @@ -1,8 +1,9 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" #define NUM_RECORDS 1000 diff --git a/ccan/ntdb/test/api-firstkey-nextkey.c b/ccan/ntdb/test/api-firstkey-nextkey.c index 179cf76c..6d9ad67a 100644 --- a/ccan/ntdb/test/api-firstkey-nextkey.c +++ b/ccan/ntdb/test/api-firstkey-nextkey.c @@ -1,8 +1,9 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" #define NUM_RECORDS 1000 diff --git a/ccan/ntdb/test/api-fork-test.c b/ccan/ntdb/test/api-fork-test.c index 4b114d6f..32c6ebe4 100644 --- a/ccan/ntdb/test/api-fork-test.c +++ b/ccan/ntdb/test/api-fork-test.c @@ -11,10 +11,11 @@ * that doesn't matter. */ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" static bool am_child = false; diff --git a/ccan/ntdb/test/api-locktimeout.c b/ccan/ntdb/test/api-locktimeout.c index 4c0fda28..235409b3 100644 --- a/ccan/ntdb/test/api-locktimeout.c +++ b/ccan/ntdb/test/api-locktimeout.c @@ -1,10 +1,11 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include #include "logging.h" #include "external-agent.h" +#include "helpapi-external-agent.h" #undef alarm #define alarm fast_alarm diff --git a/ccan/ntdb/test/api-missing-entries.c b/ccan/ntdb/test/api-missing-entries.c index 2a00f1b3..a6427c07 100644 --- a/ccan/ntdb/test/api-missing-entries.c +++ b/ccan/ntdb/test/api-missing-entries.c @@ -1,10 +1,11 @@ /* Another test revealed that we lost an entry. This reproduces it. */ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" #define NUM_RECORDS 1189 diff --git a/ccan/ntdb/test/api-open-multiple-times.c b/ccan/ntdb/test/api-open-multiple-times.c index 6b97bc97..59a03629 100644 --- a/ccan/ntdb/test/api-open-multiple-times.c +++ b/ccan/ntdb/test/api-open-multiple-times.c @@ -1,9 +1,10 @@ #include "config.h" -#include "ntdb.h" +#include "../ntdb.h" #include "tap-interface.h" #include #include "logging.h" #include "../private.h" +#include "helpapi-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/api-record-expand.c b/ccan/ntdb/test/api-record-expand.c index 74fb27fc..b92f13fe 100644 --- a/ccan/ntdb/test/api-record-expand.c +++ b/ccan/ntdb/test/api-record-expand.c @@ -1,8 +1,9 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" #define MAX_SIZE 10000 #define SIZE_STEP 131 diff --git a/ccan/ntdb/test/api-simple-delete.c b/ccan/ntdb/test/api-simple-delete.c index e8baf4c5..0b886c3a 100644 --- a/ccan/ntdb/test/api-simple-delete.c +++ b/ccan/ntdb/test/api-simple-delete.c @@ -1,8 +1,9 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/api-summary.c b/ccan/ntdb/test/api-summary.c index af1b5958..7701f26a 100644 --- a/ccan/ntdb/test/api-summary.c +++ b/ccan/ntdb/test/api-summary.c @@ -1,8 +1,9 @@ #include "config.h" -#include "ntdb.h" -#include "private.h" +#include "../ntdb.h" +#include "../private.h" #include "tap-interface.h" #include "logging.h" +#include "helpapi-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/failtest_helper.c b/ccan/ntdb/test/failtest_helper.c index 45b24512..ab7e61b0 100644 --- a/ccan/ntdb/test/failtest_helper.c +++ b/ccan/ntdb/test/failtest_helper.c @@ -5,15 +5,6 @@ bool failtest_suppress = false; -/* FIXME: From ccan/str */ -static inline bool strends(const char *str, const char *postfix) -{ - if (strlen(str) < strlen(postfix)) - return false; - - return !strcmp(str + strlen(str) - strlen(postfix), postfix); -} - bool failmatch(const struct failtest_call *call, const char *file, int line, enum failtest_call_type type) { diff --git a/ccan/ntdb/test/helpapi-external-agent.c b/ccan/ntdb/test/helpapi-external-agent.c deleted file mode 100644 index eb813990..00000000 --- a/ccan/ntdb/test/helpapi-external-agent.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "external-agent.h" - -/* This isn't possible with via the ntdb API, but this makes it link. */ -enum agent_return external_agent_needs_rec(struct ntdb_context *ntdb) -{ - return FAILED; -} diff --git a/ccan/ntdb/test/helpapi-external-agent.h b/ccan/ntdb/test/helpapi-external-agent.h new file mode 100644 index 00000000..eb813990 --- /dev/null +++ b/ccan/ntdb/test/helpapi-external-agent.h @@ -0,0 +1,7 @@ +#include "external-agent.h" + +/* This isn't possible with via the ntdb API, but this makes it link. */ +enum agent_return external_agent_needs_rec(struct ntdb_context *ntdb) +{ + return FAILED; +} diff --git a/ccan/ntdb/test/helprun-external-agent.c b/ccan/ntdb/test/helprun-external-agent.c deleted file mode 100644 index 81a3fe88..00000000 --- a/ccan/ntdb/test/helprun-external-agent.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "external-agent.h" -#include "private.h" - -enum agent_return external_agent_needs_rec(struct ntdb_context *ntdb) -{ - return ntdb_needs_recovery(ntdb) ? SUCCESS : FAILED; -} diff --git a/ccan/ntdb/test/helprun-external-agent.h b/ccan/ntdb/test/helprun-external-agent.h new file mode 100644 index 00000000..12610411 --- /dev/null +++ b/ccan/ntdb/test/helprun-external-agent.h @@ -0,0 +1,7 @@ +#include "external-agent.h" +#include "../private.h" + +enum agent_return external_agent_needs_rec(struct ntdb_context *ntdb) +{ + return ntdb_needs_recovery(ntdb) ? SUCCESS : FAILED; +} diff --git a/ccan/ntdb/test/helprun-layout.c b/ccan/ntdb/test/helprun-layout.c deleted file mode 100644 index fa6fa29f..00000000 --- a/ccan/ntdb/test/helprun-layout.c +++ /dev/null @@ -1,362 +0,0 @@ -/* NTDB tools to create various canned database layouts. */ -#include "layout.h" -#include -#include -#include -#include -#include "logging.h" - -struct ntdb_layout *new_ntdb_layout(void) -{ - struct ntdb_layout *layout = malloc(sizeof(*layout)); - layout->num_elems = 0; - layout->elem = NULL; - return layout; -} - -static void add(struct ntdb_layout *layout, union ntdb_layout_elem elem) -{ - layout->elem = realloc(layout->elem, - sizeof(layout->elem[0]) - * (layout->num_elems+1)); - layout->elem[layout->num_elems++] = elem; -} - -void ntdb_layout_add_freetable(struct ntdb_layout *layout) -{ - union ntdb_layout_elem elem; - elem.base.type = FREETABLE; - add(layout, elem); -} - -void ntdb_layout_add_free(struct ntdb_layout *layout, ntdb_len_t len, - unsigned ftable) -{ - union ntdb_layout_elem elem; - elem.base.type = FREE; - elem.free.len = len; - elem.free.ftable_num = ftable; - add(layout, elem); -} - -void ntdb_layout_add_capability(struct ntdb_layout *layout, - uint64_t type, - bool write_breaks, - bool check_breaks, - bool open_breaks, - ntdb_len_t extra) -{ - union ntdb_layout_elem elem; - elem.base.type = CAPABILITY; - elem.capability.type = type; - if (write_breaks) - elem.capability.type |= NTDB_CAP_NOWRITE; - if (open_breaks) - elem.capability.type |= NTDB_CAP_NOOPEN; - if (check_breaks) - elem.capability.type |= NTDB_CAP_NOCHECK; - elem.capability.extra = extra; - add(layout, elem); -} - -static NTDB_DATA dup_key(NTDB_DATA key) -{ - NTDB_DATA ret; - ret.dsize = key.dsize; - ret.dptr = malloc(ret.dsize); - memcpy(ret.dptr, key.dptr, ret.dsize); - return ret; -} - -void ntdb_layout_add_used(struct ntdb_layout *layout, - NTDB_DATA key, NTDB_DATA data, - ntdb_len_t extra) -{ - union ntdb_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 ntdb_len_t free_record_len(ntdb_len_t len) -{ - return sizeof(struct ntdb_used_record) + len; -} - -static ntdb_len_t data_record_len(struct tle_used *used) -{ - ntdb_len_t len; - len = sizeof(struct ntdb_used_record) - + used->key.dsize + used->data.dsize + used->extra; - assert(len >= sizeof(struct ntdb_free_record)); - return len; -} - -static ntdb_len_t capability_len(struct tle_capability *cap) -{ - return sizeof(struct ntdb_capability) + cap->extra; -} - -static ntdb_len_t freetable_len(struct tle_freetable *ftable) -{ - return sizeof(struct ntdb_freetable); -} - -static void set_free_record(void *mem, ntdb_len_t len) -{ - /* We do all the work in add_to_freetable */ -} - -static void add_zero_pad(struct ntdb_used_record *u, size_t len, size_t extra) -{ - if (extra) - ((char *)(u + 1))[len] = '\0'; -} - -static void set_data_record(void *mem, struct ntdb_context *ntdb, - struct tle_used *used) -{ - struct ntdb_used_record *u = mem; - - set_header(ntdb, u, NTDB_USED_MAGIC, used->key.dsize, used->data.dsize, - used->key.dsize + used->data.dsize + used->extra); - 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_capability(void *mem, struct ntdb_context *ntdb, - struct tle_capability *cap, struct ntdb_header *hdr, - ntdb_off_t last_cap) -{ - struct ntdb_capability *c = mem; - ntdb_len_t len = sizeof(*c) - sizeof(struct ntdb_used_record) + cap->extra; - - c->type = cap->type; - c->next = 0; - set_header(ntdb, &c->hdr, NTDB_CAP_MAGIC, 0, len, len); - - /* Append to capability list. */ - if (!last_cap) { - hdr->capabilities = cap->base.off; - } else { - c = (struct ntdb_capability *)((char *)hdr + last_cap); - c->next = cap->base.off; - } -} - -static void set_freetable(void *mem, struct ntdb_context *ntdb, - struct tle_freetable *freetable, struct ntdb_header *hdr, - ntdb_off_t last_ftable) -{ - struct ntdb_freetable *ftable = mem; - memset(ftable, 0, sizeof(*ftable)); - set_header(ntdb, &ftable->hdr, NTDB_FTABLE_MAGIC, 0, - sizeof(*ftable) - sizeof(ftable->hdr), - sizeof(*ftable) - sizeof(ftable->hdr)); - - if (last_ftable) { - ftable = (struct ntdb_freetable *)((char *)hdr + last_ftable); - ftable->next = freetable->base.off; - } else { - hdr->free_table = freetable->base.off; - } -} - -static void add_to_freetable(struct ntdb_context *ntdb, - ntdb_off_t eoff, - ntdb_off_t elen, - unsigned ftable, - struct tle_freetable *freetable) -{ - ntdb->ftable_off = freetable->base.off; - ntdb->ftable = ftable; - add_free_record(ntdb, eoff, sizeof(struct ntdb_used_record) + elen, - NTDB_LOCK_WAIT, false); -} - -/* 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); -} - -static ntdb_off_t encode_offset(const struct ntdb_context *ntdb, - ntdb_off_t new_off, uint32_t hash) -{ - ntdb_off_t extra; - - assert((new_off & (1ULL << NTDB_OFF_CHAIN_BIT)) == 0); - assert((new_off >> (64 - NTDB_OFF_UPPER_STEAL)) == 0); - /* We pack extra hash bits into the upper bits of the offset. */ - extra = bits(hash, ntdb->hash_bits, NTDB_OFF_UPPER_STEAL); - extra <<= (64 - NTDB_OFF_UPPER_STEAL); - - return new_off | extra; -} - -static ntdb_off_t hbucket_off(ntdb_len_t idx) -{ - return sizeof(struct ntdb_header) + sizeof(struct ntdb_used_record) - + idx * sizeof(ntdb_off_t); -} - -/* FIXME: Our hash table handling here is primitive: we don't expand! */ -static void add_to_hashtable(struct ntdb_context *ntdb, - ntdb_off_t eoff, - NTDB_DATA key) -{ - ntdb_off_t b_off; - uint32_t h = ntdb_hash(ntdb, key.dptr, key.dsize); - - b_off = hbucket_off(h & ((1 << ntdb->hash_bits)-1)); - if (ntdb_read_off(ntdb, b_off) != 0) - abort(); - - ntdb_write_off(ntdb, b_off, encode_offset(ntdb, eoff, h)); -} - -static struct tle_freetable *find_ftable(struct ntdb_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 NTDB_CONVERT */ -struct ntdb_context *ntdb_layout_get(struct ntdb_layout *layout, - void (*freefn)(void *), - union ntdb_attribute *attr) -{ - unsigned int i; - ntdb_off_t off, hdrlen, len, last_ftable, last_cap; - char *mem; - struct ntdb_context *ntdb; - - /* Now populate our header, cribbing from a real NTDB header. */ - ntdb = ntdb_open("layout", NTDB_INTERNAL, O_RDWR, 0, attr); - - off = sizeof(struct ntdb_header) + sizeof(struct ntdb_used_record) - + (sizeof(ntdb_off_t) << ntdb->hash_bits); - hdrlen = off; - - /* First pass of layout: calc lengths */ - for (i = 0; i < layout->num_elems; i++) { - union ntdb_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 CAPABILITY: - len = capability_len(&e->capability); - break; - default: - abort(); - } - off += len; - } - - mem = malloc(off); - /* Fill with some weird pattern. */ - memset(mem, 0x99, off); - memcpy(mem, ntdb->file->map_ptr, hdrlen); - - /* Mug the ntdb we have to make it use this. */ - freefn(ntdb->file->map_ptr); - ntdb->file->map_ptr = mem; - ntdb->file->map_size = off; - - last_ftable = 0; - last_cap = 0; - for (i = 0; i < layout->num_elems; i++) { - union ntdb_layout_elem *e = &layout->elem[i]; - switch (e->base.type) { - case FREETABLE: - set_freetable(mem + e->base.off, ntdb, &e->ftable, - (struct ntdb_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, ntdb, &e->used); - break; - case CAPABILITY: - set_capability(mem + e->base.off, ntdb, &e->capability, - (struct ntdb_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 ntdb_layout_elem *e = &layout->elem[i]; - switch (e->base.type) { - case FREE: - add_to_freetable(ntdb, e->base.off, e->free.len, - e->free.ftable_num, - find_ftable(layout, e->free.ftable_num)); - break; - case DATA: - add_to_hashtable(ntdb, e->base.off, e->used.key); - break; - default: - break; - } - } - - ntdb->ftable_off = find_ftable(layout, 0)->base.off; - return ntdb; -} - -void ntdb_layout_write(struct ntdb_layout *layout, void (*freefn)(void *), - union ntdb_attribute *attr, const char *filename) -{ - struct ntdb_context *ntdb = ntdb_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, ntdb->file->map_ptr, ntdb->file->map_size) - != ntdb->file->map_size) - err(1, "writing %s", filename); - close(fd); - ntdb_close(ntdb); -} - -void ntdb_layout_free(struct ntdb_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/ccan/ntdb/test/helprun-layout.h b/ccan/ntdb/test/helprun-layout.h new file mode 100644 index 00000000..1bacd5e7 --- /dev/null +++ b/ccan/ntdb/test/helprun-layout.h @@ -0,0 +1,341 @@ +/* NTDB tools to create various canned database layouts. */ +#include "layout.h" +#include +#include +#include +#include +#include "logging.h" + +struct ntdb_layout *new_ntdb_layout(void) +{ + struct ntdb_layout *layout = malloc(sizeof(*layout)); + layout->num_elems = 0; + layout->elem = NULL; + return layout; +} + +static void add(struct ntdb_layout *layout, union ntdb_layout_elem elem) +{ + layout->elem = realloc(layout->elem, + sizeof(layout->elem[0]) + * (layout->num_elems+1)); + layout->elem[layout->num_elems++] = elem; +} + +void ntdb_layout_add_freetable(struct ntdb_layout *layout) +{ + union ntdb_layout_elem elem; + elem.base.type = FREETABLE; + add(layout, elem); +} + +void ntdb_layout_add_free(struct ntdb_layout *layout, ntdb_len_t len, + unsigned ftable) +{ + union ntdb_layout_elem elem; + elem.base.type = FREE; + elem.free.len = len; + elem.free.ftable_num = ftable; + add(layout, elem); +} + +void ntdb_layout_add_capability(struct ntdb_layout *layout, + uint64_t type, + bool write_breaks, + bool check_breaks, + bool open_breaks, + ntdb_len_t extra) +{ + union ntdb_layout_elem elem; + elem.base.type = CAPABILITY; + elem.capability.type = type; + if (write_breaks) + elem.capability.type |= NTDB_CAP_NOWRITE; + if (open_breaks) + elem.capability.type |= NTDB_CAP_NOOPEN; + if (check_breaks) + elem.capability.type |= NTDB_CAP_NOCHECK; + elem.capability.extra = extra; + add(layout, elem); +} + +static NTDB_DATA dup_key(NTDB_DATA key) +{ + NTDB_DATA ret; + ret.dsize = key.dsize; + ret.dptr = malloc(ret.dsize); + memcpy(ret.dptr, key.dptr, ret.dsize); + return ret; +} + +void ntdb_layout_add_used(struct ntdb_layout *layout, + NTDB_DATA key, NTDB_DATA data, + ntdb_len_t extra) +{ + union ntdb_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 ntdb_len_t free_record_len(ntdb_len_t len) +{ + return sizeof(struct ntdb_used_record) + len; +} + +static ntdb_len_t data_record_len(struct tle_used *used) +{ + ntdb_len_t len; + len = sizeof(struct ntdb_used_record) + + used->key.dsize + used->data.dsize + used->extra; + assert(len >= sizeof(struct ntdb_free_record)); + return len; +} + +static ntdb_len_t capability_len(struct tle_capability *cap) +{ + return sizeof(struct ntdb_capability) + cap->extra; +} + +static ntdb_len_t freetable_len(struct tle_freetable *ftable) +{ + return sizeof(struct ntdb_freetable); +} + +static void set_free_record(void *mem, ntdb_len_t len) +{ + /* We do all the work in add_to_freetable */ +} + +static void add_zero_pad(struct ntdb_used_record *u, size_t len, size_t extra) +{ + if (extra) + ((char *)(u + 1))[len] = '\0'; +} + +static void set_data_record(void *mem, struct ntdb_context *ntdb, + struct tle_used *used) +{ + struct ntdb_used_record *u = mem; + + set_header(ntdb, u, NTDB_USED_MAGIC, used->key.dsize, used->data.dsize, + used->key.dsize + used->data.dsize + used->extra); + 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_capability(void *mem, struct ntdb_context *ntdb, + struct tle_capability *cap, struct ntdb_header *hdr, + ntdb_off_t last_cap) +{ + struct ntdb_capability *c = mem; + ntdb_len_t len = sizeof(*c) - sizeof(struct ntdb_used_record) + cap->extra; + + c->type = cap->type; + c->next = 0; + set_header(ntdb, &c->hdr, NTDB_CAP_MAGIC, 0, len, len); + + /* Append to capability list. */ + if (!last_cap) { + hdr->capabilities = cap->base.off; + } else { + c = (struct ntdb_capability *)((char *)hdr + last_cap); + c->next = cap->base.off; + } +} + +static void set_freetable(void *mem, struct ntdb_context *ntdb, + struct tle_freetable *freetable, struct ntdb_header *hdr, + ntdb_off_t last_ftable) +{ + struct ntdb_freetable *ftable = mem; + memset(ftable, 0, sizeof(*ftable)); + set_header(ntdb, &ftable->hdr, NTDB_FTABLE_MAGIC, 0, + sizeof(*ftable) - sizeof(ftable->hdr), + sizeof(*ftable) - sizeof(ftable->hdr)); + + if (last_ftable) { + ftable = (struct ntdb_freetable *)((char *)hdr + last_ftable); + ftable->next = freetable->base.off; + } else { + hdr->free_table = freetable->base.off; + } +} + +static void add_to_freetable(struct ntdb_context *ntdb, + ntdb_off_t eoff, + ntdb_off_t elen, + unsigned ftable, + struct tle_freetable *freetable) +{ + ntdb->ftable_off = freetable->base.off; + ntdb->ftable = ftable; + add_free_record(ntdb, eoff, sizeof(struct ntdb_used_record) + elen, + NTDB_LOCK_WAIT, false); +} + +static ntdb_off_t hbucket_offset(ntdb_len_t idx) +{ + return sizeof(struct ntdb_header) + sizeof(struct ntdb_used_record) + + idx * sizeof(ntdb_off_t); +} + +/* FIXME: Our hash table handling here is primitive: we don't expand! */ +static void add_to_hashtable(struct ntdb_context *ntdb, + ntdb_off_t eoff, + NTDB_DATA key) +{ + ntdb_off_t b_off; + uint32_t h = ntdb_hash(ntdb, key.dptr, key.dsize); + + b_off = hbucket_offset(h & ((1 << ntdb->hash_bits)-1)); + if (ntdb_read_off(ntdb, b_off) != 0) + abort(); + + ntdb_write_off(ntdb, b_off, encode_offset(ntdb, eoff, h)); +} + +static struct tle_freetable *find_ftable(struct ntdb_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 NTDB_CONVERT */ +struct ntdb_context *ntdb_layout_get(struct ntdb_layout *layout, + void (*freefn)(void *), + union ntdb_attribute *attr) +{ + unsigned int i; + ntdb_off_t off, hdrlen, len, last_ftable, last_cap; + char *mem; + struct ntdb_context *ntdb; + + /* Now populate our header, cribbing from a real NTDB header. */ + ntdb = ntdb_open("layout", NTDB_INTERNAL, O_RDWR, 0, attr); + + off = sizeof(struct ntdb_header) + sizeof(struct ntdb_used_record) + + (sizeof(ntdb_off_t) << ntdb->hash_bits); + hdrlen = off; + + /* First pass of layout: calc lengths */ + for (i = 0; i < layout->num_elems; i++) { + union ntdb_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 CAPABILITY: + len = capability_len(&e->capability); + break; + default: + abort(); + } + off += len; + } + + mem = malloc(off); + /* Fill with some weird pattern. */ + memset(mem, 0x99, off); + memcpy(mem, ntdb->file->map_ptr, hdrlen); + + /* Mug the ntdb we have to make it use this. */ + freefn(ntdb->file->map_ptr); + ntdb->file->map_ptr = mem; + ntdb->file->map_size = off; + + last_ftable = 0; + last_cap = 0; + for (i = 0; i < layout->num_elems; i++) { + union ntdb_layout_elem *e = &layout->elem[i]; + switch (e->base.type) { + case FREETABLE: + set_freetable(mem + e->base.off, ntdb, &e->ftable, + (struct ntdb_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, ntdb, &e->used); + break; + case CAPABILITY: + set_capability(mem + e->base.off, ntdb, &e->capability, + (struct ntdb_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 ntdb_layout_elem *e = &layout->elem[i]; + switch (e->base.type) { + case FREE: + add_to_freetable(ntdb, e->base.off, e->free.len, + e->free.ftable_num, + find_ftable(layout, e->free.ftable_num)); + break; + case DATA: + add_to_hashtable(ntdb, e->base.off, e->used.key); + break; + default: + break; + } + } + + ntdb->ftable_off = find_ftable(layout, 0)->base.off; + return ntdb; +} + +void ntdb_layout_write(struct ntdb_layout *layout, void (*freefn)(void *), + union ntdb_attribute *attr, const char *filename) +{ + struct ntdb_context *ntdb = ntdb_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, ntdb->file->map_ptr, ntdb->file->map_size) + != ntdb->file->map_size) + err(1, "writing %s", filename); + close(fd); + ntdb_close(ntdb); +} + +void ntdb_layout_free(struct ntdb_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/ccan/ntdb/test/layout.h b/ccan/ntdb/test/layout.h index b4f6a960..ea84382c 100644 --- a/ccan/ntdb/test/layout.h +++ b/ccan/ntdb/test/layout.h @@ -1,6 +1,6 @@ #ifndef NTDB_TEST_LAYOUT_H #define NTDB_TEST_LAYOUT_H -#include "private.h" +#include "../private.h" struct ntdb_layout *new_ntdb_layout(void); void ntdb_layout_add_freetable(struct ntdb_layout *layout); @@ -76,4 +76,6 @@ struct ntdb_layout { unsigned int num_elems; union ntdb_layout_elem *elem; }; + +#include "helprun-layout.h" #endif /* NTDB_TEST_LAYOUT_H */ diff --git a/ccan/ntdb/test/lock-tracking.c b/ccan/ntdb/test/lock-tracking.c index 525a5c4c..2d654e4b 100644 --- a/ccan/ntdb/test/lock-tracking.c +++ b/ccan/ntdb/test/lock-tracking.c @@ -1,5 +1,5 @@ /* We save the locks so we can reaquire them. */ -#include "private.h" /* For NTDB_HASH_LOCK_START, etc. */ +#include "../private.h" /* For NTDB_HASH_LOCK_START, etc. */ #include #include #include diff --git a/ccan/ntdb/test/logging.h b/ccan/ntdb/test/logging.h index 0336ccab..f8e1eb0e 100644 --- a/ccan/ntdb/test/logging.h +++ b/ccan/ntdb/test/logging.h @@ -1,6 +1,6 @@ #ifndef NTDB_TEST_LOGGING_H #define NTDB_TEST_LOGGING_H -#include "ntdb.h" +#include "../ntdb.h" #include #include diff --git a/ccan/ntdb/test/ntdb-source.h b/ccan/ntdb/test/ntdb-source.h index 52268440..88e517eb 100644 --- a/ccan/ntdb/test/ntdb-source.h +++ b/ccan/ntdb/test/ntdb-source.h @@ -1,11 +1,11 @@ #include "config.h" -#include "check.c" -#include "free.c" -#include "hash.c" -#include "io.c" -#include "lock.c" -#include "open.c" -#include "summary.c" -#include "ntdb.c" -#include "transaction.c" -#include "traverse.c" +#include "../check.c" +#include "../free.c" +#include "../hash.c" +#include "../io.c" +#include "../lock.c" +#include "../open.c" +#include "../summary.c" +#include "../ntdb.c" +#include "../transaction.c" +#include "../traverse.c" diff --git a/ccan/ntdb/test/run-001-encode.c b/ccan/ntdb/test/run-001-encode.c index b8a61bee..81f3e170 100644 --- a/ccan/ntdb/test/run-001-encode.c +++ b/ccan/ntdb/test/run-001-encode.c @@ -1,6 +1,7 @@ #include "ntdb-source.h" #include "tap-interface.h" #include "logging.h" +#include "helprun-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/run-001-fls.c b/ccan/ntdb/test/run-001-fls.c index ec61294c..6ed46fe0 100644 --- a/ccan/ntdb/test/run-001-fls.c +++ b/ccan/ntdb/test/run-001-fls.c @@ -1,5 +1,6 @@ #include "ntdb-source.h" #include "tap-interface.h" +#include "helprun-external-agent.h" static unsigned int dumb_fls(uint64_t num) { diff --git a/ccan/ntdb/test/run-01-new_database.c b/ccan/ntdb/test/run-01-new_database.c index ab69477b..11fb0248 100644 --- a/ccan/ntdb/test/run-01-new_database.c +++ b/ccan/ntdb/test/run-01-new_database.c @@ -4,6 +4,7 @@ #include #include "logging.h" #include "failtest_helper.h" +#include "helprun-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/run-02-expand.c b/ccan/ntdb/test/run-02-expand.c index e808989d..55927d9b 100644 --- a/ccan/ntdb/test/run-02-expand.c +++ b/ccan/ntdb/test/run-02-expand.c @@ -4,6 +4,7 @@ #include #include "logging.h" #include "failtest_helper.h" +#include "helprun-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/run-03-coalesce.c b/ccan/ntdb/test/run-03-coalesce.c index dc76e6a4..e86ee656 100644 --- a/ccan/ntdb/test/run-03-coalesce.c +++ b/ccan/ntdb/test/run-03-coalesce.c @@ -2,6 +2,7 @@ #include "tap-interface.h" #include "logging.h" #include "layout.h" +#include "helprun-external-agent.h" static ntdb_len_t free_record_length(struct ntdb_context *ntdb, ntdb_off_t off) { diff --git a/ccan/ntdb/test/run-04-basichash.c b/ccan/ntdb/test/run-04-basichash.c index 9888f6e5..9936d859 100644 --- a/ccan/ntdb/test/run-04-basichash.c +++ b/ccan/ntdb/test/run-04-basichash.c @@ -1,6 +1,7 @@ #include "ntdb-source.h" #include "tap-interface.h" #include "logging.h" +#include "helprun-external-agent.h" /* We rig the hash so all records clash. */ static uint32_t clash(const void *key, size_t len, uint32_t seed, void *priv) diff --git a/ccan/ntdb/test/run-05-readonly-open.c b/ccan/ntdb/test/run-05-readonly-open.c index 87caf953..057fa088 100644 --- a/ccan/ntdb/test/run-05-readonly-open.c +++ b/ccan/ntdb/test/run-05-readonly-open.c @@ -4,6 +4,7 @@ #include #include "logging.h" #include "failtest_helper.h" +#include "helprun-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/run-10-simple-store.c b/ccan/ntdb/test/run-10-simple-store.c index 0add1f10..d3f3b7fd 100644 --- a/ccan/ntdb/test/run-10-simple-store.c +++ b/ccan/ntdb/test/run-10-simple-store.c @@ -4,6 +4,7 @@ #include #include "logging.h" #include "failtest_helper.h" +#include "helprun-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/run-11-simple-fetch.c b/ccan/ntdb/test/run-11-simple-fetch.c index 779a5ea1..fba76202 100644 --- a/ccan/ntdb/test/run-11-simple-fetch.c +++ b/ccan/ntdb/test/run-11-simple-fetch.c @@ -4,6 +4,7 @@ #include #include "logging.h" #include "failtest_helper.h" +#include "helprun-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/run-12-check.c b/ccan/ntdb/test/run-12-check.c index 7211761f..c2354cb5 100644 --- a/ccan/ntdb/test/run-12-check.c +++ b/ccan/ntdb/test/run-12-check.c @@ -1,10 +1,11 @@ -#include "private.h" +#include "../private.h" #include #include "ntdb-source.h" #include "tap-interface.h" #include #include "logging.h" #include "failtest_helper.h" +#include "helprun-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/run-15-append.c b/ccan/ntdb/test/run-15-append.c index 05fa594b..fb8d7c20 100644 --- a/ccan/ntdb/test/run-15-append.c +++ b/ccan/ntdb/test/run-15-append.c @@ -2,6 +2,7 @@ #include "tap-interface.h" #include #include "logging.h" +#include "helprun-external-agent.h" #define MAX_SIZE 13100 #define SIZE_STEP 131 diff --git a/ccan/ntdb/test/run-25-hashoverload.c b/ccan/ntdb/test/run-25-hashoverload.c index d82b3edb..5a2c9cd7 100644 --- a/ccan/ntdb/test/run-25-hashoverload.c +++ b/ccan/ntdb/test/run-25-hashoverload.c @@ -1,6 +1,7 @@ #include "ntdb-source.h" #include "tap-interface.h" #include "logging.h" +#include "helprun-external-agent.h" #define OVERLOAD 100 diff --git a/ccan/ntdb/test/run-30-exhaust-before-expand.c b/ccan/ntdb/test/run-30-exhaust-before-expand.c index bcf1c1f6..e44b32c8 100644 --- a/ccan/ntdb/test/run-30-exhaust-before-expand.c +++ b/ccan/ntdb/test/run-30-exhaust-before-expand.c @@ -1,6 +1,7 @@ #include "ntdb-source.h" #include "tap-interface.h" #include "logging.h" +#include "helprun-external-agent.h" static bool empty_freetable(struct ntdb_context *ntdb) { diff --git a/ccan/ntdb/test/run-35-convert.c b/ccan/ntdb/test/run-35-convert.c index 873d4e77..4899dc66 100644 --- a/ccan/ntdb/test/run-35-convert.c +++ b/ccan/ntdb/test/run-35-convert.c @@ -1,10 +1,11 @@ -#include "private.h" +#include "../private.h" #include #include "ntdb-source.h" #include "tap-interface.h" #include #include "logging.h" #include "failtest_helper.h" +#include "helprun-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/run-50-multiple-freelists.c b/ccan/ntdb/test/run-50-multiple-freelists.c index 5496e3e0..4a7cf899 100644 --- a/ccan/ntdb/test/run-50-multiple-freelists.c +++ b/ccan/ntdb/test/run-50-multiple-freelists.c @@ -2,6 +2,7 @@ #include "tap-interface.h" #include "logging.h" #include "layout.h" +#include "helprun-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/run-56-open-during-transaction.c b/ccan/ntdb/test/run-56-open-during-transaction.c index 1c8786ce..c28fbfd3 100644 --- a/ccan/ntdb/test/run-56-open-during-transaction.c +++ b/ccan/ntdb/test/run-56-open-during-transaction.c @@ -1,4 +1,4 @@ -#include "private.h" +#include "../private.h" #include #include "lock-tracking.h" @@ -18,6 +18,7 @@ static int ftruncate_check(int fd, off_t length); #include #include "external-agent.h" #include "logging.h" +#include "helprun-external-agent.h" static struct agent *agent; static bool opened; diff --git a/ccan/ntdb/test/run-57-die-during-transaction.c b/ccan/ntdb/test/run-57-die-during-transaction.c index 32f781e4..9a86fca0 100644 --- a/ccan/ntdb/test/run-57-die-during-transaction.c +++ b/ccan/ntdb/test/run-57-die-during-transaction.c @@ -1,4 +1,4 @@ -#include "private.h" +#include "../private.h" #include #include "lock-tracking.h" #include "tap-interface.h" @@ -97,6 +97,7 @@ static void free_all(void) #include #include "external-agent.h" #include "logging.h" +#include "helprun-external-agent.h" static bool in_transaction; static int target, current; diff --git a/ccan/ntdb/test/run-64-bit-tdb.c b/ccan/ntdb/test/run-64-bit-tdb.c index 552866f8..9fcc6c9b 100644 --- a/ccan/ntdb/test/run-64-bit-tdb.c +++ b/ccan/ntdb/test/run-64-bit-tdb.c @@ -1,6 +1,7 @@ #include "ntdb-source.h" #include "tap-interface.h" #include "logging.h" +#include "helprun-external-agent.h" /* The largest 32-bit value which is still a multiple of NTDB_PGSIZE */ #define ALMOST_4G ((uint32_t)-NTDB_PGSIZE) diff --git a/ccan/ntdb/test/run-90-get-set-attributes.c b/ccan/ntdb/test/run-90-get-set-attributes.c index 5548aa4f..aafd4613 100644 --- a/ccan/ntdb/test/run-90-get-set-attributes.c +++ b/ccan/ntdb/test/run-90-get-set-attributes.c @@ -1,6 +1,7 @@ #include "ntdb-source.h" #include "tap-interface.h" #include "logging.h" +#include "helprun-external-agent.h" static int mylock(int fd, int rw, off_t off, off_t len, bool waitflag, void *unused) diff --git a/ccan/ntdb/test/run-capabilities.c b/ccan/ntdb/test/run-capabilities.c index f968393a..dc2df2ab 100644 --- a/ccan/ntdb/test/run-capabilities.c +++ b/ccan/ntdb/test/run-capabilities.c @@ -5,6 +5,7 @@ #include "layout.h" #include "failtest_helper.h" #include +#include "helprun-external-agent.h" static size_t len_of(bool breaks_check, bool breaks_write, bool breaks_open) { diff --git a/ccan/ntdb/test/run-expand-in-transaction.c b/ccan/ntdb/test/run-expand-in-transaction.c index 07c7129f..20a28ee6 100644 --- a/ccan/ntdb/test/run-expand-in-transaction.c +++ b/ccan/ntdb/test/run-expand-in-transaction.c @@ -1,6 +1,7 @@ #include "ntdb-source.h" #include "tap-interface.h" #include "logging.h" +#include "helprun-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/run-features.c b/ccan/ntdb/test/run-features.c index a332572d..631ce876 100644 --- a/ccan/ntdb/test/run-features.c +++ b/ccan/ntdb/test/run-features.c @@ -1,6 +1,7 @@ #include "ntdb-source.h" #include "tap-interface.h" #include "logging.h" +#include "helprun-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/run-lockall.c b/ccan/ntdb/test/run-lockall.c index 5ec448c9..a4cd1e47 100644 --- a/ccan/ntdb/test/run-lockall.c +++ b/ccan/ntdb/test/run-lockall.c @@ -1,4 +1,4 @@ -#include "private.h" +#include "../private.h" #include #include "lock-tracking.h" @@ -11,6 +11,7 @@ #include #include "external-agent.h" #include "logging.h" +#include "helprun-external-agent.h" #define TEST_DBNAME "run-lockall.ntdb" #define KEY_STR "key" diff --git a/ccan/ntdb/test/run-remap-in-read_traverse.c b/ccan/ntdb/test/run-remap-in-read_traverse.c index ee72c615..6fe537d4 100644 --- a/ccan/ntdb/test/run-remap-in-read_traverse.c +++ b/ccan/ntdb/test/run-remap-in-read_traverse.c @@ -4,6 +4,7 @@ #include "tap-interface.h" #include "external-agent.h" #include "logging.h" +#include "helprun-external-agent.h" static bool file_larger(int fd, ntdb_len_t size) { diff --git a/ccan/ntdb/test/run-seed.c b/ccan/ntdb/test/run-seed.c index 5d74dbc2..5ca6678a 100644 --- a/ccan/ntdb/test/run-seed.c +++ b/ccan/ntdb/test/run-seed.c @@ -1,6 +1,7 @@ #include "ntdb-source.h" #include "tap-interface.h" #include "logging.h" +#include "helprun-external-agent.h" static int log_count = 0; diff --git a/ccan/ntdb/test/run-tdb_errorstr.c b/ccan/ntdb/test/run-tdb_errorstr.c index 5b023140..499eb42e 100644 --- a/ccan/ntdb/test/run-tdb_errorstr.c +++ b/ccan/ntdb/test/run-tdb_errorstr.c @@ -1,5 +1,6 @@ #include "ntdb-source.h" #include "tap-interface.h" +#include "helprun-external-agent.h" int main(int argc, char *argv[]) { diff --git a/ccan/ntdb/test/run-tdb_foreach.c b/ccan/ntdb/test/run-tdb_foreach.c index 11eac5d0..532474b9 100644 --- a/ccan/ntdb/test/run-tdb_foreach.c +++ b/ccan/ntdb/test/run-tdb_foreach.c @@ -1,6 +1,7 @@ #include "ntdb-source.h" #include "tap-interface.h" #include "logging.h" +#include "helprun-external-agent.h" static int drop_count(struct ntdb_context *ntdb, unsigned int *count) { diff --git a/ccan/ntdb/test/run-traverse.c b/ccan/ntdb/test/run-traverse.c index a326b9c5..29b517db 100644 --- a/ccan/ntdb/test/run-traverse.c +++ b/ccan/ntdb/test/run-traverse.c @@ -1,6 +1,7 @@ #include "ntdb-source.h" #include "tap-interface.h" #include "logging.h" +#include "helprun-external-agent.h" #define NUM_RECORDS 1000