e86b8b753ed7a1b0c189f9b544617b7d9da6759c
[WebKit-https.git] / Tools / Scripts / webkitpy / layout_tests / port / chromium_gpu.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
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27 import sys
28
29 import chromium_linux
30 import chromium_mac
31 import chromium_win
32
33 from webkitpy.layout_tests.port import test_files
34
35
36 def get(host, platform=None, port_name='chromium-gpu', **kwargs):
37     """Some tests have slightly different results when run while using
38     hardware acceleration.  In those cases, we prepend an additional directory
39     to the baseline paths."""
40     platform = platform or sys.platform
41     if port_name == 'chromium-gpu':
42         if platform in ('cygwin', 'win32'):
43             port_name = 'chromium-gpu-win'
44         elif platform.startswith('linux'):
45             port_name = 'chromium-gpu-linux'
46         elif platform == 'darwin':
47             port_name = 'chromium-gpu-cg-mac'
48         else:
49             raise NotImplementedError('unsupported platform: %s' % platform)
50
51     if port_name.startswith('chromium-gpu-linux'):
52         return ChromiumGpuLinuxPort(host, port_name=port_name, **kwargs)
53     if port_name.startswith('chromium-gpu-cg-mac'):
54         return ChromiumGpuCgMacPort(host, port_name=port_name, **kwargs)
55     if port_name.startswith('chromium-gpu-mac'):
56         return ChromiumGpuMacPort(host, port_name=port_name, **kwargs)
57     if port_name.startswith('chromium-gpu-win'):
58         return ChromiumGpuWinPort(host, port_name=port_name, **kwargs)
59     raise NotImplementedError('unsupported port: %s' % port_name)
60
61
62 # FIXME: These should really be a mixin class.
63
64 def _set_gpu_options(port, graphics_type='gpu'):
65     port._graphics_type = graphics_type
66     if port.get_option('accelerated_2d_canvas') is None:
67         port._options.accelerated_2d_canvas = True
68     if port.get_option('accelerated_video') is None:
69         port._options.accelerated_video = True
70     if port.get_option('experimental_fully_parallel') is None:
71         port._options.experimental_fully_parallel = True
72
73     # FIXME: Remove this after http://codereview.chromium.org/5133001/ is enabled
74     # on the bots.
75     if port.get_option('builder_name') is not None and not ' - GPU' in port._options.builder_name:
76         port._options.builder_name += ' - GPU'
77
78
79 def _tests(port, paths):
80     if not paths:
81         paths = []
82         if (port.name() != 'chromium-gpu-mac-leopard' and
83             port.name() != 'chromium-gpu-cg-mac-leopard'):
84             # Only run tests requiring accelerated compositing on platforms that
85             # support it.
86             # FIXME: we should add the above paths here as well but let's test
87             # the waters with media first.
88             paths += ['media']
89
90         if not port.name().startswith('chromium-gpu-cg-mac'):
91             # Canvas is not yet accelerated on the Mac, so there's no point
92             # in running the tests there.
93             paths += ['fast/canvas', 'canvas/philip']
94
95         if not paths:
96             # FIXME: This is a hack until we can turn of the webkit_gpu
97             # tests on the bots. If paths is empty, test_files.find()
98             # finds *everything*. However, we have to return something,
99             # or NRWT thinks there's something wrong. So, we return a single
100             # short directory. See https://bugs.webkit.org/show_bug.cgi?id=72498.
101             paths = ['fast/html']
102
103     return set([port.relative_test_filename(f) for f in test_files.find(port, paths)])
104
105
106 class ChromiumGpuLinuxPort(chromium_linux.ChromiumLinuxPort):
107     def __init__(self, host, port_name='chromium-gpu-linux', **kwargs):
108         chromium_linux.ChromiumLinuxPort.__init__(self, host, port_name=port_name, **kwargs)
109         _set_gpu_options(self)
110
111     def baseline_search_path(self):
112         # Mimic the Linux -> Win expectations fallback in the ordinary Chromium port.
113         return (map(self._webkit_baseline_path, ['chromium-gpu-linux', 'chromium-gpu-win', 'chromium-gpu']) +
114                 chromium_linux.ChromiumLinuxPort.baseline_search_path(self))
115
116     def tests(self, paths):
117         return _tests(self, paths)
118
119
120 class ChromiumGpuCgMacPort(chromium_mac.ChromiumMacPort):
121     def __init__(self, host, port_name='chromium-gpu-cg-mac', **kwargs):
122         chromium_mac.ChromiumMacPort.__init__(self, host, port_name=port_name, **kwargs)
123         _set_gpu_options(self, graphics_type='gpu-cg')
124
125     def baseline_search_path(self):
126         return (map(self._webkit_baseline_path, ['chromium-gpu-cg-mac', 'chromium-gpu']) +
127                 chromium_mac.ChromiumMacPort.baseline_search_path(self))
128
129     def tests(self, paths):
130         return _tests(self, paths)
131
132
133 class ChromiumGpuMacPort(chromium_mac.ChromiumMacPort):
134     def __init__(self, host, port_name='chromium-gpu-mac', **kwargs):
135         chromium_mac.ChromiumMacPort.__init__(self, host, port_name=port_name, **kwargs)
136         _set_gpu_options(self)
137
138     def baseline_search_path(self):
139         return (map(self._webkit_baseline_path, ['chromium-gpu-mac', 'chromium-gpu']) +
140                 chromium_mac.ChromiumMacPort.baseline_search_path(self))
141
142     def tests(self, paths):
143         return _tests(self, paths)
144
145
146 class ChromiumGpuWinPort(chromium_win.ChromiumWinPort):
147     def __init__(self, host, port_name='chromium-gpu-win', **kwargs):
148         chromium_win.ChromiumWinPort.__init__(self, host, port_name=port_name, **kwargs)
149         _set_gpu_options(self)
150
151     def baseline_search_path(self):
152         return (map(self._webkit_baseline_path, ['chromium-gpu-win', 'chromium-gpu']) +
153                 chromium_win.ChromiumWinPort.baseline_search_path(self))
154
155     def tests(self, paths):
156         return _tests(self, paths)