1 #include <ccan/tdb2/tdb.c>
2 #include <ccan/tdb2/open.c>
3 #include <ccan/tdb2/free.c>
4 #include <ccan/tdb2/lock.c>
5 #include <ccan/tdb2/io.c>
6 #include <ccan/tdb2/hash.c>
7 #include <ccan/tdb2/check.c>
8 #include <ccan/tdb2/transaction.c>
9 #include <ccan/tap/tap.h>
12 /* We use the same seed which we saw a failure on. */
13 static uint64_t fixedhash(const void *key, size_t len, uint64_t seed, void *p)
15 return hash64_stable((const unsigned char *)key, len,
19 int main(int argc, char *argv[])
22 struct tdb_context *tdb;
23 uint64_t seed = 16014841315512641303ULL;
24 union tdb_attribute fixed_hattr
25 = { .hash = { .base = { TDB_ATTRIBUTE_HASH },
28 int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
29 TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
30 TDB_NOMMAP|TDB_CONVERT };
31 struct tdb_data key = { (unsigned char *)&j, sizeof(j) };
32 struct tdb_data data = { (unsigned char *)&j, sizeof(j) };
34 fixed_hattr.base.next = &tap_log_attr;
36 plan_tests(sizeof(flags) / sizeof(flags[0]) * (1 + 500 * 3) + 1);
37 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
38 tdb = tdb_open("run-12-store.tdb", flags[i],
39 O_RDWR|O_CREAT|O_TRUNC, 0600, &fixed_hattr);
44 /* We seemed to lose some keys.
45 * Insert and check they're in there! */
46 for (j = 0; j < 500; j++) {
47 struct tdb_data d = { NULL, 0 }; /* Bogus GCC warning */
48 ok1(tdb_store(tdb, key, data, TDB_REPLACE) == 0);
49 ok1(tdb_fetch(tdb, key, &d) == TDB_SUCCESS);
50 ok1(tdb_deq(d, data));
56 ok1(tap_log_messages == 0);