| Index: webrtc/system_wrappers/source/clock_unittest.cc
|
| diff --git a/webrtc/system_wrappers/source/clock_unittest.cc b/webrtc/system_wrappers/source/clock_unittest.cc
|
| index 76507ce3f340c9ca4396073f46d40666de4be218..5010d37c18a8e75a8765f0a46d020644bfdbce36 100644
|
| --- a/webrtc/system_wrappers/source/clock_unittest.cc
|
| +++ b/webrtc/system_wrappers/source/clock_unittest.cc
|
| @@ -18,11 +18,19 @@ TEST(ClockTest, NtpTime) {
|
| Clock* clock = Clock::GetRealTimeClock();
|
| uint32_t seconds;
|
| uint32_t fractions;
|
| +
|
| + // To ensure the test runs correctly even on a heavily loaded system, do not
|
| + // compare the seconds/fractions and millisecond values directly. Instead,
|
| + // we check that the NTP time is between the "milliseconds" values returned
|
| + // right before and right after the call.
|
| + // The comparison includes 1 ms of margin to account for the rounding error in
|
| + // the conversion.
|
| + int64_t milliseconds_lower_bound = clock->CurrentNtpInMilliseconds();
|
| clock->CurrentNtp(seconds, fractions);
|
| - int64_t milliseconds = clock->CurrentNtpInMilliseconds();
|
| - EXPECT_GT(milliseconds / 1000, kNtpJan1970);
|
| - EXPECT_GE(milliseconds, Clock::NtpToMs(seconds, fractions));
|
| - EXPECT_NEAR(milliseconds, Clock::NtpToMs(seconds, fractions), 100);
|
| + int64_t milliseconds_upper_bound = clock->CurrentNtpInMilliseconds();
|
| + EXPECT_GT(milliseconds_lower_bound / 1000, kNtpJan1970);
|
| + EXPECT_LE(milliseconds_lower_bound - 1, Clock::NtpToMs(seconds, fractions));
|
| + EXPECT_GE(milliseconds_upper_bound + 1, Clock::NtpToMs(seconds, fractions));
|
| }
|
|
|
| } // namespace webrtc
|
|
|