| OLD | NEW |
| (Empty) |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 import sys | |
| 5 from telemetry.story import story_set as story_set_module | |
| 6 from telemetry.page import legacy_page_test | |
| 7 | |
| 8 from gpu_tests import gpu_test_base | |
| 9 | |
| 10 class GpuProcessSharedPageState(gpu_test_base.GpuSharedPageState): | |
| 11 | |
| 12 gpu_switches = ['--gpu-no-complete-info-collection', | |
| 13 '--gpu-testing-os-version', | |
| 14 '--gpu-testing-vendor-id', | |
| 15 '--gpu-testing-device-id', | |
| 16 '--gpu-testing-secondary-vendor-ids', | |
| 17 '--gpu-testing-secondary-device-ids', | |
| 18 '--gpu-testing-driver-date', | |
| 19 '--gpu-testing-gl-vendor', | |
| 20 '--gpu-testing-gl-renderer', | |
| 21 '--gpu-testing-gl-version'] | |
| 22 | |
| 23 def __init__(self, test, finder_options, story_set): | |
| 24 super(GpuProcessSharedPageState, self).__init__( | |
| 25 test, finder_options, story_set) | |
| 26 options = finder_options.browser_options.extra_browser_args | |
| 27 | |
| 28 # Clear all existing gpu testing switches. | |
| 29 old_gpu_switches = [] | |
| 30 for opt in options: | |
| 31 for gpu_switch in self.gpu_switches: | |
| 32 if opt.startswith(gpu_switch): | |
| 33 old_gpu_switches.append(opt) | |
| 34 options.difference_update(old_gpu_switches) | |
| 35 | |
| 36 | |
| 37 class IdentifyActiveGpuPageBase(gpu_test_base.PageBase): | |
| 38 | |
| 39 def __init__(self, name=None, page_set=None, shared_page_state_class=None, | |
| 40 expectations=None, active_gpu=None, inactive_gpus=None): | |
| 41 super(IdentifyActiveGpuPageBase, self).__init__( | |
| 42 url='chrome:gpu', | |
| 43 name=name, | |
| 44 page_set=page_set, | |
| 45 shared_page_state_class=shared_page_state_class, | |
| 46 expectations=expectations) | |
| 47 self.active_gpu = active_gpu | |
| 48 self.inactive_gpus = inactive_gpus | |
| 49 | |
| 50 def Validate(self, tab, results): | |
| 51 basic_infos = tab.EvaluateJavaScript('browserBridge.gpuInfo.basic_info') | |
| 52 active_gpu = [] | |
| 53 inactive_gpus = [] | |
| 54 index = 0 | |
| 55 for info in basic_infos: | |
| 56 description = info['description'] | |
| 57 value = info['value'] | |
| 58 if description.startswith('GPU%d' % index) and value.startswith('VENDOR'): | |
| 59 if value.endswith('*ACTIVE*'): | |
| 60 active_gpu.append(value) | |
| 61 else: | |
| 62 inactive_gpus.append(value) | |
| 63 index += 1 | |
| 64 | |
| 65 if active_gpu != self.active_gpu: | |
| 66 raise legacy_page_test.Failure( | |
| 67 'Active GPU field is wrong %s' % active_gpu) | |
| 68 | |
| 69 if inactive_gpus != self.inactive_gpus: | |
| 70 raise legacy_page_test.Failure( | |
| 71 'Inactive GPU field is wrong %s' % inactive_gpus) | |
| 72 | |
| 73 | |
| 74 class DriverBugWorkaroundsTestsPage(gpu_test_base.PageBase): | |
| 75 def __init__(self, page_set=None, name='', | |
| 76 shared_page_state_class=None, | |
| 77 expectations=None, | |
| 78 expected_workaround=None, | |
| 79 unexpected_workaround=None): | |
| 80 super(DriverBugWorkaroundsTestsPage, self).__init__( | |
| 81 url='chrome:gpu', | |
| 82 page_set=page_set, | |
| 83 name=name, | |
| 84 shared_page_state_class=shared_page_state_class, | |
| 85 expectations=expectations) | |
| 86 self.expected_workaround = expected_workaround | |
| 87 self.unexpected_workaround = unexpected_workaround | |
| 88 | |
| 89 def _Validate(self, tab, process_kind, is_expected, workaround_name): | |
| 90 if process_kind == "browser_process": | |
| 91 gpu_driver_bug_workarounds = tab.EvaluateJavaScript( \ | |
| 92 'GetDriverBugWorkarounds()') | |
| 93 elif process_kind == "gpu_process": | |
| 94 gpu_driver_bug_workarounds = tab.EvaluateJavaScript( \ | |
| 95 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()') | |
| 96 | |
| 97 is_present = workaround_name in gpu_driver_bug_workarounds | |
| 98 | |
| 99 failure = False | |
| 100 if is_expected and not is_present: | |
| 101 failure = True | |
| 102 error_message = "is missing" | |
| 103 elif not is_expected and is_present: | |
| 104 failure = True | |
| 105 error_message = "is not expected" | |
| 106 | |
| 107 if failure: | |
| 108 print 'Test failed. Printing page contents:' | |
| 109 print tab.EvaluateJavaScript('document.body.innerHTML') | |
| 110 raise legacy_page_test.Failure('%s %s in Browser process workarounds: %s' | |
| 111 % (workaround_name, error_message, gpu_driver_bug_workarounds)) | |
| 112 | |
| 113 def Validate(self, tab, results): | |
| 114 if not self.expected_workaround and not self.unexpected_workaround: | |
| 115 return | |
| 116 | |
| 117 if self.expected_workaround: | |
| 118 self._Validate(tab, "browser_process", True, self.expected_workaround) | |
| 119 self._Validate(tab, "gpu_process", True, self.expected_workaround) | |
| 120 | |
| 121 if self.unexpected_workaround: | |
| 122 self._Validate(tab, "browser_process", False, self.unexpected_workaround) | |
| 123 self._Validate(tab, "gpu_process", False, self.unexpected_workaround) | |
| 124 | |
| 125 | |
| 126 class EqualBugWorkaroundsBasePage(gpu_test_base.PageBase): | |
| 127 def __init__(self, name=None, page_set=None, shared_page_state_class=None, | |
| 128 expectations=None): | |
| 129 super(EqualBugWorkaroundsBasePage, self).__init__( | |
| 130 url='chrome:gpu', | |
| 131 name=name, | |
| 132 page_set=page_set, | |
| 133 shared_page_state_class=shared_page_state_class, | |
| 134 expectations=expectations) | |
| 135 | |
| 136 def Validate(self, tab, results): | |
| 137 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' | |
| 138 if not tab.EvaluateJavaScript(has_gpu_process_js): | |
| 139 raise legacy_page_test.Failure('No GPU process detected') | |
| 140 | |
| 141 has_gpu_channel_js = 'chrome.gpuBenchmarking.hasGpuChannel()' | |
| 142 if not tab.EvaluateJavaScript(has_gpu_channel_js): | |
| 143 raise legacy_page_test.Failure('No GPU channel detected') | |
| 144 | |
| 145 browser_list = tab.EvaluateJavaScript('GetDriverBugWorkarounds()') | |
| 146 gpu_list = tab.EvaluateJavaScript( \ | |
| 147 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()') | |
| 148 | |
| 149 diff = set(browser_list).symmetric_difference(set(gpu_list)) | |
| 150 if len(diff) > 0: | |
| 151 print 'Test failed. Printing page contents:' | |
| 152 print tab.EvaluateJavaScript('document.body.innerHTML') | |
| 153 raise legacy_page_test.Failure( | |
| 154 'Browser and GPU process list of driver bug' | |
| 155 'workarounds are not equal: %s != %s, diff: %s' % | |
| 156 (browser_list, gpu_list, list(diff))) | |
| 157 | |
| 158 basic_infos = tab.EvaluateJavaScript('browserBridge.gpuInfo.basic_info') | |
| 159 disabled_gl_extensions = None | |
| 160 for info in basic_infos: | |
| 161 if info['description'].startswith('Disabled Extensions'): | |
| 162 disabled_gl_extensions = info['value'] | |
| 163 break | |
| 164 | |
| 165 return gpu_list, disabled_gl_extensions | |
| 166 | |
| 167 | |
| 168 class GpuProcessTestsPage(gpu_test_base.PageBase): | |
| 169 def __init__(self, url, name, story_set, expectations): | |
| 170 super(GpuProcessTestsPage, self).__init__(url=url, | |
| 171 shared_page_state_class=gpu_test_base.GpuSharedPageState, | |
| 172 page_set=story_set, | |
| 173 name=name, | |
| 174 expectations=expectations) | |
| 175 | |
| 176 | |
| 177 class FunctionalVideoPage(GpuProcessTestsPage): | |
| 178 | |
| 179 def __init__(self, story_set, expectations): | |
| 180 super(FunctionalVideoPage, self).__init__( | |
| 181 url='file://../../data/gpu/functional_video.html', | |
| 182 name='GpuProcess.video', | |
| 183 story_set=story_set, | |
| 184 expectations=expectations) | |
| 185 | |
| 186 def RunNavigateSteps(self, action_runner): | |
| 187 super(FunctionalVideoPage, self).RunNavigateSteps(action_runner) | |
| 188 action_runner.WaitForJavaScriptCondition( | |
| 189 'domAutomationController._finished', timeout_in_seconds=30) | |
| 190 | |
| 191 | |
| 192 class GpuInfoCompletePage(GpuProcessTestsPage): | |
| 193 | |
| 194 def __init__(self, story_set, expectations): | |
| 195 super(GpuInfoCompletePage, self).__init__( | |
| 196 url='file://../../data/gpu/functional_3d_css.html', | |
| 197 name='GpuProcess.gpu_info_complete', | |
| 198 story_set=story_set, | |
| 199 expectations=expectations) | |
| 200 | |
| 201 def Validate(self, tab, results): | |
| 202 # Regression test for crbug.com/454906 | |
| 203 if not tab.browser.supports_system_info: | |
| 204 raise legacy_page_test.Failure('Browser must support system info') | |
| 205 system_info = tab.browser.GetSystemInfo() | |
| 206 if not system_info.gpu: | |
| 207 raise legacy_page_test.Failure('Target machine must have a GPU') | |
| 208 if not system_info.gpu.aux_attributes: | |
| 209 raise legacy_page_test.Failure('Browser must support GPU aux attributes') | |
| 210 if not 'gl_renderer' in system_info.gpu.aux_attributes: | |
| 211 raise legacy_page_test.Failure( | |
| 212 'Browser must have gl_renderer in aux attribs') | |
| 213 if len(system_info.gpu.aux_attributes['gl_renderer']) <= 0: | |
| 214 raise legacy_page_test.Failure( | |
| 215 'Must have a non-empty gl_renderer string') | |
| 216 | |
| 217 | |
| 218 class NoGpuProcessSharedPageState(GpuProcessSharedPageState): | |
| 219 def __init__(self, test, finder_options, story_set): | |
| 220 super(NoGpuProcessSharedPageState, self).__init__( | |
| 221 test, finder_options, story_set) | |
| 222 options = finder_options.browser_options | |
| 223 | |
| 224 if options.browser_type.startswith('android'): | |
| 225 # Android doesn't support starting up the browser without any | |
| 226 # GPU process. This test is skipped on Android in | |
| 227 # gpu_process_expectations.py, but we must at least be able to | |
| 228 # bring up the browser in order to detect that the test | |
| 229 # shouldn't run. Faking a vendor and device ID can get the | |
| 230 # browser into a state where it won't launch. | |
| 231 pass | |
| 232 elif sys.platform in ('cygwin', 'win32'): | |
| 233 # Hit id 34 from kSoftwareRenderingListJson. | |
| 234 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x5333') | |
| 235 options.AppendExtraBrowserArgs('--gpu-testing-device-id=0x8811') | |
| 236 elif sys.platform.startswith('linux'): | |
| 237 # Hit id 50 from kSoftwareRenderingListJson. | |
| 238 options.AppendExtraBrowserArgs('--gpu-no-complete-info-collection') | |
| 239 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x10de') | |
| 240 options.AppendExtraBrowserArgs('--gpu-testing-device-id=0x0de1') | |
| 241 options.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=VMware') | |
| 242 options.AppendExtraBrowserArgs('--gpu-testing-gl-renderer=softpipe') | |
| 243 options.AppendExtraBrowserArgs('--gpu-testing-gl-version="2.1 Mesa 10.1"') | |
| 244 elif sys.platform == 'darwin': | |
| 245 # Hit id 81 from kSoftwareRenderingListJson. | |
| 246 options.AppendExtraBrowserArgs('--gpu-testing-os-version=10.7') | |
| 247 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x15ad') | |
| 248 options.AppendExtraBrowserArgs('--gpu-testing-device-id=0x0393') | |
| 249 | |
| 250 | |
| 251 class NoGpuProcessPage(gpu_test_base.PageBase): | |
| 252 | |
| 253 def __init__(self, story_set, expectations): | |
| 254 super(NoGpuProcessPage, self).__init__( | |
| 255 url='about:blank', | |
| 256 name='GpuProcess.no_gpu_process', | |
| 257 page_set=story_set, | |
| 258 shared_page_state_class=NoGpuProcessSharedPageState, | |
| 259 expectations=expectations) | |
| 260 | |
| 261 def Validate(self, tab, results): | |
| 262 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' | |
| 263 has_gpu_process = tab.EvaluateJavaScript(has_gpu_process_js) | |
| 264 if has_gpu_process: | |
| 265 raise legacy_page_test.Failure('GPU process detected') | |
| 266 | |
| 267 | |
| 268 class SoftwareGpuProcessSharedPageState(GpuProcessSharedPageState): | |
| 269 def __init__(self, test, finder_options, story_set): | |
| 270 super(SoftwareGpuProcessSharedPageState, self).__init__( | |
| 271 test, finder_options, story_set) | |
| 272 options = finder_options.browser_options | |
| 273 | |
| 274 # Hit exception from id 50 from kSoftwareRenderingListJson. | |
| 275 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x10de') | |
| 276 options.AppendExtraBrowserArgs('--gpu-testing-device-id=0x0de1') | |
| 277 options.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=VMware') | |
| 278 options.AppendExtraBrowserArgs('--gpu-testing-gl-renderer=SVGA3D') | |
| 279 options.AppendExtraBrowserArgs('--gpu-testing-gl-version=2.1 Mesa 10.1') | |
| 280 | |
| 281 | |
| 282 class SoftwareGpuProcessPage(gpu_test_base.PageBase): | |
| 283 | |
| 284 def __init__(self, story_set, expectations): | |
| 285 super(SoftwareGpuProcessPage, self).__init__( | |
| 286 url='about:blank', | |
| 287 name='GpuProcess.software_gpu_process', | |
| 288 page_set=story_set, | |
| 289 shared_page_state_class=SoftwareGpuProcessSharedPageState, | |
| 290 expectations=expectations) | |
| 291 | |
| 292 | |
| 293 class SkipGpuProcessSharedPageState(GpuProcessSharedPageState): | |
| 294 def __init__(self, test, finder_options, story_set): | |
| 295 super(SkipGpuProcessSharedPageState, self).__init__( | |
| 296 test, finder_options, story_set) | |
| 297 options = finder_options.browser_options | |
| 298 | |
| 299 options.AppendExtraBrowserArgs('--disable-gpu') | |
| 300 options.AppendExtraBrowserArgs('--skip-gpu-data-loading') | |
| 301 | |
| 302 | |
| 303 class SkipGpuProcessPage(gpu_test_base.PageBase): | |
| 304 | |
| 305 def __init__(self, story_set, expectations): | |
| 306 super(SkipGpuProcessPage, self).__init__( | |
| 307 url='chrome:gpu', | |
| 308 name='GpuProcess.skip_gpu_process', | |
| 309 page_set=story_set, | |
| 310 shared_page_state_class=SkipGpuProcessSharedPageState, | |
| 311 expectations=expectations) | |
| 312 | |
| 313 def Validate(self, tab, results): | |
| 314 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' | |
| 315 has_gpu_process = tab.EvaluateJavaScript(has_gpu_process_js) | |
| 316 if has_gpu_process: | |
| 317 raise legacy_page_test.Failure('GPU process detected') | |
| 318 | |
| 319 | |
| 320 class DriverBugWorkaroundsShared(GpuProcessSharedPageState): | |
| 321 def __init__(self, test, finder_options, story_set): | |
| 322 super(DriverBugWorkaroundsShared, self).__init__( | |
| 323 test, finder_options, story_set) | |
| 324 options = finder_options.browser_options | |
| 325 options.AppendExtraBrowserArgs('--use_gpu_driver_workaround_for_testing') | |
| 326 | |
| 327 | |
| 328 class DriverBugWorkaroundsInGpuProcessPage(DriverBugWorkaroundsTestsPage): | |
| 329 def __init__(self, story_set, expectations): | |
| 330 super(DriverBugWorkaroundsInGpuProcessPage, self).__init__( | |
| 331 name='GpuProcess.driver_bug_workarounds_in_gpu_process', | |
| 332 page_set=story_set, | |
| 333 shared_page_state_class=DriverBugWorkaroundsShared, | |
| 334 expectations=expectations, | |
| 335 expected_workaround='use_gpu_driver_workaround_for_testing') | |
| 336 | |
| 337 def Validate(self, tab, results): | |
| 338 super(DriverBugWorkaroundsInGpuProcessPage, self).Validate(tab, results) | |
| 339 | |
| 340 | |
| 341 class DriverBugWorkaroundsUponGLRendererShared(GpuProcessSharedPageState): | |
| 342 def __init__(self, test, finder_options, story_set): | |
| 343 super(DriverBugWorkaroundsUponGLRendererShared, self).__init__( | |
| 344 test, finder_options, story_set) | |
| 345 options = finder_options.browser_options | |
| 346 if options.browser_type.startswith('android'): | |
| 347 # Hit id 108 from kGpuDriverBugListJson. | |
| 348 options.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=' \ | |
| 349 'NVIDIA Corporation') | |
| 350 options.AppendExtraBrowserArgs('--gpu-testing-gl-renderer=NVIDIA Tegra') | |
| 351 options.AppendExtraBrowserArgs('--gpu-testing-gl-version=' \ | |
| 352 'OpenGL ES 3.1 NVIDIA 343.00') | |
| 353 elif sys.platform in ('cygwin', 'win32'): | |
| 354 # Hit id 51 and 87 from kGpuDriverBugListJson. | |
| 355 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x1002') | |
| 356 options.AppendExtraBrowserArgs('--gpu-testing-device-id=0x6779') | |
| 357 options.AppendExtraBrowserArgs('--gpu-testing-driver-date=11-20-2014') | |
| 358 options.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=Google Inc.') | |
| 359 options.AppendExtraBrowserArgs('--gpu-testing-gl-renderer=ANGLE ' \ | |
| 360 '(AMD Radeon HD 6450 Direct3D11 vs_5_0 ps_5_0)') | |
| 361 options.AppendExtraBrowserArgs('--gpu-testing-gl-version=OpenGL ES 2.0 ' \ | |
| 362 '(ANGLE 2.1.0.0c0d8006a9dd)') | |
| 363 elif sys.platform.startswith('linux'): | |
| 364 # Hit id 40 from kGpuDriverBugListJson. | |
| 365 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x0101') | |
| 366 options.AppendExtraBrowserArgs('--gpu-testing-device-id=0x0102') | |
| 367 options.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=ARM') | |
| 368 options.AppendExtraBrowserArgs('--gpu-testing-gl-renderer=Mali-400 MP') | |
| 369 elif sys.platform == 'darwin': | |
| 370 # Currently on osx no workaround relies on gl-renderer. | |
| 371 pass | |
| 372 | |
| 373 | |
| 374 class DriverBugWorkaroundsUponGLRendererPage(DriverBugWorkaroundsTestsPage): | |
| 375 def __init__(self, story_set, expectations, is_platform_android): | |
| 376 self.expected_workaround = None | |
| 377 self.unexpected_workaround = None | |
| 378 | |
| 379 if is_platform_android: | |
| 380 self.expected_workaround = \ | |
| 381 "unpack_overlapping_rows_separately_unpack_buffer" | |
| 382 elif sys.platform in ('cygwin', 'win32'): | |
| 383 self.expected_workaround = "texsubimage_faster_than_teximage" | |
| 384 self.unexpected_workaround = "disable_d3d11" | |
| 385 elif sys.platform.startswith('linux'): | |
| 386 self.expected_workaround = "disable_discard_framebuffer" | |
| 387 elif sys.platform == 'darwin': | |
| 388 pass | |
| 389 super(DriverBugWorkaroundsUponGLRendererPage, self).__init__( | |
| 390 name='GpuProcess.driver_bug_workarounds_upon_gl_renderer', | |
| 391 page_set=story_set, | |
| 392 shared_page_state_class=DriverBugWorkaroundsUponGLRendererShared, | |
| 393 expectations=expectations, | |
| 394 expected_workaround=self.expected_workaround, | |
| 395 unexpected_workaround=self.unexpected_workaround) | |
| 396 | |
| 397 def Validate(self, tab, results): | |
| 398 super(DriverBugWorkaroundsUponGLRendererPage, self).Validate(tab, results) | |
| 399 | |
| 400 | |
| 401 class IdentifyActiveGpuSharedPageState1(GpuProcessSharedPageState): | |
| 402 def __init__(self, test, finder_options, story_set): | |
| 403 super(IdentifyActiveGpuSharedPageState1, self).__init__( | |
| 404 test, finder_options, story_set) | |
| 405 opts = finder_options.browser_options | |
| 406 | |
| 407 opts.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x8086') | |
| 408 opts.AppendExtraBrowserArgs('--gpu-testing-device-id=0x040a') | |
| 409 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-vendor-ids=0x10de') | |
| 410 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-device-ids=0x0de1') | |
| 411 opts.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=nouveau') | |
| 412 | |
| 413 | |
| 414 class IdentifyActiveGpuPage1(IdentifyActiveGpuPageBase): | |
| 415 def __init__(self, story_set, expectations): | |
| 416 active_gpu = ['VENDOR = 0x10de, DEVICE= 0x0de1 *ACTIVE*'] | |
| 417 inactive_gpus = ['VENDOR = 0x8086, DEVICE= 0x040a'] | |
| 418 | |
| 419 super(IdentifyActiveGpuPage1, self).__init__( | |
| 420 name='GpuProcess.identify_active_gpu1', | |
| 421 page_set=story_set, | |
| 422 shared_page_state_class=IdentifyActiveGpuSharedPageState1, | |
| 423 expectations=expectations, | |
| 424 active_gpu=active_gpu, | |
| 425 inactive_gpus=inactive_gpus) | |
| 426 | |
| 427 def Validate(self, tab, results): | |
| 428 super(IdentifyActiveGpuPage1, self).Validate(tab, results) | |
| 429 | |
| 430 | |
| 431 class IdentifyActiveGpuSharedPageState2(GpuProcessSharedPageState): | |
| 432 def __init__(self, test, finder_options, story_set): | |
| 433 super(IdentifyActiveGpuSharedPageState2, self).__init__( | |
| 434 test, finder_options, story_set) | |
| 435 opts = finder_options.browser_options | |
| 436 | |
| 437 opts.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x8086') | |
| 438 opts.AppendExtraBrowserArgs('--gpu-testing-device-id=0x040a') | |
| 439 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-vendor-ids=0x10de') | |
| 440 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-device-ids=0x0de1') | |
| 441 opts.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=Intel') | |
| 442 | |
| 443 | |
| 444 class IdentifyActiveGpuPage2(IdentifyActiveGpuPageBase): | |
| 445 def __init__(self, story_set, expectations): | |
| 446 active_gpu = ['VENDOR = 0x8086, DEVICE= 0x040a *ACTIVE*'] | |
| 447 inactive_gpus = ['VENDOR = 0x10de, DEVICE= 0x0de1'] | |
| 448 | |
| 449 super(IdentifyActiveGpuPage2, self).__init__( | |
| 450 name='GpuProcess.identify_active_gpu2', | |
| 451 page_set=story_set, | |
| 452 shared_page_state_class=IdentifyActiveGpuSharedPageState2, | |
| 453 expectations=expectations, | |
| 454 active_gpu=active_gpu, | |
| 455 inactive_gpus=inactive_gpus) | |
| 456 | |
| 457 def Validate(self, tab, results): | |
| 458 super(IdentifyActiveGpuPage2, self).Validate(tab, results) | |
| 459 | |
| 460 | |
| 461 class IdentifyActiveGpuSharedPageState3(GpuProcessSharedPageState): | |
| 462 def __init__(self, test, finder_options, story_set): | |
| 463 super(IdentifyActiveGpuSharedPageState3, self).__init__( | |
| 464 test, finder_options, story_set) | |
| 465 opts = finder_options.browser_options | |
| 466 | |
| 467 opts.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x8086') | |
| 468 opts.AppendExtraBrowserArgs('--gpu-testing-device-id=0x040a') | |
| 469 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-vendor-ids= \ | |
| 470 0x10de;0x1002') | |
| 471 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-device-ids= \ | |
| 472 0x0de1;0x6779') | |
| 473 opts.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=X.Org') | |
| 474 opts.AppendExtraBrowserArgs('--gpu-testing-gl-renderer=AMD R600') | |
| 475 | |
| 476 | |
| 477 class IdentifyActiveGpuPage3(IdentifyActiveGpuPageBase): | |
| 478 def __init__(self, story_set, expectations): | |
| 479 active_gpu = ['VENDOR = 0x1002, DEVICE= 0x6779 *ACTIVE*'] | |
| 480 inactive_gpus = ['VENDOR = 0x8086, DEVICE= 0x040a', \ | |
| 481 'VENDOR = 0x10de, DEVICE= 0x0de1'] | |
| 482 | |
| 483 super(IdentifyActiveGpuPage3, self).__init__( | |
| 484 name='GpuProcess.identify_active_gpu3', | |
| 485 page_set=story_set, | |
| 486 shared_page_state_class=IdentifyActiveGpuSharedPageState3, | |
| 487 expectations=expectations, | |
| 488 active_gpu=active_gpu, | |
| 489 inactive_gpus=inactive_gpus) | |
| 490 | |
| 491 def Validate(self, tab, results): | |
| 492 super(IdentifyActiveGpuPage3, self).Validate(tab, results) | |
| 493 | |
| 494 | |
| 495 class IdentifyActiveGpuSharedPageState4(GpuProcessSharedPageState): | |
| 496 def __init__(self, test, finder_options, story_set): | |
| 497 super(IdentifyActiveGpuSharedPageState4, self).__init__( | |
| 498 test, finder_options, story_set) | |
| 499 opts = finder_options.browser_options | |
| 500 | |
| 501 opts.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x10de') | |
| 502 opts.AppendExtraBrowserArgs('--gpu-testing-device-id=0x0de1') | |
| 503 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-vendor-ids=') | |
| 504 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-device-ids=') | |
| 505 opts.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=nouveau') | |
| 506 | |
| 507 | |
| 508 class IdentifyActiveGpuPage4(IdentifyActiveGpuPageBase): | |
| 509 def __init__(self, story_set, expectations): | |
| 510 active_gpu = ['VENDOR = 0x10de, DEVICE= 0x0de1 *ACTIVE*'] | |
| 511 inactive_gpus = [] | |
| 512 | |
| 513 super(IdentifyActiveGpuPage4, self).__init__( | |
| 514 name='GpuProcess.identify_active_gpu4', | |
| 515 page_set=story_set, | |
| 516 shared_page_state_class=IdentifyActiveGpuSharedPageState4, | |
| 517 expectations=expectations, | |
| 518 active_gpu=active_gpu, | |
| 519 inactive_gpus=inactive_gpus) | |
| 520 | |
| 521 def Validate(self, tab, results): | |
| 522 super(IdentifyActiveGpuPage4, self).Validate(tab, results) | |
| 523 | |
| 524 | |
| 525 class ReadbackWebGLGpuProcessSharedPageState(GpuProcessSharedPageState): | |
| 526 def __init__(self, test, finder_options, story_set): | |
| 527 super(ReadbackWebGLGpuProcessSharedPageState, self).__init__( | |
| 528 test, finder_options, story_set) | |
| 529 options = finder_options.browser_options | |
| 530 is_platform_android = options.browser_type.startswith('android') | |
| 531 | |
| 532 if sys.platform.startswith('linux') and not is_platform_android: | |
| 533 # Hit id 110 from kSoftwareRenderingListJson. | |
| 534 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x10de') | |
| 535 options.AppendExtraBrowserArgs('--gpu-testing-device-id=0x0de1') | |
| 536 options.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=VMware') | |
| 537 options.AppendExtraBrowserArgs('--gpu-testing-gl-renderer=Gallium 0.4 ' \ | |
| 538 'on llvmpipe (LLVM 3.4, 256 bits)') | |
| 539 options.AppendExtraBrowserArgs('--gpu-testing-gl-version="3.0 Mesa 11.2"') | |
| 540 | |
| 541 class ReadbackWebGLGpuProcessPage(gpu_test_base.PageBase): | |
| 542 def __init__(self, story_set, expectations, is_platform_android): | |
| 543 super(ReadbackWebGLGpuProcessPage, self).__init__( | |
| 544 url='chrome:gpu', | |
| 545 name='GpuProcess.readback_webgl_gpu_process', | |
| 546 page_set=story_set, | |
| 547 shared_page_state_class=ReadbackWebGLGpuProcessSharedPageState, | |
| 548 expectations=expectations) | |
| 549 self.is_platform_android = is_platform_android | |
| 550 | |
| 551 def Validate(self, tab, results): | |
| 552 if sys.platform.startswith('linux') and not self.is_platform_android: | |
| 553 feature_status_js = 'browserBridge.gpuInfo.featureStatus.featureStatus' | |
| 554 feature_status_list = tab.EvaluateJavaScript(feature_status_js) | |
| 555 result = True | |
| 556 for name, status in feature_status_list.items(): | |
| 557 if name == 'multiple_raster_threads': | |
| 558 result = result and status == 'enabled_on' | |
| 559 elif name == 'native_gpu_memory_buffers': | |
| 560 result = result and status == 'disabled_software' | |
| 561 elif name == 'webgl': | |
| 562 result = result and status == 'enabled_readback' | |
| 563 elif name == 'webgl2': | |
| 564 result = result and status == 'unavailable_off' | |
| 565 else: | |
| 566 result = result and status == 'unavailable_software' | |
| 567 if not result: | |
| 568 raise legacy_page_test.Failure('WebGL readback setup failed: %s' \ | |
| 569 % feature_status_list) | |
| 570 | |
| 571 | |
| 572 class HasTransparentVisualsShared(GpuProcessSharedPageState): | |
| 573 def __init__(self, test, finder_options, story_set): | |
| 574 super(HasTransparentVisualsShared, self).__init__( | |
| 575 test, finder_options, story_set) | |
| 576 options = finder_options.browser_options | |
| 577 if sys.platform.startswith('linux'): | |
| 578 # Hit id 173 from kGpuDriverBugListJson. | |
| 579 options.AppendExtraBrowserArgs('--gpu-testing-gl-version=3.0 Mesa ' \ | |
| 580 '12.1') | |
| 581 | |
| 582 class HasTransparentVisualsGpuProcessPage(DriverBugWorkaroundsTestsPage): | |
| 583 def __init__(self, story_set, expectations): | |
| 584 super(HasTransparentVisualsGpuProcessPage, self).__init__( | |
| 585 name='GpuProcess.has_transparent_visuals_gpu_process', | |
| 586 page_set=story_set, | |
| 587 shared_page_state_class=HasTransparentVisualsShared, | |
| 588 expectations=expectations, | |
| 589 expected_workaround=None, | |
| 590 unexpected_workaround=None) | |
| 591 | |
| 592 def Validate(self, tab, results): | |
| 593 if sys.platform.startswith('linux'): | |
| 594 super(HasTransparentVisualsGpuProcessPage, self).Validate(tab, results) | |
| 595 | |
| 596 | |
| 597 class NoTransparentVisualsShared(GpuProcessSharedPageState): | |
| 598 def __init__(self, test, finder_options, story_set): | |
| 599 super(NoTransparentVisualsShared, self).__init__( | |
| 600 test, finder_options, story_set) | |
| 601 | |
| 602 class NoTransparentVisualsGpuProcessPage(DriverBugWorkaroundsTestsPage): | |
| 603 def __init__(self, story_set, expectations): | |
| 604 super(NoTransparentVisualsGpuProcessPage, self).__init__( | |
| 605 name='GpuProcess.no_transparent_visuals_gpu_process', | |
| 606 page_set=story_set, | |
| 607 shared_page_state_class=NoTransparentVisualsShared, | |
| 608 expectations=expectations, | |
| 609 expected_workaround=None, | |
| 610 unexpected_workaround=None) | |
| 611 | |
| 612 def Validate(self, tab, results): | |
| 613 if sys.platform.startswith('linux'): | |
| 614 super(NoTransparentVisualsGpuProcessPage, self).Validate(tab, results) | |
| 615 | |
| 616 | |
| 617 class TransferWorkaroundSharedPageState(GpuProcessSharedPageState): | |
| 618 def __init__(self, test, finder_options, story_set): | |
| 619 super(TransferWorkaroundSharedPageState, self).__init__( | |
| 620 test, finder_options, story_set) | |
| 621 | |
| 622 # Extra browser args need to be added here. Adding them in RunStory would be | |
| 623 # too late. | |
| 624 def WillRunStory(self, results): | |
| 625 if self.WarmUpDone(): | |
| 626 options = self._finder_options.browser_options | |
| 627 options.AppendExtraBrowserArgs('--use_gpu_driver_workaround_for_testing') | |
| 628 options.AppendExtraBrowserArgs('--disable-gpu-driver-bug-workarounds') | |
| 629 | |
| 630 # Inject some info to make sure the flag above is effective. | |
| 631 if sys.platform == 'darwin': | |
| 632 # Hit id 33 from kGpuDriverBugListJson. | |
| 633 options.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=Imagination') | |
| 634 else: | |
| 635 # Hit id 5 from kGpuDriverBugListJson. | |
| 636 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x10de') | |
| 637 options.AppendExtraBrowserArgs('--gpu-testing-device-id=0x0001') | |
| 638 # no multi gpu on Android. | |
| 639 if not options.browser_type.startswith('android'): | |
| 640 options.AppendExtraBrowserArgs('--gpu-testing-secondary-vendor-ids=') | |
| 641 options.AppendExtraBrowserArgs('--gpu-testing-secondary-device-ids=') | |
| 642 | |
| 643 for workaround in self.RecordedWorkarounds(): | |
| 644 options.AppendExtraBrowserArgs('--' + workaround) | |
| 645 options.AppendExtraBrowserArgs('--disable-gl-extensions=' + \ | |
| 646 self.DisabledGLExts()) | |
| 647 super(TransferWorkaroundSharedPageState, self).WillRunStory(results) | |
| 648 | |
| 649 # self._current_page is None in WillRunStory so do the transfer here. | |
| 650 def RunStory(self, results): | |
| 651 if self.WarmUpDone(): | |
| 652 self._current_page.expected_workarounds = self.RecordedWorkarounds() | |
| 653 self._current_page.expected_disabled_exts = self.DisabledGLExts() | |
| 654 self.AddTestingWorkaround(self._current_page.expected_workarounds) | |
| 655 super(TransferWorkaroundSharedPageState, self).RunStory(results) | |
| 656 | |
| 657 def WarmUpDone(self): | |
| 658 return self._previous_page is not None and \ | |
| 659 self.RecordedWorkarounds() is not None | |
| 660 | |
| 661 def RecordedWorkarounds(self): | |
| 662 return self._previous_page.recorded_workarounds | |
| 663 | |
| 664 def DisabledGLExts(self): | |
| 665 return self._previous_page.recorded_disabled_exts | |
| 666 | |
| 667 def AddTestingWorkaround(self, workarounds): | |
| 668 if workarounds is not None: | |
| 669 workarounds.append('use_gpu_driver_workaround_for_testing') | |
| 670 | |
| 671 | |
| 672 class EqualBugWorkaroundsPage(EqualBugWorkaroundsBasePage): | |
| 673 def __init__(self, story_set, expectations): | |
| 674 super(EqualBugWorkaroundsPage, self).__init__( | |
| 675 name='GpuProcess.equal_bug_workarounds_in_browser_and_gpu_process', | |
| 676 page_set=story_set, | |
| 677 shared_page_state_class=TransferWorkaroundSharedPageState, | |
| 678 expectations=expectations) | |
| 679 self.recorded_workarounds = None | |
| 680 self.recorded_disabled_exts = None | |
| 681 | |
| 682 def Validate(self, tab, results): | |
| 683 recorded_info = super(EqualBugWorkaroundsPage, self).Validate(tab, results) | |
| 684 gpu_list, disabled_gl_extensions = recorded_info | |
| 685 | |
| 686 self.recorded_workarounds = gpu_list | |
| 687 self.recorded_disabled_exts = disabled_gl_extensions | |
| 688 | |
| 689 | |
| 690 class OnlyOneWorkaroundPage(EqualBugWorkaroundsBasePage): | |
| 691 def __init__(self, story_set, expectations): | |
| 692 super(OnlyOneWorkaroundPage, self).__init__( | |
| 693 name='GpuProcess.only_one_workaround', | |
| 694 page_set=story_set, | |
| 695 shared_page_state_class=TransferWorkaroundSharedPageState, | |
| 696 expectations=expectations) | |
| 697 self.expected_workarounds = None | |
| 698 self.expected_disabled_exts = None | |
| 699 | |
| 700 def Validate(self, tab, results): | |
| 701 # Requires EqualBugWorkaroundsPage to succeed. If it has failed then just | |
| 702 # pass to not overload the logs. | |
| 703 if self.expected_workarounds is None: | |
| 704 return | |
| 705 | |
| 706 recorded_info = super(OnlyOneWorkaroundPage, self).Validate(tab, results) | |
| 707 gpu_list, disabled_gl_extensions = recorded_info | |
| 708 | |
| 709 diff = set(self.expected_workarounds).symmetric_difference(set(gpu_list)) | |
| 710 if len(diff) > 0: | |
| 711 print 'Test failed. Printing page contents:' | |
| 712 print tab.EvaluateJavaScript('document.body.innerHTML') | |
| 713 raise legacy_page_test.Failure( | |
| 714 'GPU process and expected list of driver bug' | |
| 715 'workarounds are not equal: %s != %s, diff: %s' % | |
| 716 (self.expected_workarounds, gpu_list, list(diff))) | |
| 717 | |
| 718 if self.expected_disabled_exts != disabled_gl_extensions: | |
| 719 print 'Test failed. Printing page contents:' | |
| 720 print tab.EvaluateJavaScript('document.body.innerHTML') | |
| 721 raise legacy_page_test.Failure( | |
| 722 'The expected disabled gl extensions are ' | |
| 723 'incorrect: %s != %s:' % | |
| 724 (self.expected_disabled_exts, disabled_gl_extensions)) | |
| 725 | |
| 726 | |
| 727 class GpuProcessTestsStorySet(story_set_module.StorySet): | |
| 728 | |
| 729 """ Tests that accelerated content triggers the creation of a GPU process """ | |
| 730 | |
| 731 def __init__(self, expectations, is_platform_android): | |
| 732 super(GpuProcessTestsStorySet, self).__init__( | |
| 733 serving_dirs=set(['../../../../content/test/data'])) | |
| 734 | |
| 735 urls_and_names_list = [ | |
| 736 ('file://../../data/gpu/functional_canvas_demo.html', | |
| 737 'GpuProcess.canvas2d'), | |
| 738 ('file://../../data/gpu/functional_3d_css.html', | |
| 739 'GpuProcess.css3d'), | |
| 740 ('file://../../data/gpu/functional_webgl.html', | |
| 741 'GpuProcess.webgl') | |
| 742 ] | |
| 743 | |
| 744 for url, name in urls_and_names_list: | |
| 745 self.AddStory(GpuProcessTestsPage(url, name, self, expectations)) | |
| 746 | |
| 747 self.AddStory(FunctionalVideoPage(self, expectations)) | |
| 748 self.AddStory(GpuInfoCompletePage(self, expectations)) | |
| 749 self.AddStory(NoGpuProcessPage(self, expectations)) | |
| 750 self.AddStory(DriverBugWorkaroundsInGpuProcessPage(self, expectations)) | |
| 751 self.AddStory(ReadbackWebGLGpuProcessPage(self, expectations, | |
| 752 is_platform_android)) | |
| 753 self.AddStory(DriverBugWorkaroundsUponGLRendererPage(self, expectations, | |
| 754 is_platform_android)) | |
| 755 self.AddStory(EqualBugWorkaroundsPage(self, expectations)) | |
| 756 self.AddStory(OnlyOneWorkaroundPage(self, expectations)) | |
| 757 | |
| 758 if not is_platform_android: | |
| 759 self.AddStory(SkipGpuProcessPage(self, expectations)) | |
| 760 self.AddStory(HasTransparentVisualsGpuProcessPage(self, expectations)) | |
| 761 self.AddStory(NoTransparentVisualsGpuProcessPage(self, expectations)) | |
| 762 | |
| 763 # There is no Android multi-gpu configuration and the helper | |
| 764 # gpu_info_collector.cc::IdentifyActiveGPU is not even called. | |
| 765 self.AddStory(IdentifyActiveGpuPage1(self, expectations)) | |
| 766 self.AddStory(IdentifyActiveGpuPage2(self, expectations)) | |
| 767 self.AddStory(IdentifyActiveGpuPage3(self, expectations)) | |
| 768 self.AddStory(IdentifyActiveGpuPage4(self, expectations)) | |
| 769 | |
| 770 # There is currently no entry in kSoftwareRenderingListJson that enables | |
| 771 # a software GL driver on Android. | |
| 772 self.AddStory(SoftwareGpuProcessPage(self, expectations)) | |
| 773 | |
| 774 @property | |
| 775 def allow_mixed_story_states(self): | |
| 776 # Return True here in order to be able to run pages with different browser | |
| 777 # command line arguments. | |
| 778 return True | |
| OLD | NEW |