Commit 1ccbfb00 authored by Fadi Meawad's avatar Fadi Meawad Committed by Commit Bot

Fix ThreadTicks.ThreadNow test on windows

The test is flaky because the OS does not sleep for the full requested
time. Adding a check for the OS sleep time.

Bug: v8:7492
Change-Id: I495ecc6595238bc1771adc434e766543513a0256
Reviewed-on: https://chromium-review.googlesource.com/937818Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Fadi Meawad <fmeawad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51774}
parent 8ca7bd39
......@@ -386,15 +386,21 @@ TEST(TimeTicks, IsMonotonic) {
TEST(ThreadTicks, MAYBE_ThreadNow) {
if (ThreadTicks::IsSupported()) {
ThreadTicks::WaitUntilInitialized();
TimeTicks begin = TimeTicks::Now();
ThreadTicks begin_thread = ThreadTicks::Now();
TimeTicks end, begin = TimeTicks::Now();
ThreadTicks end_thread, begin_thread = ThreadTicks::Now();
TimeDelta delta;
// Make sure that ThreadNow value is non-zero.
EXPECT_GT(begin_thread, ThreadTicks());
// Sleep for 10 milliseconds to get the thread de-scheduled.
OS::Sleep(base::TimeDelta::FromMilliseconds(10));
ThreadTicks end_thread = ThreadTicks::Now();
TimeTicks end = TimeTicks::Now();
TimeDelta delta = end - begin;
int iterations_count = 0;
do {
// Sleep for 10 milliseconds to get the thread de-scheduled.
OS::Sleep(base::TimeDelta::FromMilliseconds(10));
end_thread = ThreadTicks::Now();
end = TimeTicks::Now();
delta = end - begin;
EXPECT_LE(++iterations_count, 2); // fail after 2 attempts.
} while (delta.InMicroseconds() <
10000); // Make sure that the OS did sleep for at least 10 ms.
TimeDelta delta_thread = end_thread - begin_thread;
// Make sure that some thread time have elapsed.
EXPECT_GT(delta_thread.InMicroseconds(), 0);
......
......@@ -3,8 +3,5 @@
# found in the LICENSE file.
[
['system == windows', {
# BUG(7492).
'ThreadTicks.ThreadNow': [SKIP],
}], # 'system == windows'
]
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