ntdb: fix up tests.
[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 #include "helpapi-external-agent.h"
7
8 int main(int argc, char *argv[])
9 {
10         unsigned int i;
11         struct ntdb_context *ntdb;
12         int flags[] = { NTDB_INTERNAL, NTDB_DEFAULT, NTDB_NOMMAP,
13                         NTDB_INTERNAL|NTDB_CONVERT, NTDB_CONVERT,
14                         NTDB_NOMMAP|NTDB_CONVERT };
15
16         plan_tests(sizeof(flags) / sizeof(flags[0]) * 3);
17         for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
18                 ntdb = ntdb_open("api-80-ntdb_fd.ntdb", flags[i]|MAYBE_NOSYNC,
19                                O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
20                 if (!ok1(ntdb))
21                         continue;
22
23                 if (flags[i] & NTDB_INTERNAL)
24                         ok1(ntdb_fd(ntdb) == -1);
25                 else
26                         ok1(ntdb_fd(ntdb) > 2);
27                 ntdb_close(ntdb);
28                 ok1(tap_log_messages == 0);
29         }
30         return exit_status();
31 }