tdb2: test: fix run-57-die-during-transaction.c to be more efficient.
[ccan] / ccan / tdb2 / test / run-record-expand.c
index 53befc1d06fb4628dab04a5892cb43f589c1b5aa..2cde873956398f80b23069bf27334ce086b06d8e 100644 (file)
@@ -1,8 +1,4 @@
-#include <ccan/tdb2/tdb.c>
-#include <ccan/tdb2/free.c>
-#include <ccan/tdb2/lock.c>
-#include <ccan/tdb2/io.c>
-#include <ccan/tdb2/check.c>
+#include "tdb2-source.h"
 #include <ccan/tap/tap.h>
 #include "logging.h"
 
@@ -13,9 +9,15 @@ int main(int argc, char *argv[])
 {
        unsigned int i;
        struct tdb_context *tdb;
-       int flags[] = { TDB_INTERNAL, TDB_DEFAULT,
-                       TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT };
-       struct tdb_data key = { (unsigned char *)"key", 3 };
+       int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
+                       TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, 
+                       TDB_NOMMAP|TDB_CONVERT,
+                       TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1,
+                       TDB_NOMMAP|TDB_VERSION1,
+                       TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1,
+                       TDB_CONVERT|TDB_VERSION1,
+                       TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 };
+       struct tdb_data key = tdb_mkdata("key", 3);
        struct tdb_data data;
 
        data.dptr = malloc(MAX_SIZE);
@@ -24,9 +26,8 @@ int main(int argc, char *argv[])
        plan_tests(sizeof(flags) / sizeof(flags[0])
                   * (3 + (1 + (MAX_SIZE/SIZE_STEP)) * 2) + 1);
        for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
-               tdb = tdb_open("/tmp/run-new_database.tdb", flags[i],
-                              O_RDWR|O_CREAT|O_TRUNC, 0600, NULL);
-               tdb->log = tap_log_fn;
+               tdb = tdb_open("run-record-expand.tdb", flags[i],
+                              O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
                ok1(tdb);
                if (!tdb)
                        continue;
@@ -44,5 +45,7 @@ int main(int argc, char *argv[])
                tdb_close(tdb);
        }
        ok1(tap_log_messages == 0);
+       free(data.dptr);
+
        return exit_status();
 }