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 shutil | 10 import shutil |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 self.save_perf_json = options.save_perf_json | 82 self.save_perf_json = options.save_perf_json |
83 self.screenshot_failures = options.screenshot_failures | 83 self.screenshot_failures = options.screenshot_failures |
84 self.wait_for_debugger = options.wait_for_debugger | 84 self.wait_for_debugger = options.wait_for_debugger |
85 self.disable_assertions = options.disable_assertions | 85 self.disable_assertions = options.disable_assertions |
86 self.test_pkg = test_pkg | 86 self.test_pkg = test_pkg |
87 self.ports_to_forward = ports_to_forward | 87 self.ports_to_forward = ports_to_forward |
88 self.install_apk = options.install_apk | 88 self.install_apk = options.install_apk |
89 self.forwarder = None | 89 self.forwarder = None |
90 | 90 |
91 #override | 91 #override |
92 def PushDependencies(self): | 92 def InstallTestPackage(self): |
| 93 if self.install_apk: |
| 94 self.test_pkg.Install(self.adb) |
| 95 |
| 96 #override |
| 97 def PushDataDeps(self): |
93 # TODO(frankf): Implement a general approach for copying/installing | 98 # TODO(frankf): Implement a general approach for copying/installing |
94 # once across test runners. | 99 # once across test runners. |
95 if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False): | 100 if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False): |
96 logging.warning('Already copied test files to device %s, skipping.', | 101 logging.warning('Already copied test files to device %s, skipping.', |
97 self.device) | 102 self.device) |
98 return | 103 return |
99 | 104 |
100 test_data = _GetDataFilesForTestSuite(self.test_pkg.GetApkName()) | 105 test_data = _GetDataFilesForTestSuite(self.test_pkg.GetApkName()) |
101 if test_data: | 106 if test_data: |
102 # Make sure SD card is ready. | 107 # Make sure SD card is ready. |
103 self.adb.WaitForSdCardReady(20) | 108 self.adb.WaitForSdCardReady(20) |
104 for data in test_data: | 109 for data in test_data: |
105 self.CopyTestData([data], self.adb.GetExternalStorage()) | 110 self.CopyTestData([data], self.adb.GetExternalStorage()) |
106 | 111 |
107 # TODO(frankf): Specify test data in this file as opposed to passing | 112 # TODO(frankf): Specify test data in this file as opposed to passing |
108 # as command-line. | 113 # as command-line. |
109 for dest_host_pair in self.test_data: | 114 for dest_host_pair in self.test_data: |
110 dst_src = dest_host_pair.split(':',1) | 115 dst_src = dest_host_pair.split(':',1) |
111 dst_layer = dst_src[0] | 116 dst_layer = dst_src[0] |
112 host_src = dst_src[1] | 117 host_src = dst_src[1] |
113 host_test_files_path = constants.DIR_SOURCE_ROOT + '/' + host_src | 118 host_test_files_path = constants.DIR_SOURCE_ROOT + '/' + host_src |
114 if os.path.exists(host_test_files_path): | 119 if os.path.exists(host_test_files_path): |
115 self.adb.PushIfNeeded(host_test_files_path, | 120 self.adb.PushIfNeeded(host_test_files_path, |
116 self.adb.GetExternalStorage() + '/' + | 121 self.adb.GetExternalStorage() + '/' + |
117 TestRunner._DEVICE_DATA_DIR + '/' + dst_layer) | 122 TestRunner._DEVICE_DATA_DIR + '/' + dst_layer) |
118 if self.install_apk: | |
119 self.test_pkg.Install(self.adb) | |
120 self.tool.CopyFiles() | 123 self.tool.CopyFiles() |
121 TestRunner._DEVICE_HAS_TEST_FILES[self.device] = True | 124 TestRunner._DEVICE_HAS_TEST_FILES[self.device] = True |
122 | 125 |
123 def _GetInstrumentationArgs(self): | 126 def _GetInstrumentationArgs(self): |
124 ret = {} | 127 ret = {} |
125 if self.wait_for_debugger: | 128 if self.wait_for_debugger: |
126 ret['debug'] = 'true' | 129 ret['debug'] = 'true' |
127 return ret | 130 return ret |
128 | 131 |
129 def _TakeScreenshot(self, test): | 132 def _TakeScreenshot(self, test): |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 duration_ms = 0 | 352 duration_ms = 0 |
350 message = str(e) | 353 message = str(e) |
351 if not message: | 354 if not message: |
352 message = 'No information.' | 355 message = 'No information.' |
353 results.AddResult(test_result.InstrumentationTestResult( | 356 results.AddResult(test_result.InstrumentationTestResult( |
354 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, | 357 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, |
355 log=message)) | 358 log=message)) |
356 raw_result = None | 359 raw_result = None |
357 self.TestTeardown(test, raw_result) | 360 self.TestTeardown(test, raw_result) |
358 return (results, None if results.DidRunPass() else test) | 361 return (results, None if results.DidRunPass() else test) |
OLD | NEW |