Home | History | Annotate | Download | only in port
      1 # Copyright (C) 2010 Google Inc. All rights reserved.
      2 #
      3 # Redistribution and use in source and binary forms, with or without
      4 # modification, are permitted provided that the following conditions are
      5 # met:
      6 #
      7 #     * Redistributions of source code must retain the above copyright
      8 # notice, this list of conditions and the following disclaimer.
      9 #     * Redistributions in binary form must reproduce the above
     10 # copyright notice, this list of conditions and the following disclaimer
     11 # in the documentation and/or other materials provided with the
     12 # distribution.
     13 #     * Neither the Google name nor the names of its
     14 # contributors may be used to endorse or promote products derived from
     15 # this software without specific prior written permission.
     16 #
     17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 
     29 """QtWebKit implementation of the Port interface."""
     30 
     31 import logging
     32 import os
     33 import signal
     34 import sys
     35 
     36 import webkit
     37 
     38 from webkitpy.layout_tests.port.webkit import WebKitPort
     39 
     40 _log = logging.getLogger("webkitpy.layout_tests.port.qt")
     41 
     42 
     43 class QtPort(WebKitPort):
     44     """QtWebKit implementation of the Port class."""
     45 
     46     def __init__(self, **kwargs):
     47         kwargs.setdefault('port_name', 'qt')
     48         WebKitPort.__init__(self, **kwargs)
     49 
     50     def baseline_search_path(self):
     51         port_names = []
     52         if sys.platform == 'linux2':
     53             port_names.append("qt-linux")
     54         elif sys.platform in ('win32', 'cygwin'):
     55             port_names.append("qt-win")
     56         elif sys.platform == 'darwin':
     57             port_names.append("qt-mac")
     58         port_names.append("qt")
     59         return map(self._webkit_baseline_path, port_names)
     60 
     61     def _tests_for_other_platforms(self):
     62         # FIXME: This list could be dynamic based on platform name and
     63         # pushed into base.Port.
     64         # This really need to be automated.
     65         return [
     66             "platform/chromium",
     67             "platform/win",
     68             "platform/gtk",
     69             "platform/mac",
     70         ]
     71 
     72     def _path_to_apache_config_file(self):
     73         # FIXME: This needs to detect the distribution and change config files.
     74         return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
     75                                      'apache2-debian-httpd.conf')
     76 
     77     def _shut_down_http_server(self, server_pid):
     78         """Shut down the httpd web server. Blocks until it's fully
     79         shut down.
     80 
     81         Args:
     82             server_pid: The process ID of the running server.
     83         """
     84         # server_pid is not set when "http_server.py stop" is run manually.
     85         if server_pid is None:
     86             # FIXME: This isn't ideal, since it could conflict with
     87             # lighttpd processes not started by http_server.py,
     88             # but good enough for now.
     89             self._executive.kill_all('apache2')
     90         else:
     91             try:
     92                 os.kill(server_pid, signal.SIGTERM)
     93                 # TODO(mmoss) Maybe throw in a SIGKILL just to be sure?
     94             except OSError:
     95                 # Sometimes we get a bad PID (e.g. from a stale httpd.pid
     96                 # file), so if kill fails on the given PID, just try to
     97                 # 'killall' web servers.
     98                 self._shut_down_http_server(None)
     99 
    100     def _build_driver(self):
    101         # The Qt port builds DRT as part of the main build step
    102         return True
    103 
    104     def _path_to_driver(self):
    105         return self._build_path('bin/DumpRenderTree')
    106 
    107     def _path_to_image_diff(self):
    108         return self._build_path('bin/ImageDiff')
    109 
    110     def _path_to_webcore_library(self):
    111         return self._build_path('lib/libQtWebKit.so')
    112 
    113     def _runtime_feature_list(self):
    114         return None
    115 
    116     def setup_environ_for_server(self):
    117         env = WebKitPort.setup_environ_for_server(self)
    118         env['QTWEBKIT_PLUGIN_PATH'] = self._build_path('lib/plugins')
    119         return env
    120