OLD | NEW |
| (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 options_for_unittests | |
18 | |
19 | |
20 # In general you should @test.Disabled individual benchmarks that fail, | |
21 # instead of this entire smoke test suite. | |
22 # TODO(achuith): Multiple tests failing on CrOS. crbug.com/351114 | |
23 @test.Disabled('android', 'chromeos', 'win') | |
24 class BenchmarkSmokeTest(unittest.TestCase): | |
25 """Placeholder class for the tests. | |
26 | |
27 The members of this class are generated in load_tests, below. | |
28 """ | |
29 | |
30 | |
31 def SmokeTestGenerator(benchmark): | |
32 def SmokeTest(self): | |
33 # Only measure a single page so that this test cycles reasonably quickly. | |
34 benchmark.options['pageset_repeat'] = 1 | |
35 benchmark.options['page_repeat'] = 1 | |
36 | |
37 class SinglePageBenchmark(benchmark): # pylint: disable=W0232 | |
38 def CreatePageSet(self, options): | |
39 # pylint: disable=E1002 | |
40 ps = super(SinglePageBenchmark, self).CreatePageSet(options) | |
41 ps.pages = ps.pages[:1] | |
42 return ps | |
43 | |
44 # Set the benchmark's default arguments. | |
45 options = options_for_unittests.GetCopy() | |
46 options.output_format = 'none' | |
47 parser = options.CreateParser() | |
48 | |
49 benchmark.AddCommandLineArgs(parser) | |
50 test.AddCommandLineArgs(parser) | |
51 benchmark.SetArgumentDefaults(parser) | |
52 options.MergeDefaultValues(parser.get_default_values()) | |
53 | |
54 benchmark.ProcessCommandLineArgs(None, options) | |
55 test.ProcessCommandLineArgs(None, options) | |
56 | |
57 self.assertEqual(0, SinglePageBenchmark().Run(options), | |
58 msg='Failed: %s' % benchmark) | |
59 | |
60 return SmokeTest | |
61 | |
62 | |
63 def load_tests(_, _2, _3): | |
64 suite = unittest.TestSuite() | |
65 | |
66 benchmarks_dir = os.path.dirname(__file__) | |
67 top_level_dir = os.path.dirname(benchmarks_dir) | |
68 measurements_dir = os.path.join(top_level_dir, 'measurements') | |
69 | |
70 all_measurements = discover.DiscoverClasses( | |
71 measurements_dir, top_level_dir, page_measurement.PageMeasurement, | |
72 pattern='*.py').values() | |
73 all_benchmarks = discover.DiscoverClasses( | |
74 benchmarks_dir, top_level_dir, test.Test, pattern='*.py').values() | |
75 | |
76 for benchmark in all_benchmarks: | |
77 if benchmark.PageTestClass() not in all_measurements: | |
78 # If the benchmark is not in measurements, then it is not composable. | |
79 # Ideally we'd like to test these as well, but the non-composable | |
80 # benchmarks are usually long-running benchmarks. | |
81 continue | |
82 | |
83 if hasattr(benchmark, 'generated_profile_archive'): | |
84 # We'd like to test these, but don't know how yet. | |
85 continue | |
86 | |
87 setattr(BenchmarkSmokeTest, benchmark.Name(), SmokeTestGenerator(benchmark)) | |
88 suite.addTest(BenchmarkSmokeTest(benchmark.Name())) | |
89 | |
90 return suite | |
OLD | NEW |