| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 contextlib | 5 import contextlib |
| 6 import datetime | 6 import datetime |
| 7 import json | 7 import json |
| 8 import os | 8 import os |
| 9 import pipes | 9 import pipes |
| 10 import re | 10 import re |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 cwd=self.m.path['checkout'], | 733 cwd=self.m.path['checkout'], |
| 734 env=self.m.chromium.get_env(), | 734 env=self.m.chromium.get_env(), |
| 735 **kwargs) | 735 **kwargs) |
| 736 | 736 |
| 737 def run_sharded_perf_tests(self, config, flaky_config=None, perf_id=None, | 737 def run_sharded_perf_tests(self, config, flaky_config=None, perf_id=None, |
| 738 test_type_transform=lambda x: x, | 738 test_type_transform=lambda x: x, |
| 739 chartjson_file=False, max_battery_temp=None, | 739 chartjson_file=False, max_battery_temp=None, |
| 740 upload_archives_to_bucket=None, | 740 upload_archives_to_bucket=None, |
| 741 known_devices_file=None, | 741 known_devices_file=None, |
| 742 enable_platform_mode=False, | 742 enable_platform_mode=False, |
| 743 timestamp_as_point_id=False, **kwargs): | 743 timestamp_as_point_id=False, |
| 744 pass_adb_path=True, **kwargs): |
| 744 """Run the perf tests from the given config file. | 745 """Run the perf tests from the given config file. |
| 745 | 746 |
| 746 config: the path of the config file containing perf tests. | 747 config: the path of the config file containing perf tests. |
| 747 flaky_config: optional file of tests to avoid. | 748 flaky_config: optional file of tests to avoid. |
| 748 perf_id: the id of the builder running these tests | 749 perf_id: the id of the builder running these tests |
| 749 test_type_transform: a lambda transforming the test name to the | 750 test_type_transform: a lambda transforming the test name to the |
| 750 test_type to upload to. | 751 test_type to upload to. |
| 751 known_devices_file: Path to file containing serial numbers of known devices. | 752 known_devices_file: Path to file containing serial numbers of known devices. |
| 752 enable_platform_mode: If set, will run using the android test runner's new | 753 enable_platform_mode: If set, will run using the android test runner's new |
| 753 platform mode. | 754 platform mode. |
| 754 timestamp_as_point_id: If True, will use a unix timestamp as a point_id to | 755 timestamp_as_point_id: If True, will use a unix timestamp as a point_id to |
| 755 identify values in the perf dashboard; otherwise the default (commit | 756 identify values in the perf dashboard; otherwise the default (commit |
| 756 position) is used. | 757 position) is used. |
| 758 pass_adb_path: If True, will pass the configured adb binary to the test |
| 759 runner via --adb-path. |
| 757 """ | 760 """ |
| 761 # TODO(jbudorick): Remove pass_adb_path once telemetry can use a |
| 762 # configurable adb path. |
| 763 |
| 758 # test_runner.py actually runs the tests and records the results | 764 # test_runner.py actually runs the tests and records the results |
| 759 self._run_sharded_tests(config=config, flaky_config=flaky_config, | 765 self._run_sharded_tests(config=config, flaky_config=flaky_config, |
| 760 chartjson_output=chartjson_file, | 766 chartjson_output=chartjson_file, |
| 761 max_battery_temp=max_battery_temp, | 767 max_battery_temp=max_battery_temp, |
| 762 known_devices_file=known_devices_file, | 768 known_devices_file=known_devices_file, |
| 763 enable_platform_mode=enable_platform_mode, **kwargs) | 769 enable_platform_mode=enable_platform_mode, |
| 770 pass_adb_path=pass_adb_path, **kwargs) |
| 764 | 771 |
| 765 # now obtain the list of tests that were executed. | 772 # now obtain the list of tests that were executed. |
| 766 result = self.test_runner( | 773 result = self.test_runner( |
| 767 'get perf test list', | 774 'get perf test list', |
| 768 ['perf', '--steps', config, '--output-json-list', self.m.json.output(), | 775 ['perf', '--steps', config, '--output-json-list', self.m.json.output(), |
| 769 '--blacklist-file', self.blacklist_file], | 776 '--blacklist-file', self.blacklist_file], |
| 770 step_test_data=lambda: self.m.json.test_api.output([ | 777 step_test_data=lambda: self.m.json.test_api.output([ |
| 771 {'test': 'perf_test.foo', 'device_affinity': 0, | 778 {'test': 'perf_test.foo', 'device_affinity': 0, |
| 772 'end_time': 1443438432.949711, 'has_archive': True}, | 779 'end_time': 1443438432.949711, 'has_archive': True}, |
| 773 {'test': 'page_cycler.foo', 'device_affinity': 0}]), | 780 {'test': 'page_cycler.foo', 'device_affinity': 0}]), |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 raise i | 1547 raise i |
| 1541 elif (f.result.retcode == EXIT_CODES['warning']): | 1548 elif (f.result.retcode == EXIT_CODES['warning']): |
| 1542 w = self.m.step.StepWarning(f.name or f.reason, result=f.result) | 1549 w = self.m.step.StepWarning(f.name or f.reason, result=f.result) |
| 1543 w.result.presentation.status = self.m.step.WARNING | 1550 w.result.presentation.status = self.m.step.WARNING |
| 1544 raise w | 1551 raise w |
| 1545 elif (f.result.retcode == EXIT_CODES['error']): | 1552 elif (f.result.retcode == EXIT_CODES['error']): |
| 1546 f.result.presentation.status = self.m.step.FAILURE | 1553 f.result.presentation.status = self.m.step.FAILURE |
| 1547 raise | 1554 raise |
| 1548 | 1555 |
| 1549 def test_runner(self, step_name, args=None, wrapper_script_suite_name=None, | 1556 def test_runner(self, step_name, args=None, wrapper_script_suite_name=None, |
| 1550 **kwargs): | 1557 pass_adb_path=True, **kwargs): |
| 1551 """Wrapper for the python testrunner script. | 1558 """Wrapper for the python testrunner script. |
| 1552 | 1559 |
| 1553 Args: | 1560 Args: |
| 1554 step_name: Name of the step. | 1561 step_name: Name of the step. |
| 1555 args: Testrunner arguments. | 1562 args: Testrunner arguments. |
| 1556 """ | 1563 """ |
| 1557 if not args: # pragma: no cover | 1564 if not args: # pragma: no cover |
| 1558 args = [] | 1565 args = [] |
| 1559 args.extend(['--adb-path', self.m.adb.adb_path()]) | 1566 if pass_adb_path: |
| 1567 args.extend(['--adb-path', self.m.adb.adb_path()]) |
| 1560 with self.handle_exit_codes(): | 1568 with self.handle_exit_codes(): |
| 1561 script = self.c.test_runner | 1569 script = self.c.test_runner |
| 1562 if wrapper_script_suite_name: | 1570 if wrapper_script_suite_name: |
| 1563 script = self.m.chromium.output_dir.join('bin', 'run_%s' % | 1571 script = self.m.chromium.output_dir.join('bin', 'run_%s' % |
| 1564 wrapper_script_suite_name) | 1572 wrapper_script_suite_name) |
| 1565 else: | 1573 else: |
| 1566 env = kwargs.get('env', {}) | 1574 env = kwargs.get('env', {}) |
| 1567 env['CHROMIUM_OUTPUT_DIR'] = env.get('CHROMIUM_OUTPUT_DIR', | 1575 env['CHROMIUM_OUTPUT_DIR'] = env.get('CHROMIUM_OUTPUT_DIR', |
| 1568 self.m.chromium.output_dir) | 1576 self.m.chromium.output_dir) |
| 1569 kwargs['env'] = env | 1577 kwargs['env'] = env |
| 1570 return self.m.python(step_name, script, args, **kwargs) | 1578 return self.m.python(step_name, script, args, **kwargs) |
| OLD | NEW |