wintest: add option to select the dns backend
[Samba/gebeck_regimport.git] / lib / ntdb / test / run-35-convert.c
blob5b8099c4487d420638df4bef5be510758f6ebfa8
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>
6 #include "logging.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);
23 if (!ok1(ntdb))
24 failtest_exit(exit_status());
26 ntdb_close(ntdb);
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) {
36 if (!ntdb)
37 failtest_exit(exit_status());
38 ok1(ntdb_get_flags(ntdb) & NTDB_CONVERT);
39 ntdb_close(ntdb);
40 } else {
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);
52 if (!ntdb)
53 failtest_exit(exit_status());
54 ok1(ntdb_get_flags(ntdb) == flags[i]);
55 ntdb_close(ntdb);
57 failtest_exit(exit_status());