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"
9 int main(int argc
, char *argv
[])
11 unsigned int i
, messages
= 0;
12 struct ntdb_context
*ntdb
;
13 int flags
[] = { NTDB_DEFAULT
, NTDB_NOMMAP
,
14 NTDB_CONVERT
, NTDB_NOMMAP
|NTDB_CONVERT
};
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]) * 4);
20 for (i
= 0; i
< sizeof(flags
) / sizeof(flags
[0]); i
++) {
21 ntdb
= ntdb_open("run-35-convert.ntdb", flags
[i
],
22 O_RDWR
|O_CREAT
|O_TRUNC
, 0600, &tap_log_attr
);
24 failtest_exit(exit_status());
27 /* We can fail in log message formatting or open. That's OK */
28 if (failtest_has_failed()) {
29 failtest_exit(exit_status());
31 /* If we say NTDB_CONVERT, it must be converted */
32 ntdb
= ntdb_open("run-35-convert.ntdb",
33 flags
[i
]|NTDB_CONVERT
,
34 O_RDWR
, 0600, &tap_log_attr
);
35 if (flags
[i
] & NTDB_CONVERT
) {
37 failtest_exit(exit_status());
38 ok1(ntdb_get_flags(ntdb
) & NTDB_CONVERT
);
41 if (!ok1(!ntdb
&& errno
== EIO
))
42 failtest_exit(exit_status());
43 ok1(tap_log_messages
== ++messages
);
44 if (!ok1(log_last
&& strstr(log_last
, "NTDB_CONVERT")))
45 failtest_exit(exit_status());
48 /* If don't say NTDB_CONVERT, it *may* be converted */
49 ntdb
= ntdb_open("run-35-convert.ntdb",
50 flags
[i
] & ~NTDB_CONVERT
,
51 O_RDWR
, 0600, &tap_log_attr
);
53 failtest_exit(exit_status());
54 ok1(ntdb_get_flags(ntdb
) == flags
[i
]);
57 failtest_exit(exit_status());