1 #include "private.h" // for ntdb_context
3 #include "tap-interface.h"
6 int main(int argc
, char *argv
[])
9 struct ntdb_context
*ntdb
;
10 int flags
[] = { NTDB_INTERNAL
, NTDB_DEFAULT
, NTDB_NOMMAP
,
11 NTDB_INTERNAL
|NTDB_CONVERT
, NTDB_CONVERT
,
12 NTDB_NOMMAP
|NTDB_CONVERT
};
15 for (i
= 0; i
< sizeof(flags
) / sizeof(flags
[0]); i
++) {
16 ntdb
= ntdb_open("run-add-remove-flags.ntdb",
17 flags
[i
]|MAYBE_NOSYNC
,
18 O_RDWR
|O_CREAT
|O_TRUNC
, 0600, &tap_log_attr
);
23 ok1(ntdb_get_flags(ntdb
) == ntdb
->flags
);
25 ntdb_add_flag(ntdb
, NTDB_NOLOCK
);
26 if (flags
[i
] & NTDB_INTERNAL
)
27 ok1(tap_log_messages
== 1);
29 ok1(tap_log_messages
== 0);
30 ok1(ntdb_get_flags(ntdb
) & NTDB_NOLOCK
);
34 ntdb_add_flag(ntdb
, NTDB_NOMMAP
);
35 if (flags
[i
] & NTDB_INTERNAL
)
36 ok1(tap_log_messages
== 1);
38 ok1(tap_log_messages
== 0);
39 ok1(ntdb_get_flags(ntdb
) & NTDB_NOMMAP
);
40 ok1(ntdb
->file
->map_ptr
== NULL
);
44 ntdb_add_flag(ntdb
, NTDB_NOSYNC
);
45 if (flags
[i
] & NTDB_INTERNAL
)
46 ok1(tap_log_messages
== 1);
48 ok1(tap_log_messages
== 0);
49 ok1(ntdb_get_flags(ntdb
) & NTDB_NOSYNC
);
52 ok1(ntdb_get_flags(ntdb
) == ntdb
->flags
);
55 ntdb_remove_flag(ntdb
, NTDB_NOLOCK
);
56 if (flags
[i
] & NTDB_INTERNAL
)
57 ok1(tap_log_messages
== 1);
59 ok1(tap_log_messages
== 0);
60 ok1(!(ntdb_get_flags(ntdb
) & NTDB_NOLOCK
));
64 ntdb_remove_flag(ntdb
, NTDB_NOMMAP
);
65 if (flags
[i
] & NTDB_INTERNAL
)
66 ok1(tap_log_messages
== 1);
68 ok1(tap_log_messages
== 0);
69 ok1(!(ntdb_get_flags(ntdb
) & NTDB_NOMMAP
));
70 ok1(ntdb
->file
->map_ptr
!= NULL
);
74 ntdb_remove_flag(ntdb
, NTDB_NOSYNC
);
75 if (flags
[i
] & NTDB_INTERNAL
)
76 ok1(tap_log_messages
== 1);
78 ok1(tap_log_messages
== 0);
79 ok1(!(ntdb_get_flags(ntdb
) & NTDB_NOSYNC
));
85 ok1(tap_log_messages
== 0);