]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb/test/run-corrupt.c
tdb: put example hashes into header, so we notice incorrect hash_fn.
[ccan] / ccan / tdb / test / run-corrupt.c
index eaa326bdd0e70274ce14fec0804feb5ae133100e..bea7dbcdf490218e4cd8ab0a4983246f6fb8be13 100644 (file)
@@ -12,6 +12,7 @@
 #include <ccan/tap/tap.h>
 #include <stdlib.h>
 #include <err.h>
+#include "logging.h"
 
 static int check(TDB_DATA key, TDB_DATA data, void *private)
 {
@@ -72,7 +73,8 @@ static void check_test(struct tdb_context *tdb)
        /* This is how many bytes we expect to be verifiable. */
        /* From the file header. */
        verifiable = strlen(TDB_MAGIC_FOOD) + 1
-               + 2 * sizeof(uint32_t) + 2 * sizeof(tdb_off_t);
+               + 2 * sizeof(uint32_t) + 2 * sizeof(tdb_off_t)
+               + 2 * sizeof(uint32_t);
        /* From the free list chain and hash chains. */
        verifiable += 3 * sizeof(tdb_off_t);
        /* From the record headers & tailer */
@@ -103,8 +105,8 @@ int main(int argc, char *argv[])
 
        plan_tests(4);
        /* This should use mmap. */
-       tdb = tdb_open("/tmp/test6.tdb", 2, TDB_CLEAR_IF_FIRST,
-                      O_CREAT|O_TRUNC|O_RDWR, 0600);
+       tdb = tdb_open_ex("run-corrupt.tdb", 2, TDB_CLEAR_IF_FIRST,
+                         O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
 
        if (!tdb)
                abort();
@@ -112,8 +114,8 @@ int main(int argc, char *argv[])
        tdb_close(tdb);
 
        /* This should not. */
-       tdb = tdb_open("/tmp/test6.tdb", 2, TDB_CLEAR_IF_FIRST|TDB_NOMMAP,
-                      O_CREAT|O_TRUNC|O_RDWR, 0600);
+       tdb = tdb_open_ex("run-corrupt.tdb", 2, TDB_CLEAR_IF_FIRST|TDB_NOMMAP,
+                         O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
 
        if (!tdb)
                abort();