tdb2: test: try (almost) all tests with TDB_VERSION1 flag.
[ccan] / ccan / tdb2 / test / run-80-tdb_fd.c
1 #include "tdb2-source.h"
2 #include <ccan/tap/tap.h>
3 #include "logging.h"
4
5 int main(int argc, char *argv[])
6 {
7         unsigned int i;
8         struct tdb_context *tdb;
9         int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
10                         TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, 
11                         TDB_NOMMAP|TDB_CONVERT,
12                         TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1,
13                         TDB_NOMMAP|TDB_VERSION1,
14                         TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1,
15                         TDB_CONVERT|TDB_VERSION1,
16                         TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 };
17
18         plan_tests(sizeof(flags) / sizeof(flags[0]) * 3);
19         for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
20                 tdb = tdb_open("run-new_database.tdb", flags[i],
21                                O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
22                 if (!ok1(tdb))
23                         continue;
24
25                 if (flags[i] & TDB_INTERNAL)
26                         ok1(tdb_fd(tdb) == -1);
27                 else
28                         ok1(tdb_fd(tdb) > 2);
29                 tdb_close(tdb);
30                 ok1(tap_log_messages == 0);
31         }
32         return exit_status();
33 }