lib/tdb2: adapt unit tests to SAMBA environment.
[ira/tdb.git] / lib / tdb2 / test / api-80-tdb_fd.c
1 #include "config.h"
2 #include "tdb2.h"
3 #include "tap-interface.h"
4 #include <sys/types.h>
5 #include <sys/stat.h>
6 #include <fcntl.h>
7 #include "logging.h"
8
9 int main(int argc, char *argv[])
10 {
11         unsigned int i;
12         struct tdb_context *tdb;
13         int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
14                         TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
15                         TDB_NOMMAP|TDB_CONVERT,
16                         TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1,
17                         TDB_NOMMAP|TDB_VERSION1,
18                         TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1,
19                         TDB_CONVERT|TDB_VERSION1,
20                         TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 };
21
22         plan_tests(sizeof(flags) / sizeof(flags[0]) * 3);
23         for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
24                 tdb = tdb_open("api-80-tdb_fd.tdb", flags[i],
25                                O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
26                 if (!ok1(tdb))
27                         continue;
28
29                 if (flags[i] & TDB_INTERNAL)
30                         ok1(tdb_fd(tdb) == -1);
31                 else
32                         ok1(tdb_fd(tdb) > 2);
33                 tdb_close(tdb);
34                 ok1(tap_log_messages == 0);
35         }
36         return exit_status();
37 }