1 # Copyright (C) 2010 Google Inc. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
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
13 # * Neither the name of Google Inc. 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.
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.
32 from webkitpy.common.webkit_finder import WebKitFinder
33 from webkitpy.layout_tests.breakpad.dump_reader_multipart import DumpReaderLinux
34 from webkitpy.layout_tests.models import test_run_results
35 from webkitpy.layout_tests.port import base
36 from webkitpy.layout_tests.port import win
37 from webkitpy.layout_tests.port import config
40 _log = logging.getLogger(__name__)
43 class LinuxPort(base.Port):
46 SUPPORTED_VERSIONS = ('x86', 'x86_64')
48 FALLBACK_PATHS = { 'x86_64': [ 'linux' ] + win.WinPort.latest_platform_fallback_path() }
49 FALLBACK_PATHS['x86'] = ['linux-x86'] + FALLBACK_PATHS['x86_64']
51 DEFAULT_BUILD_DIRECTORIES = ('out',)
53 BUILD_REQUIREMENTS_URL = 'https://code.google.com/p/chromium/wiki/LinuxBuildInstructions'
56 def _determine_driver_path_statically(cls, host, options):
57 config_object = config.Config(host.executive, host.filesystem)
58 build_directory = getattr(options, 'build_directory', None)
59 finder = WebKitFinder(host.filesystem)
60 webkit_base = finder.webkit_base()
61 chromium_base = finder.chromium_base()
62 driver_name = getattr(options, 'driver_name', None)
63 if driver_name is None:
64 driver_name = cls.CONTENT_SHELL_NAME
65 if hasattr(options, 'configuration') and options.configuration:
66 configuration = options.configuration
68 configuration = config_object.default_configuration()
69 return cls._static_build_path(host.filesystem, build_directory, chromium_base, configuration, [driver_name])
72 def _determine_architecture(filesystem, executive, driver_path):
74 if filesystem.isfile(driver_path):
75 # The --dereference flag tells file to follow symlinks
76 file_output = executive.run_command(['file', '--brief', '--dereference', driver_path], return_stderr=True)
78 if re.match(r'ELF 32-bit LSB\s+executable', file_output):
80 if re.match(r'ELF 64-bit LSB\s+executable', file_output):
83 _log.warning('Could not determine architecture from "file" output: %s' % file_output)
85 # We don't know what the architecture is; default to 'x86' because
86 # maybe we're rebaselining and the binary doesn't actually exist,
87 # or something else weird is going on. It's okay to do this because
88 # if we actually try to use the binary, check_build() should fail.
92 def determine_full_port_name(cls, host, options, port_name):
93 if port_name.endswith('linux'):
94 return port_name + '-' + cls._determine_architecture(host.filesystem, host.executive, cls._determine_driver_path_statically(host, options))
97 def __init__(self, host, port_name, **kwargs):
98 super(LinuxPort, self).__init__(host, port_name, **kwargs)
99 (base, arch) = port_name.rsplit('-', 1)
100 assert base == 'linux'
101 assert arch in self.SUPPORTED_VERSIONS
102 assert port_name in ('linux', 'linux-x86', 'linux-x86_64')
103 self._version = 'lucid' # We only support lucid right now.
104 self._architecture = arch
105 if not self.get_option('disable_breakpad'):
106 self._dump_reader = DumpReaderLinux(host, self._build_path())
108 def additional_drt_flag(self):
109 flags = super(LinuxPort, self).additional_drt_flag()
110 if not self.get_option('disable_breakpad'):
111 flags += ['--enable-crash-reporter', '--crash-dumps-dir=%s' % self._dump_reader.crash_dumps_directory()]
114 def default_baseline_search_path(self):
115 port_names = self.FALLBACK_PATHS[self._architecture]
116 return map(self._webkit_baseline_path, port_names)
118 def _modules_to_search_for_symbols(self):
119 return [self._build_path('libffmpegsumo.so')]
121 def check_build(self, needs_http, printer):
122 result = super(LinuxPort, self).check_build(needs_http, printer)
125 _log.error('For complete Linux build requirements, please see:')
127 _log.error(' http://code.google.com/p/chromium/wiki/LinuxBuildInstructions')
130 def look_for_new_crash_logs(self, crashed_processes, start_time):
131 if self.get_option('disable_breakpad'):
133 return self._dump_reader.look_for_new_crash_logs(crashed_processes, start_time)
135 def clobber_old_port_specific_results(self):
136 if not self.get_option('disable_breakpad'):
137 self._dump_reader.clobber_old_results()
139 def operating_system(self):
146 def _check_apache_install(self):
147 result = self._check_file_exists(self.path_to_apache(), "apache2")
148 result = self._check_file_exists(self.path_to_apache_config_file(), "apache2 config file") and result
150 _log.error(' Please install using: "sudo apt-get install apache2 libapache2-mod-php5"')
154 def _check_lighttpd_install(self):
155 result = self._check_file_exists(
156 self._path_to_lighttpd(), "LigHTTPd executable")
157 result = self._check_file_exists(self._path_to_lighttpd_php(), "PHP CGI executable") and result
158 result = self._check_file_exists(self._path_to_lighttpd_modules(), "LigHTTPd modules") and result
160 _log.error(' Please install using: "sudo apt-get install lighttpd php5-cgi"')
164 def _wdiff_missing_message(self):
165 return 'wdiff is not installed; please install using "sudo apt-get install wdiff"'
167 def path_to_apache(self):
168 # The Apache binary path can vary depending on OS and distribution
169 # See http://wiki.apache.org/httpd/DistrosDefaultLayout
170 for path in ["/usr/sbin/httpd", "/usr/sbin/apache2"]:
171 if self._filesystem.exists(path):
173 _log.error("Could not find apache. Not installed or unknown path.")
176 def path_to_lighttpd(self):
177 return "/usr/sbin/lighttpd"
179 def path_to_lighttpd_modules(self):
180 return "/usr/lib/lighttpd"
182 def path_to_lighttpd_php(self):
183 return "/usr/bin/php-cgi"
185 def _path_to_driver(self, configuration=None):
186 binary_name = self.driver_name()
187 return self._build_path_with_configuration(configuration, binary_name)
189 def _path_to_helper(self):