Open WilsonGiese opened 7 years ago
Yes, I think this is an open and interesting question. @withoutboats had a really interesting talk at RustConf about using more traits to enable testing.
One interesting possibility here: mock out some sort of pic
crate.....
Is the @withoutboats talk available online anywhere? Not able to find it anywhere :(
@WilsonGiese I believe it will be on the internet soon, but it seems like you understand the idea:
(lots of traits? Passing around real & mock impls)
For any interface between modules that you want to be an isolation boundary, instead of taking the other type directly, take a trait-bound type parameter, and then define mock impls in your unit tests.
I don't know anything about OSdev or I'd post a little practical example (ps. excited to learn something about it at Rust Belt Rust :wink:).
For any interface between modules that you want to be an isolation boundary, instead of taking the other type directly, take a trait-bound type parameter, and then define mock impls in your unit tests.
Yeah, this is basically what I was thinking!
I don't know anything about OSdev
I'll probably play around a little and see what I can come up with, concept seems easy enough to test
I believe it will be on the internet soon
Awesome, looking forward to listening to your talk @withoutboats 👍
(ps. excited to learn something about it at Rust Belt Rust :wink:).
:confetti_ball:
I was just messing around a bit, trying to add a cursor back into the new VGA code on my fork, no issues running the code in QEMU, but definitely had issues trying to access VGA hardware registers in test code. I basically broke all VGA tests by causing SIGSEGVs (woo!).
Wondering what the options are for unit testing code that needs to work so close to metal...
In school we wrote components for PintOS, but all the testing was done by running executables in user space. This worked quite well, but its really system testing, not unit testing. Without writing the kernel code to be accommodating of unit testing (lots of traits? Passing around real & mock impls), I'm not seeing how to assert on some aspects of the kernel directly.