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

Side by Side Diff: tools/perf/benchmarks/benchmark_unittest.py

Issue 2199333005: [tools/perf] Add unittests coverage for system health benchmarks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nits 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/perf/benchmarks/system_health.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 """For all the benchmarks that set options, test that the options are valid.""" 5 """For all the benchmarks that set options, test that the options are valid."""
6 6
7 from collections import defaultdict 7 from collections import defaultdict
8 import os
9 import unittest 8 import unittest
10 9
10 from core import path_util
11 from core import perf_benchmark 11 from core import perf_benchmark
12 12
13 from telemetry import benchmark as benchmark_module 13 from telemetry import benchmark as benchmark_module
14 from telemetry.core import discover 14 from telemetry.core import discover
15 from telemetry.internal.browser import browser_options 15 from telemetry.internal.browser import browser_options
16 from telemetry.testing import progress_reporter 16 from telemetry.testing import progress_reporter
17 17
18 18
19 def _GetPerfDir(*subdirs):
20 perf_dir = os.path.dirname(os.path.dirname(__file__))
21 return os.path.join(perf_dir, *subdirs)
22
23
24 def _GetAllPerfBenchmarks(): 19 def _GetAllPerfBenchmarks():
25 return discover.DiscoverClasses( 20 return discover.DiscoverClasses(
26 _GetPerfDir('benchmarks'), _GetPerfDir(), benchmark_module.Benchmark, 21 path_util.GetPerfBenchmarksDir(), path_util.GetPerfDir(),
27 index_by_class_name=True).values() 22 benchmark_module.Benchmark, index_by_class_name=True).values()
28 23
29 24
30 def _BenchmarkOptionsTestGenerator(benchmark): 25 def _BenchmarkOptionsTestGenerator(benchmark):
31 def testBenchmarkOptions(self): # pylint: disable=unused-argument 26 def testBenchmarkOptions(self): # pylint: disable=unused-argument
32 """Invalid options will raise benchmark.InvalidOptionsError.""" 27 """Invalid options will raise benchmark.InvalidOptionsError."""
33 options = browser_options.BrowserFinderOptions() 28 options = browser_options.BrowserFinderOptions()
34 parser = options.CreateParser() 29 parser = options.CreateParser()
35 benchmark.AddCommandLineArgs(parser) 30 benchmark.AddCommandLineArgs(parser)
36 benchmark_module.AddCommandLineArgs(parser) 31 benchmark_module.AddCommandLineArgs(parser)
37 benchmark.SetArgumentDefaults(parser) 32 benchmark.SetArgumentDefaults(parser)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 for benchmark in all_benchmarks: 69 for benchmark in all_benchmarks:
75 if not benchmark.options: 70 if not benchmark.options:
76 # No need to test benchmarks that have not defined options. 71 # No need to test benchmarks that have not defined options.
77 continue 72 continue
78 73
79 class BenchmarkOptionsTest(unittest.TestCase): 74 class BenchmarkOptionsTest(unittest.TestCase):
80 pass 75 pass
81 setattr(BenchmarkOptionsTest, benchmark.Name(), 76 setattr(BenchmarkOptionsTest, benchmark.Name(),
82 _BenchmarkOptionsTestGenerator(benchmark)) 77 _BenchmarkOptionsTestGenerator(benchmark))
83 suite.addTest(BenchmarkOptionsTest(benchmark.Name())) 78 suite.addTest(BenchmarkOptionsTest(benchmark.Name()))
84 suite.addTest(TestNoBenchmarkNamesDuplication())
85 suite.addTest(TestNoOverrideCustomizeBrowserOptions())
86 79
87 80
88 def load_tests(loader, standard_tests, pattern): 81 def load_tests(loader, standard_tests, pattern):
89 del loader, standard_tests, pattern # unused 82 del loader, pattern # unused
90 suite = progress_reporter.TestSuite() 83 suite = progress_reporter.TestSuite()
84 for t in standard_tests:
85 suite.addTests(t)
91 _AddBenchmarkOptionsTests(suite) 86 _AddBenchmarkOptionsTests(suite)
92 return suite 87 return suite
OLDNEW
« no previous file with comments | « no previous file | tools/perf/benchmarks/system_health.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698