summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpamg@google.com <pamg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-29 17:06:49 +0000
committerpamg@google.com <pamg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-29 17:06:49 +0000
commit2da95da3c557c70318900db9a9e06876dedf3e94 (patch)
tree7307e6cb651446e48462e40f79f7d44050860334
parentf7dadf7909952ea3c5fd8e0393209694bbb5ec50 (diff)
downloadchromium_src-2da95da3c557c70318900db9a9e06876dedf3e94.zip
chromium_src-2da95da3c557c70318900db9a9e06876dedf3e94.tar.gz
chromium_src-2da95da3c557c70318900db9a9e06876dedf3e94.tar.bz2
Add --port and --root options to the command-line interface to allow running
this server for more general purposes than only layout tests. (In particular, I've found it helpful when testing perf plots.) BUG=none TEST=none Review URL: http://codereview.chromium.org/8668 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4129 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/tools/layout_tests/layout_package/http_server.py29
1 files changed, 22 insertions, 7 deletions
diff --git a/webkit/tools/layout_tests/layout_package/http_server.py b/webkit/tools/layout_tests/layout_package/http_server.py
index 7e3aeab..0369f81 100644
--- a/webkit/tools/layout_tests/layout_package/http_server.py
+++ b/webkit/tools/layout_tests/layout_package/http_server.py
@@ -28,7 +28,7 @@ class HttpdNotStarted(Exception):
pass
class Lighttpd:
- # Webkit tests
+ # Webkit tests
_webkit_tests = PathFromBase('webkit', 'data', 'layout_tests',
'LayoutTests', 'http', 'tests')
# New tests for Chrome
@@ -53,12 +53,16 @@ class Lighttpd:
{'port': 8081, 'docroot': _all_tests}
]
- def __init__(self, output_dir, background=False):
+ def __init__(self, output_dir, background=False, port=None, root=None):
"""Args:
output_dir: the absolute path to the layout test result directory
"""
self._output_dir = output_dir
self._process = None
+ self._port = port
+ self._root = root
+ if self._port:
+ self._port = int(self._port)
def IsRunning(self):
return self._process != None
@@ -95,7 +99,11 @@ class Lighttpd:
'accesslog.filename = "%s"\n\n') % (error_log, access_log))
# dump out of virtual host config at the bottom.
- for mapping in self.VIRTUALCONFIG:
+ if self._port and self._root:
+ mappings = [{'port': self._port, 'docroot': self._root}]
+ else:
+ mappings = self.VIRTUALCONFIG
+ for mapping in mappings:
ssl_setup = ''
if 'sslcert' in mapping:
ssl_setup = (' ssl.engine = "enable"\n'
@@ -126,11 +134,12 @@ class Lighttpd:
self._process = subprocess.Popen(start_cmd, env=env)
# Ensure that the server is running on all the desired ports.
- for mapping in self.VIRTUALCONFIG:
+ for mapping in mappings:
url = 'http%s://127.0.0.1:%d/' % ('sslcert' in mapping and 's' or '',
mapping['port'])
if not self._UrlIsAlive(url):
- raise HttpdNotStarted('Failed to start httpd on port %s' % str(port))
+ raise HttpdNotStarted('Failed to start httpd on port %s' %
+ str(mapping['port']))
# Our process terminated already
if self._process.returncode != None:
@@ -184,12 +193,18 @@ if '__main__' == __name__:
# manually.
option_parser = optparse.OptionParser()
option_parser.add_option('-k', '--server', help='Server action (start|stop)')
+ option_parser.add_option('-p', '--port',
+ help='Port to listen on (overrides layout test ports)')
+ option_parser.add_option('-r', '--root',
+ help='Absolute path to DocumentRoot (overrides layout test roots)')
options, args = option_parser.parse_args()
-
+
if not options.server:
print "Usage: %s --server {start|stop} [--apache2]" % sys.argv[0]
else:
- httpd = Lighttpd('c:/cygwin/tmp')
+ if (options.root is None) != (options.port is None):
+ raise 'Either port or root is missing (need both, or neither)'
+ httpd = Lighttpd('c:/cygwin/tmp', port=options.port, root=options.root)
if 'start' == options.server:
httpd.Start()
else: