s3:include: remove typedef user_struct
[Samba/gebeck_regimport.git] / lib / tdb2 / test / api-missing-entries.c
blobc81839bc054df055bd61017821ecb7f59d2c6c74
1 /* Another test revealed that we lost an entry. This reproduces it. */
2 #include "config.h"
3 #include "tdb2.h"
4 #include <ccan/hash/hash.h>
5 #include "tap-interface.h"
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9 #include "logging.h"
11 #define NUM_RECORDS 1189
13 /* We use the same seed which we saw this failure on. */
14 static uint64_t failhash(const void *key, size_t len, uint64_t seed, void *p)
16 seed = 699537674708983027ULL;
17 return hash64_stable((const unsigned char *)key, len, seed);
20 int main(int argc, char *argv[])
22 int i;
23 struct tdb_context *tdb;
24 struct tdb_data key = { (unsigned char *)&i, sizeof(i) };
25 struct tdb_data data = { (unsigned char *)&i, sizeof(i) };
26 union tdb_attribute hattr = { .hash = { .base = { TDB_ATTRIBUTE_HASH },
27 .fn = failhash } };
29 hattr.base.next = &tap_log_attr;
30 plan_tests(1 + NUM_RECORDS + 2);
32 tdb = tdb_open("run-missing-entries.tdb", TDB_INTERNAL,
33 O_RDWR|O_CREAT|O_TRUNC, 0600, &hattr);
34 if (ok1(tdb)) {
35 for (i = 0; i < NUM_RECORDS; i++) {
36 ok1(tdb_store(tdb, key, data, TDB_REPLACE) == 0);
38 ok1(tdb_check(tdb, NULL, NULL) == 0);
39 tdb_close(tdb);
42 ok1(tap_log_messages == 0);
43 return exit_status();