tdb2: clean up logging
[ccan] / ccan / tdb2 / test / run-traverse.c
index 51d84a0a7afaa6a2554069e379e658995d53a77e..e6d102855a34fd68f1c72f497e3c15b3152de514 100644 (file)
@@ -2,8 +2,10 @@
 #include <ccan/tdb2/free.c>
 #include <ccan/tdb2/lock.c>
 #include <ccan/tdb2/io.c>
+#include <ccan/tdb2/hash.c>
 #include <ccan/tdb2/check.c>
 #include <ccan/tdb2/traverse.c>
+#include <ccan/tdb2/transaction.c>
 #include <ccan/tap/tap.h>
 #include "logging.h"
 
@@ -54,6 +56,7 @@ static int trav(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, void *p)
                td->high = val;
 
        if (td->delete) {
+
                if (tdb_delete(tdb, key) != 0) {
                        td->delete_error = tdb_error(tdb);
                        return -1;
@@ -117,7 +120,7 @@ int main(int argc, char *argv[])
 
        hattr.base.next = &tap_log_attr;
 
-       plan_tests(sizeof(flags) / sizeof(flags[0]) * 50 + 1);
+       plan_tests(sizeof(flags) / sizeof(flags[0]) * 53 + 1);
        for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
                tdb = tdb_open("run-traverse.tdb", flags[i],
                               O_RDWR|O_CREAT|O_TRUNC, 0600, &hattr);
@@ -179,6 +182,7 @@ int main(int argc, char *argv[])
                ok1(td.low <= NUM_RECORDS / 2);
                ok1(td.high > NUM_RECORDS / 2);
                ok1(tdb_check(tdb, NULL, NULL) == 0);
+               ok1(tap_log_messages == 0);
 
                /* Growing traverse.  Expect failure on r/o traverse. */
                tgd.calls = 0;
@@ -190,6 +194,8 @@ int main(int argc, char *argv[])
                ok1(tgd.error == TDB_ERR_RDONLY);
                ok1(tgd.calls == 1);
                ok1(!tgd.mismatch);
+               ok1(tap_log_messages == 1);
+               tap_log_messages = 0;
                ok1(tdb_check(tdb, NULL, NULL) == 0);
 
                /* Deleting traverse.  Expect failure on r/o traverse. */
@@ -206,9 +212,11 @@ int main(int argc, char *argv[])
                ok1(!td.mismatch);
                ok1(td.calls == 1);
                ok1(td.low == td.high);
+               ok1(tap_log_messages == 1);
+               tap_log_messages = 0;
                ok1(tdb_check(tdb, NULL, NULL) == 0);
 
-               /* Deleting traverse. */
+               /* Deleting traverse (delete everything). */
                td.calls = 0;
                td.call_limit = UINT_MAX;
                td.low = INT_MAX;
@@ -222,7 +230,7 @@ int main(int argc, char *argv[])
                ok1(!td.mismatch);
                ok1(td.calls == NUM_RECORDS);
                ok1(td.low == 0);
-               ok1(td.high == NUM_RECORDS-1);
+               ok1(td.high == NUM_RECORDS - 1);
                ok1(tdb_check(tdb, NULL, NULL) == 0);
 
                /* Now it's empty! */