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

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

Issue 18854020: Avoid forwarding the test HTTP port twice. (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
« no previous file with comments | « no previous file | no next file » | 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 """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
11 import sys 11 import sys
12 import time 12 import time
13 13
14 from pylib import android_commands 14 from pylib import android_commands
15 from pylib import cmd_helper 15 from pylib import cmd_helper
16 from pylib import constants 16 from pylib import constants
17 from pylib import forwarder
18 from pylib import json_perf_parser 17 from pylib import json_perf_parser
19 from pylib import perf_tests_helper 18 from pylib import perf_tests_helper
20 from pylib import valgrind_tools 19 from pylib import valgrind_tools
21 from pylib.base import base_test_result 20 from pylib.base import base_test_result
22 from pylib.base import base_test_runner 21 from pylib.base import base_test_runner
23 22
24 import test_result 23 import test_result
25 24
26 25
27 _PERF_TEST_ANNOTATION = 'PerfTest' 26 _PERF_TEST_ANNOTATION = 'PerfTest'
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 78
80 self.build_type = options.build_type 79 self.build_type = options.build_type
81 self.test_data = options.test_data 80 self.test_data = options.test_data
82 self.save_perf_json = options.save_perf_json 81 self.save_perf_json = options.save_perf_json
83 self.screenshot_failures = options.screenshot_failures 82 self.screenshot_failures = options.screenshot_failures
84 self.wait_for_debugger = options.wait_for_debugger 83 self.wait_for_debugger = options.wait_for_debugger
85 self.disable_assertions = options.disable_assertions 84 self.disable_assertions = options.disable_assertions
86 self.test_pkg = test_pkg 85 self.test_pkg = test_pkg
87 self.ports_to_forward = ports_to_forward 86 self.ports_to_forward = ports_to_forward
88 self.install_apk = options.install_apk 87 self.install_apk = options.install_apk
89 self.forwarder = None
90 88
91 #override 89 #override
92 def InstallTestPackage(self): 90 def InstallTestPackage(self):
93 if self.install_apk: 91 if self.install_apk:
94 self.test_pkg.Install(self.adb) 92 self.test_pkg.Install(self.adb)
95 93
96 #override 94 #override
97 def PushDataDeps(self): 95 def PushDataDeps(self):
98 # TODO(frankf): Implement a general approach for copying/installing 96 # TODO(frankf): Implement a general approach for copying/installing
99 # once across test runners. 97 # once across test runners.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if not self.adb.IsRootEnabled(): 139 if not self.adb.IsRootEnabled():
142 logging.warning('Unable to enable java asserts for %s, non rooted device', 140 logging.warning('Unable to enable java asserts for %s, non rooted device',
143 self.device) 141 self.device)
144 else: 142 else:
145 if self.adb.SetJavaAssertsEnabled(enable=not self.disable_assertions): 143 if self.adb.SetJavaAssertsEnabled(enable=not self.disable_assertions):
146 self.adb.Reboot(full_reboot=False) 144 self.adb.Reboot(full_reboot=False)
147 145
148 # 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
149 # 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
150 # launch lighttpd with same port at same time. 148 # launch lighttpd with same port at same time.
151 http_server_ports = self.LaunchTestHttpServer( 149 http_server_ports = self.LaunchTestHttpServer(
Joao da Silva 2013/07/09 14:39:26 Basically, this line already starts forwarding for
152 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port) 150 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port)
153 if self.ports_to_forward: 151 if self.ports_to_forward:
154 port_pairs = [(port, port) for port in self.ports_to_forward] 152 self.StartForwarder([(port, port) for port in self.ports_to_forward])
155 # We need to remember which ports the HTTP server is using, since the
156 # forwarder will stomp on them otherwise.
157 port_pairs.append(http_server_ports)
158 self.forwarder = forwarder.Forwarder(self.adb, self.build_type)
159 self.forwarder.Run(port_pairs, self.tool)
160 self.flags.AddFlags(['--enable-test-intents']) 153 self.flags.AddFlags(['--enable-test-intents'])
161 154
162 def TearDown(self): 155 def TearDown(self):
163 """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."""
164 if self.forwarder:
165 self.forwarder.Close()
166 super(TestRunner, self).TearDown() 157 super(TestRunner, self).TearDown()
167 158
168 def TestSetup(self, test): 159 def TestSetup(self, test):
169 """Sets up the test harness for running a particular test. 160 """Sets up the test harness for running a particular test.
170 161
171 Args: 162 Args:
172 test: The name of the test that will be run. 163 test: The name of the test that will be run.
173 """ 164 """
174 self.SetupPerfMonitoringIfNeeded(test) 165 self.SetupPerfMonitoringIfNeeded(test)
175 self._SetupIndividualTestTimeoutScale(test) 166 self._SetupIndividualTestTimeoutScale(test)
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 duration_ms = 0 347 duration_ms = 0
357 message = str(e) 348 message = str(e)
358 if not message: 349 if not message:
359 message = 'No information.' 350 message = 'No information.'
360 results.AddResult(test_result.InstrumentationTestResult( 351 results.AddResult(test_result.InstrumentationTestResult(
361 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, 352 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms,
362 log=message)) 353 log=message))
363 raw_result = None 354 raw_result = None
364 self.TestTeardown(test, raw_result) 355 self.TestTeardown(test, raw_result)
365 return (results, None if results.DidRunPass() else test) 356 return (results, None if results.DidRunPass() else test)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698