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

Unified Diff: base/debug/trace_event_unittest.cc

Issue 18338004: Don't use StaticMemorySingletonTraits for TraceLog. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: use LeakySingletonTraits as TraceLog is used on non-joinable threads Created 7 years, 5 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_impl.cc ('k') | base/debug/trace_event_win_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
===================================================================
--- base/debug/trace_event_unittest.cc (revision 210376)
+++ base/debug/trace_event_unittest.cc (working copy)
@@ -104,6 +104,8 @@
PlatformThread::SetName(old_thread_name_ ? old_thread_name_ : "");
free(old_thread_name_);
old_thread_name_ = NULL;
+ // We want our singleton torn down after each test.
+ TraceLog::DeleteForTesting();
}
char* old_thread_name_;
@@ -121,7 +123,6 @@
void TraceEventTestFixture::ManualTestSetUp() {
TraceLog::DeleteForTesting();
- TraceLog::Resurrect();
TraceLog* tracelog = TraceLog::GetInstance();
ASSERT_TRUE(tracelog);
ASSERT_FALSE(tracelog->IsEnabled());
@@ -1521,71 +1522,6 @@
}
}
-// Test trace calls made after tracing singleton shut down.
scheib 2013/07/08 22:58:57 I was initially hesitant to remove this test- but
jam 2013/07/08 23:03:10 Done.
-//
-// The singleton is destroyed by our base::AtExitManager, but there can be
-// code still executing as the C++ static objects are destroyed. This test
-// forces the singleton to destroy early, and intentinally makes trace calls
-// afterwards.
-TEST_F(TraceEventTestFixture, AtExit) {
- // Repeat this test a few times. Besides just showing robustness, it also
- // allows us to test that events at shutdown do not appear with valid events
- // recorded after the system is started again.
- for (int i = 0; i < 4; i++) {
- // Scope to contain the then destroy the TraceLog singleton.
- {
- base::ShadowingAtExitManager exit_manager_will_destroy_singletons;
-
- // Setup TraceLog singleton inside this test's exit manager scope
- // so that it will be destroyed when this scope closes.
- ManualTestSetUp();
-
- TRACE_EVENT_INSTANT0("all", "not recorded; system not enabled",
- TRACE_EVENT_SCOPE_THREAD);
-
- BeginTrace();
-
- TRACE_EVENT_INSTANT0("all", "is recorded 1; system has been enabled",
- TRACE_EVENT_SCOPE_THREAD);
- // Trace calls that will cache pointers to categories; they're valid here
- TraceCallsWithCachedCategoryPointersPointers(
- "is recorded 2; system has been enabled");
-
- EndTraceAndFlush();
- } // scope to destroy singleton
- ASSERT_FALSE(TraceLog::GetInstance());
-
- // Now that singleton is destroyed, check what trace events were recorded
- const DictionaryValue* item = NULL;
- ListValue& trace_parsed = trace_parsed_;
- EXPECT_FIND_("is recorded 1");
- EXPECT_FIND_("is recorded 2");
- EXPECT_NOT_FIND_("not recorded");
-
- // Make additional trace event calls on the shutdown system. They should
- // all pass cleanly, but the data not be recorded. We'll verify that next
- // time around the loop (the only way to flush the trace buffers).
- TRACE_EVENT_BEGIN_ETW("not recorded; system shutdown", 0, NULL);
- TRACE_EVENT_END_ETW("not recorded; system shutdown", 0, NULL);
- TRACE_EVENT_INSTANT_ETW("not recorded; system shutdown", 0, NULL);
- TRACE_EVENT0("all", "not recorded; system shutdown");
- TRACE_EVENT_INSTANT0("all", "not recorded; system shutdown",
- TRACE_EVENT_SCOPE_THREAD);
- TRACE_EVENT_BEGIN0("all", "not recorded; system shutdown");
- TRACE_EVENT_END0("all", "not recorded; system shutdown");
-
- TRACE_EVENT0("new category 0!", "not recorded; system shutdown");
- TRACE_EVENT_INSTANT0("new category 1!", "not recorded; system shutdown",
- TRACE_EVENT_SCOPE_THREAD);
- TRACE_EVENT_BEGIN0("new category 2!", "not recorded; system shutdown");
- TRACE_EVENT_END0("new category 3!", "not recorded; system shutdown");
-
- // Cached categories should be safe to check, and still disable traces
- TraceCallsWithCachedCategoryPointersPointers(
- "not recorded; system shutdown");
- }
-}
-
TEST_F(TraceEventTestFixture, NormallyNoDeepCopy) {
// Test that the TRACE_EVENT macros do not deep-copy their string. If they
// do so it may indicate a performance regression, but more-over it would
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | base/debug/trace_event_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698