madsim-rs/madsim

How to retrieve madsim seed when the test case was canceled by cargo-nextest due to timeout

Phoenix500526 opened this issue · 1 comments

When running madsim tests with cargo-nextest, it is possible that madsim tests may be canceled by cargo-nextest due to timeouts. In such cases, the seed generated by madsim cannot be retrieved. How should this issue be resolved? Would adding an function hook on kill, like issue #6 , solve the problem?

I think the function hook mentioned in #6 is not exactly what you want. #6 discussed how to do clean up when the simulated node is restarted. But now we are talking about the moment when the entire simulation is killed.

A simple solution I can think of is to print the seed at the beginning of each test.

eprintln!("seed = {}", madsim::runtime::Handle::current().seed());

This way, if the test is cancelled due to a timeout, you can retrieve the seed from stdout or stderr.