1 #include <ccan/failtest/failtest_override.h>
2 #include "ntdb-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 ntdb_context
*ntdb
;
13 int flags
[] = { NTDB_INTERNAL
, NTDB_DEFAULT
, NTDB_NOMMAP
,
14 NTDB_INTERNAL
|NTDB_CONVERT
, NTDB_CONVERT
,
15 NTDB_NOMMAP
|NTDB_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 ntdb
= ntdb_open("run-expand.ntdb", flags
[i
]|MAYBE_NOSYNC
,
26 O_RDWR
|O_CREAT
|O_TRUNC
, 0600, &tap_log_attr
);
30 val
= ntdb
->file
->map_size
;
31 /* Need some hash lock for expand. */
32 ok1(ntdb_lock_hash(ntdb
, 0, F_WRLCK
) == 0);
33 failtest_suppress
= false;
34 if (!ok1(ntdb_expand(ntdb
, 1) == 0)) {
35 failtest_suppress
= true;
39 failtest_suppress
= true;
41 ok1(ntdb
->file
->map_size
>= val
+ 1 * NTDB_EXTENSION_FACTOR
);
42 ok1(ntdb_unlock_hash(ntdb
, 0, F_WRLCK
) == 0);
43 ok1(ntdb_check(ntdb
, NULL
, NULL
) == 0);
45 val
= ntdb
->file
->map_size
;
46 ok1(ntdb_lock_hash(ntdb
, 0, F_WRLCK
) == 0);
47 failtest_suppress
= false;
48 if (!ok1(ntdb_expand(ntdb
, 1024) == 0)) {
49 failtest_suppress
= true;
53 failtest_suppress
= true;
54 ok1(ntdb_unlock_hash(ntdb
, 0, F_WRLCK
) == 0);
55 ok1(ntdb
->file
->map_size
>= val
+ 1024 * NTDB_EXTENSION_FACTOR
);
56 ok1(ntdb_check(ntdb
, NULL
, NULL
) == 0);
60 ok1(tap_log_messages
== 0);
61 failtest_exit(exit_status());