| 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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 480 |
| 481 return test_result.InstrumentationTestResult( | 481 return test_result.InstrumentationTestResult( |
| 482 test, result_type, start_ms, duration_ms, log=log) | 482 test, result_type, start_ms, duration_ms, log=log) |
| 483 | 483 |
| 484 #override | 484 #override |
| 485 def RunTest(self, test): | 485 def RunTest(self, test): |
| 486 results = base_test_result.TestRunResults() | 486 results = base_test_result.TestRunResults() |
| 487 timeout = (self._GetIndividualTestTimeoutSecs(test) * | 487 timeout = (self._GetIndividualTestTimeoutSecs(test) * |
| 488 self._GetIndividualTestTimeoutScale(test) * | 488 self._GetIndividualTestTimeoutScale(test) * |
| 489 self.tool.GetTimeoutScale()) | 489 self.tool.GetTimeoutScale()) |
| 490 if (self.device.GetProp('ro.build.version.sdk') |
| 491 < constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN): |
| 492 timeout *= 4 |
| 490 | 493 |
| 491 start_ms = 0 | 494 start_ms = 0 |
| 492 duration_ms = 0 | 495 duration_ms = 0 |
| 493 try: | 496 try: |
| 494 self.TestSetup(test) | 497 self.TestSetup(test) |
| 495 | 498 |
| 496 time_ms = lambda: int(time.time() * 1000) | 499 time_ms = lambda: int(time.time() * 1000) |
| 497 start_ms = time_ms() | 500 start_ms = time_ms() |
| 498 raw_output = self._RunTest(test, timeout) | 501 raw_output = self._RunTest(test, timeout) |
| 499 duration_ms = time_ms() - start_ms | 502 duration_ms = time_ms() - start_ms |
| 500 | 503 |
| 501 # Parse the test output | 504 # Parse the test output |
| 502 _, _, statuses = self._ParseAmInstrumentRawOutput(raw_output) | 505 _, _, statuses = self._ParseAmInstrumentRawOutput(raw_output) |
| 503 result = self._GenerateTestResult(test, statuses, start_ms, duration_ms) | 506 result = self._GenerateTestResult(test, statuses, start_ms, duration_ms) |
| 504 results.AddResult(result) | 507 results.AddResult(result) |
| 505 except device_errors.CommandTimeoutError as e: | 508 except device_errors.CommandTimeoutError as e: |
| 506 results.AddResult(test_result.InstrumentationTestResult( | 509 results.AddResult(test_result.InstrumentationTestResult( |
| 507 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, | 510 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, |
| 508 log=str(e) or 'No information')) | 511 log=str(e) or 'No information')) |
| 509 except device_errors.DeviceUnreachableError as e: | 512 except device_errors.DeviceUnreachableError as e: |
| 510 results.AddResult(test_result.InstrumentationTestResult( | 513 results.AddResult(test_result.InstrumentationTestResult( |
| 511 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, | 514 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, |
| 512 log=str(e) or 'No information')) | 515 log=str(e) or 'No information')) |
| 513 self.TestTeardown(test, results) | 516 self.TestTeardown(test, results) |
| 514 return (results, None if results.DidRunPass() else test) | 517 return (results, None if results.DidRunPass() else test) |
| OLD | NEW |