unit/btree: test basic B-Tree operations#18690
Conversation
Cover an empty tree, add/find, remove, and walk over a tree of uint64_t values. Signed-off-by: Christos Longros <chris.longros@gmail.com>
5151ce7 to
1d24912
Compare
| return (-1); | ||
| if (x > y) | ||
| return (1); | ||
| return (0); |
There was a problem hiding this comment.
We can use the TREE_CMP macro here.
| return (0); | |
| return (TREE_CMP(x, y)); |
| UNIT_TEST("empty", test_btree_empty), | ||
| UNIT_TEST("add_find", test_btree_add_find), | ||
| UNIT_TEST("remove", test_btree_remove), | ||
| UNIT_TEST("walk", test_btree_walk), |
There was a problem hiding this comment.
Let's adapt the find_without_index() and drain_tree() tests from ./tests/zfs-tests/cmd/btree_test.c and move them to this unit test. I'd like to also move stress_tree() in to the unit tests, but since it depends on an AVL tree maybe it belongs in its own test_btree_stress.c. I'm open to other suggestions, it'd just be nice to remove it from the ZTS tests.
There was a problem hiding this comment.
Probably we want test_avl before or at the same time, and then some sort of correctness test that proves that they do the same thing.
Semi-related, I'm not entirely certain where stress/performance tests fit in all this (which is part of why I haven't just dragged the ICP/algorithm tests into this framework yet). I couldn't quickly find good literature on how they fit into an overall testing position, and haven't had much chance to think about it. I'm not saying "don't do it" (better to do something than nothing) and I don't think ZTS is the right place for some of those either. So probably just do it and we can move it around later if we think of something better. But I hope someone that actually knows testing theory and practice in more depth can just say "oh yeah, you want Florple Tests, here's the prior art, wire it this way". I always hope for that sort of thing! 😆
Motivation and Context
module/zfs/btree.chas no dedicated unit test. This adds a smalltests/unitsuite for its basic public operations.Description
Adds
tests/unit/test_btree.cwith four tests over a tree ofuint64_tvalues:zfs_btree_first/zfs_btree_nextHow Has This Been Tested?
make unit T=btreeon Linux x86_64:Types of changes
Checklist
Signed-off-by.