diff options
Diffstat (limited to 'lib/tdb2/test')
-rw-r--r-- | lib/tdb2/test/layout.c | 7 | ||||
-rw-r--r-- | lib/tdb2/test/layout.h | 3 | ||||
-rw-r--r-- | lib/tdb2/test/run-03-coalesce.c | 10 | ||||
-rw-r--r-- | lib/tdb2/test/run-50-multiple-freelists.c | 8 |
4 files changed, 18 insertions, 10 deletions
diff --git a/lib/tdb2/test/layout.c b/lib/tdb2/test/layout.c index 4f66e0935f..95cca6a810 100644 --- a/lib/tdb2/test/layout.c +++ b/lib/tdb2/test/layout.c @@ -206,7 +206,7 @@ static void add_to_hashtable(struct tdb_context *tdb, b_off = hbucket_off(group_start, bucket); if (tdb_read_off(tdb, b_off) == 0) { tdb_write_off(tdb, b_off, - encode_offset(eoff, bucket, h)); + encode_offset(eoff, in_group, h)); return; } } @@ -228,7 +228,8 @@ static struct tle_freetable *find_ftable(struct tdb_layout *layout, unsigned num } /* FIXME: Support TDB_CONVERT */ -struct tdb_context *tdb_layout_get(struct tdb_layout *layout) +struct tdb_context *tdb_layout_get(struct tdb_layout *layout, + union tdb_attribute *attr) { unsigned int i; tdb_off_t off, len, last_ftable; @@ -264,7 +265,7 @@ struct tdb_context *tdb_layout_get(struct tdb_layout *layout) /* Fill with some weird pattern. */ memset(mem, 0x99, off); /* Now populate our header, cribbing from a real TDB header. */ - tdb = tdb_open(NULL, TDB_INTERNAL, O_RDWR, 0, &tap_log_attr); + tdb = tdb_open(NULL, TDB_INTERNAL, O_RDWR, 0, attr); memcpy(mem, tdb->file->map_ptr, sizeof(struct tdb_header)); /* Mug the tdb we have to make it use this. */ diff --git a/lib/tdb2/test/layout.h b/lib/tdb2/test/layout.h index 6e2e6657a7..96ecb683b8 100644 --- a/lib/tdb2/test/layout.h +++ b/lib/tdb2/test/layout.h @@ -15,7 +15,8 @@ void tdb_layout_add_hashtable(struct tdb_layout *layout, unsigned int bucket, tdb_len_t extra); #endif -struct tdb_context *tdb_layout_get(struct tdb_layout *layout); +struct tdb_context *tdb_layout_get(struct tdb_layout *layout, + union tdb_attribute *attr); void tdb_layout_free(struct tdb_layout *layout); enum layout_type { diff --git a/lib/tdb2/test/run-03-coalesce.c b/lib/tdb2/test/run-03-coalesce.c index 538613ba0a..93b8172844 100644 --- a/lib/tdb2/test/run-03-coalesce.c +++ b/lib/tdb2/test/run-03-coalesce.c @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) tdb_layout_add_freetable(layout); len = 1024; tdb_layout_add_free(layout, len, 0); - tdb = tdb_layout_get(layout); + tdb = tdb_layout_get(layout, &tap_log_attr); ok1(tdb_check(tdb, NULL, NULL) == 0); ok1(free_record_length(tdb, layout->elem[1].base.off) == len); @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) tdb_layout_add_freetable(layout); tdb_layout_add_free(layout, 1024, 0); tdb_layout_add_used(layout, key, data, 6); - tdb = tdb_layout_get(layout); + tdb = tdb_layout_get(layout, &tap_log_attr); ok1(free_record_length(tdb, layout->elem[1].base.off) == 1024); ok1(tdb_check(tdb, NULL, NULL) == 0); @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) tdb_layout_add_freetable(layout); tdb_layout_add_free(layout, 1024, 0); tdb_layout_add_free(layout, 2048, 0); - tdb = tdb_layout_get(layout); + tdb = tdb_layout_get(layout, &tap_log_attr); ok1(free_record_length(tdb, layout->elem[1].base.off) == 1024); ok1(free_record_length(tdb, layout->elem[2].base.off) == 2048); ok1(tdb_check(tdb, NULL, NULL) == 0); @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) tdb_layout_add_free(layout, 1024, 0); tdb_layout_add_free(layout, 512, 0); tdb_layout_add_used(layout, key, data, 6); - tdb = tdb_layout_get(layout); + tdb = tdb_layout_get(layout, &tap_log_attr); ok1(free_record_length(tdb, layout->elem[1].base.off) == 1024); ok1(free_record_length(tdb, layout->elem[2].base.off) == 512); ok1(tdb_check(tdb, NULL, NULL) == 0); @@ -135,7 +135,7 @@ int main(int argc, char *argv[]) tdb_layout_add_free(layout, 1024, 0); tdb_layout_add_free(layout, 512, 0); tdb_layout_add_free(layout, 256, 0); - tdb = tdb_layout_get(layout); + tdb = tdb_layout_get(layout, &tap_log_attr); ok1(free_record_length(tdb, layout->elem[1].base.off) == 1024); ok1(free_record_length(tdb, layout->elem[2].base.off) == 512); ok1(free_record_length(tdb, layout->elem[3].base.off) == 256); diff --git a/lib/tdb2/test/run-50-multiple-freelists.c b/lib/tdb2/test/run-50-multiple-freelists.c index 81c52e76c0..dae90e2398 100644 --- a/lib/tdb2/test/run-50-multiple-freelists.c +++ b/lib/tdb2/test/run-50-multiple-freelists.c @@ -9,6 +9,12 @@ int main(int argc, char *argv[]) struct tdb_context *tdb; struct tdb_layout *layout; TDB_DATA key, data; + union tdb_attribute seed; + + /* This seed value previously tickled a layout.c bug. */ + seed.base.attr = TDB_ATTRIBUTE_SEED; + seed.seed.seed = 0xb1142bc054d035b4ULL; + seed.base.next = &tap_log_attr; plan_tests(11); key = tdb_mkdata("Hello", 5); @@ -29,7 +35,7 @@ int main(int argc, char *argv[]) key.dsize--; tdb_layout_add_used(layout, key, data, 8); tdb_layout_add_free(layout, 40, 0); - tdb = tdb_layout_get(layout); + tdb = tdb_layout_get(layout, &seed); ok1(tdb_check(tdb, NULL, NULL) == 0); off = get_free(tdb, 0, 80 - sizeof(struct tdb_used_record), 0, |