Chromium Code Reviews| Index: base/time_win_unittest.cc |
| =================================================================== |
| --- base/time_win_unittest.cc (revision 59966) |
| +++ base/time_win_unittest.cc (working copy) |
| @@ -108,27 +108,29 @@ |
| } |
| } |
| -// Flaky, http://crbug.com/42850. |
| -TEST(TimeTicks, FLAKY_SubMillisecondTimers) { |
| - // Loop for a bit getting timers quickly. We want to |
| - // see at least one case where we get a new sample in |
| - // less than one millisecond. |
| +TEST(TimeTicks, SubMillisecondTimers) { |
| + // HighResNow doesn't work on some systems. Since the product still works |
| + // even if it doesn't work, it makes this entire test questionable. |
| + if (!TimeTicks::IsHighResClockWorking()) |
| + return; |
| + |
| + const int kRetries = 1000; |
| bool saw_submillisecond_timer = false; |
| - int64 min_timer = 1000; |
| - TimeTicks last_time = TimeTicks::HighResNow(); |
| + |
| + // Run kRetries attempts to see a sub-millisecond timer. |
|
Paweł Hajdan Jr.
2010/09/22 09:35:32
This test has still potential for flakiness. What
Mike Belshe
2010/09/22 21:58:48
Unfortunately, I don't think it helps. In this ca
|
| for (int index = 0; index < 1000; index++) { |
| - TimeTicks now = TimeTicks::HighResNow(); |
| - TimeDelta delta = now - last_time; |
| - if (delta.InMicroseconds() > 0 && |
| - delta.InMicroseconds() < 1000) { |
| - if (min_timer > delta.InMicroseconds()) |
| - min_timer = delta.InMicroseconds(); |
| + TimeTicks last_time = TimeTicks::HighResNow(); |
| + TimeDelta delta; |
| + // Spin until the clock changes a little |
|
Paweł Hajdan Jr.
2010/09/22 09:35:32
nit: Dot at the end, and explain why.
Mike Belshe
2010/09/22 21:58:48
Done.
|
| + do { |
| + delta = TimeTicks::HighResNow() - last_time; |
| + } while (delta.InMicroseconds() == 0); |
| + if (delta.InMicroseconds() < 1000) { |
| saw_submillisecond_timer = true; |
| + break; |
| } |
| - last_time = now; |
| } |
| EXPECT_TRUE(saw_submillisecond_timer); |
| - printf("Min timer is: %ldus\n", static_cast<long>(min_timer)); |
| } |
| TEST(TimeTicks, TimeGetTimeCaps) { |
| @@ -230,4 +232,4 @@ |
| printf("average time drift in microseconds: %lld\n", |
| total_drift / kIterations); |
| -} |
| +} |