| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 collections |
| 5 import io | 6 import io |
| 6 import json | 7 import json |
| 7 import logging | 8 import logging |
| 8 import os | 9 import os |
| 9 import pickle | 10 import pickle |
| 10 import shutil | 11 import shutil |
| 11 import tempfile | 12 import tempfile |
| 12 import threading | 13 import threading |
| 13 import time | 14 import time |
| 14 import zipfile | 15 import zipfile |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 steps['version'])) | 364 steps['version'])) |
| 364 return steps | 365 return steps |
| 365 raise PerfTestRunGetStepsError( | 366 raise PerfTestRunGetStepsError( |
| 366 'Neither single_step or steps set in test_instance.') | 367 'Neither single_step or steps set in test_instance.') |
| 367 | 368 |
| 368 def _SplitTestsByAffinity(self): | 369 def _SplitTestsByAffinity(self): |
| 369 # This splits tests by their device affinity so that the same tests always | 370 # This splits tests by their device affinity so that the same tests always |
| 370 # run on the same devices. This is important for perf tests since different | 371 # run on the same devices. This is important for perf tests since different |
| 371 # devices might yield slightly different performance results. | 372 # devices might yield slightly different performance results. |
| 372 test_dict = self._GetStepsFromDict() | 373 test_dict = self._GetStepsFromDict() |
| 373 for test, test_config in test_dict['steps'].iteritems(): | 374 for test, test_config in sorted(test_dict['steps'].iteritems()): |
| 374 try: | 375 try: |
| 375 affinity = test_config.get('device_affinity') | 376 affinity = test_config.get('device_affinity') |
| 376 if affinity is None: | 377 if affinity is None: |
| 377 self._no_device_tests[test] = test_config | 378 self._no_device_tests[test] = test_config |
| 378 else: | 379 else: |
| 379 if len(self._test_buckets) < affinity + 1: | 380 if len(self._test_buckets) < affinity + 1: |
| 380 while len(self._test_buckets) != affinity + 1: | 381 while len(self._test_buckets) != affinity + 1: |
| 381 self._test_buckets.append({}) | 382 self._test_buckets.append(collections.OrderedDict()) |
| 382 self._test_buckets[affinity][test] = test_config | 383 self._test_buckets[affinity][test] = test_config |
| 383 except KeyError: | 384 except KeyError: |
| 384 logging.exception( | 385 logging.exception( |
| 385 'Test config for %s is bad.\n Config:%s', test, str(test_config)) | 386 'Test config for %s is bad.\n Config:%s', test, str(test_config)) |
| 386 | 387 |
| 387 @staticmethod | 388 @staticmethod |
| 388 def _GetAllDevices(active_devices, devices_path): | 389 def _GetAllDevices(active_devices, devices_path): |
| 389 try: | 390 try: |
| 390 if devices_path: | 391 if devices_path: |
| 391 devices = [device_utils.DeviceUtils(s) | 392 devices = [device_utils.DeviceUtils(s) |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 # override | 509 # override |
| 509 def _RunTest(self, _device, _test): | 510 def _RunTest(self, _device, _test): |
| 510 raise NotImplementedError | 511 raise NotImplementedError |
| 511 | 512 |
| 512 | 513 |
| 513 class TestDictVersionError(Exception): | 514 class TestDictVersionError(Exception): |
| 514 pass | 515 pass |
| 515 | 516 |
| 516 class PerfTestRunGetStepsError(Exception): | 517 class PerfTestRunGetStepsError(Exception): |
| 517 pass | 518 pass |
| OLD | NEW |