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

Unified Diff: Tools/Scripts/webkitpy/layout_tests/servers/lighttpd.py

Issue 146173004: Fix run-blink-httpd to work w/ Apache and refactor webkitpy.layout_tests.servers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add cli_wrapper and update run-* scripts Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: Tools/Scripts/webkitpy/layout_tests/servers/lighttpd.py
diff --git a/Tools/Scripts/webkitpy/layout_tests/servers/http_server.py b/Tools/Scripts/webkitpy/layout_tests/servers/lighttpd.py
similarity index 56%
rename from Tools/Scripts/webkitpy/layout_tests/servers/http_server.py
rename to Tools/Scripts/webkitpy/layout_tests/servers/lighttpd.py
index 4c712a4b0d6e5859c752cb3cd0c60cc7a2adb330..cd832dc62cd8ab9f8bc15bd91639c4ec93f8894e 100644
--- a/Tools/Scripts/webkitpy/layout_tests/servers/http_server.py
+++ b/Tools/Scripts/webkitpy/layout_tests/servers/lighttpd.py
@@ -26,43 +26,27 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-"""A class to help start/stop the lighttpd server used by layout tests."""
+"""Start and stop the lighttpd server as it is used by the layout tests."""
import logging
import os
import time
-from webkitpy.layout_tests.servers import http_server_base
+from webkitpy.layout_tests.servers import server_base
_log = logging.getLogger(__name__)
-class Lighttpd(http_server_base.HttpServerBase):
+class Lighttpd(server_base.ServerBase):
- def __init__(self, port_obj, output_dir, background=False, port=None,
- root=None, run_background=None, additional_dirs=None,
- layout_tests_dir=None, number_of_servers=None):
- """Args:
- output_dir: the absolute path to the layout test result directory
- """
- # Webkit tests
- http_server_base.HttpServerBase.__init__(self, port_obj, number_of_servers)
+ def __init__(self, port_obj, output_dir):
+ super(Lighttpd, self).__init__(port_obj, output_dir)
self._name = 'lighttpd'
- self._output_dir = output_dir
- self._port = port
- self._root = root
- self._run_background = run_background
- self._additional_dirs = additional_dirs
- self._layout_tests_dir = layout_tests_dir
-
+ self._log_prefixes = ('access.log-', 'error.log-')
self._pid_file = self._filesystem.join(self._runtime_path, '%s.pid' % self._name)
- if self._port:
- self._port = int(self._port)
-
- if not self._layout_tests_dir:
- self._layout_tests_dir = self._port_obj.layout_tests_dir()
+ self._layout_tests_dir = self._port_obj.layout_tests_dir()
self._webkit_tests = os.path.join(self._layout_tests_dir, 'http', 'tests')
self._js_test_resource = os.path.join(self._layout_tests_dir, 'resources')
@@ -73,16 +57,11 @@ class Lighttpd(http_server_base.HttpServerBase):
self._pem_file = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'httpd2.pem')
- # One mapping where we can get to everything
- self.VIRTUALCONFIG = []
-
- if self._webkit_tests:
- self.VIRTUALCONFIG.extend(
- # Three mappings (one with SSL) for LayoutTests http tests
- [{'port': 8000, 'docroot': self._webkit_tests},
- {'port': 8080, 'docroot': self._webkit_tests},
- {'port': 8443, 'docroot': self._webkit_tests,
- 'sslcert': self._pem_file}])
+ self.mappings = [
+ {'port': 8000, 'docroot': self._webkit_tests},
+ {'port': 8080, 'docroot': self._webkit_tests},
+ {'port': 8443, 'docroot': self._webkit_tests, 'sslcert': self._pem_file},
+ ]
def _prepare_config(self):
base_conf_file = self._port_obj.path_from_webkit_base('Tools',
@@ -124,32 +103,12 @@ class Lighttpd(http_server_base.HttpServerBase):
f.write(('alias.url = ( "/js-test-resources" => "%s" )\n\n') %
(self._js_test_resource))
- if self._additional_dirs:
- for alias, path in self._additional_dirs.iteritems():
- f.write(('alias.url += ( "%s" => "%s" )\n\n') % (alias, path))
-
# Setup a link to where the media resources are stored.
f.write(('alias.url += ( "/media-resources" => "%s" )\n\n') %
(self._media_resource))
# dump out of virtual host config at the bottom.
- if self._root:
- if self._port:
- # Have both port and root dir.
- mappings = [{'port': self._port, 'docroot': self._root}]
- else:
- # Have only a root dir - set the ports as for LayoutTests.
- # This is used in ui_tests to run http tests against a browser.
-
- # default set of ports as for LayoutTests but with a
- # specified root.
- mappings = [{'port': 8000, 'docroot': self._root},
- {'port': 8080, 'docroot': self._root},
- {'port': 8443, 'docroot': self._root,
- 'sslcert': self._pem_file}]
- else:
- mappings = self.VIRTUALCONFIG
- for mapping in mappings:
+ for mapping in self.mappings:
ssl_setup = ''
if 'sslcert' in mapping:
ssl_setup = (' ssl.engine = "enable"\n'
@@ -169,9 +128,7 @@ class Lighttpd(http_server_base.HttpServerBase):
# Where it can find its module dynamic libraries
'-m', module_path]
- if not self._run_background:
- start_cmd.append(# Don't background
- '-D')
+ start_cmd.append('-D')
# Copy liblightcomp.dylib to /tmp/lighttpd/lib to work around the
# bug that mod_alias.so loads it from the hard coded path.
@@ -185,44 +142,3 @@ class Lighttpd(http_server_base.HttpServerBase):
self._start_cmd = start_cmd
self._env = self._port_obj.setup_environ_for_server('lighttpd')
- self._mappings = mappings
-
- def _remove_stale_logs(self):
- # Sometimes logs are open in other processes but they should clear eventually.
- for log_prefix in ('access.log-', 'error.log-'):
- try:
- self._remove_log_files(self._output_dir, log_prefix)
- except OSError, e:
- _log.warning('Failed to remove old %s %s files' % (self._name, log_prefix))
-
- def _spawn_process(self):
- _log.debug('Starting %s server, cmd="%s"' % (self._name, self._start_cmd))
- process = self._executive.popen(self._start_cmd, env=self._env, shell=False, stderr=self._executive.PIPE)
- pid = process.pid
- self._filesystem.write_text_file(self._pid_file, str(pid))
- return pid
-
- def _stop_running_server(self):
- # FIXME: It would be nice if we had a cleaner way of killing this process.
- # Currently we throw away the process object created in _spawn_process,
- # since there doesn't appear to be any way to kill the server any more
- # cleanly using it than just killing the pid, and we need to support
- # killing a pid directly anyway for run-webkit-httpd and run-webkit-websocketserver.
- self._wait_for_action(self._check_and_kill)
- if self._filesystem.exists(self._pid_file):
- self._filesystem.remove(self._pid_file)
-
- def _check_and_kill(self):
- if self._executive.check_running_pid(self._pid):
- host = self._port_obj.host
- if host.platform.is_win() and not host.platform.is_cygwin():
- # FIXME: https://bugs.webkit.org/show_bug.cgi?id=106838
- # We need to kill all of the child processes as well as the
- # parent, so we can't use executive.kill_process().
- #
- # If this is actually working, we should figure out a clean API.
- self._executive.run_command(["taskkill.exe", "/f", "/t", "/pid", self._pid], error_handler=self._executive.ignore_error)
- else:
- self._executive.kill_process(self._pid)
- return False
- return True

Powered by Google App Engine
This is Rietveld 408576698