Diff
Modified: trunk/Tools/ChangeLog (196777 => 196778)
--- trunk/Tools/ChangeLog 2016-02-18 21:58:15 UTC (rev 196777)
+++ trunk/Tools/ChangeLog 2016-02-18 22:31:49 UTC (rev 196778)
@@ -1,3 +1,23 @@
+2016-02-18 Jer Noble <[email protected]>
+
+ run-webkit-httpd should use webkitpy to run httpd.
+ https://bugs.webkit.org/show_bug.cgi?id=154271
+
+ Reviewed by Alexey Proskuryakov.
+
+ Update run-webkit-httpd to use webkitpy.port to launch httpd. Pass on http_port and http_all_interface
+ options to match the current run-webkit-httpd (optional) behavior.
+
+ * Scripts/run-webkit-httpd:
+ (parse_args):
+ (main):
+ * Scripts/webkitpy/layout_tests/servers/apache_http_server.py:
+ (LayoutTestApacheHttpd.__init__):
+ * Scripts/webkitpy/layout_tests/servers/http_server.py:
+ (Lighttpd._prepare_config):
+ * Scripts/webkitpy/port/base.py:
+ (Port.to.start_http_server):
+
2016-02-18 Filip Pizlo <[email protected]>
Remove remaining references to LLVM, and make sure comments refer to the backend as "B3" not "LLVM"
Modified: trunk/Tools/Scripts/run-webkit-httpd (196777 => 196778)
--- trunk/Tools/Scripts/run-webkit-httpd 2016-02-18 21:58:15 UTC (rev 196777)
+++ trunk/Tools/Scripts/run-webkit-httpd 2016-02-18 22:31:49 UTC (rev 196778)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/python
# Copyright (C) 2005, 2006, 2007, 2015 Apple Inc. All rights reserved.
# Copyright (C) 2006 Alexey Proskuryakov ([email protected])
@@ -28,73 +28,51 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-# Script to run Apache with the same configuration as used in http layout tests.
+import optparse
+import subprocess
+import sys
+import tempfile
+import time
-use strict;
-use warnings;
+from webkitpy.common.host import Host
+from webkitpy.port import platform_options
-use Cwd;
-use File::Path;
-use File::Basename;
-use Getopt::Long;
-use FindBin;
+def parse_args(args):
+ parser = optparse.OptionParser()
+ parser.add_option("-a", "--all-interfaces", help="Bind to all interfaces", action="" dest="http_all_interfaces")
+ parser.add_option("-p", "--port", help="Bind to port NNNN", action="" type="int", dest="http_port")
+ return parser.parse_args(args)
-use lib $FindBin::Bin;
-use webkitperl::httpd;
-use webkitdirs;
+def main(argv, stdout, stderr):
+ options, args = parse_args(argv)
+ host = Host()
-# FIXME: Dynamic HTTP-port configuration in this file is wrong. The various
-# apache config files in LayoutTests/http/config govern the port numbers.
-# Dynamic configuration as-written will also cause random failures in
-# an IPv6 environment. See https://bugs.webkit.org/show_bug.cgi?id=37104.
-# Argument handling
-my $httpdPort = 8000;
-my $allInterfaces = 0;
-my $showHelp;
+ log_file = tempfile.NamedTemporaryFile()
+ options.http_access_log = log_file.name
+ options.http_error_log = log_file.name
+ options.platform = None
-my $result = GetOptions(
- 'all-interfaces|a' => \$allInterfaces,
- 'help|h' => \$showHelp,
- 'port=i' => \$httpdPort,
-);
+ try:
+ port = host.port_factory.get(options.platform, options)
+ except NotImplementedError, e:
+ print >> stderr, str(e)
+ return EXCEPTIONAL_EXIT_STATUS
-if (!$result || @ARGV || $showHelp) {
- print "Usage: " . basename($0) . " [options]\n";
- print " -a|--all-interfaces Bind to all interfaces\n";
- print " -h|--help Show this help message\n";
- print " -p|--port NNNN Bind to port NNNN\n";
- exit 1;
-}
+ # FIXME(154294): somehow retrieve the actual ports and interfaces bound by the httpd server
+ http_port = options.http_port if options.http_port is not None else "8000"
+ if options.http_all_interfaces is not None:
+ print "Starting httpd on port %s (all interfaces)" % http_port
+ else:
+ print "Starting httpd on <http://127.0.0.1:%s>" % http_port
-setConfiguration();
-my $productDir = productDir();
-chdirWebKit();
-my $testDirectory = File::Spec->catfile(getcwd(), "LayoutTests");
-my $listen = "127.0.0.1:$httpdPort";
-$listen = "$httpdPort" if ($allInterfaces);
+ port.start_http_server()
-if ($allInterfaces) {
- print "Starting httpd on port $httpdPort (all interfaces)...\n";
-} else {
- print "Starting httpd on <http://$listen/>...\n";
-}
-setShouldWaitForUserInterrupt();
-print "Press Ctrl+C to stop it.\n\n";
+ try:
+ tail = subprocess.Popen(['tail', '-F', log_file.name], stdout=subprocess.PIPE)
+ while True:
+ sys.stdout.write(tail.stdout.readline())
+ except KeyboardInterrupt:
+ port.stop_http_server()
-my @args = (
- "-C", "Listen $listen",
- # Run in single-process mode, do not detach from the controlling terminal.
- "-X",
- # Disable Keep-Alive support. Makes testing in multiple browsers easier (no need to wait
- # for another browser's connection to expire).
- "-c", "KeepAlive off"
-);
-
-if (!isAnyWindows()) {
- push(@args, "-c", "CustomLog |/usr/bin/tee common");
- push(@args, "-c", "ErrorLog |/usr/bin/tee");
-}
-
-my @defaultArgs = getDefaultConfigForTestDirectory($testDirectory);
-@args = (@defaultArgs, @args);
-openHTTPD(@args);
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:], sys.stdout, sys.stderr))
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/servers/apache_http_server.py (196777 => 196778)
--- trunk/Tools/Scripts/webkitpy/layout_tests/servers/apache_http_server.py 2016-02-18 21:58:15 UTC (rev 196777)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/servers/apache_http_server.py 2016-02-18 22:31:49 UTC (rev 196778)
@@ -43,7 +43,7 @@
class LayoutTestApacheHttpd(http_server_base.HttpServerBase):
- def __init__(self, port_obj, output_dir, additional_dirs=None):
+ def __init__(self, port_obj, output_dir, additional_dirs=None, port=None):
"""Args:
port_obj: handle to the platform-specific routines
output_dir: the absolute path to the layout test result directory
@@ -51,10 +51,15 @@
http_server_base.HttpServerBase.__init__(self, port_obj)
# We use the name "httpd" instead of "apache" to make our paths (e.g. the pid file: /tmp/WebKit/httpd.pid)
# match old-run-webkit-tests: https://bugs.webkit.org/show_bug.cgi?id=63956
+
self._name = 'httpd'
- self._mappings = [{'port': 8000},
- {'port': 8080},
- {'port': 8443, 'sslcert': True}]
+ self._port = port
+ if self._port is not None:
+ self._mappings = [{'port': self._port}]
+ else:
+ self._mappings = [{'port': 8000},
+ {'port': 8080},
+ {'port': 8443, 'sslcert': True}]
self._output_dir = output_dir
self._filesystem.maybe_make_directory(output_dir)
@@ -80,6 +85,12 @@
error_log = self._filesystem.join(output_dir, "error_log.txt")
document_root = self._filesystem.join(test_dir, "http", "tests")
+ if port_obj.get_option('http_access_log'):
+ access_log = port_obj.get_option('http_access_log')
+
+ if port_obj.get_option('http_error_log'):
+ error_log = port_obj.get_option('http_error_log')
+
# FIXME: We shouldn't be calling a protected method of _port_obj!
executable = self._port_obj._path_to_apache()
@@ -110,10 +121,12 @@
except:
enable_ipv6 = False
+ bind_address = '' if self._port_obj.get_option("http_all_interfaces") else '127.0.0.1:'
+
for mapping in self._mappings:
port = mapping['port']
- start_cmd += ['-C', "\'Listen 127.0.0.1:%d\'" % port]
+ start_cmd += ['-C', "\'Listen %s%d\'" % (bind_address, port)]
# We listen to both IPv4 and IPv6 loop-back addresses, but ignore
# requests to 8000 from random users on network.
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/servers/http_server.py (196777 => 196778)
--- trunk/Tools/Scripts/webkitpy/layout_tests/servers/http_server.py 2016-02-18 21:58:15 UTC (rev 196777)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/servers/http_server.py 2016-02-18 22:31:49 UTC (rev 196778)
@@ -94,6 +94,12 @@
log_file_name = "error.log-" + time_str + ".txt"
error_log = os.path.join(self._output_dir, log_file_name)
+ if self._port_obj.get_option('http_access_log'):
+ access_log = self._port_obj.get_option('http_access_log')
+
+ if self._port_obj.get_option('http_error_log'):
+ error_log = self._port_obj.get_option('http_error_log')
+
# Write out the config
base_conf = self._filesystem.read_text_file(base_conf_file)
@@ -149,16 +155,18 @@
'sslcert': self._pem_file}]
else:
mappings = self.VIRTUALCONFIG
+
+ bind_address = '' if self._port_obj.get_option('http_all_addresses') else '127.0.0.1'
for mapping in mappings:
ssl_setup = ''
if 'sslcert' in mapping:
ssl_setup = (' ssl.engine = "enable"\n'
' ssl.pemfile = "%s"\n' % mapping['sslcert'])
- f.write(('$SERVER["socket"] == "127.0.0.1:%d" {\n'
+ f.write(('$SERVER["socket"] == "%s:%d" {\n'
' server.document-root = "%s"\n' +
ssl_setup +
- '}\n\n') % (mapping['port'], mapping['docroot']))
+ '}\n\n') % (bind_address, mapping['port'], mapping['docroot']))
f.close()
executable = self._port_obj._path_to_lighttpd()
Modified: trunk/Tools/Scripts/webkitpy/port/base.py (196777 => 196778)
--- trunk/Tools/Scripts/webkitpy/port/base.py 2016-02-18 21:58:15 UTC (rev 196777)
+++ trunk/Tools/Scripts/webkitpy/port/base.py 2016-02-18 22:31:49 UTC (rev 196778)
@@ -905,11 +905,11 @@
Ports can stub this out if they don't need a web server to be running."""
assert not self._http_server, 'Already running an http server.'
-
+ http_port = self.get_option('http_port')
if self._uses_apache():
- server = apache_http_server.LayoutTestApacheHttpd(self, self.results_directory(), additional_dirs=additional_dirs)
+ server = apache_http_server.LayoutTestApacheHttpd(self, self.results_directory(), additional_dirs=additional_dirs, port=http_port)
else:
- server = http_server.Lighttpd(self, self.results_directory(), additional_dirs=additional_dirs)
+ server = http_server.Lighttpd(self, self.results_directory(), additional_dirs=additional_dirs, port=http_port)
server.start()
self._http_server = server