| 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 """Generates test runner factory and tests for performance tests.""" | 5 """Generates test runner factory and tests for performance tests.""" |
| 6 | 6 |
| 7 import json | 7 import json |
| 8 import fnmatch | 8 import fnmatch |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 'version': 1, | 35 'version': 1, |
| 36 'steps': { | 36 'steps': { |
| 37 'single_step': { | 37 'single_step': { |
| 38 'device_affinity': 0, | 38 'device_affinity': 0, |
| 39 'cmd': test_options.single_step | 39 'cmd': test_options.single_step |
| 40 }, | 40 }, |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 return steps_dict | 43 return steps_dict |
| 44 | 44 |
| 45 # TODO(bulach): remove once it rolls downstream, crbug.com/378862. | |
| 46 def _GetStepsDictFromV0(steps_v0): | |
| 47 steps_dict = { | |
| 48 'version': 1, | |
| 49 'steps': {}, | |
| 50 } | |
| 51 affinity = 0 | |
| 52 for step in steps_v0: | |
| 53 steps_dict['steps'][step[0]] = { | |
| 54 'device_affinity': affinity, | |
| 55 'cmd': step[1], | |
| 56 } | |
| 57 affinity += 1 | |
| 58 return steps_dict | |
| 59 | |
| 60 | 45 |
| 61 def _GetStepsDict(test_options): | 46 def _GetStepsDict(test_options): |
| 62 if test_options.single_step: | 47 if test_options.single_step: |
| 63 return _GetStepsDictFromSingleStep(test_options) | 48 return _GetStepsDictFromSingleStep(test_options) |
| 64 if test_options.steps: | 49 if test_options.steps: |
| 65 with file(test_options.steps, 'r') as f: | 50 with file(test_options.steps, 'r') as f: |
| 66 steps = json.load(f) | 51 steps = json.load(f) |
| 67 # TODO(bulach): remove once it rolls downstream, crbug.com/378862. | |
| 68 if isinstance(steps, list): | |
| 69 return _GetStepsDictFromV0(steps) | |
| 70 | 52 |
| 71 # Already using the new format. | 53 # Already using the new format. |
| 72 assert steps['version'] == 1 | 54 assert steps['version'] == 1 |
| 73 return steps | 55 return steps |
| 74 | 56 |
| 75 | 57 |
| 76 def Setup(test_options): | 58 def Setup(test_options): |
| 77 """Create and return the test runner factory and tests. | 59 """Create and return the test runner factory and tests. |
| 78 | 60 |
| 79 Args: | 61 Args: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 106 if test_options.flaky_steps: | 88 if test_options.flaky_steps: |
| 107 with file(test_options.flaky_steps, 'r') as f: | 89 with file(test_options.flaky_steps, 'r') as f: |
| 108 flaky_steps = json.load(f) | 90 flaky_steps = json.load(f) |
| 109 | 91 |
| 110 def TestRunnerFactory(device, shard_index): | 92 def TestRunnerFactory(device, shard_index): |
| 111 return test_runner.TestRunner( | 93 return test_runner.TestRunner( |
| 112 test_options, device, shard_index, len(all_devices), | 94 test_options, device, shard_index, len(all_devices), |
| 113 steps_dict, flaky_steps) | 95 steps_dict, flaky_steps) |
| 114 | 96 |
| 115 return (TestRunnerFactory, sorted_step_names, all_devices) | 97 return (TestRunnerFactory, sorted_step_names, all_devices) |
| OLD | NEW |