1 #include "tdb2-source.h"
2 #include <ccan/tap/tap.h>
5 #define NUM_TESTS 50000
7 static bool store_all(struct tdb_context *tdb)
10 struct tdb_data key = { (unsigned char *)&i, sizeof(i) };
11 struct tdb_data dbuf = { (unsigned char *)&i, sizeof(i) };
13 for (i = 0; i < NUM_TESTS; i++) {
14 if (tdb_store(tdb, key, dbuf, TDB_INSERT) != TDB_SUCCESS)
20 static int mark_entry(struct tdb_context *tdb,
21 TDB_DATA key, TDB_DATA data, bool found[])
25 if (key.dsize != sizeof(num))
27 memcpy(&num, key.dptr, key.dsize);
36 static bool is_all_set(bool found[], unsigned int num)
40 for (i = 0; i < num; i++)
46 int main(int argc, char *argv[])
49 bool found[NUM_TESTS];
50 struct tdb_context *tdb;
51 int flags[] = { TDB_DEFAULT, TDB_NOMMAP,
52 TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT,
55 plan_tests(sizeof(flags) / sizeof(flags[0]) * 6 + 1);
57 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
58 tdb = tdb_open("run-93-repack.tdb", flags[i],
59 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
66 ok1(tdb_repack(tdb) == TDB_SUCCESS);
67 memset(found, 0, sizeof(found));
68 ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);
69 ok1(tdb_traverse(tdb, mark_entry, found) == NUM_TESTS);
70 ok1(is_all_set(found, NUM_TESTS));
74 ok1(tap_log_messages == 0);