How to properly test std/libc/etc. on a custom cross-compiled target

I have rust cross-compiling for a non-standard OS. I created a custom target, modified libc/std/backtrace/etc., and I'm building using the cargo's nightly build cross compilation feature:
# cargo build -Z build-std=core,alloc,compiler_builtins,panic_unwind,std --target /path/to/target.json

It builds fine and things are running on the target OS, but I'm looking to properly test the libc/std crates. To test other crates, I've downloaded source, made my modifications and compiled the tests using:
# cargo test --no-run -Z build-std=core,alloc,compiler_builtins,panic_unwind,std --target /path/to/target.json

This is a bit of a pain as I have to find the tests manually in the build directory, copy them to the target and run them manually. I'm wondering what the best method for testing the custom libc/std/etc. crates is? I really want to put it through the ringer as I'm sure I've made mistakes somewhere along the way in some of the libc mappings. I'm also curious if there is a way of having the tests automatically run on a virtual machine or external target instead of trying to run on the host system when cargo test -Z build-std=... is used. Obviously trying to run on the host machine makes no sense in this case. Many thanks!

Just fyi, I think for this kind of question you're likely to get more responses on Zulip.

You can set a runner for your target to do whatever you need to copy and execute the test.

1 Like