I would like some ideas on how I should test some objects that might be blocked to wait for another member. The specific module under test is the channel between the participants, the participants themselves are prototype lamps for testing purposes.
It would be nice to confirm that the participants are deadlocked when they are expected, but for me this is not very important, because what happens after the deadlock can be reasonably described as undefined.
More important would be to make sure that certain interactions of the participants were not at an impasse.
In any case, I'm not sure what the optimal testing strategy should be. My real concept is to run a test running thread for each participant, sleeping a bit, and then find out if the child threads have returned. In case they didn’t return on time, suppose that they have reached a dead end and safely terminate the threads and the test fails (or succeeds if a dead end is expected).
This seems a bit plausible, as there may be all sorts of reasons (as if unlikely) that the thread may take longer than expected. Are there any other good ways to solve this problem?
EDIT: I'm sure testing will be nice, but I don't think I need this. I think of three levels of validation.
- "Actual behavior has proven to be consistent with expected behavior." "Dead end can't happen"
- “Actual behavior consistent with expected behavior” deadlock not seen in N tests
- "Actual behavior is consistent with expected behavior" N tests completed in expected time
The first, of course, is a valuable test for passing, but ShiDoiSi's answer suggests this is impractical. The second is much weaker than the first, but still heavy; How can you establish that a network of processes has actually reached an impasse? I'm not sure it's easier to prove than the first (maybe a lot harder)
The latter is more like what I mean.
source share