Index: Tools/Scripts/webkitpy/layout_tests/servers/third_party/wptserve_http.py |
diff --git a/Tools/Scripts/webkitpy/layout_tests/servers/third_party/wptserve_http.py b/Tools/Scripts/webkitpy/layout_tests/servers/third_party/wptserve_http.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a47b313a2032e552a186eca62f06c8d39857a962 |
--- /dev/null |
+++ b/Tools/Scripts/webkitpy/layout_tests/servers/third_party/wptserve_http.py |
@@ -0,0 +1,102 @@ |
+# Copyright (C) 2015 Google Inc. All rights reserved. |
jsbell
2015/06/04 17:43:25
Don't copy/paste the header, use the latest from:
burnik
2015/06/05 12:59:29
Done.
|
+# |
Dirk Pranke
2015/06/04 20:51:53
Put this file in layout_tests/servers; you do not
burnik
2015/06/05 12:59:29
Done.
|
+# Redistribution and use in source and binary forms, with or without |
+# modification, are permitted provided that the following conditions are |
+# met: |
+# |
+# * Redistributions of source code must retain the above copyright |
+# notice, this list of conditions and the following disclaimer. |
+# * Redistributions in binary form must reproduce the above |
+# copyright notice, this list of conditions and the following disclaimer |
+# in the documentation and/or other materials provided with the |
+# distribution. |
+# * Neither the name of Google Inc. nor the names of its |
+# contributors may be used to endorse or promote products derived from |
+# this software without specific prior written permission. |
+# |
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ |
+"""Start and stop the Apache HTTP server as it is used by the layout tests.""" |
+ |
+import logging |
+import os |
+import socket |
+ |
+from webkitpy.layout_tests.servers import server_base |
+ |
+ |
+_log = logging.getLogger(__name__) |
+ |
+ |
+class WPTServeHTTP(server_base.ServerBase): |
+ def __init__(self, port_obj, output_dir): |
+ super(WPTServeHTTP, self).__init__(port_obj, output_dir) |
+ # TODO(burnik): This should be the only place where we set up the ports. |
+ secure_port, insecure_port = (8001, 8444) |
+ self._name = 'wptserve' |
+ self._log_prefixes = ('access_log', 'error_log') |
+ self._mappings = [{'port': secure_port}, |
+ {'port': insecure_port, 'sslcert': True}] |
+ |
+ # TODO(burnik): We can probably avoid PID files for WPT in the future. |
+ self._pid_file = self._filesystem.join(self._runtime_path, '%s.pid' % self._name) |
+ |
+ script_path = os.path.dirname(os.path.abspath(__file__)) |
+ self._path_to_wpt = os.path.abspath(os.path.join(script_path, "wpt")) |
+ self._executable = os.path.join(self._path_to_wpt, "serve") |
+ self._path_to_wpt_config = os.path.join(self._path_to_wpt, "config.json") |
+ self._path_to_wpt_tests = os.path.abspath(os.path.join(self._port_obj.layout_tests_dir(), |
+ "imported", "web-platform-tests")) |
+ self._wpt_config = {"host": "web-platform.test", |
+ "doc_root": self._path_to_wpt_tests, |
+ "insecure_port": secure_port, |
+ "secure_port": insecure_port} |
+ self._start_cmd = [self._executable, "--config", self._path_to_wpt_config] |
+ |
+ def _spawn_process(self): |
+ _log.debug('Starting %s server, cmd="%s"' % (self._name, str(self._start_cmd))) |
+ |
+ # TODO(burnik): This config should probably be available in advance. |
+ config = ('{' |
+ '"host": "%(host)s",' |
+ '"doc_root": "%(doc_root)s",' |
+ '"ports":{' |
+ '"http":[%(insecure_port)d, "auto"],' |
+ '"https":[%(secure_port)d],' |
+ '"ws":["auto"],' |
+ '"wss":["auto"]}' |
+ '}') % self._wpt_config |
+ fs = self._port_obj.host.filesystem |
+ fs.write_text_file(self._path_to_wpt_config, config) |
+ |
+ self._process = self._executive.popen(self._start_cmd, |
+ cwd=self._path_to_wpt, |
+ shell=True, |
+ stdout=self._executive.DEVNULL, |
+ stderr=self._executive.DEVNULL, |
+ preexec_fn=os.setsid) |
+ |
+ # We probably won't need a PID file, but server_base needs it. |
+ fs.write_text_file(self._pid_file, str(self._process.pid)) |
+ return self._process.pid |
+ |
+ def stop(self): |
+ self._stop_running_server() |
+ |
+ def _stop_running_server(self): |
+ # Clean up the pid file. |
+ if self._pid and not self._executive.check_running_pid(self._pid): |
+ self._filesystem.remove(self._pid_file) |
+ return |
+ |
+ self._executive.kill_process(self._pid) |