fuchsia: Fix race in AtomicFlagTest.ReadFromDifferentThread

My understanding is:

- start thread

- post a BusyWaitUntilFlagSet to that thread which does:
  - busy loop until for tested_flag is set (calling sched_yield())
  - EXPECTs expected_after_flag to be set by then
  - sets done_flag

- meanwhile on the main thread:
  - sleep 20ms
  - set expected_after_flag
  - set tested_flag
  - sleep 20ms
  - assert that done_flag has been set

So, previously the test relied on the background thread winning the race
between being released from the busy loop and getting to set done_flag
vs. the main loop getting from setting the tested_flag, sleeping for
20ms and then the assert.

20ms is a relatively long time, but it also seems reasonable that the
background thread wouldn't be scheduled during that 20ms to get
done_flag set before the ASSERT_TRUE. Instead, wait for reset_flag to be
set to make sure it does get set before the test continues.

Bug: 734130
Change-Id: I8cfb6dc79352079ac95cc2a554327500b8de4ebd
Reviewed-on: https://chromium-review.googlesource.com/538091
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#480440}
1 file changed