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"
7 #include "helprun-external-agent.h"
9 int main(int argc, char *argv[])
13 struct ntdb_context *ntdb;
14 int flags[] = { NTDB_INTERNAL, NTDB_DEFAULT, NTDB_NOMMAP,
15 NTDB_INTERNAL|NTDB_CONVERT, NTDB_CONVERT,
16 NTDB_NOMMAP|NTDB_CONVERT };
18 plan_tests(sizeof(flags) / sizeof(flags[0]) * 11 + 1);
20 failtest_init(argc, argv);
21 failtest_hook = block_repeat_failures;
22 failtest_exit_check = exit_check_log;
24 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
25 failtest_suppress = true;
26 ntdb = ntdb_open("run-expand.ntdb", flags[i]|MAYBE_NOSYNC,
27 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
31 val = ntdb->file->map_size;
32 /* Need some hash lock for expand. */
33 ok1(ntdb_lock_hash(ntdb, 0, F_WRLCK) == 0);
34 failtest_suppress = false;
35 if (!ok1(ntdb_expand(ntdb, 1) == 0)) {
36 failtest_suppress = true;
40 failtest_suppress = true;
42 ok1(ntdb->file->map_size >= val + 1 * NTDB_EXTENSION_FACTOR);
43 ok1(ntdb_unlock_hash(ntdb, 0, F_WRLCK) == 0);
44 ok1(ntdb_check(ntdb, NULL, NULL) == 0);
46 val = ntdb->file->map_size;
47 ok1(ntdb_lock_hash(ntdb, 0, F_WRLCK) == 0);
48 failtest_suppress = false;
49 if (!ok1(ntdb_expand(ntdb, 1024) == 0)) {
50 failtest_suppress = true;
54 failtest_suppress = true;
55 ok1(ntdb_unlock_hash(ntdb, 0, F_WRLCK) == 0);
56 ok1(ntdb->file->map_size >= val + 1024 * NTDB_EXTENSION_FACTOR);
57 ok1(ntdb_check(ntdb, NULL, NULL) == 0);
61 ok1(tap_log_messages == 0);
62 failtest_exit(exit_status());
65 * We will never reach this but the compiler complains if we do not
66 * return in this function.