OLD | NEW |
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 """Base script for doing test setup.""" | 5 """Base script for doing test setup.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 | 9 |
10 from pylib import constants | 10 from pylib import constants |
11 from pylib import valgrind_tools | 11 from pylib import valgrind_tools |
12 from pylib.utils import isolator | 12 from pylib.utils import isolator |
13 | 13 |
14 def GenerateDepsDirUsingIsolate(suite_name, isolate_file_path, | 14 def GenerateDepsDirUsingIsolate(suite_name, isolate_file_path, |
15 isolate_file_paths, deps_exclusion_list): | 15 isolate_file_paths, deps_exclusion_list): |
16 """Generate the dependency dir for the test suite using isolate. | 16 """Generate the dependency dir for the test suite using isolate. |
17 | 17 |
18 Args: | 18 Args: |
19 suite_name: Name of the test suite (e.g. base_unittests). | 19 suite_name: Name of the test suite (e.g. base_unittests). |
20 isolate_file_path: .isolate file path to use. If there is a default .isolate | 20 isolate_file_path: .isolate file path to use. If there is a default .isolate |
21 file path for the suite_name, this will override it. | 21 file path for the suite_name, this will override it. |
22 isolate_file_paths: Dictionary with the default .isolate file paths for | 22 isolate_file_paths: Dictionary with the default .isolate file paths for |
23 the test suites. | 23 the test suites. |
24 deps_exclusion_list: A list of files that are listed as dependencies in the | 24 deps_exclusion_list: A list of files that are listed as dependencies in the |
25 .isolate files but should not be pushed to the device. | 25 .isolate files but should not be pushed to the device. |
| 26 Returns: |
| 27 The Isolator instance used to remap the dependencies, or None. |
26 """ | 28 """ |
27 if isolate_file_path: | 29 if isolate_file_path: |
28 if os.path.isabs(isolate_file_path): | 30 if os.path.isabs(isolate_file_path): |
29 isolate_abs_path = isolate_file_path | 31 isolate_abs_path = isolate_file_path |
30 else: | 32 else: |
31 isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, | 33 isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, |
32 isolate_file_path) | 34 isolate_file_path) |
33 else: | 35 else: |
34 isolate_rel_path = isolate_file_paths.get(suite_name) | 36 isolate_rel_path = isolate_file_paths.get(suite_name) |
35 if not isolate_rel_path: | 37 if not isolate_rel_path: |
36 logging.info('Did not find an isolate file for the test suite.') | 38 logging.info('Did not find an isolate file for the test suite.') |
37 return | 39 return |
38 isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) | 40 isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) |
39 | 41 |
40 isolated_abs_path = os.path.join( | 42 isolated_abs_path = os.path.join( |
41 constants.GetOutDirectory(), '%s.isolated' % suite_name) | 43 constants.GetOutDirectory(), '%s.isolated' % suite_name) |
42 assert os.path.exists(isolate_abs_path), 'Cannot find %s' % isolate_abs_path | 44 assert os.path.exists(isolate_abs_path), 'Cannot find %s' % isolate_abs_path |
43 | 45 |
44 i = isolator.Isolator(constants.ISOLATE_DEPS_DIR) | 46 i = isolator.Isolator(constants.ISOLATE_DEPS_DIR) |
45 i.Clear() | 47 i.Clear() |
46 i.Remap(isolate_abs_path, isolated_abs_path) | 48 i.Remap(isolate_abs_path, isolated_abs_path) |
47 # We're relying on the fact that timestamps are preserved | 49 # We're relying on the fact that timestamps are preserved |
48 # by the remap command (hardlinked). Otherwise, all the data | 50 # by the remap command (hardlinked). Otherwise, all the data |
49 # will be pushed to the device once we move to using time diff | 51 # will be pushed to the device once we move to using time diff |
50 # instead of md5sum. Perform a sanity check here. | 52 # instead of md5sum. Perform a sanity check here. |
51 i.VerifyHardlinks() | 53 i.VerifyHardlinks() |
52 i.PurgeExcluded(deps_exclusion_list) | 54 i.PurgeExcluded(deps_exclusion_list) |
53 i.MoveOutputDeps() | 55 i.MoveOutputDeps() |
| 56 return i |
54 | 57 |
55 | 58 |
56 def PushDataDeps(device, device_dir, test_options): | 59 def PushDataDeps(device, device_dir, test_options): |
57 valgrind_tools.PushFilesForTool(test_options.tool, device) | 60 valgrind_tools.PushFilesForTool(test_options.tool, device) |
58 if os.path.exists(constants.ISOLATE_DEPS_DIR): | 61 if os.path.exists(constants.ISOLATE_DEPS_DIR): |
59 device.PushChangedFiles([ | 62 device.PushChangedFiles([ |
60 (os.path.join(constants.ISOLATE_DEPS_DIR, p), | 63 (os.path.join(constants.ISOLATE_DEPS_DIR, p), |
61 '%s/%s' % (device_dir, p)) | 64 '%s/%s' % (device_dir, p)) |
62 for p in os.listdir(constants.ISOLATE_DEPS_DIR)]) | 65 for p in os.listdir(constants.ISOLATE_DEPS_DIR)]) |
OLD | NEW |