]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/test/run-expand.c
tdb2: tdb_expand on empty database now tested.
[ccan] / ccan / tdb2 / test / run-expand.c
diff --git a/ccan/tdb2/test/run-expand.c b/ccan/tdb2/test/run-expand.c
new file mode 100644 (file)
index 0000000..92dbf18
--- /dev/null
@@ -0,0 +1,30 @@
+#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 <ccan/tap/tap.h>
+#include "logging.h"
+
+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 };
+
+       plan_tests(sizeof(flags) / sizeof(flags[0]) * 3 + 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;
+               ok1(tdb);
+               if (tdb) {
+                       ok1(tdb_expand(tdb, 1, 1, false) == 0);
+                       ok1(tdb_check(tdb, NULL, NULL) == 0);
+                       tdb_close(tdb);
+               }
+       }
+       ok1(tap_log_messages == 0);
+       return exit_status();
+}