diff options
author | Joe Thornber <ejt@redhat.com> | 2018-06-20 10:04:59 +0100 |
---|---|---|
committer | Joe Thornber <ejt@redhat.com> | 2018-06-21 09:49:43 +0100 |
commit | 40c1f7889fd88ce4a2f2b42c594db3deb8f84593 (patch) | |
tree | ee75ecc23622640dfa3cea0c185eec1422c01127 /test/unit | |
parent | c8cfbfa605ce6577c390cf940d51d872b3556c64 (diff) | |
download | lvm2-40c1f7889fd88ce4a2f2b42c594db3deb8f84593.tar.gz |
radix-tree: More debugging of remove
There's now a pretty printer called radix_tree_dump()
n4, n16, and n48 weren't UNSETting the last entry after
sliding values down.
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/radix_tree_t.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/unit/radix_tree_t.c b/test/unit/radix_tree_t.c index 4ee22c159..2fba15f05 100644 --- a/test/unit/radix_tree_t.c +++ b/test/unit/radix_tree_t.c @@ -605,6 +605,37 @@ static void test_destroy_calls_dtr(void *fixture) //---------------------------------------------------------------- +static void test_bcache_scenario(void *fixture) +{ + struct radix_tree *rt = fixture; + + unsigned i; + uint8_t k[6]; + union radix_value v; + + memset(k, 0, sizeof(k)); + + for (i = 0; i < 3; i++) { + // it has to be the 4th byte that varies to + // trigger the bug. + k[4] = i; + v.n = i; + T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v)); + } + T_ASSERT(radix_tree_is_well_formed(rt)); + + k[4] = 0; + T_ASSERT(radix_tree_remove(rt, k, k + sizeof(k))); + T_ASSERT(radix_tree_is_well_formed(rt)); + + k[4] = i; + v.n = i; + T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v)); + T_ASSERT(radix_tree_is_well_formed(rt)); +} + +//---------------------------------------------------------------- + #define T(path, desc, fn) register_test(ts, "/base/data-struct/radix-tree/" path, desc, fn) void radix_tree_tests(struct dm_list *all_tests) @@ -637,6 +668,7 @@ void radix_tree_tests(struct dm_list *all_tests) T("iterate-vary-middle", "iterate keys that vary in the middle", test_iterate_vary_middle); T("remove-calls-dtr", "remove should call the dtr for the value", test_remove_calls_dtr); T("destroy-calls-dtr", "destroy should call the dtr for all values", test_destroy_calls_dtr); + T("bcache-scenario", "A specific series of keys from a bcache scenario", test_bcache_scenario); dm_list_add(all_tests, &ts->list); } |