1 #include <ccan/failtest/failtest_override.h>
2 #include "tdb2-source.h"
3 #include "tap-interface.h"
4 #include <ccan/failtest/failtest.h>
6 #include "failtest_helper.h"
8 int main(int argc
, char *argv
[])
12 struct tdb_context
*tdb
;
13 int flags
[] = { TDB_INTERNAL
, TDB_DEFAULT
, TDB_NOMMAP
,
14 TDB_INTERNAL
|TDB_CONVERT
, TDB_CONVERT
,
15 TDB_NOMMAP
|TDB_CONVERT
};
17 plan_tests(sizeof(flags
) / sizeof(flags
[0]) * 11 + 1);
19 failtest_init(argc
, argv
);
20 failtest_hook
= block_repeat_failures
;
21 failtest_exit_check
= exit_check_log
;
23 for (i
= 0; i
< sizeof(flags
) / sizeof(flags
[0]); i
++) {
24 failtest_suppress
= true;
25 tdb
= tdb_open("run-expand.tdb", flags
[i
],
26 O_RDWR
|O_CREAT
|O_TRUNC
, 0600, &tap_log_attr
);
30 val
= tdb
->file
->map_size
;
31 /* Need some hash lock for expand. */
32 ok1(tdb_lock_hashes(tdb
, 0, 1, F_WRLCK
, TDB_LOCK_WAIT
) == 0);
33 failtest_suppress
= false;
34 if (!ok1(tdb_expand(tdb
, 1) == 0)) {
35 failtest_suppress
= true;
39 failtest_suppress
= true;
41 ok1(tdb
->file
->map_size
>= val
+ 1 * TDB_EXTENSION_FACTOR
);
42 ok1(tdb_unlock_hashes(tdb
, 0, 1, F_WRLCK
) == 0);
43 ok1(tdb_check(tdb
, NULL
, NULL
) == 0);
45 val
= tdb
->file
->map_size
;
46 ok1(tdb_lock_hashes(tdb
, 0, 1, F_WRLCK
, TDB_LOCK_WAIT
) == 0);
47 failtest_suppress
= false;
48 if (!ok1(tdb_expand(tdb
, 1024) == 0)) {
49 failtest_suppress
= true;
53 failtest_suppress
= true;
54 ok1(tdb_unlock_hashes(tdb
, 0, 1, F_WRLCK
) == 0);
55 ok1(tdb
->file
->map_size
>= val
+ 1024 * TDB_EXTENSION_FACTOR
);
56 ok1(tdb_check(tdb
, NULL
, NULL
) == 0);
60 ok1(tap_log_messages
== 0);
61 failtest_exit(exit_status());