Merge branch 'ntdb' of https://github.com/ddiss/ccan into ddiss-ntdb
[ccan] / ccan / ntdb / test / api-80-tdb_fd.c
1 #include "config.h"
2 #include "ntdb.h"
3 #include "private.h"
4 #include "tap-interface.h"
5 #include "logging.h"
6
7 int main(int argc, char *argv[])
8 {
9         unsigned int i;
10         struct ntdb_context *ntdb;
11         int flags[] = { NTDB_INTERNAL, NTDB_DEFAULT, NTDB_NOMMAP,
12                         NTDB_INTERNAL|NTDB_CONVERT, NTDB_CONVERT,
13                         NTDB_NOMMAP|NTDB_CONVERT };
14
15         plan_tests(sizeof(flags) / sizeof(flags[0]) * 3);
16         for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
17                 ntdb = ntdb_open("api-80-ntdb_fd.ntdb", flags[i]|MAYBE_NOSYNC,
18                                O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
19                 if (!ok1(ntdb))
20                         continue;
21
22                 if (flags[i] & NTDB_INTERNAL)
23                         ok1(ntdb_fd(ntdb) == -1);
24                 else
25                         ok1(ntdb_fd(ntdb) > 2);
26                 ntdb_close(ntdb);
27                 ok1(tap_log_messages == 0);
28         }
29         return exit_status();
30 }