OLD | NEW |
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 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 CategoryFilter("-inc"), | 1198 CategoryFilter("-inc"), |
1199 TraceLog::RECORDING_MODE, | 1199 TraceLog::RECORDING_MODE, |
1200 TraceOptions()); | 1200 TraceOptions()); |
1201 TRACE_EVENT_INSTANT0("inc", "name", TRACE_EVENT_SCOPE_THREAD); | 1201 TRACE_EVENT_INSTANT0("inc", "name", TRACE_EVENT_SCOPE_THREAD); |
1202 TRACE_EVENT_INSTANT0("inc2", "name", TRACE_EVENT_SCOPE_THREAD); | 1202 TRACE_EVENT_INSTANT0("inc2", "name", TRACE_EVENT_SCOPE_THREAD); |
1203 TRACE_EVENT_INSTANT0("inc2,inc", "name", TRACE_EVENT_SCOPE_THREAD); | 1203 TRACE_EVENT_INSTANT0("inc2,inc", "name", TRACE_EVENT_SCOPE_THREAD); |
1204 TRACE_EVENT_INSTANT0("inc,inc2", "name", TRACE_EVENT_SCOPE_THREAD); | 1204 TRACE_EVENT_INSTANT0("inc,inc2", "name", TRACE_EVENT_SCOPE_THREAD); |
1205 EndTraceAndFlush(); | 1205 EndTraceAndFlush(); |
1206 EXPECT_TRUE(FindMatchingValue("cat", "inc2")); | 1206 EXPECT_TRUE(FindMatchingValue("cat", "inc2")); |
1207 EXPECT_FALSE(FindMatchingValue("cat", "inc")); | 1207 EXPECT_FALSE(FindMatchingValue("cat", "inc")); |
1208 EXPECT_FALSE(FindMatchingValue("cat", "inc2,inc")); | 1208 EXPECT_TRUE(FindMatchingValue("cat", "inc2,inc")); |
1209 EXPECT_FALSE(FindMatchingValue("cat", "inc,inc2")); | 1209 EXPECT_TRUE(FindMatchingValue("cat", "inc,inc2")); |
1210 | 1210 |
1211 // Exclude existent wildcard -> all categories not matching wildcard | 1211 // Exclude existent wildcard -> all categories not matching wildcard |
1212 Clear(); | 1212 Clear(); |
1213 TraceLog::GetInstance()->SetEnabled( | 1213 TraceLog::GetInstance()->SetEnabled( |
1214 CategoryFilter("-inc_wildcard_*,-inc_wildchar_?_end"), | 1214 CategoryFilter("-inc_wildcard_*,-inc_wildchar_?_end"), |
1215 TraceLog::RECORDING_MODE, | 1215 TraceLog::RECORDING_MODE, |
1216 TraceOptions()); | 1216 TraceOptions()); |
1217 TRACE_EVENT_INSTANT0("inc_wildcard_abc", "not_inc", | 1217 TRACE_EVENT_INSTANT0("inc_wildcard_abc", "not_inc", |
1218 TRACE_EVENT_SCOPE_THREAD); | 1218 TRACE_EVENT_SCOPE_THREAD); |
1219 TRACE_EVENT_INSTANT0("inc_wildcard_", "not_inc", | 1219 TRACE_EVENT_INSTANT0("inc_wildcard_", "not_inc", |
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2617 // Test the category filter. | 2617 // Test the category filter. |
2618 TEST_F(TraceEventTestFixture, CategoryFilter) { | 2618 TEST_F(TraceEventTestFixture, CategoryFilter) { |
2619 // Using the default filter. | 2619 // Using the default filter. |
2620 CategoryFilter default_cf = CategoryFilter( | 2620 CategoryFilter default_cf = CategoryFilter( |
2621 CategoryFilter::kDefaultCategoryFilterString); | 2621 CategoryFilter::kDefaultCategoryFilterString); |
2622 std::string category_filter_str = default_cf.ToString(); | 2622 std::string category_filter_str = default_cf.ToString(); |
2623 EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str()); | 2623 EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str()); |
2624 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category")); | 2624 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category")); |
2625 EXPECT_FALSE( | 2625 EXPECT_FALSE( |
2626 default_cf.IsCategoryGroupEnabled("disabled-by-default-category")); | 2626 default_cf.IsCategoryGroupEnabled("disabled-by-default-category")); |
2627 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("Category1,CategoryDebug")); | 2627 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("Category1,CategoryDebug")); |
2628 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryDebug,Category1")); | 2628 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("CategoryDebug,Category1")); |
2629 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryTest,Category2")); | 2629 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("CategoryTest,Category2")); |
2630 | 2630 |
2631 // Make sure that upon an empty string, we fall back to the default filter. | 2631 // Make sure that upon an empty string, we fall back to the default filter. |
2632 default_cf = CategoryFilter(); | 2632 default_cf = CategoryFilter(); |
2633 category_filter_str = default_cf.ToString(); | 2633 category_filter_str = default_cf.ToString(); |
2634 EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str()); | 2634 EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str()); |
2635 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category")); | 2635 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category")); |
2636 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("Category1,CategoryDebug")); | 2636 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("Category1,CategoryDebug")); |
2637 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryDebug,Category1")); | 2637 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("CategoryDebug,Category1")); |
2638 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryTest,Category2")); | 2638 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("CategoryTest,Category2")); |
2639 | 2639 |
2640 // Using an arbitrary non-empty filter. | 2640 // Using an arbitrary non-empty filter. |
2641 CategoryFilter cf("included,-excluded,inc_pattern*,-exc_pattern*"); | 2641 CategoryFilter cf("included,-excluded,inc_pattern*,-exc_pattern*"); |
2642 category_filter_str = cf.ToString(); | 2642 category_filter_str = cf.ToString(); |
2643 EXPECT_STREQ("included,inc_pattern*,-excluded,-exc_pattern*", | 2643 EXPECT_STREQ("included,inc_pattern*,-excluded,-exc_pattern*", |
2644 category_filter_str.c_str()); | 2644 category_filter_str.c_str()); |
2645 EXPECT_TRUE(cf.IsCategoryGroupEnabled("included")); | 2645 EXPECT_TRUE(cf.IsCategoryGroupEnabled("included")); |
2646 EXPECT_TRUE(cf.IsCategoryGroupEnabled("inc_pattern_category")); | 2646 EXPECT_TRUE(cf.IsCategoryGroupEnabled("inc_pattern_category")); |
2647 EXPECT_FALSE(cf.IsCategoryGroupEnabled("exc_pattern_category")); | 2647 EXPECT_FALSE(cf.IsCategoryGroupEnabled("exc_pattern_category")); |
2648 EXPECT_FALSE(cf.IsCategoryGroupEnabled("excluded")); | 2648 EXPECT_FALSE(cf.IsCategoryGroupEnabled("excluded")); |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3074 EXPECT_EQ(original_option.record_mode, new_options.record_mode); | 3074 EXPECT_EQ(original_option.record_mode, new_options.record_mode); |
3075 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); | 3075 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); |
3076 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); | 3076 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); |
3077 } | 3077 } |
3078 } | 3078 } |
3079 } | 3079 } |
3080 } | 3080 } |
3081 | 3081 |
3082 } // namespace trace_event | 3082 } // namespace trace_event |
3083 } // namespace base | 3083 } // namespace base |
OLD | NEW |