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 GTests.""" | 5 """Generates test runner factory and tests for GTests.""" |
6 | 6 |
7 import fnmatch | 7 import fnmatch |
8 import glob | 8 import glob |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 _ISOLATE_SCRIPT = os.path.join( | 68 _ISOLATE_SCRIPT = os.path.join( |
69 constants.DIR_SOURCE_ROOT, 'tools', 'swarm_client', 'isolate.py') | 69 constants.DIR_SOURCE_ROOT, 'tools', 'swarm_client', 'isolate.py') |
70 | 70 |
71 | 71 |
72 def _GenerateDepsDirUsingIsolate(suite_name): | 72 def _GenerateDepsDirUsingIsolate(suite_name): |
73 """Generate the dependency dir for the test suite using isolate. | 73 """Generate the dependency dir for the test suite using isolate. |
74 | 74 |
75 Args: | 75 Args: |
76 suite_name: Name of the test suite (e.g. base_unittests). | 76 suite_name: Name of the test suite (e.g. base_unittests). |
77 """ | 77 """ |
78 product_dir = os.path.join(cmd_helper.OutDirectory.get(), | |
79 constants.GetBuildType()) | |
80 assert os.path.isabs(product_dir) | |
81 | |
82 if os.path.isdir(constants.ISOLATE_DEPS_DIR): | 78 if os.path.isdir(constants.ISOLATE_DEPS_DIR): |
83 shutil.rmtree(constants.ISOLATE_DEPS_DIR) | 79 shutil.rmtree(constants.ISOLATE_DEPS_DIR) |
84 | 80 |
85 isolate_rel_path = _ISOLATE_FILE_PATHS.get(suite_name) | 81 isolate_rel_path = _ISOLATE_FILE_PATHS.get(suite_name) |
86 if not isolate_rel_path: | 82 if not isolate_rel_path: |
87 logging.info('Did not find an isolate file for the test suite.') | 83 logging.info('Did not find an isolate file for the test suite.') |
88 return | 84 return |
89 | 85 |
90 isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) | 86 isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) |
91 isolated_abs_path = os.path.join( | 87 isolated_abs_path = os.path.join( |
92 product_dir, '%s.isolated' % suite_name) | 88 constants.GetBuildDirectory(), '%s.isolated' % suite_name) |
93 assert os.path.exists(isolate_abs_path) | 89 assert os.path.exists(isolate_abs_path) |
94 isolate_cmd = [ | 90 isolate_cmd = [ |
95 'python', _ISOLATE_SCRIPT, | 91 'python', _ISOLATE_SCRIPT, |
96 'remap', | 92 'remap', |
97 '--isolate', isolate_abs_path, | 93 '--isolate', isolate_abs_path, |
98 '--isolated', isolated_abs_path, | 94 '--isolated', isolated_abs_path, |
99 '-V', 'PRODUCT_DIR=%s' % product_dir, | 95 '-V', 'PRODUCT_DIR=%s' % constants.GetBuildDirectory(), |
100 '-V', 'OS=android', | 96 '-V', 'OS=android', |
101 '--outdir', constants.ISOLATE_DEPS_DIR, | 97 '--outdir', constants.ISOLATE_DEPS_DIR, |
102 ] | 98 ] |
103 assert not cmd_helper.RunCmd(isolate_cmd) | 99 assert not cmd_helper.RunCmd(isolate_cmd) |
104 | 100 |
105 # We're relying on the fact that timestamps are preserved | 101 # We're relying on the fact that timestamps are preserved |
106 # by the remap command (hardlinked). Otherwise, all the data | 102 # by the remap command (hardlinked). Otherwise, all the data |
107 # will be pushed to the device once we move to using time diff | 103 # will be pushed to the device once we move to using time diff |
108 # instead of md5sum. Perform a sanity check here. | 104 # instead of md5sum. Perform a sanity check here. |
109 for root, _, filenames in os.walk(constants.ISOLATE_DEPS_DIR): | 105 for root, _, filenames in os.walk(constants.ISOLATE_DEPS_DIR): |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 attached_devices = android_commands.GetAttachedDevices() | 289 attached_devices = android_commands.GetAttachedDevices() |
294 tests = _GetTestsFiltered(test_options.suite_name, test_options.gtest_filter, | 290 tests = _GetTestsFiltered(test_options.suite_name, test_options.gtest_filter, |
295 TestRunnerFactory, attached_devices) | 291 TestRunnerFactory, attached_devices) |
296 # Coalesce unit tests into a single test per device | 292 # Coalesce unit tests into a single test per device |
297 if test_options.suite_name != 'content_browsertests': | 293 if test_options.suite_name != 'content_browsertests': |
298 num_devices = len(attached_devices) | 294 num_devices = len(attached_devices) |
299 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] | 295 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] |
300 tests = [t for t in tests if t] | 296 tests = [t for t in tests if t] |
301 | 297 |
302 return (TestRunnerFactory, tests) | 298 return (TestRunnerFactory, tests) |
OLD | NEW |