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 import logging | 5 import logging |
6 import os | 6 import os |
7 import unittest | 7 import unittest |
8 | 8 |
9 from telemetry import test | 9 from telemetry import test |
10 from telemetry.core import discover | 10 from telemetry.core import discover |
11 from telemetry.page import page_measurement | 11 from telemetry.page import page_measurement |
12 from telemetry.unittest import options_for_unittests | 12 from telemetry.unittest import options_for_unittests |
13 | 13 |
14 | 14 |
15 class MeasurementUnitTest(unittest.TestCase): | 15 class MeasurementUnitTest(unittest.TestCase): |
16 | 16 |
17 # TODO(achuith): Fix crbug.com/351114. | 17 # TODO(achuith): Fix crbug.com/351114. |
18 @test.Disabled('android', 'chromeos') | 18 @test.Disabled('android', 'chromeos') |
19 def testMeasurementSmoke(self): | 19 def testMeasurementSmoke(self): |
20 # Run all Measurements against the first Page in the PageSet of the first | 20 # Run all Measurements against the first Page in the PageSet of the first |
21 # Benchmark that uses them. | 21 # Benchmark that uses them. |
22 # | 22 # |
23 # Ideally this test would be comprehensive, but the above serves as a | 23 # Ideally this test would be comprehensive, but the above serves as a |
24 # kind of smoke test. | 24 # kind of smoke test. |
25 measurements_dir = os.path.dirname(__file__) | 25 measurements_dir = os.path.dirname(os.path.realpath(__file__)) |
26 top_level_dir = os.path.dirname(measurements_dir) | 26 top_level_dir = os.path.dirname(measurements_dir) |
27 benchmarks_dir = os.path.join(top_level_dir, 'benchmarks') | 27 benchmarks_dir = os.path.join(top_level_dir, 'benchmarks') |
28 | 28 |
29 all_measurements = discover.DiscoverClasses( | 29 all_measurements = discover.DiscoverClasses( |
30 measurements_dir, top_level_dir, page_measurement.PageMeasurement, | 30 measurements_dir, top_level_dir, page_measurement.PageMeasurement, |
31 pattern='*.py').values() | 31 pattern='*.py').values() |
32 all_benchmarks = discover.DiscoverClasses( | 32 all_benchmarks = discover.DiscoverClasses( |
33 benchmarks_dir, top_level_dir, test.Test, pattern='*.py').values() | 33 benchmarks_dir, top_level_dir, test.Test, pattern='*.py').values() |
34 | 34 |
35 for benchmark in all_benchmarks: | 35 for benchmark in all_benchmarks: |
36 if benchmark.test not in all_measurements: | 36 if benchmark.PageTestClass() not in all_measurements: |
37 # If the benchmark is not in measurements, then it is not composable. | 37 # If the benchmark is not in measurements, then it is not composable. |
38 # Ideally we'd like to test these as well, but the non-composable | 38 # Ideally we'd like to test these as well, but the non-composable |
39 # benchmarks are usually long-running benchmarks. | 39 # benchmarks are usually long-running benchmarks. |
40 continue | 40 continue |
41 | 41 |
42 if hasattr(benchmark, 'generated_profile_archive'): | 42 if hasattr(benchmark, 'generated_profile_archive'): |
43 # We'd like to test these, but don't know how yet. | 43 # We'd like to test these, but don't know how yet. |
44 continue | 44 continue |
45 | 45 |
46 # Only measure a single page so that this test cycles reasonably quickly. | 46 # Only measure a single page so that this test cycles reasonably quickly. |
(...skipping 17 matching lines...) Expand all Loading... |
64 benchmark.AddCommandLineArgs(parser) | 64 benchmark.AddCommandLineArgs(parser) |
65 test.AddCommandLineArgs(parser) | 65 test.AddCommandLineArgs(parser) |
66 benchmark.SetArgumentDefaults(parser) | 66 benchmark.SetArgumentDefaults(parser) |
67 options.MergeDefaultValues(parser.get_default_values()) | 67 options.MergeDefaultValues(parser.get_default_values()) |
68 | 68 |
69 benchmark.ProcessCommandLineArgs(None, options) | 69 benchmark.ProcessCommandLineArgs(None, options) |
70 test.ProcessCommandLineArgs(None, options) | 70 test.ProcessCommandLineArgs(None, options) |
71 | 71 |
72 self.assertEqual(0, SinglePageBenchmark().Run(options), | 72 self.assertEqual(0, SinglePageBenchmark().Run(options), |
73 msg='Failed: %s' % benchmark) | 73 msg='Failed: %s' % benchmark) |
OLD | NEW |