1 #include <ccan/tdb2/tdb.c>
2 #include <ccan/tdb2/free.c>
3 #include <ccan/tdb2/lock.c>
4 #include <ccan/tdb2/io.c>
5 #include <ccan/tdb2/hash.c>
6 #include <ccan/tdb2/check.c>
7 #include <ccan/tap/tap.h>
10 #define MAX_SIZE 10000
13 int main(int argc, char *argv[])
16 struct tdb_context *tdb;
17 int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
18 TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
19 TDB_NOMMAP|TDB_CONVERT };
20 struct tdb_data key = { (unsigned char *)"key", 3 };
23 data.dptr = malloc(MAX_SIZE);
24 memset(data.dptr, 0x24, MAX_SIZE);
26 plan_tests(sizeof(flags) / sizeof(flags[0])
27 * (3 + (1 + (MAX_SIZE/SIZE_STEP)) * 2) + 1);
28 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
29 tdb = tdb_open("run-record-expand.tdb", flags[i],
30 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
36 ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0);
37 ok1(tdb_check(tdb, NULL, NULL) == 0);
39 data.dsize < MAX_SIZE;
40 data.dsize += SIZE_STEP) {
41 memset(data.dptr, data.dsize, data.dsize);
42 ok1(tdb_store(tdb, key, data, TDB_MODIFY) == 0);
43 ok1(tdb_check(tdb, NULL, NULL) == 0);
47 ok1(tap_log_messages == 0);