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/937818 Reviewed-by: Yang Guo <yangguo@chromium.org> Commit-Queue: Fadi Meawad <fmeawad@chromium.org> Cr-Commit-Position: refs/heads/master@{#51774}
This commit is contained in:
parent
8ca7bd39a5
commit
1ccbfb0019
@ -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());
|
||||
int iterations_count = 0;
|
||||
do {
|
||||
// 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;
|
||||
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'
|
||||
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user