| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Runs linker tests on a particular device.""" | 5 """Runs linker tests on a particular device.""" |
| 6 | 6 |
| 7 import logging | 7 import logging |
| 8 import os.path | 8 import os.path |
| 9 import sys | 9 import sys |
| 10 import traceback | 10 import traceback |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 | 43 |
| 44 class LinkerTestRunner(base_test_runner.BaseTestRunner): | 44 class LinkerTestRunner(base_test_runner.BaseTestRunner): |
| 45 """Orchestrates running a set of linker tests. | 45 """Orchestrates running a set of linker tests. |
| 46 | 46 |
| 47 Any Python exceptions in the tests are caught and translated into a failed | 47 Any Python exceptions in the tests are caught and translated into a failed |
| 48 result, rather than being re-raised on the main thread. | 48 result, rather than being re-raised on the main thread. |
| 49 """ | 49 """ |
| 50 | 50 |
| 51 #override | 51 #override |
| 52 def __init__(self, device, tool, cleanup_test_files): | 52 def __init__(self, device, tool): |
| 53 """Creates a new LinkerTestRunner. | 53 """Creates a new LinkerTestRunner. |
| 54 | 54 |
| 55 Args: | 55 Args: |
| 56 device: Attached android device. | 56 device: Attached android device. |
| 57 tool: Name of the Valgrind tool. | 57 tool: Name of the Valgrind tool. |
| 58 cleanup_test_files: Whether or not to cleanup test files on device. | |
| 59 """ | 58 """ |
| 60 | 59 super(LinkerTestRunner, self).__init__(device, tool) |
| 61 super(LinkerTestRunner, self).__init__(device, tool, cleanup_test_files) | |
| 62 | 60 |
| 63 #override | 61 #override |
| 64 def InstallTestPackage(self): | 62 def InstallTestPackage(self): |
| 65 apk_path = os.path.join( | 63 apk_path = os.path.join( |
| 66 constants.GetOutDirectory(), 'apks', '%s.apk' % _PACKAGE_NAME) | 64 constants.GetOutDirectory(), 'apks', '%s.apk' % _PACKAGE_NAME) |
| 67 | 65 |
| 68 if not os.path.exists(apk_path): | 66 if not os.path.exists(apk_path): |
| 69 raise Exception('%s not found, please build it' % apk_path) | 67 raise Exception('%s not found, please build it' % apk_path) |
| 70 | 68 |
| 71 package_name = apk_helper.GetPackageName(apk_path) | 69 self.device.Install(apk_path) |
| 72 self.device.old_interface.ManagedInstall(apk_path, package_name) | |
| 73 | 70 |
| 74 #override | 71 #override |
| 75 def RunTest(self, test): | 72 def RunTest(self, test): |
| 76 """Sets up and runs a test case. | 73 """Sets up and runs a test case. |
| 77 | 74 |
| 78 Args: | 75 Args: |
| 79 test: An object which is ostensibly a subclass of LinkerTestCaseBase. | 76 test: An object which is ostensibly a subclass of LinkerTestCaseBase. |
| 80 | 77 |
| 81 Returns: | 78 Returns: |
| 82 A TestRunResults object which contains the result produced by the test | 79 A TestRunResults object which contains the result produced by the test |
| 83 and, in the case of a failure, the test that should be retried. | 80 and, in the case of a failure, the test that should be retried. |
| 84 """ | 81 """ |
| 85 | 82 |
| 86 assert isinstance(test, test_case.LinkerTestCaseBase) | 83 assert isinstance(test, test_case.LinkerTestCaseBase) |
| 87 | 84 |
| 88 try: | 85 try: |
| 89 results = test.Run(self.device) | 86 results = test.Run(self.device) |
| 90 except Exception: | 87 except Exception: |
| 91 logging.exception('Caught exception while trying to run test: ' + | 88 logging.exception('Caught exception while trying to run test: ' + |
| 92 test.tagged_name) | 89 test.tagged_name) |
| 93 exc_info = sys.exc_info() | 90 exc_info = sys.exc_info() |
| 94 results = base_test_result.TestRunResults() | 91 results = base_test_result.TestRunResults() |
| 95 results.AddResult(LinkerExceptionTestResult( | 92 results.AddResult(LinkerExceptionTestResult( |
| 96 test.tagged_name, exc_info)) | 93 test.tagged_name, exc_info)) |
| 97 | 94 |
| 98 if not results.DidRunPass(): | 95 if not results.DidRunPass(): |
| 99 return results, test | 96 return results, test |
| 100 else: | 97 else: |
| 101 return results, None | 98 return results, None |
| OLD | NEW |