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 """WebKit Gtk implementation of the Port interface.""" 30 31 import logging 32 import os 33 import signal 34 35 from webkitpy.layout_tests.port.webkit import WebKitPort 36 37 _log = logging.getLogger("webkitpy.layout_tests.port.gtk") 38 39 40 class GtkPort(WebKitPort): 41 """WebKit Gtk implementation of the Port class.""" 42 43 def __init__(self, **kwargs): 44 kwargs.setdefault('port_name', 'gtk') 45 WebKitPort.__init__(self, **kwargs) 46 47 def _tests_for_other_platforms(self): 48 # FIXME: This list could be dynamic based on platform name and 49 # pushed into base.Port. 50 # This really need to be automated. 51 return [ 52 "platform/chromium", 53 "platform/win", 54 "platform/qt", 55 "platform/mac", 56 ] 57 58 def _path_to_apache_config_file(self): 59 # FIXME: This needs to detect the distribution and change config files. 60 return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 61 'apache2-debian-httpd.conf') 62 63 def _shut_down_http_server(self, server_pid): 64 """Shut down the httpd web server. Blocks until it's fully 65 shut down. 66 67 Args: 68 server_pid: The process ID of the running server. 69 """ 70 # server_pid is not set when "http_server.py stop" is run manually. 71 if server_pid is None: 72 # FIXME: This isn't ideal, since it could conflict with 73 # lighttpd processes not started by http_server.py, 74 # but good enough for now. 75 self._executive.kill_all('apache2') 76 else: 77 try: 78 os.kill(server_pid, signal.SIGTERM) 79 # TODO(mmoss) Maybe throw in a SIGKILL just to be sure? 80 except OSError: 81 # Sometimes we get a bad PID (e.g. from a stale httpd.pid 82 # file), so if kill fails on the given PID, just try to 83 # 'killall' web servers. 84 self._shut_down_http_server(None) 85 86 def _path_to_driver(self): 87 return self._build_path('Programs', 'DumpRenderTree') 88 89 def check_build(self, needs_http): 90 if not self._check_driver(): 91 return False 92 return True 93 94 def _path_to_apache(self): 95 if self._is_redhat_based(): 96 return '/usr/sbin/httpd' 97 else: 98 return '/usr/sbin/apache2' 99 100 def _path_to_apache_config_file(self): 101 if self._is_redhat_based(): 102 config_name = 'fedora-httpd.conf' 103 else: 104 config_name = 'apache2-debian-httpd.conf' 105 106 return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 107 config_name) 108 109 def _path_to_wdiff(self): 110 if self._is_redhat_based(): 111 return '/usr/bin/dwdiff' 112 else: 113 return '/usr/bin/wdiff' 114 115 def _is_redhat_based(self): 116 return self._filesystem.exists(self._filesystem.join('/etc', 'redhat-release')) 117