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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 return 10 * 60 | 292 return 10 * 60 |
293 if 'EnormousTest' in annotations: | 293 if 'EnormousTest' in annotations: |
294 return 10 * 60 | 294 return 10 * 60 |
295 if 'LargeTest' in annotations or _PERF_TEST_ANNOTATION in annotations: | 295 if 'LargeTest' in annotations or _PERF_TEST_ANNOTATION in annotations: |
296 return 5 * 60 | 296 return 5 * 60 |
297 if 'MediumTest' in annotations: | 297 if 'MediumTest' in annotations: |
298 return 3 * 60 | 298 return 3 * 60 |
299 if 'SmallTest' in annotations: | 299 if 'SmallTest' in annotations: |
300 return 1 * 60 | 300 return 1 * 60 |
301 | 301 |
302 logging.warn(("Test size not found in annotations for test '{0}', using " + | 302 logging.warn(("Test size not found in annotations for test '%s', using " + |
303 "1 minute for timeout.").format(test)) | 303 "1 minute for timeout.") % test) |
304 return 1 * 60 | 304 return 1 * 60 |
305 | 305 |
306 def _RunTest(self, test, timeout): | 306 def _RunTest(self, test, timeout): |
307 """Runs a single instrumentation test. | 307 """Runs a single instrumentation test. |
308 | 308 |
309 Args: | 309 Args: |
310 test: Test class/method. | 310 test: Test class/method. |
311 timeout: Timeout time in seconds. | 311 timeout: Timeout time in seconds. |
312 | 312 |
313 Returns: | 313 Returns: |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 436 |
437 return test_result.InstrumentationTestResult( | 437 return test_result.InstrumentationTestResult( |
438 test, result_type, start_ms, duration_ms, log=log) | 438 test, result_type, start_ms, duration_ms, log=log) |
439 | 439 |
440 #override | 440 #override |
441 def RunTest(self, test): | 441 def RunTest(self, test): |
442 results = base_test_result.TestRunResults() | 442 results = base_test_result.TestRunResults() |
443 timeout = (self._GetIndividualTestTimeoutSecs(test) * | 443 timeout = (self._GetIndividualTestTimeoutSecs(test) * |
444 self._GetIndividualTestTimeoutScale(test) * | 444 self._GetIndividualTestTimeoutScale(test) * |
445 self.tool.GetTimeoutScale()) | 445 self.tool.GetTimeoutScale()) |
446 if (self.device.GetProp('ro.build.version.sdk') | 446 if (self.device.build_version_sdk |
447 < constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN): | 447 < constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN): |
448 timeout *= 10 | 448 timeout *= 10 |
449 | 449 |
450 start_ms = 0 | 450 start_ms = 0 |
451 duration_ms = 0 | 451 duration_ms = 0 |
452 try: | 452 try: |
453 self.TestSetup(test) | 453 self.TestSetup(test) |
454 | 454 |
455 time_ms = lambda: int(time.time() * 1000) | 455 time_ms = lambda: int(time.time() * 1000) |
456 start_ms = time_ms() | 456 start_ms = time_ms() |
457 raw_output = self._RunTest(test, timeout) | 457 raw_output = self._RunTest(test, timeout) |
458 duration_ms = time_ms() - start_ms | 458 duration_ms = time_ms() - start_ms |
459 | 459 |
460 # Parse the test output | 460 # Parse the test output |
461 _, _, statuses = self._ParseAmInstrumentRawOutput(raw_output) | 461 _, _, statuses = self._ParseAmInstrumentRawOutput(raw_output) |
462 result = self._GenerateTestResult(test, statuses, start_ms, duration_ms) | 462 result = self._GenerateTestResult(test, statuses, start_ms, duration_ms) |
463 results.AddResult(result) | 463 results.AddResult(result) |
464 except device_errors.CommandTimeoutError as e: | 464 except device_errors.CommandTimeoutError as e: |
465 results.AddResult(test_result.InstrumentationTestResult( | 465 results.AddResult(test_result.InstrumentationTestResult( |
466 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, | 466 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, |
467 log=str(e) or 'No information')) | 467 log=str(e) or 'No information')) |
468 except device_errors.DeviceUnreachableError as e: | 468 except device_errors.DeviceUnreachableError as e: |
469 results.AddResult(test_result.InstrumentationTestResult( | 469 results.AddResult(test_result.InstrumentationTestResult( |
470 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, | 470 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, |
471 log=str(e) or 'No information')) | 471 log=str(e) or 'No information')) |
472 self.TestTeardown(test, results) | 472 self.TestTeardown(test, results) |
473 return (results, None if results.DidRunPass() else test) | 473 return (results, None if results.DidRunPass() else test) |
OLD | NEW |