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 | 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 from pylib.forwarder import Forwarder | 26 from pylib.forwarder import Forwarder |
27 | 27 |
28 # Path that are needed to import necessary modules when launching a testserver. | |
M-A Ruel
2013/12/04 21:16:43
Modifying os.environ as a side-effect of importing
bulach
2013/12/06 09:56:54
sorry about the delay, pliard@ would be a better r
| |
29 os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', '') + (':%s:%s:%s:%s:%s' | |
30 % (os.path.join(constants.DIR_SOURCE_ROOT, 'third_party'), | |
31 os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', 'tlslite'), | |
32 os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', 'pyftpdlib', | |
33 'src'), | |
34 os.path.join(constants.DIR_SOURCE_ROOT, 'net', 'tools', 'testserver'), | |
35 os.path.join(constants.DIR_SOURCE_ROOT, 'sync', 'tools', 'testserver'))) | |
36 | |
37 | 28 |
38 SERVER_TYPES = { | 29 SERVER_TYPES = { |
39 'http': '', | 30 'http': '', |
40 'ftp': '-f', | 31 'ftp': '-f', |
41 'sync': '', # Sync uses its own script, and doesn't take a server type arg. | 32 'sync': '', # Sync uses its own script, and doesn't take a server type arg. |
42 'tcpecho': '--tcp-echo', | 33 'tcpecho': '--tcp-echo', |
43 'udpecho': '--udp-echo', | 34 'udpecho': '--udp-echo', |
44 } | 35 } |
45 | 36 |
46 | 37 |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
427 | 418 |
428 def CleanupState(self): | 419 def CleanupState(self): |
429 """Cleans up the spawning server state. | 420 """Cleans up the spawning server state. |
430 | 421 |
431 This should be called if the test server spawner is reused, | 422 This should be called if the test server spawner is reused, |
432 to avoid sharing the test server instance. | 423 to avoid sharing the test server instance. |
433 """ | 424 """ |
434 if self.server.test_server_instance: | 425 if self.server.test_server_instance: |
435 self.server.test_server_instance.Stop() | 426 self.server.test_server_instance.Stop() |
436 self.server.test_server_instance = None | 427 self.server.test_server_instance = None |
OLD | NEW |