tdb2: allow multiple chain locks.
[ccan] / ccan / tdb2 / test / run-01-new_database.c
1 #include <ccan/failtest/failtest_override.h>
2 #include <ccan/tdb2/tdb.c>
3 #include <ccan/tdb2/open.c>
4 #include <ccan/tdb2/free.c>
5 #include <ccan/tdb2/lock.c>
6 #include <ccan/tdb2/io.c>
7 #include <ccan/tdb2/hash.c>
8 #include <ccan/tdb2/transaction.c>
9 #include <ccan/tdb2/check.c>
10 #include <ccan/tap/tap.h>
11 #include <ccan/failtest/failtest.h>
12 #include "logging.h"
13 #include "failtest_helper.h"
14
15 int main(int argc, char *argv[])
16 {
17         unsigned int i;
18         struct tdb_context *tdb;
19         int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
20                         TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, 
21                         TDB_NOMMAP|TDB_CONVERT };
22
23         failtest_init(argc, argv);
24         failtest_hook = block_repeat_failures;
25         failtest_exit_check = exit_check_log;
26         plan_tests(sizeof(flags) / sizeof(flags[0]) * 3);
27         for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
28                 tdb = tdb_open("run-new_database.tdb", flags[i],
29                                O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
30                 if (!ok1(tdb))
31                         failtest_exit(exit_status());
32                 if (tdb) {
33                         bool ok = ok1(tdb_check(tdb, NULL, NULL) == 0);
34                         tdb_close(tdb);
35                         if (!ok)
36                                 failtest_exit(exit_status());
37                 }
38                 if (!ok1(tap_log_messages == 0))
39                         break;
40         }
41         failtest_exit(exit_status());
42 }