OLD | NEW |
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 """Run the first page of every benchmark that has a composable measurement. | 5 """Run the first page of every benchmark that has a composable measurement. |
6 | 6 |
7 Ideally this test would be comprehensive, but the above serves as a | 7 Ideally this test would be comprehensive, but the above serves as a |
8 kind of smoke test. | 8 kind of smoke test. |
9 """ | 9 """ |
10 | 10 |
11 import os | 11 import os |
12 import unittest | 12 import unittest |
13 | 13 |
14 from telemetry import benchmark as benchmark_module | 14 from telemetry import benchmark as benchmark_module |
15 from telemetry.core import discover | 15 from telemetry.core import discover |
16 from telemetry.page import page_measurement | 16 from telemetry.page import page_measurement |
17 from telemetry.unittest import options_for_unittests | 17 from telemetry.unittest import options_for_unittests |
18 from telemetry.unittest import output_formatter | 18 from telemetry.unittest import progress_reporter |
19 | 19 |
20 | 20 |
21 def SmokeTestGenerator(benchmark): | 21 def SmokeTestGenerator(benchmark): |
22 # In general you should @benchmark_module.Disabled individual benchmarks that | 22 # In general you should @benchmark_module.Disabled individual benchmarks that |
23 # fail, instead of this entire smoke test suite. | 23 # fail, instead of this entire smoke test suite. |
24 # TODO(achuith): Multiple tests failing on CrOS. crbug.com/351114 | 24 # TODO(achuith): Multiple tests failing on CrOS. crbug.com/351114 |
25 @benchmark_module.Disabled('chromeos') | 25 @benchmark_module.Disabled('chromeos') |
26 # Flaky, http://crbug.com/400747 . | 26 # Flaky, http://crbug.com/400747 . |
27 @benchmark_module.Disabled('mac') | 27 @benchmark_module.Disabled('mac') |
28 def BenchmarkSmokeTest(self): | 28 def BenchmarkSmokeTest(self): |
(...skipping 22 matching lines...) Expand all Loading... |
51 benchmark.ProcessCommandLineArgs(None, options) | 51 benchmark.ProcessCommandLineArgs(None, options) |
52 benchmark_module.ProcessCommandLineArgs(None, options) | 52 benchmark_module.ProcessCommandLineArgs(None, options) |
53 | 53 |
54 self.assertEqual(0, SinglePageBenchmark().Run(options), | 54 self.assertEqual(0, SinglePageBenchmark().Run(options), |
55 msg='Failed: %s' % benchmark) | 55 msg='Failed: %s' % benchmark) |
56 | 56 |
57 return BenchmarkSmokeTest | 57 return BenchmarkSmokeTest |
58 | 58 |
59 | 59 |
60 def load_tests(_, _2, _3): | 60 def load_tests(_, _2, _3): |
61 suite = output_formatter.TestSuite() | 61 suite = progress_reporter.TestSuite() |
62 | 62 |
63 benchmarks_dir = os.path.dirname(__file__) | 63 benchmarks_dir = os.path.dirname(__file__) |
64 top_level_dir = os.path.dirname(benchmarks_dir) | 64 top_level_dir = os.path.dirname(benchmarks_dir) |
65 measurements_dir = os.path.join(top_level_dir, 'measurements') | 65 measurements_dir = os.path.join(top_level_dir, 'measurements') |
66 | 66 |
67 all_measurements = discover.DiscoverClasses( | 67 all_measurements = discover.DiscoverClasses( |
68 measurements_dir, top_level_dir, page_measurement.PageMeasurement, | 68 measurements_dir, top_level_dir, page_measurement.PageMeasurement, |
69 pattern='*.py').values() | 69 pattern='*.py').values() |
70 all_benchmarks = discover.DiscoverClasses( | 70 all_benchmarks = discover.DiscoverClasses( |
71 benchmarks_dir, top_level_dir, benchmark_module.Benchmark, | 71 benchmarks_dir, top_level_dir, benchmark_module.Benchmark, |
(...skipping 12 matching lines...) Expand all Loading... |
84 if hasattr(benchmark, 'generated_profile_archive'): | 84 if hasattr(benchmark, 'generated_profile_archive'): |
85 # We'd like to test these, but don't know how yet. | 85 # We'd like to test these, but don't know how yet. |
86 continue | 86 continue |
87 | 87 |
88 class BenchmarkSmokeTest(unittest.TestCase): | 88 class BenchmarkSmokeTest(unittest.TestCase): |
89 pass | 89 pass |
90 setattr(BenchmarkSmokeTest, benchmark.Name(), SmokeTestGenerator(benchmark)) | 90 setattr(BenchmarkSmokeTest, benchmark.Name(), SmokeTestGenerator(benchmark)) |
91 suite.addTest(BenchmarkSmokeTest(benchmark.Name())) | 91 suite.addTest(BenchmarkSmokeTest(benchmark.Name())) |
92 | 92 |
93 return suite | 93 return suite |
OLD | NEW |