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

Side by Side Diff: base/trace_event/trace_event_unittest.cc

Issue 1067233002: Added a trace option for whitewashing trace args against a known-PII-less list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed enable_args_whitelist Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « base/trace_event/trace_event_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <math.h> 5 #include <math.h>
6 #include <cstdlib> 6 #include <cstdlib>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2197 EXPECT_EQ(0, int_value); 2197 EXPECT_EQ(0, int_value);
2198 2198
2199 dict = FindNamePhase("event15", "X"); 2199 dict = FindNamePhase("event15", "X");
2200 ASSERT_TRUE(dict); 2200 ASSERT_TRUE(dict);
2201 dict->GetDictionary("args", &args_dict); 2201 dict->GetDictionary("args", &args_dict);
2202 ASSERT_TRUE(args_dict); 2202 ASSERT_TRUE(args_dict);
2203 EXPECT_TRUE(args_dict->GetInteger("timeticks_one", &int_value)); 2203 EXPECT_TRUE(args_dict->GetInteger("timeticks_one", &int_value));
2204 EXPECT_EQ(1, int_value); 2204 EXPECT_EQ(1, int_value);
2205 } 2205 }
2206 2206
2207 namespace {
2208
2209 bool IsTraceEventArgsWhitelisted(const char* category_group_name,
2210 const char* event_name) {
2211 if (MatchPattern(category_group_name, "toplevel") &&
2212 MatchPattern(event_name, "*")) {
2213 return true;
2214 }
2215
2216 return false;
2217 }
2218
2219 } // namespace
2220
2221 TEST_F(TraceEventTestFixture, ArgsWhitelisting) {
2222 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"),
2223 TraceLog::RECORDING_MODE, TraceOptions());
2224
2225 TraceLog::GetInstance()->SetEventFilterPredicate(
2226 base::Bind(&IsTraceEventArgsWhitelisted));
2227
2228 TRACE_EVENT1("toplevel", "event1", "int_one", 1);
2229 TRACE_EVENT1("whitewashed", "event2", "int_two", 1);
2230 EndTraceAndFlush();
2231
2232 const DictionaryValue* args_dict = NULL;
2233 DictionaryValue* dict = NULL;
2234 int int_value;
2235
2236 dict = FindNamePhase("event1", "X");
2237 ASSERT_TRUE(dict);
2238 dict->GetDictionary("args", &args_dict);
2239 ASSERT_TRUE(args_dict);
2240 EXPECT_TRUE(args_dict->GetInteger("int_one", &int_value));
2241 EXPECT_EQ(1, int_value);
2242
2243 dict = FindNamePhase("event2", "X");
2244 ASSERT_TRUE(dict);
2245 dict->GetDictionary("args", &args_dict);
2246 ASSERT_TRUE(args_dict);
2247 EXPECT_FALSE(args_dict->GetInteger("int_two", &int_value));
2248 EXPECT_TRUE(args_dict->GetInteger("stripped", &int_value));
2249 }
2250
2207 class TraceEventCallbackTest : public TraceEventTestFixture { 2251 class TraceEventCallbackTest : public TraceEventTestFixture {
2208 public: 2252 public:
2209 void SetUp() override { 2253 void SetUp() override {
2210 TraceEventTestFixture::SetUp(); 2254 TraceEventTestFixture::SetUp();
2211 ASSERT_EQ(NULL, s_instance); 2255 ASSERT_EQ(NULL, s_instance);
2212 s_instance = this; 2256 s_instance = this;
2213 } 2257 }
2214 void TearDown() override { 2258 void TearDown() override {
2215 TraceLog::GetInstance()->SetDisabled(); 2259 TraceLog::GetInstance()->SetDisabled();
2216 ASSERT_TRUE(!!s_instance); 2260 ASSERT_TRUE(!!s_instance);
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
3074 EXPECT_EQ(original_option.record_mode, new_options.record_mode); 3118 EXPECT_EQ(original_option.record_mode, new_options.record_mode);
3075 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); 3119 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling);
3076 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); 3120 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace);
3077 } 3121 }
3078 } 3122 }
3079 } 3123 }
3080 } 3124 }
3081 3125
3082 } // namespace trace_event 3126 } // namespace trace_event
3083 } // namespace base 3127 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698