| 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 import logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import re | 7 import re |
| 8 import tempfile | 8 import tempfile |
| 9 | 9 |
| 10 from pylib import pexpect | 10 from pylib import pexpect |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 RE_PASSED = re.compile('\\[ PASSED \\] ?(.*)\r\n') | 25 RE_PASSED = re.compile('\\[ PASSED \\] ?(.*)\r\n') |
| 26 RE_RUNNER_FAIL = re.compile('\\[ RUNNER_FAILED \\] ?(.*)\r\n') | 26 RE_RUNNER_FAIL = re.compile('\\[ RUNNER_FAILED \\] ?(.*)\r\n') |
| 27 # Signal handlers are installed before starting tests | 27 # Signal handlers are installed before starting tests |
| 28 # to output the CRASHED marker when a crash happens. | 28 # to output the CRASHED marker when a crash happens. |
| 29 RE_CRASH = re.compile('\\[ CRASHED \\](.*)\r\n') | 29 RE_CRASH = re.compile('\\[ CRASHED \\](.*)\r\n') |
| 30 | 30 |
| 31 # Bots that don't output anything for 20 minutes get timed out, so that's our | 31 # Bots that don't output anything for 20 minutes get timed out, so that's our |
| 32 # hard cap. | 32 # hard cap. |
| 33 _INFRA_STDOUT_TIMEOUT = 20 * 60 | 33 _INFRA_STDOUT_TIMEOUT = 20 * 60 |
| 34 | 34 |
| 35 def _TestSuiteRunsInSubThread(suite_name): |
| 36 """Returns True if the test suite needs to run in a sub-thread""" |
| 37 # net_unittests create an Android service that needs to receive Java main |
| 38 # thread events while the tests are running, so run the tests in a sub-thread. |
| 39 tests_run_in_sub_thread = ['net_unittests'] |
| 40 return (suite_name in tests_run_in_sub_thread) |
| 35 | 41 |
| 36 def _TestSuiteRequiresMockTestServer(suite_name): | 42 def _TestSuiteRequiresMockTestServer(suite_name): |
| 37 """Returns True if the test suite requires mock test server.""" | 43 """Returns True if the test suite requires mock test server.""" |
| 38 tests_require_net_test_server = ['unit_tests', 'net_unittests', | 44 tests_require_net_test_server = ['unit_tests', 'net_unittests', |
| 39 'components_browsertests', | 45 'components_browsertests', |
| 40 'content_unittests', | 46 'content_unittests', |
| 41 'content_browsertests'] | 47 'content_browsertests'] |
| 42 return (suite_name in | 48 return (suite_name in |
| 43 tests_require_net_test_server) | 49 tests_require_net_test_server) |
| 44 | 50 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 def RunTest(self, test): | 177 def RunTest(self, test): |
| 172 test_results = base_test_result.TestRunResults() | 178 test_results = base_test_result.TestRunResults() |
| 173 if not test: | 179 if not test: |
| 174 return test_results, None | 180 return test_results, None |
| 175 | 181 |
| 176 try: | 182 try: |
| 177 self.test_package.ClearApplicationState(self.device) | 183 self.test_package.ClearApplicationState(self.device) |
| 178 self.test_package.CreateCommandLineFileOnDevice( | 184 self.test_package.CreateCommandLineFileOnDevice( |
| 179 self.device, test, self._test_arguments) | 185 self.device, test, self._test_arguments) |
| 180 test_results = self._ParseTestOutput( | 186 test_results = self._ParseTestOutput( |
| 181 self.test_package.SpawnTestProcess(self.device)) | 187 self.test_package.SpawnTestProcess( |
| 188 self.device, |
| 189 _TestSuiteRunsInSubThread(self.test_package.suite_name))) |
| 182 if self._app_data_files: | 190 if self._app_data_files: |
| 183 self.test_package.PullAppFiles(self.device, self._app_data_files, | 191 self.test_package.PullAppFiles(self.device, self._app_data_files, |
| 184 self._app_data_file_dir) | 192 self._app_data_file_dir) |
| 185 finally: | 193 finally: |
| 186 for s in self._servers: | 194 for s in self._servers: |
| 187 s.Reset() | 195 s.Reset() |
| 188 # Calculate unknown test results. | 196 # Calculate unknown test results. |
| 189 all_tests = set(test.split(':')) | 197 all_tests = set(test.split(':')) |
| 190 all_tests_ran = set([t.GetName() for t in test_results.GetAll()]) | 198 all_tests_ran = set([t.GetName() for t in test_results.GetAll()]) |
| 191 unknown_tests = all_tests - all_tests_ran | 199 unknown_tests = all_tests - all_tests_ran |
| (...skipping 16 matching lines...) Expand all Loading... |
| 208 #override | 216 #override |
| 209 def TearDown(self): | 217 def TearDown(self): |
| 210 """Cleans up the test enviroment for the test suite.""" | 218 """Cleans up the test enviroment for the test suite.""" |
| 211 for s in self._servers: | 219 for s in self._servers: |
| 212 s.TearDown() | 220 s.TearDown() |
| 213 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name): | 221 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name): |
| 214 self._perf_controller.SetDefaultPerfMode() | 222 self._perf_controller.SetDefaultPerfMode() |
| 215 self.test_package.ClearApplicationState(self.device) | 223 self.test_package.ClearApplicationState(self.device) |
| 216 self.tool.CleanUpEnvironment() | 224 self.tool.CleanUpEnvironment() |
| 217 super(TestRunner, self).TearDown() | 225 super(TestRunner, self).TearDown() |
| OLD | NEW |