Skip to content

[test] Make Mutex.cpp unittest more reliable. #25049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

gottesmm
Copy link
Contributor

We have started to hit some spurious failures in package testing on 5.1 from these tests. This was happening on master as well pretty regularly until MikeA tweaked the tests to make them more reliable. This PR just cherry-picks these two test modifications to 5.1 to stabilize the tests there as well.

rdar://51093916

mikeash added 2 commits May 24, 2019 10:20
Many of these tests would fail if one of the test threads didn't begin execution within 100 milliseconds. They would hit while (!done) the very first time and never execute the loop body. That does happen from time to time, and the result would be a spurious failure. Change the loops to do {} while(!done) to ensure they always execute at least one iteration.

Many tests also had the test threads concurrently write results to a std::vector, which appeared to be causing some failures in my local testing when I had extra sleeps inserted to simulate pathological scheduling. Change the results vectors to be vectors of std::atomic to ensure that this concurrent writing is safe.

These changes shouldn't affect its ability to test the functionality it intends to test.

rdar://problem/49386389
(cherry picked from commit 6172f72)
The restrictions on std::atomic make a it fragile to have a vector of them, and this failed to compile on Linux in CI.

While I'm in there, clean up a couple of tests that repeated a raw `10` for the thread count.

rdar://problem/49709062
(cherry picked from commit 855dd8d)
@gottesmm gottesmm requested a review from mikeash May 24, 2019 17:23
@gottesmm
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooray!

@gottesmm gottesmm merged commit 3fcdacf into swiftlang:swift-5.1-branch May 24, 2019
@gottesmm gottesmm deleted the swift-5.1-branch-rdar51093916 branch May 24, 2019 20:31
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.

2 participants