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