ntdb: fix up tests.
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 20 Mar 2015 01:06:52 +0000 (11:36 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 20 Mar 2015 01:06:52 +0000 (11:36 +1030)
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 <rusty@rustcorp.com.au>
66 files changed:
ccan/ntdb/test/api-12-store.c
ccan/ntdb/test/api-13-delete.c
ccan/ntdb/test/api-14-exists.c
ccan/ntdb/test/api-16-wipe_all.c
ccan/ntdb/test/api-20-alloc-attr.c
ccan/ntdb/test/api-21-parse_record.c
ccan/ntdb/test/api-55-transaction.c
ccan/ntdb/test/api-60-noop-transaction.c
ccan/ntdb/test/api-80-tdb_fd.c
ccan/ntdb/test/api-81-seqnum.c
ccan/ntdb/test/api-82-lockattr.c
ccan/ntdb/test/api-83-openhook.c
ccan/ntdb/test/api-91-get-stats.c
ccan/ntdb/test/api-92-get-set-readonly.c
ccan/ntdb/test/api-93-repack.c
ccan/ntdb/test/api-94-expand-during-parse.c
ccan/ntdb/test/api-95-read-only-during-parse.c
ccan/ntdb/test/api-add-remove-flags.c
ccan/ntdb/test/api-check-callback.c
ccan/ntdb/test/api-firstkey-nextkey.c
ccan/ntdb/test/api-fork-test.c
ccan/ntdb/test/api-locktimeout.c
ccan/ntdb/test/api-missing-entries.c
ccan/ntdb/test/api-open-multiple-times.c
ccan/ntdb/test/api-record-expand.c
ccan/ntdb/test/api-simple-delete.c
ccan/ntdb/test/api-summary.c
ccan/ntdb/test/failtest_helper.c
ccan/ntdb/test/helpapi-external-agent.c [deleted file]
ccan/ntdb/test/helpapi-external-agent.h [new file with mode: 0644]
ccan/ntdb/test/helprun-external-agent.c [deleted file]
ccan/ntdb/test/helprun-external-agent.h [new file with mode: 0644]
ccan/ntdb/test/helprun-layout.c [deleted file]
ccan/ntdb/test/helprun-layout.h [new file with mode: 0644]
ccan/ntdb/test/layout.h
ccan/ntdb/test/lock-tracking.c
ccan/ntdb/test/logging.h
ccan/ntdb/test/ntdb-source.h
ccan/ntdb/test/run-001-encode.c
ccan/ntdb/test/run-001-fls.c
ccan/ntdb/test/run-01-new_database.c
ccan/ntdb/test/run-02-expand.c
ccan/ntdb/test/run-03-coalesce.c
ccan/ntdb/test/run-04-basichash.c
ccan/ntdb/test/run-05-readonly-open.c
ccan/ntdb/test/run-10-simple-store.c
ccan/ntdb/test/run-11-simple-fetch.c
ccan/ntdb/test/run-12-check.c
ccan/ntdb/test/run-15-append.c
ccan/ntdb/test/run-25-hashoverload.c
ccan/ntdb/test/run-30-exhaust-before-expand.c
ccan/ntdb/test/run-35-convert.c
ccan/ntdb/test/run-50-multiple-freelists.c
ccan/ntdb/test/run-56-open-during-transaction.c
ccan/ntdb/test/run-57-die-during-transaction.c
ccan/ntdb/test/run-64-bit-tdb.c
ccan/ntdb/test/run-90-get-set-attributes.c
ccan/ntdb/test/run-capabilities.c
ccan/ntdb/test/run-expand-in-transaction.c
ccan/ntdb/test/run-features.c
ccan/ntdb/test/run-lockall.c
ccan/ntdb/test/run-remap-in-read_traverse.c
ccan/ntdb/test/run-seed.c
ccan/ntdb/test/run-tdb_errorstr.c
ccan/ntdb/test/run-tdb_foreach.c
ccan/ntdb/test/run-traverse.c

index 532a8ee5c8223a33d4d31dae27c993ec8275f261..f5b3b72a373e4dd17dafde6999c21bff88b08bfa 100644 (file)
@@ -1,10 +1,10 @@
 #include "config.h"
-#include "ntdb.h"
-#include "private.h"
+#include "../ntdb.h"
+#include "../private.h"
 #include "tap-interface.h"
 #include <ccan/hash/hash.h>
-
 #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)
index 730ade5afbb8d5366482ae484e4590a0f13ab7fc..44820ff1bbd714db307d3375bfa13c9a6cd33c52 100644 (file)
@@ -1,8 +1,9 @@
-#include "private.h" // For NTDB_TOPLEVEL_HASH_BITS
+#include "../private.h" // For NTDB_TOPLEVEL_HASH_BITS
 #include <ccan/hash/hash.h>
-#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)
index c40d9016cfbd71067f2dbb2b3b88da9d47dfcc1c..37f40b000bcb5a1dc2ae12e99ca4b9e41b5ba658 100644 (file)
@@ -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)
 {
index 4eea151e5d1bf68bfcca36056e41db25cc519082..fb70523f20b003a3f1f17a02e0a6ba35fb9ed262 100644 (file)
@@ -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)
 {
index 3df5003af78ac242b220ed80a431f1191a9537dd..1abdcf6a902d186b315df6c6041c4320f00636c4 100644 (file)
@@ -1,11 +1,12 @@
 #include "config.h"
-#include "ntdb.h"
-#include "private.h"
+#include "../ntdb.h"
+#include "../private.h"
 #include "tap-interface.h"
 #include <ccan/hash/hash.h>
 #include <assert.h>
 
 #include "logging.h"
+#include "helpapi-external-agent.h"
 
 static const struct ntdb_context *curr_ntdb;
 static const struct ntdb_file *curr_file;
index 5af9abe00fea77dab0155998097e345020a20bc8..a841a1a72c623ca0cc5b74a9801a0e1bec4deafa 100644 (file)
@@ -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)
 {
index 3d3e53998ea7d7956e1fe698a8493e12c3777796..21dd1c46ff26fced83bba85ec883bddc4f8a9989 100644 (file)
@@ -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 <stdlib.h>
 #include "logging.h"
+#include "helpapi-external-agent.h"
 
 int main(int argc, char *argv[])
 {
index 5e56dbc521bcfcc30618996a9b6e5fd24fb8d1ce..53a4ade63248b9b90232273df41272563149f151 100644 (file)
@@ -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 <stdlib.h>
 #include "logging.h"
+#include "helpapi-external-agent.h"
 
 int main(int argc, char *argv[])
 {
index ca520a9967d4155270800890f3fc7abfafa86384..0d37754e3c1adcb84a329f409bc4a9d7f27e365f 100644 (file)
@@ -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[])
 {
index 45963ff5a6fd39d94c97c74597184957a06505bf..33ced82c93b325b6ae322072568411efd1a89d20 100644 (file)
@@ -1,9 +1,10 @@
 #include "config.h"
-#include "ntdb.h"
-#include "private.h"
+#include "../ntdb.h"
+#include "../private.h"
 #include "tap-interface.h"
 #include <stdlib.h>
 #include "logging.h"
+#include "helpapi-external-agent.h"
 
 int main(int argc, char *argv[])
 {
index f71600c182b4478a7cb5d1a7d1007a10c6ec9292..3b7ba8c8a0544fe6b95ce7b824b74474cb67f462 100644 (file)
@@ -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 <errno.h>
 #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)
index d2930acf552916fab9d1edd6e8a6bd474e229640..cdd015a5fc7abd1c6cef397ee58c0b5f492aaa17 100644 (file)
@@ -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"
 
index 1041cba53b5a106db4d8377f5e1ea3b2ed210444..120b62edfd336a375c54642fc79578fba23ee09b 100644 (file)
@@ -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[])
 {
index c557f34cf990649534f613790b1f119a654126be..dda5acb944737dfadc27e2cceced5a518505fb3a 100644 (file)
@@ -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[])
 {
index 0fade08224fd0ced678282d7f5f077cf81d93b1b..437c0f855a4778c3e60888e00a2dc3a4e48eb0bf 100644 (file)
@@ -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
 
index 3aca88bd78bb54ca2cfe4d953e5f135b5994df02..39b199888bd373a2126b256bc5296de88be07a24 100644 (file)
@@ -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;
 
index 53adbc3ceb77d86ac45ac2e32c2465a214ab142e..0b0eb69fb97e755f72d5adba2d532772b8e08518 100644 (file)
@@ -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;
 
index c16ceeb2f6a3b8b18d360272182a68ac7b59c921..a09046e2badceb148c5063f9db699515cd742576 100644 (file)
@@ -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[])
 {
index 20c88e7175b78cea08b1809885bab9ef22a4990c..eaf60d483bf7e3007a95c9017b1e297df8a43a18 100644 (file)
@@ -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
 
index 179cf76c8e2c0fa540872019d164ab9bc593177c..6d9ad67ad9723d282a9fc5f2bbf4bd1b58cd52ae 100644 (file)
@@ -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
 
index 4b114d6f60b7ea9a495a54256256123b44aff482..32c6ebe4a0804358cfce66c1e382bf9fa1e685c4 100644 (file)
  * 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;
 
index 4c0fda28974bf1cd6c33a472e9999cf29f0fe810..235409b34765099787925c82400ff6b1b8b88ccb 100644 (file)
@@ -1,10 +1,11 @@
 #include "config.h"
-#include "ntdb.h"
-#include "private.h"
+#include "../ntdb.h"
+#include "../private.h"
 #include "tap-interface.h"
 #include <limits.h>
 #include "logging.h"
 #include "external-agent.h"
+#include "helpapi-external-agent.h"
 
 #undef alarm
 #define alarm fast_alarm
index 2a00f1b33e87692dca49c2196b99f57c51084750..a6427c074c5fa1c8d6c5a2da94e673e915805939 100644 (file)
@@ -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 <ccan/hash/hash.h>
 #include "tap-interface.h"
 #include "logging.h"
+#include "helpapi-external-agent.h"
 
 #define NUM_RECORDS 1189
 
index 6b97bc9718b1062aabc3d864ce1b4084d06ee253..59a0362981d17b21bb233cf3c8942b78f0436c60 100644 (file)
@@ -1,9 +1,10 @@
 #include "config.h"
-#include "ntdb.h"
+#include "../ntdb.h"
 #include "tap-interface.h"
 #include <stdlib.h>
 #include "logging.h"
 #include "../private.h"
+#include "helpapi-external-agent.h"
 
 int main(int argc, char *argv[])
 {
index 74fb27fc47b8883875bb07b1e85031dda7bee993..b92f13fef9fa7faffc636d80e17ca494f5ea68b7 100644 (file)
@@ -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
index e8baf4c51661ba8efb6696efbd16b652e6115c76..0b886c3a133350c658b90aa794942332a0da2e62 100644 (file)
@@ -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[])
 {
index af1b59581f8da29e5ba49250402755523aed57f2..7701f26a93b1f4264d6b4d4ad6c11db9f956932d 100644 (file)
@@ -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[])
 {
index 45b24512e9936ae8b01ba8b45e7947764cc94886..ab7e61b0d7ff9b32419479e8671a83bea4a07785 100644 (file)
@@ -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 (file)
index eb81399..0000000
+++ /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 (file)
index 0000000..eb81399
--- /dev/null
@@ -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 (file)
index 81a3fe8..0000000
+++ /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 (file)
index 0000000..1261041
--- /dev/null
@@ -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 (file)
index fa6fa29..0000000
+++ /dev/null
@@ -1,362 +0,0 @@
-/* NTDB tools to create various canned database layouts. */
-#include "layout.h"
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <ccan/err/err.h>
-#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 (file)
index 0000000..1bacd5e
--- /dev/null
@@ -0,0 +1,341 @@
+/* NTDB tools to create various canned database layouts. */
+#include "layout.h"
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <ccan/err/err.h>
+#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);
+}
index b4f6a960eb9639437dc6c0519b8975703c6fb8b9..ea84382cc30453cc0eb6aceee1fcf42ed2ea5c6d 100644 (file)
@@ -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 */
index 525a5c4ca7f6467d3138a6417786604a9c84e1b4..2d654e4b8a578e07090a7680cebece6303dc27c2 100644 (file)
@@ -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 <unistd.h>
 #include <fcntl.h>
 #include <stdarg.h>
index 0336ccaba3f77fab45f04195e44a24da2c234d3a..f8e1eb0ee0662e20b0444f2ed25ca99e862e412d 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef NTDB_TEST_LOGGING_H
 #define NTDB_TEST_LOGGING_H
-#include "ntdb.h"
+#include "../ntdb.h"
 #include <stdbool.h>
 #include <string.h>
 
index 52268440d24c5d1e649a75b288f54e0b3f9304f6..88e517eb09b1305b71d7d04ffb1e96dee614d13c 100644 (file)
@@ -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"
index b8a61bee8c592a7f1dfc33315215ee1495b058cc..81f3e17088d6b1717fe840fb74e713b40c4825bf 100644 (file)
@@ -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[])
 {
index ec61294c6f32b21db970503fb3d0356a1afa1b91..6ed46fe0a04907f58f419e0f9d28c8a9e0478599 100644 (file)
@@ -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)
 {
index ab69477b86f5740afbe4b41774bd0de892825818..11fb02481265352cd9f5721d74a1a9af33ec4a93 100644 (file)
@@ -4,6 +4,7 @@
 #include <ccan/failtest/failtest.h>
 #include "logging.h"
 #include "failtest_helper.h"
+#include "helprun-external-agent.h"
 
 int main(int argc, char *argv[])
 {
index e808989db459ed2d73bcd1597401a9c029a5ffa3..55927d9b2d674c7490431040dd47173e4a502ff6 100644 (file)
@@ -4,6 +4,7 @@
 #include <ccan/failtest/failtest.h>
 #include "logging.h"
 #include "failtest_helper.h"
+#include "helprun-external-agent.h"
 
 int main(int argc, char *argv[])
 {
index dc76e6a4ad3c37e504d8af4c0ddf7fc7782d9532..e86ee656778e99c0201c46c9b6ae6b6e70c78ee2 100644 (file)
@@ -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)
 {
index 9888f6e551db6511955b97cb6cc564afab73aa98..9936d85985f2b3b19290fd06a9c3b1185dcdf273 100644 (file)
@@ -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)
index 87caf9533fdda5d0e17ec6b8cdf16de37a625b1d..057fa0880b432f326545af28f71262c9e6479cbc 100644 (file)
@@ -4,6 +4,7 @@
 #include <ccan/failtest/failtest.h>
 #include "logging.h"
 #include "failtest_helper.h"
+#include "helprun-external-agent.h"
 
 int main(int argc, char *argv[])
 {
index 0add1f10fb588534fa3787e8d4337e2b084e13f0..d3f3b7fd80fffca7730833dff265265bdf8dce64 100644 (file)
@@ -4,6 +4,7 @@
 #include <ccan/failtest/failtest.h>
 #include "logging.h"
 #include "failtest_helper.h"
+#include "helprun-external-agent.h"
 
 int main(int argc, char *argv[])
 {
index 779a5ea14dac29c14cf64020654a98fce96b1bb5..fba7620236afb44407f9ac6f7000b1da6708853a 100644 (file)
@@ -4,6 +4,7 @@
 #include <ccan/failtest/failtest.h>
 #include "logging.h"
 #include "failtest_helper.h"
+#include "helprun-external-agent.h"
 
 int main(int argc, char *argv[])
 {
index 7211761f1896ea4bb43ca33821ced781ef5425c1..c2354cb5fcf9c235eb73ae4e6667a544acc6a83c 100644 (file)
@@ -1,10 +1,11 @@
-#include "private.h"
+#include "../private.h"
 #include <ccan/failtest/failtest_override.h>
 #include "ntdb-source.h"
 #include "tap-interface.h"
 #include <ccan/failtest/failtest.h>
 #include "logging.h"
 #include "failtest_helper.h"
+#include "helprun-external-agent.h"
 
 int main(int argc, char *argv[])
 {
index 05fa594b6b52c97937d5f490092f2ee5d3774214..fb8d7c2067e7496ae2ed3bae5771405073c1aa0e 100644 (file)
@@ -2,6 +2,7 @@
 #include "tap-interface.h"
 #include <ccan/ilog/ilog.h>
 #include "logging.h"
+#include "helprun-external-agent.h"
 
 #define MAX_SIZE 13100
 #define SIZE_STEP 131
index d82b3edb3d30129d14fec308b10996e4f69c2d2f..5a2c9cd7a2d25d02f76f1a4f10fb389beba57508 100644 (file)
@@ -1,6 +1,7 @@
 #include "ntdb-source.h"
 #include "tap-interface.h"
 #include "logging.h"
+#include "helprun-external-agent.h"
 
 #define OVERLOAD 100
 
index bcf1c1f665567b461edcc65ee4d4ceb71c3a7019..e44b32c8374e35670fd07173fe919b5feff6b9c0 100644 (file)
@@ -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)
 {
index 873d4e7781810debd6cc010794172a0b02d40258..4899dc6628f40f8846da892455d838d80592a3f1 100644 (file)
@@ -1,10 +1,11 @@
-#include "private.h"
+#include "../private.h"
 #include <ccan/failtest/failtest_override.h>
 #include "ntdb-source.h"
 #include "tap-interface.h"
 #include <ccan/failtest/failtest.h>
 #include "logging.h"
 #include "failtest_helper.h"
+#include "helprun-external-agent.h"
 
 int main(int argc, char *argv[])
 {
index 5496e3e0dd2a9e657ed71822cf07bf74c5c20710..4a7cf8992d6cb8b0cf962f2092b8c6351414ae2f 100644 (file)
@@ -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[])
 {
index 1c8786ce2f4f667de7561d9ab5f44d5cbd67e477..c28fbfd3fd77bb57a4aa2c42cbc7c56168ed2db9 100644 (file)
@@ -1,4 +1,4 @@
-#include "private.h"
+#include "../private.h"
 #include <unistd.h>
 #include "lock-tracking.h"
 
@@ -18,6 +18,7 @@ static int ftruncate_check(int fd, off_t length);
 #include <stdarg.h>
 #include "external-agent.h"
 #include "logging.h"
+#include "helprun-external-agent.h"
 
 static struct agent *agent;
 static bool opened;
index 32f781e4a89585f63765f65e51adf8e4b0af0fb5..9a86fca0521e232d67c8fb6f9ca767c474ea13d5 100644 (file)
@@ -1,4 +1,4 @@
-#include "private.h"
+#include "../private.h"
 #include <unistd.h>
 #include "lock-tracking.h"
 #include "tap-interface.h"
@@ -97,6 +97,7 @@ static void free_all(void)
 #include <setjmp.h>
 #include "external-agent.h"
 #include "logging.h"
+#include "helprun-external-agent.h"
 
 static bool in_transaction;
 static int target, current;
index 552866f8bad5fe0584dfdb1799bd459d5362717a..9fcc6c9bc207fef78c73feefa05bb6b65ab5ab32 100644 (file)
@@ -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)
index 5548aa4f7e0fbd53f2b27aecbb1ecf5036bda829..aafd46133464c6adce36317c17943645816abcc9 100644 (file)
@@ -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)
index f968393a1a70b453b08813e60c497110e40f4bfc..dc2df2abed1e1478cf842d6818f8a5fac47f8aad 100644 (file)
@@ -5,6 +5,7 @@
 #include "layout.h"
 #include "failtest_helper.h"
 #include <stdarg.h>
+#include "helprun-external-agent.h"
 
 static size_t len_of(bool breaks_check, bool breaks_write, bool breaks_open)
 {
index 07c7129f8c9159c5d50c12cd2bf5d2943ebda30f..20a28ee6f5b11556f74f35ebed6de25371f636e2 100644 (file)
@@ -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[])
 {
index a332572deb58764f7e230298eeda65434e6bcbf7..631ce87667187be8fbb9bdd33828fbdddb44d221 100644 (file)
@@ -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[])
 {
index 5ec448c982278a167817dcb01798e07f1895c2a9..a4cd1e47ba03276cebd67e87f59b28d1c1b6f17b 100644 (file)
@@ -1,4 +1,4 @@
-#include "private.h"
+#include "../private.h"
 #include <unistd.h>
 #include "lock-tracking.h"
 
@@ -11,6 +11,7 @@
 #include <stdarg.h>
 #include "external-agent.h"
 #include "logging.h"
+#include "helprun-external-agent.h"
 
 #define TEST_DBNAME "run-lockall.ntdb"
 #define KEY_STR "key"
index ee72c615379ccc1a8b649e38e117fae85df337b3..6fe537d4cd4b42496ee48af4109c495ed24e055a 100644 (file)
@@ -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)
 {
index 5d74dbc22e1e10405e5089a7cedd0d7a3f899105..5ca6678afa7764d2ce8e3df62884c727a360ee11 100644 (file)
@@ -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;
 
index 5b023140a7637da84d50575854b49155cd4973ec..499eb42e10cbe91e59e34c0a0e6784037c06ff1e 100644 (file)
@@ -1,5 +1,6 @@
 #include "ntdb-source.h"
 #include "tap-interface.h"
+#include "helprun-external-agent.h"
 
 int main(int argc, char *argv[])
 {
index 11eac5d0f255e0161bb8b0e49dc3f0eb1d54fa0e..532474b900649708e20862b369920f84d1bc116d 100644 (file)
@@ -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)
 {
index a326b9c5d55dd90a1c5c621f7d0b3f79ff16ef88..29b517dbec7a944476e584fae2147123f1ef8ce6 100644 (file)
@@ -1,6 +1,7 @@
 #include "ntdb-source.h"
 #include "tap-interface.h"
 #include "logging.h"
+#include "helprun-external-agent.h"
 
 #define NUM_RECORDS 1000