tdb2: more tests, hash collision fixes, attribute support.
[ccan] / ccan / tdb2 / test / run-enlarge_hash.c
1 #include <ccan/tdb2/tdb.c>
2 #include <ccan/tdb2/free.c>
3 #include <ccan/tdb2/lock.c>
4 #include <ccan/tdb2/io.c>
5 #include <ccan/tdb2/check.c>
6 #include <ccan/tap/tap.h>
7 #include "logging.h"
8
9 int main(int argc, char *argv[])
10 {
11         unsigned int i;
12         struct tdb_context *tdb;
13         int flags[] = { TDB_INTERNAL, TDB_DEFAULT,
14                         TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT };
15
16         plan_tests(sizeof(flags) / sizeof(flags[0]) * 2 + 1);
17         for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
18                 tdb = tdb_open("run-enlarge-hash.tdb", flags[i],
19                                O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
20                 ok1(tdb);
21                 if (tdb) {
22                         enlarge_hash(tdb);
23                         ok1(tdb_check(tdb, NULL, NULL) == 0);
24                         tdb_close(tdb);
25                 }
26                 /* FIXME: Test enlarging with hash clash. */
27         }
28         ok1(tap_log_messages == 0);
29         return exit_status();
30 }