tizen beta release
[profile/ivi/webkit-efl.git] / Tools / Scripts / webkitpy / layout_tests / port / chromium_mac.py
1 #!/usr/bin/env python
2 # Copyright (C) 2010 Google Inc. All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7 #
8 #     * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 #     * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
13 # distribution.
14 #     * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 """Chromium Mac implementation of the Port interface."""
31
32 import logging
33 import os
34 import signal
35
36 from webkitpy.layout_tests.port import mac
37 from webkitpy.layout_tests.port import chromium
38
39 from webkitpy.common.system.executive import Executive
40
41
42 _log = logging.getLogger(__name__)
43
44
45 class ChromiumMacPort(chromium.ChromiumPort):
46     SUPPORTED_OS_VERSIONS = ('leopard', 'snowleopard', 'lion', 'future')
47
48     FALLBACK_PATHS = {
49         'leopard': [
50             'chromium-mac-leopard',
51             'chromium-mac-snowleopard',
52             'chromium-mac',
53             'chromium',
54             'mac-leopard',
55             'mac-snowleopard',
56             'mac-lion',
57             'mac',
58         ],
59         'snowleopard': [
60             'chromium-mac-snowleopard',
61             'chromium-mac',
62             'chromium',
63             'mac-snowleopard',
64             'mac-lion',
65             'mac',
66         ],
67         'lion': [
68             'chromium-mac',
69             'chromium',
70             'mac-lion',
71             'mac',
72         ],
73         'future': [
74             'chromium-mac',
75             'chromium',
76             'mac',
77         ],
78     }
79
80     FALLBACK_PATHS_CG = {
81         'leopard': [
82             'chromium-cg-mac-leopard',
83             'chromium-cg-mac-snowleopard',
84             'chromium-cg-mac',
85             'chromium',
86             'mac-leopard',
87             'mac-snowleopard',
88             'mac-lion',
89             'mac',
90         ],
91         'snowleopard': [
92             'chromium-cg-mac-snowleopard',
93             'chromium-cg-mac',
94             'chromium',
95             'mac-snowleopard',
96             'mac-lion',
97             'mac',
98         ],
99         'lion': [
100             'chromium-cg-mac',
101             'chromium',
102             'mac-lion',
103             'mac',
104         ],
105         'future': [
106             'chromium-cg-mac',
107             'chromium',
108             'mac',
109         ],
110     }
111
112     def __init__(self, host, port_name=None, os_version_string=None, **kwargs):
113         # We're a little generic here because this code is reused by the
114         # 'google-chrome' port as well as the 'mock-' and 'dryrun-' ports.
115         port_name = port_name or 'chromium-cg-mac'
116         chromium.ChromiumPort.__init__(self, host, port_name=port_name, **kwargs)
117         if port_name.endswith('-mac'):
118             self._version = mac.os_version(os_version_string, self.SUPPORTED_OS_VERSIONS)
119             self._name = port_name + '-' + self._version
120         else:
121             self._version = port_name[port_name.index('-mac-') + len('-mac-'):]
122             assert self._version in self.SUPPORTED_OS_VERSIONS
123         self._using_core_graphics = port_name.find('-cg-') != -1
124         if self._using_core_graphics:
125             self._graphics_type = 'cpu-cg'
126         else:
127             self._graphics_type = 'cpu'
128         self._operating_system = 'mac'
129
130     def baseline_search_path(self):
131         fallback_paths = self.FALLBACK_PATHS
132         if self._using_core_graphics:
133             fallback_paths = self.FALLBACK_PATHS_CG
134         return map(self._webkit_baseline_path, fallback_paths[self._version])
135
136     def check_build(self, needs_http):
137         result = chromium.ChromiumPort.check_build(self, needs_http)
138         result = self.check_wdiff() and result
139         if not result:
140             _log.error('For complete Mac build requirements, please see:')
141             _log.error('')
142             _log.error('    http://code.google.com/p/chromium/wiki/MacBuildInstructions')
143
144         return result
145
146     def default_child_processes(self):
147         if not self._multiprocessing_is_available:
148             # Running multiple threads in Mac Python is unstable (See
149             # https://bugs.webkit.org/show_bug.cgi?id=38553 for more info).
150             return 1
151         return chromium.ChromiumPort.default_child_processes(self)
152
153     #
154     # PROTECTED METHODS
155     #
156
157     def _build_path(self, *comps):
158         if self.get_option('build_directory'):
159             return self._filesystem.join(self.get_option('build_directory'),
160                                          *comps)
161         base = self.path_from_chromium_base()
162         if self._filesystem.exists(self._filesystem.join(base, 'out')):
163             return self._filesystem.join(base, 'out', *comps)
164         if self._filesystem.exists(self._filesystem.join(base, 'xcodebuild', *comps)):
165             return self._filesystem.join(base, 'xcodebuild', *comps)
166         base = self.path_from_webkit_base()
167         if self._filesystem.exists(self._filesystem.join(base, 'out')):
168             return self._filesystem.join(base, 'out', *comps)
169         return self._filesystem.join(base, 'xcodebuild', *comps)
170
171     def check_wdiff(self, logging=True):
172         try:
173             # We're ignoring the return and always returning True
174             self._executive.run_command([self._path_to_wdiff()], error_handler=Executive.ignore_error)
175         except OSError:
176             if logging:
177                 _log.warning('wdiff not found. Install using MacPorts or some other means')
178         return True
179
180     def _lighttpd_path(self, *comps):
181         return self.path_from_chromium_base('third_party', 'lighttpd', 'mac', *comps)
182
183     def _path_to_apache(self):
184         return '/usr/sbin/httpd'
185
186     def _path_to_apache_config_file(self):
187         return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'apache2-httpd.conf')
188
189     def _path_to_lighttpd(self):
190         return self._lighttpd_path('bin', 'lighttpd')
191
192     def _path_to_lighttpd_modules(self):
193         return self._lighttpd_path('lib')
194
195     def _path_to_lighttpd_php(self):
196         return self._lighttpd_path('bin', 'php-cgi')
197
198     def _path_to_driver(self, configuration=None):
199         # FIXME: make |configuration| happy with case-sensitive file systems.
200         if not configuration:
201             configuration = self.get_option('configuration')
202         return self._build_path(configuration, self.driver_name() + '.app',
203             'Contents', 'MacOS', self.driver_name())
204
205     def _path_to_helper(self):
206         binary_name = 'LayoutTestHelper'
207         return self._build_path(self.get_option('configuration'), binary_name)
208
209     def _path_to_wdiff(self):
210         return 'wdiff'