Web Inspector: chromium: I'd like to add a script for running perf tests for WebInspe...
[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 _tests(port, paths):
78     if not paths:
79         paths = []
80         if (port.name() != 'chromium-gpu-mac-leopard' and
81             port.name() != 'chromium-gpu-cg-mac-leopard'):
82             # Only run tests requiring accelerated compositing on platforms that
83             # support it.
84             # FIXME: we should add the above paths here as well but let's test
85             # the waters with media first.
86             paths += ['media']
87
88         if not port.name().startswith('chromium-gpu-cg-mac'):
89             # Canvas is not yet accelerated on the Mac, so there's no point
90             # in running the tests there.
91             paths += ['fast/canvas', 'canvas/philip']
92
93         if not paths:
94             # FIXME: This is a hack until we can turn of the webkit_gpu
95             # tests on the bots. If paths is empty, port.find_test_files()
96             # finds *everything*. However, we have to return something,
97             # or NRWT thinks there's something wrong. So, we return a single
98             # short directory. See https://bugs.webkit.org/show_bug.cgi?id=72498.
99             paths = ['fast/html']
100
101     return set([port.relative_test_filename(f) for f in port.find_test_files(paths)])
102
103
104 class ChromiumGpuLinuxPort(chromium_linux.ChromiumLinuxPort):
105     def __init__(self, host, port_name='chromium-gpu-linux', **kwargs):
106         chromium_linux.ChromiumLinuxPort.__init__(self, host, port_name=port_name, **kwargs)
107         _set_gpu_options(self)
108
109     def baseline_search_path(self):
110         # Mimic the Linux -> Win expectations fallback in the ordinary Chromium port.
111         return (map(self._webkit_baseline_path, ['chromium-gpu-linux', 'chromium-gpu-win', 'chromium-gpu']) +
112                 chromium_linux.ChromiumLinuxPort.baseline_search_path(self))
113
114     def tests(self, paths):
115         return _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         return _tests(self, paths)
129
130
131 class ChromiumGpuMacPort(chromium_mac.ChromiumMacPort):
132     def __init__(self, host, port_name='chromium-gpu-mac', **kwargs):
133         chromium_mac.ChromiumMacPort.__init__(self, host, port_name=port_name, **kwargs)
134         _set_gpu_options(self)
135
136     def baseline_search_path(self):
137         return (map(self._webkit_baseline_path, ['chromium-gpu-mac', 'chromium-gpu']) +
138                 chromium_mac.ChromiumMacPort.baseline_search_path(self))
139
140     def tests(self, paths):
141         return _tests(self, paths)
142
143
144 class ChromiumGpuWinPort(chromium_win.ChromiumWinPort):
145     def __init__(self, host, port_name='chromium-gpu-win', **kwargs):
146         chromium_win.ChromiumWinPort.__init__(self, host, port_name=port_name, **kwargs)
147         _set_gpu_options(self)
148
149     def baseline_search_path(self):
150         return (map(self._webkit_baseline_path, ['chromium-gpu-win', 'chromium-gpu']) +
151                 chromium_win.ChromiumWinPort.baseline_search_path(self))
152
153     def tests(self, paths):
154         return _tests(self, paths)