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

Side by Side Diff: build/android/pylib/host_driven/test_server_setup.py

Issue 23726004: Add test_server_setup.py and add support for additional flags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
(Empty)
1 #!/usr/bin/python
2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import os
7 import os.path
8 import subprocess
9
10 from pylib import constants
11
12 # NOTE: when adding or modifying these lines, omit any leading slashes!
13 # Otherwise os.path.join() will (correctly) treat them as absolute paths
14 # instead of relative paths, and will do nothing.
15 PYTHONPATH_DIRS = [
frankf 2013/08/29 00:07:19 Add a leading underscore since these are private.
nyquist 2013/08/29 23:59:43 Done.
16 'net/tools/testserver/',
17 'third_party/',
18 'third_party/pyftpdlib/src/',
19 'third_party/pywebsocket/src',
20 'third_party/tlslite/',
21 ]
22
23 # Python files in these directories are generated as part of the build.
24 # These dirs are located in out/(Debug|Release) directory.
25 # The correct path is determined based on the build type. E.g. out/Debug for
26 # debug builds and out/Release for release builds.
27 GENERATED_PYTHONPATH_DIRS = [
28 'pyproto/sync/protocol/',
29 'pyproto/'
30 ]
31
frankf 2013/08/29 00:07:19 run gpylint. 2 blank lines between top-level decla
nyquist 2013/08/29 23:59:43 Done.
32 def SetUpTestServer(adb, shard_index, test_server_port, test_server_path):
frankf 2013/08/29 00:07:19 So it makes sense to make this into a class and en
nyquist 2013/08/29 23:59:43 Done.
33 """Sets up a server.
34
35 Args:
36 adb: AndroidCommands object.
37 shard_index: Index of the current shard.
38 test_server_port: port to run the test server on.
frankf 2013/08/29 00:07:19 Capital first letter.
nyquist 2013/08/29 23:59:43 Done.
39 test_server_path: the path (relative to the root src dir) of the server
40
41 Returns:
42 A tuple where the first element is the port used by the server, and the
43 second is the mock server that was setup.
44 """
45 port = test_server_port + shard_index
46
47 src_dir = constants.DIR_SOURCE_ROOT
48 # Make dirs into a list of absolute paths.
49 abs_dirs = [os.path.join(src_dir, d) for d in PYTHONPATH_DIRS]
50 # Add the generated python files to the path
51 abs_dirs.extend([os.path.join(src_dir, 'out', constants.GetBuildType(), d)
52 for d in GENERATED_PYTHONPATH_DIRS])
53 # Note the colon after $PYTHONPATH. This appends the list of PYTHONPATH_DIRS
54 # to the existing PYTHONPATH.
55 python_path = '$PYTHONPATH:' + ':'.join(abs_dirs)
craigdh 2013/08/29 00:06:46 just modify os.environ
nyquist 2013/08/29 23:59:43 Uses os.environ now, but does not edit it here, si
56
57 # NOTE: A separate python process is used to simplify getting the right system
58 # path for finding includes.
59 server_flags = ['python', os.path.join(src_dir, test_server_path),
60 '--log-to-console',
61 ('--host=%s' % constants.TEST_SERVER_HOST),
62 ('--port=%d' % port)]
63 test_server = subprocess.Popen(server_flags, env={'PYTHONPATH': python_path})
craigdh 2013/08/29 00:06:46 We've had issues with bugs in Python 2.x's subproc
nyquist 2013/08/29 23:59:43 There is no waiting for output here, so that does
craigdh 2013/08/30 17:55:50 Ah, you're right, I thought it was returning a Pop
64 return (port, test_server)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698