Btree unit tests
Added 2018-06-08 00:46:34 +0000 UTCBeen spending a surprising amount of time lately on the core btree - in a good way, as in "oh, here's some good an useful improvements I can easily make", not "oh crap, this thing is broken and I have to fix it".
Some of this was motivated by the truncate bug and needing implement BTREE_INSERT_NOUNLOCK, and more has been motivated by some more advanced transaction functionality I'm working on (that I should write another post), but the actual work has mostly revolved around clarifying and making more rigorous various btree iterator related invariants.
Which is pretty nice. Overall I'm pretty happy with the state of the btree code - I feel like it's shaping up to be one of the most robust, bulletproof btree implementations out there. I'm not as happy with it as I would be if I had correctness proofs for it - e.g. like compcert - but all the work I've been doing on clarifying and simplifying the various invariants goes a long ways toward making it possible to write assertions that are almost as good.
But, one thing we still don't have is any unit tests. Given the test coverage I get just from running xfstests plus all the assertions in debug mode this isn't a gaping hole, but adding a good set of unit tests would still definitely be worthwhile.
This would be a _perfect_ project for anyone who wants to jump in and help by writing code, but is looking for something small to start out on. It's non critical - there's no chance your code is going to corrupt anyone's data - but it would still involve learning about the core btree code. It's also always really helpful to have someone who isn't the original author and has a fresh perspective trying to come up with tests and think of ways to break things.
If this sounds interesting to anyone, I just pushed my btree performance tests - what I've got there should be a decent starting point for a unit test framework too.
Here's the new tests.c:
https://evilpiepirate.org/git/bcachefs.git/tree/fs/bcachefs/tests.c