]> git.ozlabs.org Git - ccan/blob - ccan/tdb2/test/run-01-new_database.c
htable: fix bug where first entry has hash of 0 or 1.
[ccan] / ccan / tdb2 / test / run-01-new_database.c
1 #include <ccan/failtest/failtest_override.h>
2 #include "tdb2-source.h"
3 #include <ccan/tap/tap.h>
4 #include <ccan/failtest/failtest.h>
5 #include "logging.h"
6 #include "failtest_helper.h"
7
8 int main(int argc, char *argv[])
9 {
10         unsigned int i;
11         struct tdb_context *tdb;
12         int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
13                         TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, 
14                         TDB_NOMMAP|TDB_CONVERT,
15                         TDB_INTERNAL|TDB_VERSION1, TDB_VERSION1,
16                         TDB_NOMMAP|TDB_VERSION1,
17                         TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1,
18                         TDB_CONVERT|TDB_VERSION1,
19                         TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 };
20
21         failtest_init(argc, argv);
22         failtest_hook = block_repeat_failures;
23         failtest_exit_check = exit_check_log;
24         plan_tests(sizeof(flags) / sizeof(flags[0]) * 3);
25         for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
26                 tdb = tdb_open("run-new_database.tdb", flags[i],
27                                O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
28                 if (!ok1(tdb))
29                         failtest_exit(exit_status());
30
31                 failtest_suppress = true;
32                 ok1(tdb_check(tdb, NULL, NULL) == 0);
33                 failtest_suppress = false;
34                 tdb_close(tdb);
35                 if (!ok1(tap_log_messages == 0))
36                         break;
37         }
38         failtest_exit(exit_status());
39 }