1 #include <ccan/tdb2/private.h>
2 #include <ccan/failtest/failtest_override.h>
3 #include "tdb2-source.h"
4 #include <ccan/tap/tap.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 tdb_context
*tdb
;
13 int flags
[] = { TDB_DEFAULT
, TDB_NOMMAP
,
14 TDB_CONVERT
, TDB_NOMMAP
|TDB_CONVERT
,
15 TDB_VERSION1
, TDB_NOMMAP
|TDB_VERSION1
,
16 TDB_CONVERT
|TDB_VERSION1
,
17 TDB_NOMMAP
|TDB_CONVERT
|TDB_VERSION1
};
19 failtest_init(argc
, argv
);
20 failtest_hook
= block_repeat_failures
;
21 failtest_exit_check
= exit_check_log
;
22 plan_tests(sizeof(flags
) / sizeof(flags
[0]) * 4);
23 for (i
= 0; i
< sizeof(flags
) / sizeof(flags
[0]); i
++) {
24 tdb
= tdb_open("run-35-convert.tdb", flags
[i
],
25 O_RDWR
|O_CREAT
|O_TRUNC
, 0600, &tap_log_attr
);
27 failtest_exit(exit_status());
30 /* If we say TDB_CONVERT, it must be converted */
31 tdb
= tdb_open("run-35-convert.tdb",
33 O_RDWR
, 0600, &tap_log_attr
);
34 if (flags
[i
] & TDB_CONVERT
) {
36 failtest_exit(exit_status());
37 ok1(tdb_get_flags(tdb
) & TDB_CONVERT
);
40 if (!ok1(!tdb
&& errno
== EIO
))
41 failtest_exit(exit_status());
42 ok1(tap_log_messages
== ++messages
);
43 if (!ok1(log_last
&& strstr(log_last
, "TDB_CONVERT")))
44 failtest_exit(exit_status());
47 /* If don't say TDB_CONVERT, it *may* be converted */
48 tdb
= tdb_open("run-35-convert.tdb",
49 flags
[i
] & ~TDB_CONVERT
,
50 O_RDWR
, 0600, &tap_log_attr
);
52 failtest_exit(exit_status());
53 ok1(tdb_get_flags(tdb
) == flags
[i
]);
56 failtest_exit(exit_status());