Index: base/debug/trace_event_synthetic_delay_unittest.cc |
diff --git a/base/debug/trace_event_synthetic_delay_unittest.cc b/base/debug/trace_event_synthetic_delay_unittest.cc |
index 7833e7bbcdeb89d47bc2bb404e280cf962f48260..5b9c20d2fa428f07e0d3c432a2f8f87976558981 100644 |
--- a/base/debug/trace_event_synthetic_delay_unittest.cc |
+++ b/base/debug/trace_event_synthetic_delay_unittest.cc |
@@ -4,6 +4,7 @@ |
#include "base/debug/trace_event_synthetic_delay.h" |
+#include "base/threading/simple_thread.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace base { |
@@ -14,6 +15,7 @@ const int kTargetDurationMs = 100; |
// Allow some leeway in timings to make it possible to run these tests with a |
// wall clock time source too. |
const int kShortDurationMs = 10; |
+const char kThreadedDelayName[] = "test.ThreadedDelay"; |
} // namespace |
@@ -152,5 +154,34 @@ TEST_F(TraceEventSyntheticDelayTest, BeginParallel) { |
EXPECT_LT((Now() - start_time).InMilliseconds(), kShortDurationMs); |
} |
+class ThreadWithSyntheticDelay : public SimpleThread { |
+ public: |
+ ThreadWithSyntheticDelay() |
+ : SimpleThread("delay_test", SimpleThread::Options()) {} |
+ |
+ virtual void Run() OVERRIDE { |
+ TRACE_EVENT_SYNTHETIC_DELAY(kThreadedDelayName); |
+ } |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ThreadWithSyntheticDelay); |
+}; |
+ |
+TEST_F(TraceEventSyntheticDelayTest, ThreadedSetup) { |
+ // This test is designed to exercise various multithreaded scenarios with |
+ // synthetic delays so that dynamic analyzers like TSAN can spot any |
Alexander Potapenko
2014/07/15 14:30:15
That's 'TSan', not 'TSAN' :)
Have you actually tr
|
+ // problems. |
+ ThreadWithSyntheticDelay threads[2]; |
+ |
+ for (size_t i = 0; i < arraysize(threads); ++i) |
+ threads[i].Start(); |
Alexander Potapenko
2014/07/15 14:30:15
I think there should be two-space indentation here
|
+ TraceEventSyntheticDelay* delay = |
+ TraceEventSyntheticDelay::Lookup(kThreadedDelayName); |
+ delay->SetTargetDuration( |
+ base::TimeDelta::FromMilliseconds(kShortDurationMs)); |
+ for (size_t i = 0; i < arraysize(threads); ++i) |
+ threads[i].Join(); |
+} |
+ |
} // namespace debug |
} // namespace base |