TDB2: make SAMBA use tdb1 again for the moment.
[metze/samba/wip.git] / lib / tdb2 / test / api-tdb1-flag-removal.c
1 #include "config.h"
2 #include "tdb2.h"
3 #include "tap-interface.h"
4 #include <ccan/hash/hash.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <fcntl.h>
8
9 #include "logging.h"
10
11 int main(int argc, char *argv[])
12 {
13         unsigned int i;
14         struct tdb_context *tdb;
15         int flags[] = { TDB_DEFAULT, TDB_NOMMAP,
16                         TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT };
17
18         plan_tests(sizeof(flags) / sizeof(flags[0]) * 3 + 1);
19         for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
20                 tdb = tdb_open("run-12-store.tdb", flags[i],
21                                O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
22                 if (!ok1(tdb))
23                         continue;
24
25                 tdb_close(tdb);
26
27                 tdb = tdb_open("run-12-store.tdb", flags[i] | TDB_VERSION1,
28                                O_RDWR, 0600, &tap_log_attr);
29                 if (!ok1(tdb))
30                         continue;
31                 /* It's not a version1 */
32                 ok1(!(tdb_get_flags(tdb) & TDB_VERSION1));
33
34                 tdb_close(tdb);
35         }
36
37         ok1(tap_log_messages == 0);
38         return exit_status();
39 }