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 io | 5 import io |
6 import json | 6 import json |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import pickle | 9 import pickle |
10 import shutil | 10 import shutil |
11 import tempfile | 11 import tempfile |
12 import time | 12 import time |
13 import zipfile | 13 import zipfile |
14 | 14 |
15 from devil.android import battery_utils | 15 from devil.android import battery_utils |
16 from devil.android import device_errors | 16 from devil.android import device_errors |
17 from devil.android import device_list | 17 from devil.android import device_list |
18 from devil.android import device_utils | 18 from devil.android import device_utils |
19 from devil.android import forwarder | 19 from devil.android import forwarder |
20 from devil.android.tools import device_recovery | 20 from devil.android.tools import device_recovery |
21 from devil.android.tools import device_status | 21 from devil.android.tools import device_status |
22 from devil.utils import cmd_helper | 22 from devil.utils import cmd_helper |
23 from devil.utils import parallelizer | 23 from devil.utils import parallelizer |
24 from pylib import constants | 24 from pylib import constants |
25 from pylib.base import base_test_result | 25 from pylib.base import base_test_result |
26 from pylib.constants import host_paths | 26 from pylib.constants import host_paths |
| 27 from pylib.local.device import local_device_environment |
27 from pylib.local.device import local_device_test_run | 28 from pylib.local.device import local_device_test_run |
28 | 29 |
29 | 30 |
30 class TestShard(object): | 31 class TestShard(object): |
31 def __init__( | 32 def __init__( |
32 self, env, test_instance, device, index, tests, retries=3, timeout=None): | 33 self, env, test_instance, device, index, tests, retries=3, timeout=None): |
33 logging.info('Create shard %s for device %s to run the following tests:', | 34 logging.info('Create shard %s for device %s to run the following tests:', |
34 index, device) | 35 index, device) |
35 for t in tests: | 36 for t in tests: |
36 logging.info(' %s', t) | 37 logging.info(' %s', t) |
37 self._battery = battery_utils.BatteryUtils(device) | 38 self._battery = battery_utils.BatteryUtils(device) |
38 self._device = device | 39 self._device = device |
39 self._env = env | 40 self._env = env |
40 self._index = index | 41 self._index = index |
41 self._output_dir = None | 42 self._output_dir = None |
42 self._retries = retries | 43 self._retries = retries |
43 self._test_instance = test_instance | 44 self._test_instance = test_instance |
44 self._tests = tests | 45 self._tests = tests |
45 self._timeout = timeout | 46 self._timeout = timeout |
46 | 47 |
47 @local_device_test_run.handle_shard_failures | 48 @local_device_environment.handle_shard_failures |
48 def RunTestsOnShard(self): | 49 def RunTestsOnShard(self): |
49 results = base_test_result.TestRunResults() | 50 results = base_test_result.TestRunResults() |
50 for test in self._tests: | 51 for test in self._tests: |
51 tries_left = self._retries | 52 tries_left = self._retries |
52 result_type = None | 53 result_type = None |
53 while (result_type != base_test_result.ResultType.PASS | 54 while (result_type != base_test_result.ResultType.PASS |
54 and tries_left > 0): | 55 and tries_left > 0): |
55 try: | 56 try: |
56 self._TestSetUp(test) | 57 self._TestSetUp(test) |
57 result_type = self._RunSingleTest(test) | 58 result_type = self._RunSingleTest(test) |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 # override | 374 # override |
374 def _RunTest(self, _device, _test): | 375 def _RunTest(self, _device, _test): |
375 raise NotImplementedError | 376 raise NotImplementedError |
376 | 377 |
377 | 378 |
378 class TestDictVersionError(Exception): | 379 class TestDictVersionError(Exception): |
379 pass | 380 pass |
380 | 381 |
381 class PerfTestRunGetStepsError(Exception): | 382 class PerfTestRunGetStepsError(Exception): |
382 pass | 383 pass |
OLD | NEW |