Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2928)

Unified Diff: base/debug/trace_event_unittest.cc

Issue 10828326: Fix TraceEventTestFixture flakiness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sharing HighResSleepForTraceTest between tests Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/debug/trace_event_unittest.h ('k') | base/test/trace_event_analyzer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/trace_event_unittest.cc
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc
index 5d32f2f606df9e41bf08fc1f02613f1d3b04802e..f806cf1928e870dd1ba637f3cb14ba05e13cb160 100644
--- a/base/debug/trace_event_unittest.cc
+++ b/base/debug/trace_event_unittest.cc
@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/debug/trace_event.h"
+#include "base/debug/trace_event_unittest.h"
#include "base/bind.h"
#include "base/command_line.h"
+#include "base/debug/trace_event.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/memory/ref_counted_memory.h"
@@ -20,6 +21,8 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+using base::debug::HighResSleepForTraceTest;
+
namespace base {
namespace debug {
@@ -633,6 +636,13 @@ void TraceCallsWithCachedCategoryPointersPointers(const char* name_str) {
} // namespace
+void HighResSleepForTraceTest(base::TimeDelta elapsed) {
+ base::TimeTicks end_time = base::TimeTicks::HighResNow() + elapsed;
+ do {
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1));
jar (doing other things) 2012/08/16 01:23:35 As per our discussion... it is very alarming that
+ } while (base::TimeTicks::HighResNow() < end_time);
+}
+
// Simple Test for emitting data and validating it was received.
TEST_F(TraceEventTestFixture, DataCaptured) {
ManualTestSetUp();
@@ -843,7 +853,7 @@ TEST_F(TraceEventTestFixture, DataCapturedThreshold) {
// 100+ seconds to avoid flakiness.
TRACE_EVENT_IF_LONGER_THAN0(100000000, "time", "threshold long1");
TRACE_EVENT_IF_LONGER_THAN0(200000000, "time", "threshold long2");
- base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20));
+ HighResSleepForTraceTest(base::TimeDelta::FromMilliseconds(20));
}
// Test that a normal nested event remains after it's parent event is dropped.
@@ -868,8 +878,7 @@ TEST_F(TraceEventTestFixture, DataCapturedThreshold) {
TRACE_EVENT_IF_LONGER_THAN0(1000, "time", "3threshold1000");
{
TRACE_EVENT_IF_LONGER_THAN0(100, "time", "3threshold100");
- base::PlatformThread::Sleep(
- base::TimeDelta::FromMilliseconds(20));
+ HighResSleepForTraceTest(base::TimeDelta::FromMilliseconds(20));
}
}
}
@@ -893,8 +902,7 @@ TEST_F(TraceEventTestFixture, DataCapturedThreshold) {
{
TRACE_EVENT_IF_LONGER_THAN0(200000000, "time",
"4thresholdlong2");
- base::PlatformThread::Sleep(
- base::TimeDelta::FromMilliseconds(20));
+ HighResSleepForTraceTest(base::TimeDelta::FromMilliseconds(20));
}
}
}
« no previous file with comments | « base/debug/trace_event_unittest.h ('k') | base/test/trace_event_analyzer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698