OLD | NEW |
1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging | 5 import logging |
6 import os | 6 import os |
7 import sys | 7 import sys |
8 | 8 |
9 from gpu_tests import gpu_integration_test | 9 from gpu_tests import gpu_integration_test |
10 from gpu_tests import gpu_process_expectations | 10 from gpu_tests import gpu_process_expectations |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 url = self.UrlOfStaticFilePath(test_path) | 134 url = self.UrlOfStaticFilePath(test_path) |
135 # It's crucial to use the action_runner, rather than the tab's | 135 # It's crucial to use the action_runner, rather than the tab's |
136 # Navigate method directly. It waits for the document ready state | 136 # Navigate method directly. It waits for the document ready state |
137 # to become interactive or better, avoiding critical race | 137 # to become interactive or better, avoiding critical race |
138 # conditions. | 138 # conditions. |
139 self.tab.action_runner.Navigate( | 139 self.tab.action_runner.Navigate( |
140 url, script_to_evaluate_on_commit=test_harness_script) | 140 url, script_to_evaluate_on_commit=test_harness_script) |
141 | 141 |
142 def _NavigateAndWait(self, test_path): | 142 def _NavigateAndWait(self, test_path): |
143 self._Navigate(test_path) | 143 self._Navigate(test_path) |
144 self.tab.action_runner.WaitForJavaScriptCondition2( | 144 self.tab.action_runner.WaitForJavaScriptCondition( |
145 'window.domAutomationController._finished', timeout=10) | 145 'window.domAutomationController._finished', timeout=10) |
146 | 146 |
147 def _VerifyGpuProcessPresent(self): | 147 def _VerifyGpuProcessPresent(self): |
148 tab = self.tab | 148 tab = self.tab |
149 if not tab.EvaluateJavaScript2('chrome.gpuBenchmarking.hasGpuChannel()'): | 149 if not tab.EvaluateJavaScript('chrome.gpuBenchmarking.hasGpuChannel()'): |
150 self.fail('No GPU channel detected') | 150 self.fail('No GPU channel detected') |
151 | 151 |
152 def _ValidateDriverBugWorkaroundsImpl(self, process_kind, is_expected, | 152 def _ValidateDriverBugWorkaroundsImpl(self, process_kind, is_expected, |
153 workaround_name): | 153 workaround_name): |
154 tab = self.tab | 154 tab = self.tab |
155 if process_kind == "browser_process": | 155 if process_kind == "browser_process": |
156 gpu_driver_bug_workarounds = tab.EvaluateJavaScript2( | 156 gpu_driver_bug_workarounds = tab.EvaluateJavaScript( |
157 'GetDriverBugWorkarounds()') | 157 'GetDriverBugWorkarounds()') |
158 elif process_kind == "gpu_process": | 158 elif process_kind == "gpu_process": |
159 gpu_driver_bug_workarounds = tab.EvaluateJavaScript2( | 159 gpu_driver_bug_workarounds = tab.EvaluateJavaScript( |
160 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()') | 160 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()') |
161 | 161 |
162 is_present = workaround_name in gpu_driver_bug_workarounds | 162 is_present = workaround_name in gpu_driver_bug_workarounds |
163 failure = False | 163 failure = False |
164 if is_expected and not is_present: | 164 if is_expected and not is_present: |
165 failure = True | 165 failure = True |
166 error_message = "is missing" | 166 error_message = "is missing" |
167 elif not is_expected and is_present: | 167 elif not is_expected and is_present: |
168 failure = True | 168 failure = True |
169 error_message = "is not expected" | 169 error_message = "is not expected" |
170 | 170 |
171 if failure: | 171 if failure: |
172 print 'Test failed. Printing page contents:' | 172 print 'Test failed. Printing page contents:' |
173 print tab.EvaluateJavaScript2('document.body.innerHTML') | 173 print tab.EvaluateJavaScript('document.body.innerHTML') |
174 self.fail('%s %s in %s workarounds: %s' | 174 self.fail('%s %s in %s workarounds: %s' |
175 % (workaround_name, error_message, process_kind, | 175 % (workaround_name, error_message, process_kind, |
176 gpu_driver_bug_workarounds)) | 176 gpu_driver_bug_workarounds)) |
177 | 177 |
178 def _ValidateDriverBugWorkarounds(self, expected_workaround, | 178 def _ValidateDriverBugWorkarounds(self, expected_workaround, |
179 unexpected_workaround): | 179 unexpected_workaround): |
180 if not expected_workaround and not unexpected_workaround: | 180 if not expected_workaround and not unexpected_workaround: |
181 return | 181 return |
182 if expected_workaround: | 182 if expected_workaround: |
183 self._ValidateDriverBugWorkaroundsImpl( | 183 self._ValidateDriverBugWorkaroundsImpl( |
184 "browser_process", True, expected_workaround) | 184 "browser_process", True, expected_workaround) |
185 self._ValidateDriverBugWorkaroundsImpl( | 185 self._ValidateDriverBugWorkaroundsImpl( |
186 "gpu_process", True, expected_workaround) | 186 "gpu_process", True, expected_workaround) |
187 if unexpected_workaround: | 187 if unexpected_workaround: |
188 self._ValidateDriverBugWorkaroundsImpl( | 188 self._ValidateDriverBugWorkaroundsImpl( |
189 "browser_process", False, unexpected_workaround) | 189 "browser_process", False, unexpected_workaround) |
190 self._ValidateDriverBugWorkaroundsImpl( | 190 self._ValidateDriverBugWorkaroundsImpl( |
191 "gpu_process", False, unexpected_workaround) | 191 "gpu_process", False, unexpected_workaround) |
192 | 192 |
193 # This can only be called from one of the tests, i.e., after the | 193 # This can only be called from one of the tests, i.e., after the |
194 # browser's been brought up once. | 194 # browser's been brought up once. |
195 def _RunningOnAndroid(self): | 195 def _RunningOnAndroid(self): |
196 options = self.__class__._original_finder_options.browser_options | 196 options = self.__class__._original_finder_options.browser_options |
197 return options.browser_type.startswith('android') | 197 return options.browser_type.startswith('android') |
198 | 198 |
199 def _CompareAndCaptureDriverBugWorkarounds(self): | 199 def _CompareAndCaptureDriverBugWorkarounds(self): |
200 tab = self.tab | 200 tab = self.tab |
201 if not tab.EvaluateJavaScript2('chrome.gpuBenchmarking.hasGpuProcess()'): | 201 if not tab.EvaluateJavaScript('chrome.gpuBenchmarking.hasGpuProcess()'): |
202 self.fail('No GPU process detected') | 202 self.fail('No GPU process detected') |
203 | 203 |
204 if not tab.EvaluateJavaScript2('chrome.gpuBenchmarking.hasGpuChannel()'): | 204 if not tab.EvaluateJavaScript('chrome.gpuBenchmarking.hasGpuChannel()'): |
205 self.fail('No GPU channel detected') | 205 self.fail('No GPU channel detected') |
206 | 206 |
207 browser_list = tab.EvaluateJavaScript2('GetDriverBugWorkarounds()') | 207 browser_list = tab.EvaluateJavaScript('GetDriverBugWorkarounds()') |
208 gpu_list = tab.EvaluateJavaScript2( | 208 gpu_list = tab.EvaluateJavaScript( |
209 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()') | 209 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()') |
210 | 210 |
211 diff = set(browser_list).symmetric_difference(set(gpu_list)) | 211 diff = set(browser_list).symmetric_difference(set(gpu_list)) |
212 if len(diff) > 0: | 212 if len(diff) > 0: |
213 print 'Test failed. Printing page contents:' | 213 print 'Test failed. Printing page contents:' |
214 print tab.EvaluateJavaScript2('document.body.innerHTML') | 214 print tab.EvaluateJavaScript('document.body.innerHTML') |
215 self.fail('Browser and GPU process list of driver bug' | 215 self.fail('Browser and GPU process list of driver bug' |
216 'workarounds are not equal: %s != %s, diff: %s' % | 216 'workarounds are not equal: %s != %s, diff: %s' % |
217 (browser_list, gpu_list, list(diff))) | 217 (browser_list, gpu_list, list(diff))) |
218 | 218 |
219 basic_infos = tab.EvaluateJavaScript2('browserBridge.gpuInfo.basic_info') | 219 basic_infos = tab.EvaluateJavaScript('browserBridge.gpuInfo.basic_info') |
220 disabled_gl_extensions = None | 220 disabled_gl_extensions = None |
221 for info in basic_infos: | 221 for info in basic_infos: |
222 if info['description'].startswith('Disabled Extensions'): | 222 if info['description'].startswith('Disabled Extensions'): |
223 disabled_gl_extensions = info['value'] | 223 disabled_gl_extensions = info['value'] |
224 break | 224 break |
225 | 225 |
226 return gpu_list, disabled_gl_extensions | 226 return gpu_list, disabled_gl_extensions |
227 | 227 |
228 def _VerifyActiveAndInactiveGPUs( | 228 def _VerifyActiveAndInactiveGPUs( |
229 self, expected_active_gpu, expected_inactive_gpus): | 229 self, expected_active_gpu, expected_inactive_gpus): |
230 tab = self.tab | 230 tab = self.tab |
231 basic_infos = tab.EvaluateJavaScript2('browserBridge.gpuInfo.basic_info') | 231 basic_infos = tab.EvaluateJavaScript('browserBridge.gpuInfo.basic_info') |
232 active_gpu = [] | 232 active_gpu = [] |
233 inactive_gpus = [] | 233 inactive_gpus = [] |
234 index = 0 | 234 index = 0 |
235 for info in basic_infos: | 235 for info in basic_infos: |
236 description = info['description'] | 236 description = info['description'] |
237 value = info['value'] | 237 value = info['value'] |
238 if description.startswith('GPU%d' % index) and value.startswith('VENDOR'): | 238 if description.startswith('GPU%d' % index) and value.startswith('VENDOR'): |
239 if value.endswith('*ACTIVE*'): | 239 if value.endswith('*ACTIVE*'): |
240 active_gpu.append(value) | 240 active_gpu.append(value) |
241 else: | 241 else: |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 '--gpu-testing-device-id=0x0de1', | 309 '--gpu-testing-device-id=0x0de1', |
310 '--gpu-testing-gl-vendor=VMware', | 310 '--gpu-testing-gl-vendor=VMware', |
311 '--gpu-testing-gl-renderer=softpipe', | 311 '--gpu-testing-gl-renderer=softpipe', |
312 '--gpu-testing-gl-version="2.1 Mesa 10.1"']) | 312 '--gpu-testing-gl-version="2.1 Mesa 10.1"']) |
313 elif sys.platform == 'darwin': | 313 elif sys.platform == 'darwin': |
314 # Hit id 112 from kSoftwareRenderingListJson. | 314 # Hit id 112 from kSoftwareRenderingListJson. |
315 self.RestartBrowserIfNecessaryWithArgs([ | 315 self.RestartBrowserIfNecessaryWithArgs([ |
316 '--gpu-testing-vendor-id=0x8086', | 316 '--gpu-testing-vendor-id=0x8086', |
317 '--gpu-testing-device-id=0x0116']) | 317 '--gpu-testing-device-id=0x0116']) |
318 self._Navigate(test_path) | 318 self._Navigate(test_path) |
319 if self.tab.EvaluateJavaScript2('chrome.gpuBenchmarking.hasGpuProcess()'): | 319 if self.tab.EvaluateJavaScript('chrome.gpuBenchmarking.hasGpuProcess()'): |
320 self.fail('GPU process detected') | 320 self.fail('GPU process detected') |
321 | 321 |
322 def _GpuProcess_driver_bug_workarounds_in_gpu_process(self, test_path): | 322 def _GpuProcess_driver_bug_workarounds_in_gpu_process(self, test_path): |
323 self.RestartBrowserIfNecessaryWithArgs([ | 323 self.RestartBrowserIfNecessaryWithArgs([ |
324 '--use_gpu_driver_workaround_for_testing']) | 324 '--use_gpu_driver_workaround_for_testing']) |
325 self._Navigate(test_path) | 325 self._Navigate(test_path) |
326 self._ValidateDriverBugWorkarounds( | 326 self._ValidateDriverBugWorkarounds( |
327 'use_gpu_driver_workaround_for_testing', None) | 327 'use_gpu_driver_workaround_for_testing', None) |
328 | 328 |
329 def _GpuProcess_readback_webgl_gpu_process(self, test_path): | 329 def _GpuProcess_readback_webgl_gpu_process(self, test_path): |
330 # This test was designed to only run on desktop Linux. | 330 # This test was designed to only run on desktop Linux. |
331 options = self.__class__._original_finder_options.browser_options | 331 options = self.__class__._original_finder_options.browser_options |
332 is_platform_android = options.browser_type.startswith('android') | 332 is_platform_android = options.browser_type.startswith('android') |
333 if sys.platform.startswith('linux') and not is_platform_android: | 333 if sys.platform.startswith('linux') and not is_platform_android: |
334 # Hit id 110 from kSoftwareRenderingListJson. | 334 # Hit id 110 from kSoftwareRenderingListJson. |
335 self.RestartBrowserIfNecessaryWithArgs([ | 335 self.RestartBrowserIfNecessaryWithArgs([ |
336 '--gpu-testing-vendor-id=0x10de', | 336 '--gpu-testing-vendor-id=0x10de', |
337 '--gpu-testing-device-id=0x0de1', | 337 '--gpu-testing-device-id=0x0de1', |
338 '--gpu-testing-gl-vendor=VMware', | 338 '--gpu-testing-gl-vendor=VMware', |
339 '--gpu-testing-gl-renderer=Gallium 0.4 ' \ | 339 '--gpu-testing-gl-renderer=Gallium 0.4 ' \ |
340 'on llvmpipe (LLVM 3.4, 256 bits)', | 340 'on llvmpipe (LLVM 3.4, 256 bits)', |
341 '--gpu-testing-gl-version="3.0 Mesa 11.2"']) | 341 '--gpu-testing-gl-version="3.0 Mesa 11.2"']) |
342 self._Navigate(test_path) | 342 self._Navigate(test_path) |
343 feature_status_list = self.tab.EvaluateJavaScript2( | 343 feature_status_list = self.tab.EvaluateJavaScript( |
344 'browserBridge.gpuInfo.featureStatus.featureStatus') | 344 'browserBridge.gpuInfo.featureStatus.featureStatus') |
345 result = True | 345 result = True |
346 for name, status in feature_status_list.items(): | 346 for name, status in feature_status_list.items(): |
347 if name == 'multiple_raster_threads': | 347 if name == 'multiple_raster_threads': |
348 result = result and status == 'enabled_on' | 348 result = result and status == 'enabled_on' |
349 elif name == 'native_gpu_memory_buffers': | 349 elif name == 'native_gpu_memory_buffers': |
350 result = result and status == 'disabled_software' | 350 result = result and status == 'disabled_software' |
351 elif name == 'webgl': | 351 elif name == 'webgl': |
352 result = result and status == 'enabled_readback' | 352 result = result and status == 'enabled_readback' |
353 elif name == 'webgl2': | 353 elif name == 'webgl2': |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 recorded_disabled_gl_extensions) | 428 recorded_disabled_gl_extensions) |
429 self.RestartBrowserIfNecessaryWithArgs(browser_args) | 429 self.RestartBrowserIfNecessaryWithArgs(browser_args) |
430 self._Navigate(test_path) | 430 self._Navigate(test_path) |
431 self._VerifyGpuProcessPresent() | 431 self._VerifyGpuProcessPresent() |
432 new_workarounds, new_disabled_gl_extensions = ( | 432 new_workarounds, new_disabled_gl_extensions = ( |
433 self._CompareAndCaptureDriverBugWorkarounds()) | 433 self._CompareAndCaptureDriverBugWorkarounds()) |
434 diff = set(recorded_workarounds).symmetric_difference(new_workarounds) | 434 diff = set(recorded_workarounds).symmetric_difference(new_workarounds) |
435 tab = self.tab | 435 tab = self.tab |
436 if len(diff) > 0: | 436 if len(diff) > 0: |
437 print 'Test failed. Printing page contents:' | 437 print 'Test failed. Printing page contents:' |
438 print tab.EvaluateJavaScript2('document.body.innerHTML') | 438 print tab.EvaluateJavaScript('document.body.innerHTML') |
439 self.fail( | 439 self.fail( |
440 'GPU process and expected list of driver bug ' | 440 'GPU process and expected list of driver bug ' |
441 'workarounds are not equal: %s != %s, diff: %s' % | 441 'workarounds are not equal: %s != %s, diff: %s' % |
442 (recorded_workarounds, new_workarounds, list(diff))) | 442 (recorded_workarounds, new_workarounds, list(diff))) |
443 if recorded_disabled_gl_extensions != new_disabled_gl_extensions: | 443 if recorded_disabled_gl_extensions != new_disabled_gl_extensions: |
444 print 'Test failed. Printing page contents:' | 444 print 'Test failed. Printing page contents:' |
445 print tab.EvaluateJavaScript2('document.body.innerHTML') | 445 print tab.EvaluateJavaScript('document.body.innerHTML') |
446 self.fail( | 446 self.fail( |
447 'The expected disabled gl extensions are ' | 447 'The expected disabled gl extensions are ' |
448 'incorrect: %s != %s:' % | 448 'incorrect: %s != %s:' % |
449 (recorded_disabled_gl_extensions, new_disabled_gl_extensions)) | 449 (recorded_disabled_gl_extensions, new_disabled_gl_extensions)) |
450 | 450 |
451 def _GpuProcess_skip_gpu_process(self, test_path): | 451 def _GpuProcess_skip_gpu_process(self, test_path): |
452 self.RestartBrowserIfNecessaryWithArgs([ | 452 self.RestartBrowserIfNecessaryWithArgs([ |
453 '--disable-gpu', | 453 '--disable-gpu', |
454 '--skip-gpu-data-loading']) | 454 '--skip-gpu-data-loading']) |
455 self._Navigate(test_path) | 455 self._Navigate(test_path) |
456 if self.tab.EvaluateJavaScript2('chrome.gpuBenchmarking.hasGpuProcess()'): | 456 if self.tab.EvaluateJavaScript('chrome.gpuBenchmarking.hasGpuProcess()'): |
457 self.fail('GPU process detected') | 457 self.fail('GPU process detected') |
458 | 458 |
459 def _GpuProcess_identify_active_gpu1(self, test_path): | 459 def _GpuProcess_identify_active_gpu1(self, test_path): |
460 self.RestartBrowserIfNecessaryWithArgs([ | 460 self.RestartBrowserIfNecessaryWithArgs([ |
461 '--gpu-testing-vendor-id=0x8086', | 461 '--gpu-testing-vendor-id=0x8086', |
462 '--gpu-testing-device-id=0x040a', | 462 '--gpu-testing-device-id=0x040a', |
463 '--gpu-testing-secondary-vendor-ids=0x10de', | 463 '--gpu-testing-secondary-vendor-ids=0x10de', |
464 '--gpu-testing-secondary-device-ids=0x0de1', | 464 '--gpu-testing-secondary-device-ids=0x0de1', |
465 '--gpu-testing-gl-vendor=nouveau']) | 465 '--gpu-testing-gl-vendor=nouveau']) |
466 self._Navigate(test_path) | 466 self._Navigate(test_path) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 '--gpu-testing-secondary-device-ids=', | 502 '--gpu-testing-secondary-device-ids=', |
503 '--gpu-testing-gl-vendor=nouveau']) | 503 '--gpu-testing-gl-vendor=nouveau']) |
504 self._Navigate(test_path) | 504 self._Navigate(test_path) |
505 self._VerifyActiveAndInactiveGPUs( | 505 self._VerifyActiveAndInactiveGPUs( |
506 ['VENDOR = 0x10de, DEVICE= 0x0de1 *ACTIVE*'], | 506 ['VENDOR = 0x10de, DEVICE= 0x0de1 *ACTIVE*'], |
507 []) | 507 []) |
508 | 508 |
509 def load_tests(loader, tests, pattern): | 509 def load_tests(loader, tests, pattern): |
510 del loader, tests, pattern # Unused. | 510 del loader, tests, pattern # Unused. |
511 return gpu_integration_test.LoadAllTestsInModule(sys.modules[__name__]) | 511 return gpu_integration_test.LoadAllTestsInModule(sys.modules[__name__]) |
OLD | NEW |