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

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

Issue 18086004: Move Python setup/tear down logic into Forwarder itself. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months 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 | Annotate | Revision Log
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 """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 shutil 10 import shutil
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 else: 142 else:
143 if self.adb.SetJavaAssertsEnabled(enable=not self.disable_assertions): 143 if self.adb.SetJavaAssertsEnabled(enable=not self.disable_assertions):
144 self.adb.Reboot(full_reboot=False) 144 self.adb.Reboot(full_reboot=False)
145 145
146 # We give different default value to launch HTTP server based on shard index 146 # We give different default value to launch HTTP server based on shard index
147 # because it may have race condition when multiple processes are trying to 147 # because it may have race condition when multiple processes are trying to
148 # launch lighttpd with same port at same time. 148 # launch lighttpd with same port at same time.
149 http_server_ports = self.LaunchTestHttpServer( 149 http_server_ports = self.LaunchTestHttpServer(
150 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port) 150 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port)
151 if self.ports_to_forward: 151 if self.ports_to_forward:
152 self.StartForwarder([(port, port) for port in self.ports_to_forward]) 152 self.ForwardPorts([(port, port) for port in self.ports_to_forward])
153 self.flags.AddFlags(['--enable-test-intents']) 153 self.flags.AddFlags(['--enable-test-intents'])
154 154
155 def TearDown(self): 155 def TearDown(self):
156 """Cleans up the test harness and saves outstanding data from test run.""" 156 """Cleans up the test harness and saves outstanding data from test run."""
157 if self.ports_to_forward:
158 self.UnmapPorts(self.ports_to_forward)
157 super(TestRunner, self).TearDown() 159 super(TestRunner, self).TearDown()
158 160
159 def TestSetup(self, test): 161 def TestSetup(self, test):
160 """Sets up the test harness for running a particular test. 162 """Sets up the test harness for running a particular test.
161 163
162 Args: 164 Args:
163 test: The name of the test that will be run. 165 test: The name of the test that will be run.
164 """ 166 """
165 self.SetupPerfMonitoringIfNeeded(test) 167 self.SetupPerfMonitoringIfNeeded(test)
166 self._SetupIndividualTestTimeoutScale(test) 168 self._SetupIndividualTestTimeoutScale(test)
167 self.tool.SetupEnvironment() 169 self.tool.SetupEnvironment()
168 170
169 # Make sure the forwarder is still running.
170 self.RestartHttpServerForwarderIfNecessary()
171
172 def _IsPerfTest(self, test): 171 def _IsPerfTest(self, test):
173 """Determines whether a test is a performance test. 172 """Determines whether a test is a performance test.
174 173
175 Args: 174 Args:
176 test: The name of the test to be checked. 175 test: The name of the test to be checked.
177 176
178 Returns: 177 Returns:
179 Whether the test is annotated as a performance test. 178 Whether the test is annotated as a performance test.
180 """ 179 """
181 return _PERF_TEST_ANNOTATION in self.test_pkg.GetTestAnnotations(test) 180 return _PERF_TEST_ANNOTATION in self.test_pkg.GetTestAnnotations(test)
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 duration_ms = 0 346 duration_ms = 0
348 message = str(e) 347 message = str(e)
349 if not message: 348 if not message:
350 message = 'No information.' 349 message = 'No information.'
351 results.AddResult(test_result.InstrumentationTestResult( 350 results.AddResult(test_result.InstrumentationTestResult(
352 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, 351 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms,
353 log=message)) 352 log=message))
354 raw_result = None 353 raw_result = None
355 self.TestTeardown(test, raw_result) 354 self.TestTeardown(test, raw_result)
356 return (results, None if results.DidRunPass() else test) 355 return (results, None if results.DidRunPass() else test)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698