s3:net registry: fix violation of coding conventions
[Samba.git] / lib / ntdb / test / run-02-expand.c
blob635bf8920655a7aed903155581bb16493ffb72de
1 #include <ccan/failtest/failtest_override.h>
2 #include "ntdb-source.h"
3 #include "tap-interface.h"
4 #include <ccan/failtest/failtest.h>
5 #include "logging.h"
6 #include "failtest_helper.h"
8 int main(int argc, char *argv[])
10 unsigned int i;
11 uint64_t val;
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);
27 if (!ok1(ntdb))
28 break;
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;
36 ntdb_close(ntdb);
37 break;
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;
50 ntdb_close(ntdb);
51 break;
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);
57 ntdb_close(ntdb);
60 ok1(tap_log_messages == 0);
61 failtest_exit(exit_status());