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

Side by Side Diff: build/android/pylib/chrome_test_server_spawner.py

Issue 15979032: Android: renames pylib.constants.CHROME_DIR to DIR_SOURCE_ROOT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 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 """A "Test Server Spawner" that handles killing/stopping per-test test servers. 5 """A "Test Server Spawner" that handles killing/stopping per-test test servers.
6 6
7 It's used to accept requests from the device to spawn and kill instances of the 7 It's used to accept requests from the device to spawn and kill instances of the
8 chrome test server on the host. 8 chrome test server on the host.
9 """ 9 """
10 10
11 import BaseHTTPServer 11 import BaseHTTPServer
12 import json 12 import json
13 import logging 13 import logging
14 import os 14 import os
15 import select 15 import select
16 import struct 16 import struct
17 import subprocess 17 import subprocess
18 import sys 18 import sys
19 import threading 19 import threading
20 import time 20 import time
21 import urlparse 21 import urlparse
22 22
23 import constants 23 import constants
24 import ports 24 import ports
25 25
26 26
27 # Path that are needed to import necessary modules when launching a testserver. 27 # Path that are needed to import necessary modules when launching a testserver.
28 os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', '') + (':%s:%s:%s:%s:%s' 28 os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', '') + (':%s:%s:%s:%s:%s'
29 % (os.path.join(constants.CHROME_DIR, 'third_party'), 29 % (os.path.join(constants.DIR_SOURCE_ROOT, 'third_party'),
30 os.path.join(constants.CHROME_DIR, 'third_party', 'tlslite'), 30 os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', 'tlslite'),
31 os.path.join(constants.CHROME_DIR, 'third_party', 'pyftpdlib', 'src'), 31 os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', 'pyftpdlib',
32 os.path.join(constants.CHROME_DIR, 'net', 'tools', 'testserver'), 32 'src'),
33 os.path.join(constants.CHROME_DIR, 'sync', 'tools', 'testserver'))) 33 os.path.join(constants.DIR_SOURCE_ROOT, 'net', 'tools', 'testserver'),
34 os.path.join(constants.DIR_SOURCE_ROOT, 'sync', 'tools', 'testserver')))
34 35
35 36
36 SERVER_TYPES = { 37 SERVER_TYPES = {
37 'http': '', 38 'http': '',
38 'ftp': '-f', 39 'ftp': '-f',
39 'sync': '', # Sync uses its own script, and doesn't take a server type arg. 40 'sync': '', # Sync uses its own script, and doesn't take a server type arg.
40 'tcpecho': '--tcp-echo', 41 'tcpecho': '--tcp-echo',
41 'udpecho': '--udp-echo', 42 'udpecho': '--udp-echo',
42 } 43 }
43 44
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 self.command_line.append(type_cmd) 185 self.command_line.append(type_cmd)
185 self.command_line.append('--port=%d' % self.host_port) 186 self.command_line.append('--port=%d' % self.host_port)
186 # Use a pipe to get the port given by the instance of Python test server 187 # Use a pipe to get the port given by the instance of Python test server
187 # if the test does not specify the port. 188 # if the test does not specify the port.
188 if self.host_port == 0: 189 if self.host_port == 0:
189 (self.pipe_in, self.pipe_out) = os.pipe() 190 (self.pipe_in, self.pipe_out) = os.pipe()
190 self.command_line.append('--startup-pipe=%d' % self.pipe_out) 191 self.command_line.append('--startup-pipe=%d' % self.pipe_out)
191 self.command_line.append('--host=%s' % self.arguments['host']) 192 self.command_line.append('--host=%s' % self.arguments['host'])
192 data_dir = self.arguments['data-dir'] or 'chrome/test/data' 193 data_dir = self.arguments['data-dir'] or 'chrome/test/data'
193 if not os.path.isabs(data_dir): 194 if not os.path.isabs(data_dir):
194 data_dir = os.path.join(constants.CHROME_DIR, data_dir) 195 data_dir = os.path.join(constants.DIR_SOURCE_ROOT, data_dir)
195 self.command_line.append('--data-dir=%s' % data_dir) 196 self.command_line.append('--data-dir=%s' % data_dir)
196 # The following arguments are optional depending on the individual test. 197 # The following arguments are optional depending on the individual test.
197 if self.arguments.has_key('log-to-console'): 198 if self.arguments.has_key('log-to-console'):
198 self.command_line.append('--log-to-console') 199 self.command_line.append('--log-to-console')
199 if self.arguments.has_key('auth-token'): 200 if self.arguments.has_key('auth-token'):
200 self.command_line.append('--auth-token=%s' % self.arguments['auth-token']) 201 self.command_line.append('--auth-token=%s' % self.arguments['auth-token'])
201 if self.arguments.has_key('https'): 202 if self.arguments.has_key('https'):
202 self.command_line.append('--https') 203 self.command_line.append('--https')
203 if self.arguments.has_key('cert-and-key-file'): 204 if self.arguments.has_key('cert-and-key-file'):
204 self.command_line.append('--cert-and-key-file=%s' % os.path.join( 205 self.command_line.append('--cert-and-key-file=%s' % os.path.join(
205 constants.CHROME_DIR, self.arguments['cert-and-key-file'])) 206 constants.DIR_SOURCE_ROOT, self.arguments['cert-and-key-file']))
206 if self.arguments.has_key('ocsp'): 207 if self.arguments.has_key('ocsp'):
207 self.command_line.append('--ocsp=%s' % self.arguments['ocsp']) 208 self.command_line.append('--ocsp=%s' % self.arguments['ocsp'])
208 if self.arguments.has_key('https-record-resume'): 209 if self.arguments.has_key('https-record-resume'):
209 self.command_line.append('--https-record-resume') 210 self.command_line.append('--https-record-resume')
210 if self.arguments.has_key('ssl-client-auth'): 211 if self.arguments.has_key('ssl-client-auth'):
211 self.command_line.append('--ssl-client-auth') 212 self.command_line.append('--ssl-client-auth')
212 if self.arguments.has_key('tls-intolerant'): 213 if self.arguments.has_key('tls-intolerant'):
213 self.command_line.append('--tls-intolerant=%s' % 214 self.command_line.append('--tls-intolerant=%s' %
214 self.arguments['tls-intolerant']) 215 self.arguments['tls-intolerant'])
215 if self.arguments.has_key('ssl-client-ca'): 216 if self.arguments.has_key('ssl-client-ca'):
216 for ca in self.arguments['ssl-client-ca']: 217 for ca in self.arguments['ssl-client-ca']:
217 self.command_line.append('--ssl-client-ca=%s' % 218 self.command_line.append('--ssl-client-ca=%s' %
218 os.path.join(constants.CHROME_DIR, ca)) 219 os.path.join(constants.DIR_SOURCE_ROOT, ca))
219 if self.arguments.has_key('ssl-bulk-cipher'): 220 if self.arguments.has_key('ssl-bulk-cipher'):
220 for bulk_cipher in self.arguments['ssl-bulk-cipher']: 221 for bulk_cipher in self.arguments['ssl-bulk-cipher']:
221 self.command_line.append('--ssl-bulk-cipher=%s' % bulk_cipher) 222 self.command_line.append('--ssl-bulk-cipher=%s' % bulk_cipher)
222 223
223 def run(self): 224 def run(self):
224 logging.info('Start running the thread!') 225 logging.info('Start running the thread!')
225 self.wait_event.clear() 226 self.wait_event.clear()
226 self._GenerateCommandLineArguments() 227 self._GenerateCommandLineArguments()
227 command = constants.CHROME_DIR 228 command = constants.DIR_SOURCE_ROOT
228 if self.arguments['server-type'] == 'sync': 229 if self.arguments['server-type'] == 'sync':
229 command = [os.path.join(command, 'sync', 'tools', 'testserver', 230 command = [os.path.join(command, 'sync', 'tools', 'testserver',
230 'sync_testserver.py')] + self.command_line 231 'sync_testserver.py')] + self.command_line
231 else: 232 else:
232 command = [os.path.join(command, 'net', 'tools', 'testserver', 233 command = [os.path.join(command, 'net', 'tools', 'testserver',
233 'testserver.py')] + self.command_line 234 'testserver.py')] + self.command_line
234 logging.info('Running: %s', command) 235 logging.info('Running: %s', command)
235 self.process = subprocess.Popen(command) 236 self.process = subprocess.Popen(command)
236 if self.process: 237 if self.process:
237 if self.pipe_out: 238 if self.pipe_out:
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 424
424 def CleanupState(self): 425 def CleanupState(self):
425 """Cleans up the spawning server state. 426 """Cleans up the spawning server state.
426 427
427 This should be called if the test server spawner is reused, 428 This should be called if the test server spawner is reused,
428 to avoid sharing the test server instance. 429 to avoid sharing the test server instance.
429 """ 430 """
430 if self.server.test_server_instance: 431 if self.server.test_server_instance:
431 self.server.test_server_instance.Stop() 432 self.server.test_server_instance.Stop()
432 self.server.test_server_instance = None 433 self.server.test_server_instance = None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698