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