loom
loom copied to clipboard
Any interest in a way to check that a state is possible?
It occurred to me that certain tests might want to say "there exists a thread interleaving where assertion". For example, one of the loom tests in Jon Gjengset's haphazard crate checks that a sum of a bunch of counts is equal to 1, but additionally it should be the case that each of these counts is individually equal to 1 in some execution. Additional checks like this would help to rule out fairly insidious bugs where one of the operations is accidentally a no-op.
I expect this could be implemented on a case-by-case basis by stepping around loom. One could set up an AtomicBool
flag outside of the model, set the flag to true
if the desired state is reached, and then check that the flag is true
at the end. But that seems a bit clunky and potentially error prone (e.g., loom might want to disable this feature for tests that prune interleavings).
Would y'all be interested in seeing a PR that adds a feature like this to loom? I'm not asking for help or resources, really, I just don't want to implement this if there are serious objections at the outset.