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

Unified Diff: base/trace_event/trace_event_unittest.cc

Issue 2259493003: [tracing] Add trace events filtering predicate for heap profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@heap_prof_filter
Patch Set: Created 4 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
Index: base/trace_event/trace_event_unittest.cc
diff --git a/base/trace_event/trace_event_unittest.cc b/base/trace_event/trace_event_unittest.cc
index bfcbd2fe2528de97dce90e5f08657c8fa254f733..e4ec2ba1fe28b494301fa9996d0b889f74d4df2d 100644
--- a/base/trace_event/trace_event_unittest.cc
+++ b/base/trace_event/trace_event_unittest.cc
@@ -3313,6 +3313,37 @@ TEST_F(TraceEventTestFixture, EventWhitelistFiltering) {
EXPECT_TRUE(FindMatchingValue("name", "a cat"));
}
+TEST_F(TraceEventTestFixture, HeapProfilerFiltering) {
+ const char config_json[] =
+ "{"
+ " \"included_categories\": ["
+ " \"filtered_cat\","
+ " \"unfiltered_cat\"],"
+ " \"excluded_categories\": [\"excluded_cat\"],"
+ " \"event_filters\": ["
+ " {"
+ " \"filter_predicate\": \"heap_profiler_predicate\", "
+ " \"included_categories\": [\"*\"]"
+ " }"
+ " ]"
+ "}";
+
+ TraceConfig trace_config(config_json);
+ TraceLog::GetInstance()->SetEnabled(trace_config, TraceLog::RECORDING_MODE);
+ EXPECT_TRUE(TraceLog::GetInstance()->IsEnabled());
+
+ TRACE_EVENT0("filtered_cat", "a snake");
+ TRACE_EVENT0("excluded_cat", "a mushroom");
+ TRACE_EVENT0("unfiltered_cat", "a cat");
+
+ EndTraceAndFlush();
+
+ // The predicate should not change behavior of the trace events.
+ EXPECT_TRUE(FindMatchingValue("name", "a snake"));
+ EXPECT_FALSE(FindMatchingValue("name", "a mushroom"));
+ EXPECT_TRUE(FindMatchingValue("name", "a cat"));
+}
+
TEST_F(TraceEventTestFixture, ClockSyncEventsAreAlwaysAddedToTrace) {
BeginSpecificTrace("-*");
TRACE_EVENT_CLOCK_SYNC_RECEIVER(1);

Powered by Google App Engine
This is Rietveld 408576698