1 #include <ccan/tdb2/tdb2.h>
2 #include <ccan/tap/tap.h>
8 #define NUM_TESTS 50000
10 static bool store_all(struct tdb_context *tdb)
13 struct tdb_data key = { (unsigned char *)&i, sizeof(i) };
14 struct tdb_data dbuf = { (unsigned char *)&i, sizeof(i) };
16 for (i = 0; i < NUM_TESTS; i++) {
17 if (tdb_store(tdb, key, dbuf, TDB_INSERT) != TDB_SUCCESS)
23 static int mark_entry(struct tdb_context *tdb,
24 TDB_DATA key, TDB_DATA data, bool found[])
28 if (key.dsize != sizeof(num))
30 memcpy(&num, key.dptr, key.dsize);
39 static bool is_all_set(bool found[], unsigned int num)
43 for (i = 0; i < num; i++)
49 int main(int argc, char *argv[])
52 bool found[NUM_TESTS];
53 struct tdb_context *tdb;
54 int flags[] = { TDB_DEFAULT, TDB_NOMMAP,
55 TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT,
58 plan_tests(sizeof(flags) / sizeof(flags[0]) * 6 + 1);
60 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
61 tdb = tdb_open("run-93-repack.tdb", flags[i],
62 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
69 ok1(tdb_repack(tdb) == TDB_SUCCESS);
70 memset(found, 0, sizeof(found));
71 ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);
72 ok1(tdb_traverse(tdb, mark_entry, found) == NUM_TESTS);
73 ok1(is_all_set(found, NUM_TESTS));
77 ok1(tap_log_messages == 0);