postage-rs icon indicating copy to clipboard operation
postage-rs copied to clipboard

Add loom tests

Open arthurprs opened this issue 3 years ago • 3 comments

Loom https://github.com/tokio-rs/loom

This can be a significant amount of work but in my experience it is MUCH more effective catching concurrency bugs compared to stress tests.

Eg. https://github.com/tokio-rs/tokio/blob/master/tokio/src/sync/tests/loom_broadcast.rs

arthurprs avatar Feb 04 '21 11:02 arthurprs

This is a great idea! Thanks for the suggestion 💯

austinjones avatar Feb 06 '21 20:02 austinjones

Hmm, there is an obstacle here. I use the atomic crate a lot for atomic enums. Unfortunately, it doesn't support loom. I think I'll need to write my own enum wrapper in order to implement this.

austinjones avatar Feb 08 '21 03:02 austinjones

Yeah, it's a very invasive test suite. There's also the crossbeam-queue data structures.

Tokio uses a trick that imports all primitives from a loom module, then swaps its contents based on a cfg flag https://github.com/tokio-rs/tokio/blob/master/tokio/src/loom/mod.rs but that breaks as soon as you have a single external crate :weary:

arthurprs avatar Feb 08 '21 10:02 arthurprs