summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorojan@chromium.org <ojan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-05 02:38:36 +0000
committerojan@chromium.org <ojan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-05 02:38:36 +0000
commit9ae4d4b39c1f75f319d7b71de2364d9d7620e876 (patch)
treed7afc1e647812f914e0a98bd48c058c6492971e4
parent7de03266c2c54238fe225256c481bcea8ae5347d (diff)
downloadchromium_src-9ae4d4b39c1f75f319d7b71de2364d9d7620e876.zip
chromium_src-9ae4d4b39c1f75f319d7b71de2364d9d7620e876.tar.gz
chromium_src-9ae4d4b39c1f75f319d7b71de2364d9d7620e876.tar.bz2
Almost get the checked in apache 1.3.3 working on cygwin.
On my Vista machine I get remap errors that rebase doesn't seem to fix. I"m sure I'm just doing something wrong. Hopefully with this checked in, someone who understands cygwin/windows/apache can actually get this working. Also, hopefully said person can upgrade us to Apache 2 so we can match Mac/Linux. Review URL: http://codereview.chromium.org/505030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35507 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/tools/layout_tests/layout_package/apache_http_server.py115
-rw-r--r--webkit/tools/layout_tests/layout_package/platform_utils_win.py8
2 files changed, 97 insertions, 26 deletions
diff --git a/webkit/tools/layout_tests/layout_package/apache_http_server.py b/webkit/tools/layout_tests/layout_package/apache_http_server.py
index c8ab7ad..c0a4c40 100644
--- a/webkit/tools/layout_tests/layout_package/apache_http_server.py
+++ b/webkit/tools/layout_tests/layout_package/apache_http_server.py
@@ -7,6 +7,7 @@
import logging
import optparse
import os
+import re
import subprocess
import sys
@@ -42,25 +43,76 @@ class LayoutTestApacheHttpd(http_server_base.HttpServerBase):
test_dir = path_utils.PathFromBase('third_party', 'WebKit',
'LayoutTests')
- js_test_resources_dir = os.path.join(test_dir, "fast", "js", "resources")
- mime_types_path = os.path.join(test_dir, "http", "conf", "mime.types")
- cert_file = os.path.join(test_dir, "http", "conf", "webkit-httpd.pem")
-
- cmd = [platform_utils.ApacheExecutablePath(),
+ js_test_resources_dir = self._CygwinSafeJoin(test_dir, "fast", "js",
+ "resources")
+ mime_types_path = self._CygwinSafeJoin(test_dir, "http", "conf",
+ "mime.types")
+ cert_file = self._CygwinSafeJoin(test_dir, "http", "conf",
+ "webkit-httpd.pem")
+ access_log = self._CygwinSafeJoin(output_dir, "access_log.txt")
+ error_log = self._CygwinSafeJoin(output_dir, "error_log.txt")
+ document_root = self._CygwinSafeJoin(test_dir, "http", "tests")
+
+ executable = platform_utils.ApacheExecutablePath()
+ if self._IsCygwin():
+ executable = self._GetCygwinPath(executable)
+
+ cmd = [ executable,
'-f', self._GetApacheConfigFilePath(test_dir, output_dir),
- '-C', "DocumentRoot %s" % os.path.join(test_dir, "http", "tests"),
- '-c', "Alias /js-test-resources %s" % js_test_resources_dir,
- '-C', "Listen %s" % "127.0.0.1:8000",
- '-C', "Listen %s" % "127.0.0.1:8081",
- '-c', "TypesConfig \"%s\"" % mime_types_path,
- '-c', "CustomLog \"%s/access_log.txt\" common" % output_dir,
- '-c', "ErrorLog \"%s/error_log.txt\"" % output_dir,
- '-C', "User \"%s\"" % os.environ.get("USERNAME",
- os.environ.get("USER", "")),
- '-c', "SSLCertificateFile %s" % cert_file,
- ]
-
- self._start_cmd = cmd
+ '-C', "\'DocumentRoot %s\'" % document_root,
+ '-c', "\'Alias /js-test-resources %s\'" % js_test_resources_dir,
+ '-C', "\'Listen %s\'" % "127.0.0.1:8000",
+ '-C', "\'Listen %s\'" % "127.0.0.1:8081",
+ '-c', "\'TypesConfig \"%s\"\'" % mime_types_path,
+ '-c', "\'CustomLog \"%s\" common\'" % access_log,
+ '-c', "\'ErrorLog \"%s\"\'" % error_log,
+ '-C', "\'User \"%s\"\'" % os.environ.get("USERNAME",
+ os.environ.get("USER", "")),
+ ]
+
+ if self._IsCygwin():
+ cygbin = path_utils.PathFromBase('third_party', 'cygwin', 'bin')
+ # Not entirely sure why, but from cygwin we need to run the httpd command
+ # through bash.
+ self._start_cmd = [
+ os.path.join(cygbin, 'bash.exe'),
+ '-c',
+ 'PATH=%s %s' % (self._GetCygwinPath(cygbin), " ".join(cmd)),
+ ]
+ else:
+ # TODO(ojan): When we get cygwin using Apache 2, use set the cert file
+ # for cygwin as well.
+ cmd.extend(['-c', "\'SSLCertificateFile %s\'" % cert_file])
+ # Join the string here so that Cygwin/Windows and Mac/Linux can use the
+ # same code. Otherwise, we could remove the single quotes above and
+ # keep cmd as a sequence.
+ self._start_cmd = " ".join(cmd)
+
+ def _IsCygwin(self):
+ return sys.platform in ("win32", "cygwin")
+
+ def _CygwinSafeJoin(self, *parts):
+ """Returns a platform appropriate path."""
+ path = os.path.join(*parts)
+ if self._IsCygwin():
+ return self._GetCygwinPath(path)
+ return path
+
+ def _GetCygwinPath(self, path):
+ """Convert a Windows path to a cygwin path.
+
+ The cygpath utility insists on converting paths that it thinks are Cygwin
+ root paths to what it thinks the correct roots are. So paths such as
+ "C:\b\slave\webkit-release\build\third_party\cygwin\bin" are converted to
+ plain "/usr/bin". To avoid this, we do the conversion manually.
+
+ The path is expected to be an absolute path, on any drive.
+ """
+ drive_regexp = re.compile(r'([a-z]):[/\\]', re.IGNORECASE)
+ def LowerDrive(matchobj):
+ return '/cygdrive/%s/' % matchobj.group(1).lower()
+ path = drive_regexp.sub(LowerDrive, path)
+ return path.replace('\\', '/')
def _GetApacheConfigFilePath(self, test_dir, output_dir):
"""Returns the path to the apache config file to use.
@@ -70,15 +122,26 @@ class LayoutTestApacheHttpd(http_server_base.HttpServerBase):
"""
httpd_config = platform_utils.ApacheConfigFilePath()
httpd_config_copy = os.path.join(output_dir, "httpd.conf")
- main_document_root = os.path.join(path_utils.LayoutTestsDir(),
- "LayoutTests", "http", "tests")
- chrome_document_root = path_utils.PathFromBase('webkit', 'data',
- 'layout_tests')
httpd_conf = open(httpd_config).read()
+ if self._IsCygwin():
+ # This is a gross hack, but it lets us use the upstream .conf file and
+ # our checked in cygwin.
+ # This tells the server the root directory to look in for .so modules.
+ # It will use this path plus the relative paths to the .so files listed
+ # in the .conf file. We have apache/cygwin checked into our tree so
+ # people don't have to install it into their cygwin.
+ cygusr = path_utils.PathFromBase('third_party', 'cygwin', 'usr')
+ httpd_conf = httpd_conf.replace('ServerRoot "/usr"',
+ 'ServerRoot "%s"' % self._GetCygwinPath(cygusr))
+
# TODO(ojan): Instead of writing an extra file, checkin a conf file
# upstream. Or, even better, upstream/delete all our chrome http tests so we
# don't need this special-cased DocumentRoot and then just use the upstream
# conf file.
+ chrome_document_root = path_utils.PathFromBase('webkit', 'data',
+ 'layout_tests')
+ if self._IsCygwin():
+ chrome_document_root = self._GetCygwinPath(chrome_document_root)
httpd_conf = (httpd_conf +
self._GetVirtualHostConfig(chrome_document_root, 8081))
@@ -86,6 +149,8 @@ class LayoutTestApacheHttpd(http_server_base.HttpServerBase):
f.write(httpd_conf)
f.close()
+ if self._IsCygwin():
+ return self._GetCygwinPath(httpd_config_copy)
return httpd_config_copy
def _GetVirtualHostConfig(self, document_root, port, ssl=False):
@@ -97,10 +162,12 @@ class LayoutTestApacheHttpd(http_server_base.HttpServerBase):
ssl and 'SSLEngine On' or '',
'</VirtualHost>', ''))
-
def _StartHttpdProcess(self):
"""Starts the httpd process and returns whether there were errors."""
- self._httpd_proc = subprocess.Popen(self._start_cmd, stderr=subprocess.PIPE)
+ # Use shell=True because we join the arguments into a string for the sake
+ # of Window/Cygwin and it needs quoting that breaks shell=False.
+ self._httpd_proc = subprocess.Popen(self._start_cmd, stderr=subprocess.PIPE,
+ shell=True)
err = self._httpd_proc.stderr.read()
if len(err):
logging.debug(err)
diff --git a/webkit/tools/layout_tests/layout_package/platform_utils_win.py b/webkit/tools/layout_tests/layout_package/platform_utils_win.py
index 746407f..6a78cf0 100644
--- a/webkit/tools/layout_tests/layout_package/platform_utils_win.py
+++ b/webkit/tools/layout_tests/layout_package/platform_utils_win.py
@@ -96,8 +96,9 @@ def TestShellPath(target):
def ApacheExecutablePath():
"""Returns the executable path to start Apache"""
- return path_utils.PathFromBase('third_party', 'cygwin', "usr", "sbin",
- "httpd.exe")
+ path = path_utils.PathFromBase('third_party', 'cygwin', "usr", "sbin")
+ # Don't return httpd.exe since we want to use this from cygwin.
+ return os.path.join(path, "httpd")
def ApacheConfigFilePath():
"""Returns the path to Apache config file"""
@@ -128,6 +129,9 @@ def ShutDownHTTPServer(server_pid):
subprocess.Popen(('taskkill.exe', '/f', '/im', 'LightTPD.exe'),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).wait()
+ subprocess.Popen(('taskkill.exe', '/f', '/im', 'httpd.exe'),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE).wait()
def KillProcess(pid):
"""Forcefully kill the process.