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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 return 600 * 60 | 299 return 600 * 60 |
300 if 'External' in annotations: | 300 if 'External' in annotations: |
301 return 10 * 60 | 301 return 10 * 60 |
302 if 'LargeTest' in annotations or _PERF_TEST_ANNOTATION in annotations: | 302 if 'LargeTest' in annotations or _PERF_TEST_ANNOTATION in annotations: |
303 return 5 * 60 | 303 return 5 * 60 |
304 if 'MediumTest' in annotations: | 304 if 'MediumTest' in annotations: |
305 return 3 * 60 | 305 return 3 * 60 |
306 return 1 * 60 | 306 return 1 * 60 |
307 | 307 |
308 def _RunTest(self, test, timeout): | 308 def _RunTest(self, test, timeout): |
309 return self.adb.RunInstrumentationTest( | 309 return self.adb.RunInstrumentationTest( |
craigdh
2013/06/12 21:58:37
Let's only print the timeout if this guy times out
frankf
2013/06/12 22:08:19
Done.
On 2013/06/12 21:58:37, craigdh wrote:
| |
310 test, self.test_pkg.GetPackageName(), | 310 test, self.test_pkg.GetPackageName(), |
311 self._GetInstrumentationArgs(), timeout) | 311 self._GetInstrumentationArgs(), timeout) |
312 | 312 |
313 #override | 313 #override |
314 def RunTest(self, test): | 314 def RunTest(self, test): |
315 raw_result = None | 315 raw_result = None |
316 start_date_ms = None | 316 start_date_ms = None |
317 results = base_test_result.TestRunResults() | 317 results = base_test_result.TestRunResults() |
318 timeout=(self._GetIndividualTestTimeoutSecs(test) * | 318 timeout=(self._GetIndividualTestTimeoutSecs(test) * |
319 self._GetIndividualTestTimeoutScale(test) * | 319 self._GetIndividualTestTimeoutScale(test) * |
320 self.tool.GetTimeoutScale()) | 320 self.tool.GetTimeoutScale()) |
321 try: | 321 try: |
322 self.TestSetup(test) | 322 self.TestSetup(test) |
323 start_date_ms = int(time.time()) * 1000 | 323 start_date_ms = int(time.time()) * 1000 |
324 logging.info('Run test with timeout of %ds.' % timeout) | |
324 raw_result = self._RunTest(test, timeout) | 325 raw_result = self._RunTest(test, timeout) |
325 duration_ms = int(time.time()) * 1000 - start_date_ms | 326 duration_ms = int(time.time()) * 1000 - start_date_ms |
326 status_code = raw_result.GetStatusCode() | 327 status_code = raw_result.GetStatusCode() |
327 if status_code: | 328 if status_code: |
328 log = raw_result.GetFailureReason() | 329 log = raw_result.GetFailureReason() |
329 if not log: | 330 if not log: |
330 log = 'No information.' | 331 log = 'No information.' |
331 if self.screenshot_failures or log.find('INJECT_EVENTS perm') >= 0: | 332 if self.screenshot_failures or log.find('INJECT_EVENTS perm') >= 0: |
332 self._TakeScreenshot(test) | 333 self._TakeScreenshot(test) |
333 result = test_result.InstrumentationTestResult( | 334 result = test_result.InstrumentationTestResult( |
(...skipping 15 matching lines...) Expand all Loading... | |
349 duration_ms = 0 | 350 duration_ms = 0 |
350 message = str(e) | 351 message = str(e) |
351 if not message: | 352 if not message: |
352 message = 'No information.' | 353 message = 'No information.' |
353 results.AddResult(test_result.InstrumentationTestResult( | 354 results.AddResult(test_result.InstrumentationTestResult( |
354 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, | 355 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, |
355 log=message)) | 356 log=message)) |
356 raw_result = None | 357 raw_result = None |
357 self.TestTeardown(test, raw_result) | 358 self.TestTeardown(test, raw_result) |
358 return (results, None if results.DidRunPass() else test) | 359 return (results, None if results.DidRunPass() else test) |
OLD | NEW |