| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 self.adb.WaitForSdCardReady(20) | 101 self.adb.WaitForSdCardReady(20) |
| 102 for data in test_data: | 102 for data in test_data: |
| 103 self.CopyTestData([data], self.adb.GetExternalStorage()) | 103 self.CopyTestData([data], self.adb.GetExternalStorage()) |
| 104 | 104 |
| 105 # TODO(frankf): Specify test data in this file as opposed to passing | 105 # TODO(frankf): Specify test data in this file as opposed to passing |
| 106 # as command-line. | 106 # as command-line. |
| 107 for dest_host_pair in self.test_data: | 107 for dest_host_pair in self.test_data: |
| 108 dst_src = dest_host_pair.split(':',1) | 108 dst_src = dest_host_pair.split(':',1) |
| 109 dst_layer = dst_src[0] | 109 dst_layer = dst_src[0] |
| 110 host_src = dst_src[1] | 110 host_src = dst_src[1] |
| 111 host_test_files_path = constants.CHROME_DIR + '/' + host_src | 111 host_test_files_path = constants.DIR_SOURCE_ROOT + '/' + host_src |
| 112 if os.path.exists(host_test_files_path): | 112 if os.path.exists(host_test_files_path): |
| 113 self.adb.PushIfNeeded(host_test_files_path, | 113 self.adb.PushIfNeeded(host_test_files_path, |
| 114 self.adb.GetExternalStorage() + '/' + | 114 self.adb.GetExternalStorage() + '/' + |
| 115 TestRunner._DEVICE_DATA_DIR + '/' + dst_layer) | 115 TestRunner._DEVICE_DATA_DIR + '/' + dst_layer) |
| 116 if self.install_apk: | 116 if self.install_apk: |
| 117 self.test_pkg.Install(self.adb) | 117 self.test_pkg.Install(self.adb) |
| 118 self.tool.CopyFiles() | 118 self.tool.CopyFiles() |
| 119 TestRunner._DEVICE_HAS_TEST_FILES[self.device] = True | 119 TestRunner._DEVICE_HAS_TEST_FILES[self.device] = True |
| 120 | 120 |
| 121 def _GetInstrumentationArgs(self): | 121 def _GetInstrumentationArgs(self): |
| (...skipping 15 matching lines...) Expand all Loading... |
| 137 logging.warning('Unable to enable java asserts for %s, non rooted device', | 137 logging.warning('Unable to enable java asserts for %s, non rooted device', |
| 138 self.device) | 138 self.device) |
| 139 else: | 139 else: |
| 140 if self.adb.SetJavaAssertsEnabled(enable=not self.disable_assertions): | 140 if self.adb.SetJavaAssertsEnabled(enable=not self.disable_assertions): |
| 141 self.adb.Reboot(full_reboot=False) | 141 self.adb.Reboot(full_reboot=False) |
| 142 | 142 |
| 143 # We give different default value to launch HTTP server based on shard index | 143 # We give different default value to launch HTTP server based on shard index |
| 144 # because it may have race condition when multiple processes are trying to | 144 # because it may have race condition when multiple processes are trying to |
| 145 # launch lighttpd with same port at same time. | 145 # launch lighttpd with same port at same time. |
| 146 http_server_ports = self.LaunchTestHttpServer( | 146 http_server_ports = self.LaunchTestHttpServer( |
| 147 os.path.join(constants.CHROME_DIR), self._lighttp_port) | 147 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port) |
| 148 if self.ports_to_forward: | 148 if self.ports_to_forward: |
| 149 port_pairs = [(port, port) for port in self.ports_to_forward] | 149 port_pairs = [(port, port) for port in self.ports_to_forward] |
| 150 # We need to remember which ports the HTTP server is using, since the | 150 # We need to remember which ports the HTTP server is using, since the |
| 151 # forwarder will stomp on them otherwise. | 151 # forwarder will stomp on them otherwise. |
| 152 port_pairs.append(http_server_ports) | 152 port_pairs.append(http_server_ports) |
| 153 self.forwarder = forwarder.Forwarder(self.adb, self.build_type) | 153 self.forwarder = forwarder.Forwarder(self.adb, self.build_type) |
| 154 self.forwarder.Run(port_pairs, self.tool, '127.0.0.1') | 154 self.forwarder.Run(port_pairs, self.tool, '127.0.0.1') |
| 155 self.flags.AddFlags(['--enable-test-intents']) | 155 self.flags.AddFlags(['--enable-test-intents']) |
| 156 | 156 |
| 157 def TearDown(self): | 157 def TearDown(self): |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 duration_ms = 0 | 347 duration_ms = 0 |
| 348 message = str(e) | 348 message = str(e) |
| 349 if not message: | 349 if not message: |
| 350 message = 'No information.' | 350 message = 'No information.' |
| 351 results.AddResult(test_result.InstrumentationTestResult( | 351 results.AddResult(test_result.InstrumentationTestResult( |
| 352 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, | 352 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, |
| 353 log=message)) | 353 log=message)) |
| 354 raw_result = None | 354 raw_result = None |
| 355 self.TestTeardown(test, raw_result) | 355 self.TestTeardown(test, raw_result) |
| 356 return (results, None if results.DidRunPass() else test) | 356 return (results, None if results.DidRunPass() else test) |
| OLD | NEW |