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

Unified 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: 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
« no previous file with comments | « no previous file | tools/perf/benchmarks/system_health.py » ('j') | tools/perf/benchmarks/system_health.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/benchmarks/benchmark_unittest.py
diff --git a/tools/perf/benchmarks/benchmark_unittest.py b/tools/perf/benchmarks/benchmark_unittest.py
index 82cb87e0e05413750c8a6a24146e35b1871bde8b..b6298cd8d4bd4c1e7ef293d6602396e036be7570 100644
--- a/tools/perf/benchmarks/benchmark_unittest.py
+++ b/tools/perf/benchmarks/benchmark_unittest.py
@@ -7,7 +7,10 @@
from collections import defaultdict
import os
import unittest
+import sys
petrcermak 2016/08/03 08:49:27 nit: sort order ('s' < 'u')
nednguyen 2016/08/03 15:41:36 Done.
+from benchmarks import system_health
petrcermak 2016/08/03 08:49:27 nit: I would probably do `from benchmarks import s
nednguyen 2016/08/03 15:41:36 Done.
+from page_sets.system_health import system_health_stories
petrcermak 2016/08/03 08:49:26 nit: sort order ('b' < 'c' < 'p'). If you want to
nednguyen 2016/08/03 15:41:36 Done.
from core import perf_benchmark
from telemetry import benchmark as benchmark_module
@@ -27,6 +30,11 @@ def _GetAllPerfBenchmarks():
index_by_class_name=True).values()
+def _GetAllSystemHealthBenchmarks():
+ return [b for b in _GetAllPerfBenchmarks() if
+ sys.modules[b.__module__] == system_health]
+
+
def _BenchmarkOptionsTestGenerator(benchmark):
def testBenchmarkOptions(self): # pylint: disable=unused-argument
"""Invalid options will raise benchmark.InvalidOptionsError."""
@@ -51,6 +59,30 @@ class TestNoBenchmarkNamesDuplication(unittest.TestCase):
'found: %s' % (n, str(names_to_benchmarks[n])))
+class TestSystemHealthBenchmarks(unittest.TestCase):
+
+ def testNaming(self):
+ for s in _GetAllSystemHealthBenchmarks():
petrcermak 2016/08/03 08:49:27 nit: could you change the variable to |b| as well
nednguyen 2016/08/03 15:41:36 Done.
+ self.assertTrue(
+ s.Name().startswith('system_health.'),
+ '%s must have name started with "system_health." prefix')
petrcermak 2016/08/03 08:49:26 you forgot to add `% s`
petrcermak 2016/08/03 08:49:27 also, I wonder whether '%r' wouldn't be more appli
nednguyen 2016/08/03 15:41:36 Done.
+
+ def testShouldTearDownStateAfterEachStoryRunIsTrue(self):
+ for b in _GetAllSystemHealthBenchmarks():
+ self.assertTrue(
+ b.ShouldTearDownStateAfterEachStoryRun(),
+ '%s has ShouldTearDownStateAfterEachStoryRun set to False' % b)
+
+ def testSystemHealthStorySetAreUsed(self):
+ for b in _GetAllSystemHealthBenchmarks():
+ if b is system_health.WebviewStartupSystemHealthBenchmark:
+ continue
petrcermak 2016/08/03 08:49:27 nit: this should be indented only 2 spaces (-2)
petrcermak 2016/08/03 08:49:27 Does this mean that the WebView benchmark shouldn'
nednguyen 2016/08/03 15:41:36 Probably it should use the SH story set. We probab
+ self.assertIsInstance(
+ b().CreateStorySet(None),
+ system_health_stories.SystemHealthStorySet,
+ '%s does not use SystemHealthStorySet' % b)
+
+
class TestNoOverrideCustomizeBrowserOptions(unittest.TestCase):
def runTest(self):
@@ -81,12 +113,12 @@ def _AddBenchmarkOptionsTests(suite):
setattr(BenchmarkOptionsTest, benchmark.Name(),
_BenchmarkOptionsTestGenerator(benchmark))
suite.addTest(BenchmarkOptionsTest(benchmark.Name()))
- suite.addTest(TestNoBenchmarkNamesDuplication())
- suite.addTest(TestNoOverrideCustomizeBrowserOptions())
def load_tests(loader, standard_tests, pattern):
- del loader, standard_tests, pattern # unused
+ del loader, pattern # unused
suite = progress_reporter.TestSuite()
+ for t in standard_tests:
+ suite.addTests(t)
_AddBenchmarkOptionsTests(suite)
return suite
« no previous file with comments | « no previous file | tools/perf/benchmarks/system_health.py » ('j') | tools/perf/benchmarks/system_health.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698