diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-29 00:39:48 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-29 00:39:48 +0000 |
commit | b0d38d4c40304f92bf1b06027b225ac807fef702 (patch) | |
tree | 588e5dae9930f8ad2e6de6800761975b80325c3e /base/vlog_unittest.cc | |
parent | 41703f7ec3774c1f9766b263ce3e9a93c03c4765 (diff) | |
download | chromium_src-b0d38d4c40304f92bf1b06027b225ac807fef702.zip chromium_src-b0d38d4c40304f92bf1b06027b225ac807fef702.tar.gz chromium_src-b0d38d4c40304f92bf1b06027b225ac807fef702.tar.bz2 |
Added support for filtering on the entire pathname to --vmodule.
Also cleaned up spurious warning when --vmodule is used but --v is not.
Removed slow perf unittest from vlog_unittest.cc.
BUG=61123
TEST=New vlog unittests
Review URL: http://codereview.chromium.org/4140007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64346 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/vlog_unittest.cc')
-rw-r--r-- | base/vlog_unittest.cc | 86 |
1 files changed, 24 insertions, 62 deletions
diff --git a/base/vlog_unittest.cc b/base/vlog_unittest.cc index 95aa1b9a..c69f9cc 100644 --- a/base/vlog_unittest.cc +++ b/base/vlog_unittest.cc @@ -26,10 +26,10 @@ TEST_F(VlogTest, NoVmodule) { EXPECT_EQ(5, VlogInfo("5", "").GetVlogLevel("test6")); } -TEST_F(VlogTest, Vmodule) { +TEST_F(VlogTest, VmoduleBasic) { const char kVSwitch[] = "-1"; const char kVModuleSwitch[] = - "foo=,bar=0,baz=blah,,qux=0blah1,quux=1,corge=5"; + "foo=,bar=0,baz=blah,,qux=0blah1,quux=1,corge.ext=5"; VlogInfo vlog_info(kVSwitch, kVModuleSwitch); EXPECT_EQ(-1, vlog_info.GetVlogLevel("/path/to/grault.cc")); EXPECT_EQ(0, vlog_info.GetVlogLevel("/path/to/foo.cc")); @@ -38,70 +38,32 @@ TEST_F(VlogTest, Vmodule) { EXPECT_EQ(0, vlog_info.GetVlogLevel("baz.h")); EXPECT_EQ(0, vlog_info.GetVlogLevel("/another/path/to/qux.h")); EXPECT_EQ(1, vlog_info.GetVlogLevel("/path/to/quux")); - EXPECT_EQ(5, vlog_info.GetVlogLevel("c:\\path/to/corge.h")); + EXPECT_EQ(5, vlog_info.GetVlogLevel("c:\\path/to/corge.ext.h")); } -#define BENCHMARK(iters, elapsed, code) \ - do { \ - base::TimeTicks start = base::TimeTicks::Now(); \ - for (int i = 0; i < iters; ++i) code; \ - base::TimeTicks end = base::TimeTicks::Now(); \ - elapsed = end - start; \ - double cps = iters / elapsed.InSecondsF(); \ - LOG(INFO) << cps << " cps (" << elapsed.InSecondsF() \ - << "s elapsed)"; \ - } while (0) - -double GetSlowdown(const base::TimeDelta& base, - const base::TimeDelta& elapsed) { - return elapsed.InSecondsF() / base.InSecondsF(); -} - - -TEST_F(VlogTest, Perf) { - const char* kVlogs[] = { - "/path/to/foo.cc", - "C:\\path\\to\\bar.h", - "/path/to/not-matched.mm", - "C:\\path\\to\\baz-inl.mm", - "C:\\path\\to\\qux.mm", - "/path/to/quux.mm", - "/path/to/another-not-matched.mm", - }; - const int kVlogCount = arraysize(kVlogs); - const int kBenchmarkIterations = RunningOnValgrind() ? 30000 : 10000000; - - base::TimeDelta null_elapsed; - { - VlogInfo null_vlog_info("", ""); - BENCHMARK(kBenchmarkIterations, null_elapsed, { - EXPECT_NE(-1, null_vlog_info.GetVlogLevel(kVlogs[i % kVlogCount])); - }); - } - - { - VlogInfo small_vlog_info("0", "foo=1,bar=2,baz=3,qux=4,quux=5"); - base::TimeDelta elapsed; - BENCHMARK(kBenchmarkIterations, elapsed, { - EXPECT_NE(-1, small_vlog_info.GetVlogLevel(kVlogs[i % kVlogCount])); - }); - LOG(INFO) << "slowdown = " << GetSlowdown(null_elapsed, elapsed) - << "x"; - } - - { - VlogInfo pattern_vlog_info("0", "fo*=1,ba?=2,b*?z=3,*ux=4,?uux=5"); - base::TimeDelta elapsed; - BENCHMARK(kBenchmarkIterations, elapsed, { - EXPECT_NE(-1, pattern_vlog_info.GetVlogLevel(kVlogs[i % kVlogCount])); - }); - LOG(INFO) << "slowdown = " << GetSlowdown(null_elapsed, elapsed) - << "x"; - } +TEST_F(VlogTest, VmoduleDirs) { + const char kVModuleSwitch[] = + "foo/bar.cc=1,baz\\*\\qux.cc=2,*quux/*=3,*/*-inl.h=4"; + VlogInfo vlog_info("", kVModuleSwitch); + EXPECT_EQ(0, vlog_info.GetVlogLevel("/foo/bar.cc")); + EXPECT_EQ(0, vlog_info.GetVlogLevel("bar.cc")); + EXPECT_EQ(1, vlog_info.GetVlogLevel("foo/bar.cc")); + + EXPECT_EQ(0, vlog_info.GetVlogLevel("baz/grault/qux.h")); + EXPECT_EQ(0, vlog_info.GetVlogLevel("/baz/grault/qux.cc")); + EXPECT_EQ(0, vlog_info.GetVlogLevel("baz/grault/qux.cc")); + EXPECT_EQ(0, vlog_info.GetVlogLevel("baz/grault/blah/qux.cc")); + EXPECT_EQ(2, vlog_info.GetVlogLevel("baz\\grault\\qux.cc")); + EXPECT_EQ(2, vlog_info.GetVlogLevel("baz\\grault\\blah\\qux.cc")); + + EXPECT_EQ(0, vlog_info.GetVlogLevel("/foo/bar/baz/quux.cc")); + EXPECT_EQ(3, vlog_info.GetVlogLevel("/foo/bar/baz/quux/grault.cc")); + + EXPECT_EQ(0, vlog_info.GetVlogLevel("foo/bar/test-inl.cc")); + EXPECT_EQ(4, vlog_info.GetVlogLevel("foo/bar/test-inl.h")); + EXPECT_EQ(4, vlog_info.GetVlogLevel("foo/bar/baz/blah-inl.h")); } -#undef BENCHMARK - } // namespace } // namespace logging |