1 #include "../private.h"
2 #include <ccan/failtest/failtest_override.h>
3 #include "ntdb-source.h"
4 #include "tap-interface.h"
5 #include <ccan/failtest/failtest.h>
7 #include "failtest_helper.h"
8 #include "helprun-external-agent.h"
10 int main(int argc, char *argv[])
12 unsigned int i, messages = 0;
13 struct ntdb_context *ntdb;
14 int flags[] = { NTDB_DEFAULT, NTDB_NOMMAP,
15 NTDB_CONVERT, NTDB_NOMMAP|NTDB_CONVERT };
17 failtest_init(argc, argv);
18 failtest_hook = block_repeat_failures;
19 failtest_exit_check = exit_check_log;
20 plan_tests(sizeof(flags) / sizeof(flags[0]) * 4);
21 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
22 ntdb = ntdb_open("run-35-convert.ntdb", flags[i]|MAYBE_NOSYNC,
23 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
25 failtest_exit(exit_status());
28 /* We can fail in log message formatting or open. That's OK */
29 if (failtest_has_failed()) {
30 failtest_exit(exit_status());
32 /* If we say NTDB_CONVERT, it must be converted */
33 ntdb = ntdb_open("run-35-convert.ntdb",
34 flags[i]|NTDB_CONVERT|MAYBE_NOSYNC,
35 O_RDWR, 0600, &tap_log_attr);
36 if (flags[i] & NTDB_CONVERT) {
38 failtest_exit(exit_status());
39 ok1(ntdb_get_flags(ntdb) & NTDB_CONVERT);
42 if (!ok1(!ntdb && errno == EIO))
43 failtest_exit(exit_status());
44 ok1(tap_log_messages == ++messages);
45 if (!ok1(log_last && strstr(log_last, "NTDB_CONVERT")))
46 failtest_exit(exit_status());
49 /* If don't say NTDB_CONVERT, it *may* be converted */
50 ntdb = ntdb_open("run-35-convert.ntdb",
51 (flags[i] & ~NTDB_CONVERT)|MAYBE_NOSYNC,
52 O_RDWR, 0600, &tap_log_attr);
54 failtest_exit(exit_status());
55 ok1(ntdb_get_flags(ntdb) == (flags[i]|MAYBE_NOSYNC));
58 failtest_exit(exit_status());
61 * We will never reach this but the compiler complains if we do not
62 * return in this function.