Tools/Scripts: eliminate find_test_files from Port class.
[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
34 def get(host, platform=None, port_name='chromium-gpu', **kwargs):
35     """Some tests have slightly different results when run while using
36     hardware acceleration.  In those cases, we prepend an additional directory
37     to the baseline paths."""
38     platform = platform or sys.platform
39     if port_name == 'chromium-gpu':
40         if platform in ('cygwin', 'win32'):
41             port_name = 'chromium-gpu-win'
42         elif platform.startswith('linux'):
43             port_name = 'chromium-gpu-linux'
44         elif platform == 'darwin':
45             port_name = 'chromium-gpu-cg-mac'
46         else:
47             raise NotImplementedError('unsupported platform: %s' % platform)
48
49     if port_name.startswith('chromium-gpu-linux'):
50         return ChromiumGpuLinuxPort(host, port_name=port_name, **kwargs)
51     if port_name.startswith('chromium-gpu-cg-mac'):
52         return ChromiumGpuCgMacPort(host, port_name=port_name, **kwargs)
53     if port_name.startswith('chromium-gpu-mac'):
54         return ChromiumGpuMacPort(host, port_name=port_name, **kwargs)
55     if port_name.startswith('chromium-gpu-win'):
56         return ChromiumGpuWinPort(host, port_name=port_name, **kwargs)
57     raise NotImplementedError('unsupported port: %s' % port_name)
58
59
60 # FIXME: These should really be a mixin class.
61
62 def _set_gpu_options(port, graphics_type='gpu'):
63     port._graphics_type = graphics_type
64     if port.get_option('accelerated_2d_canvas') is None:
65         port._options.accelerated_2d_canvas = True
66     if port.get_option('accelerated_video') is None:
67         port._options.accelerated_video = True
68     if port.get_option('experimental_fully_parallel') is None:
69         port._options.experimental_fully_parallel = True
70
71     # FIXME: Remove this after http://codereview.chromium.org/5133001/ is enabled
72     # on the bots.
73     if port.get_option('builder_name') is not None and not ' - GPU' in port._options.builder_name:
74         port._options.builder_name += ' - GPU'
75
76
77 def _default_tests_paths(port):
78     paths = []
79     if (port.name() != 'chromium-gpu-mac-leopard' and
80         port.name() != 'chromium-gpu-cg-mac-leopard'):
81         # Only run tests requiring accelerated compositing on platforms that
82         # support it.
83         # FIXME: we should add the above paths here as well but let's test
84         # the waters with media first.
85         paths += ['media']
86
87     if not port.name().startswith('chromium-gpu-cg-mac'):
88         # Canvas is not yet accelerated on the Mac, so there's no point
89         # in running the tests there.
90         paths += ['fast/canvas', 'canvas/philip']
91
92     if not paths:
93         # FIXME: This is a hack until we can turn of the webkit_gpu
94         # tests on the bots. If paths is empty, port.tests()
95         # finds *everything*. However, we have to return something,
96         # or NRWT thinks there's something wrong. So, we return a single
97         # short directory. See https://bugs.webkit.org/show_bug.cgi?id=72498.
98         paths = ['fast/html']
99
100     return paths
101
102
103 class ChromiumGpuLinuxPort(chromium_linux.ChromiumLinuxPort):
104     def __init__(self, host, port_name='chromium-gpu-linux', **kwargs):
105         chromium_linux.ChromiumLinuxPort.__init__(self, host, port_name=port_name, **kwargs)
106         _set_gpu_options(self)
107
108     def baseline_search_path(self):
109         # Mimic the Linux -> Win expectations fallback in the ordinary Chromium port.
110         return (map(self._webkit_baseline_path, ['chromium-gpu-linux', 'chromium-gpu-win', 'chromium-gpu']) +
111                 chromium_linux.ChromiumLinuxPort.baseline_search_path(self))
112
113     def tests(self, paths):
114         paths = paths or _default_tests_paths(self)
115         return chromium_linux.ChromiumLinuxPort.tests(self, paths)
116
117
118 class ChromiumGpuCgMacPort(chromium_mac.ChromiumMacPort):
119     def __init__(self, host, port_name='chromium-gpu-cg-mac', **kwargs):
120         chromium_mac.ChromiumMacPort.__init__(self, host, port_name=port_name, **kwargs)
121         _set_gpu_options(self, graphics_type='gpu-cg')
122
123     def baseline_search_path(self):
124         return (map(self._webkit_baseline_path, ['chromium-gpu-cg-mac', 'chromium-gpu']) +
125                 chromium_mac.ChromiumMacPort.baseline_search_path(self))
126
127     def tests(self, paths):
128         paths = paths or _default_tests_paths(self)
129         return chromium_mac.ChromiumMacPort.tests(self, paths)
130
131
132 class ChromiumGpuMacPort(chromium_mac.ChromiumMacPort):
133     def __init__(self, host, port_name='chromium-gpu-mac', **kwargs):
134         chromium_mac.ChromiumMacPort.__init__(self, host, port_name=port_name, **kwargs)
135         _set_gpu_options(self)
136
137     def baseline_search_path(self):
138         return (map(self._webkit_baseline_path, ['chromium-gpu-mac', 'chromium-gpu']) +
139                 chromium_mac.ChromiumMacPort.baseline_search_path(self))
140
141     def tests(self, paths):
142         paths = paths or _default_tests_paths(self)
143         return chromium_mac.ChromiumMacPort.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         paths = paths or _default_tests_paths(self)
157         return chromium_win.ChromiumWinPort.tests(self, paths)