Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Side by Side Diff: build/android/pylib/gtest/test_runner.py

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/pylib/forwarder.py ('k') | build/android/pylib/instrumentation/test_jar.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 from pylib import pexpect 9 from pylib import pexpect
10 from pylib import ports
10 from pylib.base import base_test_result 11 from pylib.base import base_test_result
11 from pylib.base import base_test_runner 12 from pylib.base import base_test_runner
12 from pylib.device import device_errors 13 from pylib.device import device_errors
14 from pylib.local import local_test_server_spawner
13 from pylib.perf import perf_control 15 from pylib.perf import perf_control
14 16
15 17
16 def _TestSuiteRequiresMockTestServer(suite_name): 18 def _TestSuiteRequiresMockTestServer(suite_name):
17 """Returns True if the test suite requires mock test server.""" 19 """Returns True if the test suite requires mock test server."""
18 tests_require_net_test_server = ['unit_tests', 'net_unittests', 20 tests_require_net_test_server = ['unit_tests', 'net_unittests',
19 'content_unittests', 21 'content_unittests',
20 'content_browsertests'] 22 'content_browsertests']
21 return (suite_name in 23 return (suite_name in
22 tests_require_net_test_server) 24 tests_require_net_test_server)
(...skipping 23 matching lines...) Expand all
46 if timeout == 0: 48 if timeout == 0:
47 timeout = 60 49 timeout = 60
48 # On a VM (e.g. chromium buildbots), this timeout is way too small. 50 # On a VM (e.g. chromium buildbots), this timeout is way too small.
49 if os.environ.get('BUILDBOT_SLAVENAME'): 51 if os.environ.get('BUILDBOT_SLAVENAME'):
50 timeout = timeout * 2 52 timeout = timeout * 2
51 53
52 self._timeout = timeout * self.tool.GetTimeoutScale() 54 self._timeout = timeout * self.tool.GetTimeoutScale()
53 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name): 55 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name):
54 self._perf_controller = perf_control.PerfControl(self.device) 56 self._perf_controller = perf_control.PerfControl(self.device)
55 57
58 if _TestSuiteRequiresMockTestServer(self.test_package.suite_name):
59 self._servers = [
60 local_test_server_spawner.LocalTestServerSpawner(
61 ports.AllocateTestServerPort(), self.device, self.tool)]
62 else:
63 self._servers = []
64
56 #override 65 #override
57 def InstallTestPackage(self): 66 def InstallTestPackage(self):
58 self.test_package.Install(self.device) 67 self.test_package.Install(self.device)
59 68
60 def _ParseTestOutput(self, p): 69 def _ParseTestOutput(self, p):
61 """Process the test output. 70 """Process the test output.
62 71
63 Args: 72 Args:
64 p: An instance of pexpect spawn class. 73 p: An instance of pexpect spawn class.
65 74
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if not test: 151 if not test:
143 return test_results, None 152 return test_results, None
144 153
145 try: 154 try:
146 self.test_package.ClearApplicationState(self.device) 155 self.test_package.ClearApplicationState(self.device)
147 self.test_package.CreateCommandLineFileOnDevice( 156 self.test_package.CreateCommandLineFileOnDevice(
148 self.device, test, self._test_arguments) 157 self.device, test, self._test_arguments)
149 test_results = self._ParseTestOutput( 158 test_results = self._ParseTestOutput(
150 self.test_package.SpawnTestProcess(self.device)) 159 self.test_package.SpawnTestProcess(self.device))
151 finally: 160 finally:
152 self.CleanupSpawningServerState() 161 for s in self._servers:
162 s.Reset()
153 # Calculate unknown test results. 163 # Calculate unknown test results.
154 all_tests = set(test.split(':')) 164 all_tests = set(test.split(':'))
155 all_tests_ran = set([t.GetName() for t in test_results.GetAll()]) 165 all_tests_ran = set([t.GetName() for t in test_results.GetAll()])
156 unknown_tests = all_tests - all_tests_ran 166 unknown_tests = all_tests - all_tests_ran
157 test_results.AddResults( 167 test_results.AddResults(
158 [base_test_result.BaseTestResult(t, base_test_result.ResultType.UNKNOWN) 168 [base_test_result.BaseTestResult(t, base_test_result.ResultType.UNKNOWN)
159 for t in unknown_tests]) 169 for t in unknown_tests])
160 retry = ':'.join([t.GetName() for t in test_results.GetNotPass()]) 170 retry = ':'.join([t.GetName() for t in test_results.GetNotPass()])
161 return test_results, retry 171 return test_results, retry
162 172
163 #override 173 #override
164 def SetUp(self): 174 def SetUp(self):
165 """Sets up necessary test enviroment for the test suite.""" 175 """Sets up necessary test enviroment for the test suite."""
166 super(TestRunner, self).SetUp() 176 super(TestRunner, self).SetUp()
167 if _TestSuiteRequiresMockTestServer(self.test_package.suite_name): 177 for s in self._servers:
168 self.LaunchChromeTestServerSpawner() 178 s.SetUp()
169 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name): 179 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name):
170 self._perf_controller.SetHighPerfMode() 180 self._perf_controller.SetHighPerfMode()
171 self.tool.SetupEnvironment() 181 self.tool.SetupEnvironment()
172 182
173 #override 183 #override
174 def TearDown(self): 184 def TearDown(self):
175 """Cleans up the test enviroment for the test suite.""" 185 """Cleans up the test enviroment for the test suite."""
186 for s in self._servers:
187 s.TearDown()
176 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name): 188 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name):
177 self._perf_controller.SetDefaultPerfMode() 189 self._perf_controller.SetDefaultPerfMode()
178 self.test_package.ClearApplicationState(self.device) 190 self.test_package.ClearApplicationState(self.device)
179 self.tool.CleanUpEnvironment() 191 self.tool.CleanUpEnvironment()
180 super(TestRunner, self).TearDown() 192 super(TestRunner, self).TearDown()
OLDNEW
« no previous file with comments | « build/android/pylib/forwarder.py ('k') | build/android/pylib/instrumentation/test_jar.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698