OLD | NEW |
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 # pylint: disable=W0702 | 10 # pylint: disable=W0702 |
(...skipping 17 matching lines...) Expand all Loading... |
28 from pylib.constants import host_paths | 28 from pylib.constants import host_paths |
29 | 29 |
30 | 30 |
31 # Path that are needed to import necessary modules when launching a testserver. | 31 # Path that are needed to import necessary modules when launching a testserver. |
32 os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', '') + (':%s:%s:%s:%s:%s' | 32 os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', '') + (':%s:%s:%s:%s:%s' |
33 % (os.path.join(host_paths.DIR_SOURCE_ROOT, 'third_party'), | 33 % (os.path.join(host_paths.DIR_SOURCE_ROOT, 'third_party'), |
34 os.path.join(host_paths.DIR_SOURCE_ROOT, 'third_party', 'tlslite'), | 34 os.path.join(host_paths.DIR_SOURCE_ROOT, 'third_party', 'tlslite'), |
35 os.path.join(host_paths.DIR_SOURCE_ROOT, 'third_party', 'pyftpdlib', | 35 os.path.join(host_paths.DIR_SOURCE_ROOT, 'third_party', 'pyftpdlib', |
36 'src'), | 36 'src'), |
37 os.path.join(host_paths.DIR_SOURCE_ROOT, 'net', 'tools', 'testserver'), | 37 os.path.join(host_paths.DIR_SOURCE_ROOT, 'net', 'tools', 'testserver'), |
38 os.path.join(host_paths.DIR_SOURCE_ROOT, 'sync', 'tools', 'testserver'))) | 38 os.path.join(host_paths.DIR_SOURCE_ROOT, 'components', 'sync', 'tools', |
| 39 'testserver'))) |
39 | 40 |
40 | 41 |
41 SERVER_TYPES = { | 42 SERVER_TYPES = { |
42 'http': '', | 43 'http': '', |
43 'ftp': '-f', | 44 'ftp': '-f', |
44 'sync': '', # Sync uses its own script, and doesn't take a server type arg. | 45 'sync': '', # Sync uses its own script, and doesn't take a server type arg. |
45 'tcpecho': '--tcp-echo', | 46 'tcpecho': '--tcp-echo', |
46 'udpecho': '--udp-echo', | 47 'udpecho': '--udp-echo', |
47 } | 48 } |
48 | 49 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 os.close(fd) | 213 os.close(fd) |
213 except: | 214 except: |
214 pass | 215 pass |
215 | 216 |
216 def run(self): | 217 def run(self): |
217 logging.info('Start running the thread!') | 218 logging.info('Start running the thread!') |
218 self.wait_event.clear() | 219 self.wait_event.clear() |
219 self._GenerateCommandLineArguments() | 220 self._GenerateCommandLineArguments() |
220 command = host_paths.DIR_SOURCE_ROOT | 221 command = host_paths.DIR_SOURCE_ROOT |
221 if self.arguments['server-type'] == 'sync': | 222 if self.arguments['server-type'] == 'sync': |
222 command = [os.path.join(command, 'sync', 'tools', 'testserver', | 223 command = [os.path.join(command, 'components', 'sync', 'tools', |
| 224 'testserver', |
223 'sync_testserver.py')] + self.command_line | 225 'sync_testserver.py')] + self.command_line |
224 else: | 226 else: |
225 command = [os.path.join(command, 'net', 'tools', 'testserver', | 227 command = [os.path.join(command, 'net', 'tools', 'testserver', |
226 'testserver.py')] + self.command_line | 228 'testserver.py')] + self.command_line |
227 logging.info('Running: %s', command) | 229 logging.info('Running: %s', command) |
228 | 230 |
229 # Disable PYTHONUNBUFFERED because it has a bad interaction with the | 231 # Disable PYTHONUNBUFFERED because it has a bad interaction with the |
230 # testserver. Remove once this interaction is fixed. | 232 # testserver. Remove once this interaction is fixed. |
231 unbuf = os.environ.pop('PYTHONUNBUFFERED', None) | 233 unbuf = os.environ.pop('PYTHONUNBUFFERED', None) |
232 | 234 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 | 423 |
422 def CleanupState(self): | 424 def CleanupState(self): |
423 """Cleans up the spawning server state. | 425 """Cleans up the spawning server state. |
424 | 426 |
425 This should be called if the test server spawner is reused, | 427 This should be called if the test server spawner is reused, |
426 to avoid sharing the test server instance. | 428 to avoid sharing the test server instance. |
427 """ | 429 """ |
428 if self.server.test_server_instance: | 430 if self.server.test_server_instance: |
429 self.server.test_server_instance.Stop() | 431 self.server.test_server_instance.Stop() |
430 self.server.test_server_instance = None | 432 self.server.test_server_instance = None |
OLD | NEW |