Fix test flakiness due to race condition.
StartMonitoring() starts the thread asynchronously, which it must do since it happens on the UI thread and cannot block. However, the test checks that the tid() is set immediately, which is only valid once the thread starts up. This race leads to test flakiness. We could busy-loop waiting for the thread to start, or use a condition variable, or do various other fixes to ensure that we don't access the tid() until it's really there; but since the test is basically trying to ensure that a second call to StartMonitoring() is a no-op, this just checks that the thread* is non-null and unchanged between the two calls. This is sufficient and should work consistently. Bug: none Change-Id: I672e229ce07d84d04a7cd0aa2eb498a9d903d5cb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2117053 Auto-Submit: Peter Kasting <pkasting@chromium.org> Commit-Queue: Cheng-Yu Lee <cylee@chromium.org> Reviewed-by:Cheng-Yu Lee <cylee@chromium.org> Cr-Commit-Position: refs/heads/master@{#753129}
Showing
Please register or sign in to comment