Using #[test] on #![no_std] target without #![feature(start)] - RTL8195

#1

Hey guys,

i’m currently trying to get the built-in test framework running on my no_std target (Realtek RTL8195AM - Cortex-M3). The whole thing is based on a slightly modified version of https://github.com/lupyuen/rustl8710.

My setup usually looks like this: I compile the whole rust code to a static library and provide a #[no_mangle] pub extern "C" fn main_entry() function there, which serves as an “entry point”, that is called from my C code, which contains main() and where all the startup magic happens.

When trying out the cargo test build (with utest from japaric), I just tried to remove main() from the C code, but the main() provided by the test framework seems to not be found by the linker and a main() provided by SDK, which is shipped with the board, is being used.

I am a bit sceptical if this will work at all. As far as I understood, the main function is overwritten by the test framework, #[no_mangle] is NOT applied, so the function cannot be called from the C side.

Is there any way to get the test framework running on my target with this setup?

PS: I am aware that the simpler option would be to simply run the tests on the host. This is just a proof of concept.

Many greetings
Andy

0 Likes