util_test Clock.SleepNanoseconds: don’t set an upper bound for the

amount of time spent sleeping.

Even with the slop, this wound up being flaky, specifically on virtual
machines. And guess what our automated test infrastructure runs on?

TEST=util_test Clock.SleepNanoseconds
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/640373003
This commit is contained in:
Mark Mentovai 2014-10-10 14:00:43 -04:00
parent 7669b33010
commit 8f23d3e475

View File

@ -61,12 +61,8 @@ void TestSleepNanoseconds(uint64_t nanoseconds) {
// sleeping.
EXPECT_GE(diff, nanoseconds);
// Its difficult to set an upper bound for the time spent sleeping. Allow
// sleeps twice as long as requested, or sleeps a millisecond longer than
// requested, whichever is larger. This is quite a lot of slop, but the
// alternative would be test flakiness.
uint64_t slop = std::max(static_cast<uint64_t>(1E6), nanoseconds);
EXPECT_LE(diff, nanoseconds + slop);
// Its difficult to set an upper bound for the time spent sleeping, and
// attempting to do so results in a flaky test.
}
TEST(Clock, SleepNanoseconds) {