New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kernel Unit Testing #3854
Comments
From today's call, where we talked about this issue. An alternative approach to this could be to use traits and generics for the "real" and "mock" implementations of the different subsystems respectively. A concern that was voiced is that this generic argument would then need to be carried throughout much of Tock's codebase. A benefit would be that we would have a shared explicit interface between both implementations, which may reduce the potential for mismatches to evolve between the two implementations. If the fact that this generic argument would need to be carried through much of Tock's codebase is the primary concern, we may be able to alleviate that by assigning a default type to that generic. |
I don't think we should make Tock code harder to read and harder to write for unit testing. That feels like the wrong-way-round. We want to build the best OS to run, not to test. If we need a stub library, like the TBF headers, that seems like a cargo.toml issue. Can't we just compile the kernel crate with a different dependency? Even if that requires some extra scripts to accomplish, that seems fine, and overall a bunch less work than propagating a generic argument everywhere. |
(If you would like to have some fun propagating generic types, you can help me remove |
I have some experience with removing |
I am in the process of writing unit tests for the kernel, but the module I'm writing for is dependent on external crates (for example the
tock_tbf
crate). My idea is to create some fake dependencies in thetests
module and use conditional compiling in the struct declaration. For example, to emulatetock_tbf::types::TbfHeader
inside I would rewrite the definition ofProcessStandard
like so:then I would create the
TbfHeader
struct inside thetests
module and write the functions to give me the desired outputs.I am not sure if this is the best way of writing unit tests for Tock and I would really like some feedback about this.
The text was updated successfully, but these errors were encountered: