Commit 57f0e26f authored by Ivica Bogosavljevic's avatar Ivica Bogosavljevic Committed by Commit Bot

Fix ThreadTicks.ThreadNow on systems with low resolution timers

Test ThreadTicks.ThreadNow fails on systems with low resolution
thread timers because the tests detects that no time elapsed
since the beginning of the test.
This CL adds a counting loop that makes sure the thread
timer has progressed by at least one tick.

TEST=unittests/ThreadTicks.ThreadNow

Change-Id: I910309208b3a154798cbc43813d41d3755ab819d
Reviewed-on: https://chromium-review.googlesource.com/1082352
Commit-Queue: Ivica Bogosavljevic <ivica.bogosavljevic@mips.com>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53548}
parent b8f9b047
......@@ -392,6 +392,15 @@ TEST(ThreadTicks, MAYBE_ThreadNow) {
// Make sure that ThreadNow value is non-zero.
EXPECT_GT(begin_thread, ThreadTicks());
int iterations_count = 0;
// Some systems have low resolution thread timers, this code makes sure
// that thread time has progressed by at least one tick.
// Limit waiting to 10ms to prevent infinite loops.
while (ThreadTicks::Now() == begin_thread &&
((TimeTicks::Now() - begin).InMicroseconds() < 10000)) {
}
EXPECT_GT(ThreadTicks::Now(), begin_thread);
do {
// Sleep for 10 milliseconds to get the thread de-scheduled.
OS::Sleep(base::TimeDelta::FromMilliseconds(10));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment