OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Class for running instrumentation tests on a single device.""" | 5 """Class for running instrumentation tests on a single device.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import re | 9 import re |
10 import sys | 10 import sys |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 #override | 91 #override |
92 def InstallTestPackage(self): | 92 def InstallTestPackage(self): |
93 self.test_pkg.Install(self.device) | 93 self.test_pkg.Install(self.device) |
94 | 94 |
95 #override | 95 #override |
96 def PushDataDeps(self): | 96 def PushDataDeps(self): |
97 # TODO(frankf): Implement a general approach for copying/installing | 97 # TODO(frankf): Implement a general approach for copying/installing |
98 # once across test runners. | 98 # once across test runners. |
99 if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False): | 99 if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False): |
100 logging.warning('Already copied test files to device %s, skipping.', | 100 logging.warning('Already copied test files to device %s, skipping.', |
101 self.device.old_interface.GetDevice()) | 101 str(self.device)) |
102 return | 102 return |
103 | 103 |
104 test_data = _GetDataFilesForTestSuite(self.test_pkg.GetApkName()) | 104 test_data = _GetDataFilesForTestSuite(self.test_pkg.GetApkName()) |
105 if test_data: | 105 if test_data: |
106 # Make sure SD card is ready. | 106 # Make sure SD card is ready. |
107 self.device.WaitUntilFullyBooted(timeout=20) | 107 self.device.WaitUntilFullyBooted(timeout=20) |
108 for p in test_data: | 108 for p in test_data: |
109 self.device.PushChangedFiles( | 109 self.device.PushChangedFiles( |
110 os.path.join(constants.DIR_SOURCE_ROOT, p), | 110 os.path.join(constants.DIR_SOURCE_ROOT, p), |
111 os.path.join(self.device.GetExternalStoragePath(), p)) | 111 os.path.join(self.device.GetExternalStoragePath(), p)) |
112 | 112 |
113 # TODO(frankf): Specify test data in this file as opposed to passing | 113 # TODO(frankf): Specify test data in this file as opposed to passing |
114 # as command-line. | 114 # as command-line. |
115 for dest_host_pair in self.options.test_data: | 115 for dest_host_pair in self.options.test_data: |
116 dst_src = dest_host_pair.split(':', 1) | 116 dst_src = dest_host_pair.split(':', 1) |
117 dst_layer = dst_src[0] | 117 dst_layer = dst_src[0] |
118 host_src = dst_src[1] | 118 host_src = dst_src[1] |
119 host_test_files_path = '%s/%s' % (constants.DIR_SOURCE_ROOT, host_src) | 119 host_test_files_path = '%s/%s' % (constants.DIR_SOURCE_ROOT, host_src) |
120 if os.path.exists(host_test_files_path): | 120 if os.path.exists(host_test_files_path): |
121 self.device.PushChangedFiles( | 121 self.device.PushChangedFiles( |
122 host_test_files_path, | 122 host_test_files_path, |
123 '%s/%s/%s' % ( | 123 '%s/%s/%s' % ( |
124 self.device.GetExternalStoragePath(), | 124 self.device.GetExternalStoragePath(), |
125 TestRunner._DEVICE_DATA_DIR, | 125 TestRunner._DEVICE_DATA_DIR, |
126 dst_layer)) | 126 dst_layer)) |
127 self.tool.CopyFiles() | 127 self.tool.CopyFiles() |
128 TestRunner._DEVICE_HAS_TEST_FILES[ | 128 TestRunner._DEVICE_HAS_TEST_FILES[str(self.device)] = True |
129 self.device.old_interface.GetDevice()] = True | |
130 | 129 |
131 def _GetInstrumentationArgs(self): | 130 def _GetInstrumentationArgs(self): |
132 ret = {} | 131 ret = {} |
133 if self.options.wait_for_debugger: | 132 if self.options.wait_for_debugger: |
134 ret['debug'] = 'true' | 133 ret['debug'] = 'true' |
135 if self.coverage_dir: | 134 if self.coverage_dir: |
136 ret['coverage'] = 'true' | 135 ret['coverage'] = 'true' |
137 ret['coverageFile'] = self.coverage_device_file | 136 ret['coverageFile'] = self.coverage_device_file |
138 | 137 |
139 return ret | 138 return ret |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 duration_ms = 0 | 393 duration_ms = 0 |
395 message = str(e) | 394 message = str(e) |
396 if not message: | 395 if not message: |
397 message = 'No information.' | 396 message = 'No information.' |
398 results.AddResult(test_result.InstrumentationTestResult( | 397 results.AddResult(test_result.InstrumentationTestResult( |
399 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, | 398 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, |
400 log=message)) | 399 log=message)) |
401 raw_result = None | 400 raw_result = None |
402 self.TestTeardown(test, raw_result) | 401 self.TestTeardown(test, raw_result) |
403 return (results, None if results.DidRunPass() else test) | 402 return (results, None if results.DidRunPass() else test) |
OLD | NEW |