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