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

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

Issue 287773002: [telemetry] Make testMeasurementSmoke generate separate tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix @Disabled Created 6 years, 6 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/measurements/measurement_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 """Run the first page of every benchmark that has a composable measurement.
6
7 Ideally this test would be comprehensive, but the above serves as a
8 kind of smoke test.
9 """
10
11 import os
12 import unittest
13
14 from telemetry import test
15 from telemetry.core import discover
16 from telemetry.page import page_measurement
17 from telemetry.unittest import gtest_testrunner
18 from telemetry.unittest import options_for_unittests
19
20
21 def SmokeTestGenerator(benchmark):
22 # In general you should @test.Disabled individual benchmarks that fail,
23 # instead of this entire smoke test suite.
24 # TODO(achuith): Multiple tests failing on CrOS. crbug.com/351114
25 @test.Disabled('android', 'chromeos', 'win')
26 def BenchmarkSmokeTest(self):
27 # Only measure a single page so that this test cycles reasonably quickly.
28 benchmark.options['pageset_repeat'] = 1
29 benchmark.options['page_repeat'] = 1
30
31 class SinglePageBenchmark(benchmark): # pylint: disable=W0232
32 def CreatePageSet(self, options):
33 # pylint: disable=E1002
34 ps = super(SinglePageBenchmark, self).CreatePageSet(options)
35 ps.pages = ps.pages[:1]
36 return ps
37
38 # Set the benchmark's default arguments.
39 options = options_for_unittests.GetCopy()
40 options.output_format = 'none'
41 parser = options.CreateParser()
42
43 benchmark.AddCommandLineArgs(parser)
44 test.AddCommandLineArgs(parser)
45 benchmark.SetArgumentDefaults(parser)
46 options.MergeDefaultValues(parser.get_default_values())
47
48 benchmark.ProcessCommandLineArgs(None, options)
49 test.ProcessCommandLineArgs(None, options)
50
51 self.assertEqual(0, SinglePageBenchmark().Run(options),
52 msg='Failed: %s' % benchmark)
53
54 return BenchmarkSmokeTest
55
56
57 def load_tests(_, _2, _3):
58 suite = gtest_testrunner.GTestTestSuite()
59
60 benchmarks_dir = os.path.dirname(__file__)
61 top_level_dir = os.path.dirname(benchmarks_dir)
62 measurements_dir = os.path.join(top_level_dir, 'measurements')
63
64 all_measurements = discover.DiscoverClasses(
65 measurements_dir, top_level_dir, page_measurement.PageMeasurement,
66 pattern='*.py').values()
67 all_benchmarks = discover.DiscoverClasses(
68 benchmarks_dir, top_level_dir, test.Test, pattern='*.py').values()
69
70 for benchmark in all_benchmarks:
71 if benchmark.PageTestClass() not in all_measurements:
72 # If the benchmark is not in measurements, then it is not composable.
73 # Ideally we'd like to test these as well, but the non-composable
74 # benchmarks are usually long-running benchmarks.
75 continue
76
77 if hasattr(benchmark, 'generated_profile_archive'):
78 # We'd like to test these, but don't know how yet.
79 continue
80
81 class BenchmarkSmokeTest(unittest.TestCase):
82 pass
83 setattr(BenchmarkSmokeTest, benchmark.Name(), SmokeTestGenerator(benchmark))
84 suite.addTest(BenchmarkSmokeTest(benchmark.Name()))
85
86 return suite
OLDNEW
« no previous file with comments | « no previous file | tools/perf/measurements/measurement_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698