From 7189e90c2206c6825ae0459e5f424e437723d1bc Mon Sep 17 00:00:00 2001 From: krad Date: Wed, 8 Jul 2015 13:38:20 -0700 Subject: [PATCH] Fix a noisy unit test. Summary: The t/DBTest.DropWrites test still fails under certain gcc version in release unit test. I unfortunately cannot repro the failure (since the compilers have mapped library which I am not able to map to correctly). I am suspecting the clock skew. Test Plan: Run make check Reviewers: CC: sdong igore Task ID: #7312624 Blame Rev: --- db/db_test.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index 42f4bf0cb..e28a27914 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -93,10 +93,11 @@ class AtomicCounter { uint64_t start = env_->NowMicros(); while (count_ < count) { uint64_t now = env_->NowMicros(); - cond_count_.TimedWait(now + /*1s*/ 1 * 000 * 000); - if (env_->NowMicros() - start > /*10s*/ 10 * 000 * 000) { + const uint64_t elapsed_micros = (now > start) ? now - start : 0; + if (elapsed_micros > /*10s*/ 10 * 000 * 000) { return false; } + cond_count_.TimedWait(now + /*1s*/ 1 * 000 * 000); if (count_ < count) { GTEST_LOG_(WARNING) << "WaitFor is taking more time than usual"; }