]> git.ozlabs.org Git - ccan/blob - ccan/ntdb/test/run-01-new_database.c
ab69477b86f5740afbe4b41774bd0de892825818
[ccan] / ccan / ntdb / test / run-01-new_database.c
1 #include <ccan/failtest/failtest_override.h>
2 #include "ntdb-source.h"
3 #include "tap-interface.h"
4 #include <ccan/failtest/failtest.h>
5 #include "logging.h"
6 #include "failtest_helper.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         failtest_init(argc, argv);
17         failtest_hook = block_repeat_failures;
18         failtest_exit_check = exit_check_log;
19         plan_tests(sizeof(flags) / sizeof(flags[0]) * 3);
20         for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
21                 ntdb = ntdb_open("run-new_database.ntdb", flags[i]|MAYBE_NOSYNC,
22                                  O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
23                 if (!ok1(ntdb))
24                         failtest_exit(exit_status());
25
26                 failtest_suppress = true;
27                 ok1(ntdb_check(ntdb, NULL, NULL) == 0);
28                 failtest_suppress = false;
29                 ntdb_close(ntdb);
30                 if (!ok1(tap_log_messages == 0))
31                         break;
32         }
33         failtest_exit(exit_status());
34
35         /*
36          * We will never reach this but the compiler complains if we do not
37          * return in this function.
38          */
39         return EFAULT;
40 }