Skip to content

Conversation

@oldnewthing
Copy link
Member

The concurrency tests for multi-threaded collections run for a nondeterministic number of iterations, and the branches taken within the test are nondeterministic, causing the REQUIRE macro to be called a nondeterministic number of times during the run of the test. This means that each time you run the tests, the numbers in the message

All tests passed (314159 assertions in 2718 test cases)

are different. This does not contribute to confidence that the tests are working.

There is also a problem with the REQUIRE macro: It does not support concurrent usage from multiple threads. If two threads perform a REQUIRE at the same time, the assertion count is unreliable.

Fix both problems by not using REQUIRE (1) in nondeterministic ways or (2) from multiple threads simultaneously. Instead, we use check_bool, which will still throw an exception and fail the test, but does not run afoul of REQUIRE's limitations.

The concurrency tests for multi-threaded collections
run for a nondeterministic number of iterations. This means
that each time you run them, the numbers in the message

```
All tests passed (314159 assertions in 2718 test cases)
```

are different. This does not contribute to confidence that the
tests are working.

There is also a problem with the REQUIRE macro: It does not support
concurrent usage from multiple threads. If two threads perform a
REQUIRE at the same time, the assertion count is unreliable.

Fix both problems by not using REQUIRE (1) in nondeterministic ways
or (2) from multiple threads simultaneously. Instead, we use
`check_bool`, which will still throw an exception and fail the test,
but does not run afoul of REQUIRE's limitations.
@oldnewthing oldnewthing requested review from dunhor and kennykerr August 1, 2020 04:26
@kennykerr kennykerr merged commit 9523a73 into master Aug 3, 2020
@kennykerr kennykerr deleted the determinism branch August 3, 2020 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants