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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 def SetUp(self): | 147 def SetUp(self): |
148 """Sets up the test harness and device before all tests are run.""" | 148 """Sets up the test harness and device before all tests are run.""" |
149 super(TestRunner, self).SetUp() | 149 super(TestRunner, self).SetUp() |
150 if not self.device.HasRoot(): | 150 if not self.device.HasRoot(): |
151 logging.warning('Unable to enable java asserts for %s, non rooted device', | 151 logging.warning('Unable to enable java asserts for %s, non rooted device', |
152 str(self.device)) | 152 str(self.device)) |
153 else: | 153 else: |
154 if self.device.old_interface.SetJavaAssertsEnabled(True): | 154 if self.device.old_interface.SetJavaAssertsEnabled(True): |
155 # TODO(jbudorick) How to best do shell restart after the | 155 # TODO(jbudorick) How to best do shell restart after the |
156 # android_commands refactor? | 156 # android_commands refactor? |
157 self.device.old_interface.RunShellCommand('stop') | 157 self.device.RunShellCommand('stop') |
158 self.device.old_interface.RunShellCommand('start') | 158 self.device.RunShellCommand('start') |
159 | 159 |
160 # We give different default value to launch HTTP server based on shard index | 160 # We give different default value to launch HTTP server based on shard index |
161 # because it may have race condition when multiple processes are trying to | 161 # because it may have race condition when multiple processes are trying to |
162 # launch lighttpd with same port at same time. | 162 # launch lighttpd with same port at same time. |
163 self.LaunchTestHttpServer( | 163 self.LaunchTestHttpServer( |
164 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port) | 164 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port) |
165 if self.flags: | 165 if self.flags: |
166 self.flags.AddFlags(['--disable-fre', '--enable-test-intents']) | 166 self.flags.AddFlags(['--disable-fre', '--enable-test-intents']) |
167 | 167 |
168 def TearDown(self): | 168 def TearDown(self): |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 230 |
231 # The logic below relies on the test passing. | 231 # The logic below relies on the test passing. |
232 if not raw_result or raw_result.GetStatusCode(): | 232 if not raw_result or raw_result.GetStatusCode(): |
233 return | 233 return |
234 | 234 |
235 self.TearDownPerfMonitoring(test) | 235 self.TearDownPerfMonitoring(test) |
236 | 236 |
237 if self.coverage_dir: | 237 if self.coverage_dir: |
238 self.device.old_interface.Adb().Pull( | 238 self.device.old_interface.Adb().Pull( |
239 self.coverage_device_file, self.coverage_host_file) | 239 self.coverage_device_file, self.coverage_host_file) |
240 self.device.old_interface.RunShellCommand( | 240 self.device.RunShellCommand( |
241 'rm -f %s' % self.coverage_device_file) | 241 'rm -f %s' % self.coverage_device_file) |
242 | 242 |
243 def TearDownPerfMonitoring(self, test): | 243 def TearDownPerfMonitoring(self, test): |
244 """Cleans up performance monitoring if the specified test required it. | 244 """Cleans up performance monitoring if the specified test required it. |
245 | 245 |
246 Args: | 246 Args: |
247 test: The name of the test that was just run. | 247 test: The name of the test that was just run. |
248 Raises: | 248 Raises: |
249 Exception: if there's anything wrong with the perf data. | 249 Exception: if there's anything wrong with the perf data. |
250 """ | 250 """ |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 duration_ms = 0 | 386 duration_ms = 0 |
387 message = str(e) | 387 message = str(e) |
388 if not message: | 388 if not message: |
389 message = 'No information.' | 389 message = 'No information.' |
390 results.AddResult(test_result.InstrumentationTestResult( | 390 results.AddResult(test_result.InstrumentationTestResult( |
391 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, | 391 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, |
392 log=message)) | 392 log=message)) |
393 raw_result = None | 393 raw_result = None |
394 self.TestTeardown(test, raw_result) | 394 self.TestTeardown(test, raw_result) |
395 return (results, None if results.DidRunPass() else test) | 395 return (results, None if results.DidRunPass() else test) |
OLD | NEW |