OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 import sys | 4 import sys |
5 from telemetry.story import story_set as story_set_module | 5 from telemetry.story import story_set as story_set_module |
6 from telemetry.page import page_test | 6 from telemetry.page import page_test |
7 | 7 |
8 from gpu_tests import gpu_test_base | 8 from gpu_tests import gpu_test_base |
9 | 9 |
10 class GpuProcessSharedPageState(gpu_test_base.GpuSharedPageState): | 10 class GpuProcessSharedPageState(gpu_test_base.GpuSharedPageState): |
11 | 11 |
12 gpu_switches = ['--gpu-no-complete-info-collection', | 12 gpu_switches = ['--gpu-no-complete-info-collection', |
13 '--gpu-testing-os-version', | 13 '--gpu-testing-os-version', |
14 '--gpu-testing-vendor-id', | 14 '--gpu-testing-vendor-id', |
15 '--gpu-testing-device-id', | 15 '--gpu-testing-device-id', |
| 16 '--gpu-testing-secondary-vendor-ids', |
| 17 '--gpu-testing-secondary-device-ids', |
16 '--gpu-testing-gl-vendor', | 18 '--gpu-testing-gl-vendor', |
17 '--gpu-testing-gl-renderer', | 19 '--gpu-testing-gl-renderer', |
18 '--gpu-testing-gl-version'] | 20 '--gpu-testing-gl-version'] |
19 | 21 |
20 def __init__(self, test, finder_options, story_set): | 22 def __init__(self, test, finder_options, story_set): |
21 super(GpuProcessSharedPageState, self).__init__( | 23 super(GpuProcessSharedPageState, self).__init__( |
22 test, finder_options, story_set) | 24 test, finder_options, story_set) |
23 options = finder_options.browser_options.extra_browser_args | 25 options = finder_options.browser_options.extra_browser_args |
24 | 26 |
25 # Clear all existing gpu testing switches. | 27 # Clear all existing gpu testing switches. |
26 old_gpu_switches = [] | 28 old_gpu_switches = [] |
27 for opt in options: | 29 for opt in options: |
28 for gpu_switch in self.gpu_switches: | 30 for gpu_switch in self.gpu_switches: |
29 if opt.startswith(gpu_switch): | 31 if opt.startswith(gpu_switch): |
30 old_gpu_switches.append(opt) | 32 old_gpu_switches.append(opt) |
31 options.difference_update(old_gpu_switches) | 33 options.difference_update(old_gpu_switches) |
32 | 34 |
| 35 |
| 36 class IdentifyActiveGpuPageBase(gpu_test_base.PageBase): |
| 37 |
| 38 def __init__(self, name=None, page_set=None, shared_page_state_class=None, |
| 39 expectations=None, active_gpu=None, inactive_gpus=None): |
| 40 super(IdentifyActiveGpuPageBase, self).__init__( |
| 41 url='chrome:gpu', |
| 42 name=name, |
| 43 page_set=page_set, |
| 44 shared_page_state_class=shared_page_state_class, |
| 45 expectations=expectations) |
| 46 self.active_gpu = active_gpu |
| 47 self.inactive_gpus = inactive_gpus |
| 48 |
| 49 def Validate(self, tab, results): |
| 50 basic_infos = tab.EvaluateJavaScript('browserBridge.gpuInfo.basic_info') |
| 51 active_gpu = [] |
| 52 inactive_gpus = [] |
| 53 index = 0 |
| 54 for info in basic_infos: |
| 55 description = info['description'] |
| 56 value = info['value'] |
| 57 if description.startswith('GPU%d' % index) and value.startswith('VENDOR'): |
| 58 if value.endswith('*ACTIVE*'): |
| 59 active_gpu.append(value) |
| 60 else: |
| 61 inactive_gpus.append(value) |
| 62 index += 1 |
| 63 |
| 64 if active_gpu != self.active_gpu: |
| 65 raise page_test.Failure('Active GPU field is wrong %s' % active_gpu) |
| 66 |
| 67 if inactive_gpus != self.inactive_gpus: |
| 68 raise page_test.Failure('Inactive GPU field is wrong %s' % inactive_gpus) |
| 69 |
| 70 |
33 class GpuProcessTestsPage(gpu_test_base.PageBase): | 71 class GpuProcessTestsPage(gpu_test_base.PageBase): |
34 def __init__(self, url, name, story_set, expectations): | 72 def __init__(self, url, name, story_set, expectations): |
35 super(GpuProcessTestsPage, self).__init__(url=url, | 73 super(GpuProcessTestsPage, self).__init__(url=url, |
36 shared_page_state_class=gpu_test_base.GpuSharedPageState, | 74 shared_page_state_class=gpu_test_base.GpuSharedPageState, |
37 page_set=story_set, | 75 page_set=story_set, |
38 name=name, | 76 name=name, |
39 expectations=expectations) | 77 expectations=expectations) |
40 | 78 |
41 | 79 |
42 class FunctionalVideoPage(GpuProcessTestsPage): | 80 class FunctionalVideoPage(GpuProcessTestsPage): |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 % (workaround, browser_list)) | 236 % (workaround, browser_list)) |
199 | 237 |
200 gpu_list = tab.EvaluateJavaScript( \ | 238 gpu_list = tab.EvaluateJavaScript( \ |
201 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()') | 239 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()') |
202 if not workaround in gpu_list: | 240 if not workaround in gpu_list: |
203 print 'Test failed. Printing page contents:' | 241 print 'Test failed. Printing page contents:' |
204 print tab.EvaluateJavaScript('document.body.innerHTML') | 242 print tab.EvaluateJavaScript('document.body.innerHTML') |
205 raise page_test.Failure('%s missing in GPU process workarounds: %s' \ | 243 raise page_test.Failure('%s missing in GPU process workarounds: %s' \ |
206 % (workaround, gpu_list)) | 244 % (workaround, gpu_list)) |
207 | 245 |
| 246 |
| 247 class IdentifyActiveGpuSharedPageState1(GpuProcessSharedPageState): |
| 248 def __init__(self, test, finder_options, story_set): |
| 249 super(IdentifyActiveGpuSharedPageState1, self).__init__( |
| 250 test, finder_options, story_set) |
| 251 opts = finder_options.browser_options |
| 252 |
| 253 if sys.platform in ('cygwin', 'win32') or sys.platform.startswith('linux'): |
| 254 opts.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x8086') |
| 255 opts.AppendExtraBrowserArgs('--gpu-testing-device-id=0x040a') |
| 256 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-vendor-ids=0x10de') |
| 257 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-device-ids=0x0de1') |
| 258 opts.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=nouveau') |
| 259 |
| 260 |
| 261 class IdentifyActiveGpuPage1(IdentifyActiveGpuPageBase): |
| 262 def __init__(self, story_set, expectations): |
| 263 active_gpu = ['VENDOR = 0x10de, DEVICE= 0x0de1 *ACTIVE*'] |
| 264 inactive_gpus = ['VENDOR = 0x8086, DEVICE= 0x040a'] |
| 265 |
| 266 super(IdentifyActiveGpuPage1, self).__init__( |
| 267 name='GpuProcess.identify_active_gpu1', |
| 268 page_set=story_set, |
| 269 shared_page_state_class=IdentifyActiveGpuSharedPageState1, |
| 270 expectations=expectations, |
| 271 active_gpu=active_gpu, |
| 272 inactive_gpus=inactive_gpus) |
| 273 |
| 274 def Validate(self, tab, results): |
| 275 super(IdentifyActiveGpuPage1, self).Validate(tab, results) |
| 276 |
| 277 |
| 278 class IdentifyActiveGpuSharedPageState2(GpuProcessSharedPageState): |
| 279 def __init__(self, test, finder_options, story_set): |
| 280 super(IdentifyActiveGpuSharedPageState2, self).__init__( |
| 281 test, finder_options, story_set) |
| 282 opts = finder_options.browser_options |
| 283 |
| 284 if sys.platform in ('cygwin', 'win32') or sys.platform.startswith('linux'): |
| 285 opts.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x8086') |
| 286 opts.AppendExtraBrowserArgs('--gpu-testing-device-id=0x040a') |
| 287 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-vendor-ids=0x10de') |
| 288 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-device-ids=0x0de1') |
| 289 opts.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=Intel') |
| 290 |
| 291 |
| 292 class IdentifyActiveGpuPage2(IdentifyActiveGpuPageBase): |
| 293 def __init__(self, story_set, expectations): |
| 294 active_gpu = ['VENDOR = 0x8086, DEVICE= 0x040a *ACTIVE*'] |
| 295 inactive_gpus = ['VENDOR = 0x10de, DEVICE= 0x0de1'] |
| 296 |
| 297 super(IdentifyActiveGpuPage2, self).__init__( |
| 298 name='GpuProcess.identify_active_gpu2', |
| 299 page_set=story_set, |
| 300 shared_page_state_class=IdentifyActiveGpuSharedPageState2, |
| 301 expectations=expectations, |
| 302 active_gpu=active_gpu, |
| 303 inactive_gpus=inactive_gpus) |
| 304 |
| 305 def Validate(self, tab, results): |
| 306 super(IdentifyActiveGpuPage2, self).Validate(tab, results) |
| 307 |
| 308 |
| 309 class IdentifyActiveGpuSharedPageState3(GpuProcessSharedPageState): |
| 310 def __init__(self, test, finder_options, story_set): |
| 311 super(IdentifyActiveGpuSharedPageState3, self).__init__( |
| 312 test, finder_options, story_set) |
| 313 opts = finder_options.browser_options |
| 314 |
| 315 if sys.platform in ('cygwin', 'win32') or sys.platform.startswith('linux'): |
| 316 opts.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x8086') |
| 317 opts.AppendExtraBrowserArgs('--gpu-testing-device-id=0x040a') |
| 318 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-vendor-ids= \ |
| 319 0x10de;0x1002') |
| 320 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-device-ids= \ |
| 321 0x0de1;0x6779') |
| 322 opts.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=X.Org') |
| 323 opts.AppendExtraBrowserArgs('--gpu-testing-gl-renderer=AMD R600') |
| 324 |
| 325 |
| 326 class IdentifyActiveGpuPage3(IdentifyActiveGpuPageBase): |
| 327 def __init__(self, story_set, expectations): |
| 328 active_gpu = ['VENDOR = 0x1002, DEVICE= 0x6779 *ACTIVE*'] |
| 329 inactive_gpus = ['VENDOR = 0x8086, DEVICE= 0x040a', \ |
| 330 'VENDOR = 0x10de, DEVICE= 0x0de1'] |
| 331 |
| 332 super(IdentifyActiveGpuPage3, self).__init__( |
| 333 name='GpuProcess.identify_active_gpu3', |
| 334 page_set=story_set, |
| 335 shared_page_state_class=IdentifyActiveGpuSharedPageState3, |
| 336 expectations=expectations, |
| 337 active_gpu=active_gpu, |
| 338 inactive_gpus=inactive_gpus) |
| 339 |
| 340 def Validate(self, tab, results): |
| 341 super(IdentifyActiveGpuPage3, self).Validate(tab, results) |
| 342 |
| 343 |
| 344 class IdentifyActiveGpuSharedPageState4(GpuProcessSharedPageState): |
| 345 def __init__(self, test, finder_options, story_set): |
| 346 super(IdentifyActiveGpuSharedPageState4, self).__init__( |
| 347 test, finder_options, story_set) |
| 348 opts = finder_options.browser_options |
| 349 |
| 350 if sys.platform in ('cygwin', 'win32') or sys.platform.startswith('linux'): |
| 351 opts.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x10de') |
| 352 opts.AppendExtraBrowserArgs('--gpu-testing-device-id=0x0de1') |
| 353 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-vendor-ids=') |
| 354 opts.AppendExtraBrowserArgs('--gpu-testing-secondary-device-ids=') |
| 355 opts.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=nouveau') |
| 356 |
| 357 |
| 358 class IdentifyActiveGpuPage4(IdentifyActiveGpuPageBase): |
| 359 def __init__(self, story_set, expectations): |
| 360 active_gpu = ['VENDOR = 0x10de, DEVICE= 0x0de1 *ACTIVE*'] |
| 361 inactive_gpus = [] |
| 362 |
| 363 super(IdentifyActiveGpuPage4, self).__init__( |
| 364 name='GpuProcess.identify_active_gpu4', |
| 365 page_set=story_set, |
| 366 shared_page_state_class=IdentifyActiveGpuSharedPageState4, |
| 367 expectations=expectations, |
| 368 active_gpu=active_gpu, |
| 369 inactive_gpus=inactive_gpus) |
| 370 |
| 371 def Validate(self, tab, results): |
| 372 super(IdentifyActiveGpuPage4, self).Validate(tab, results) |
| 373 |
208 class GpuProcessTestsStorySet(story_set_module.StorySet): | 374 class GpuProcessTestsStorySet(story_set_module.StorySet): |
209 | 375 |
210 """ Tests that accelerated content triggers the creation of a GPU process """ | 376 """ Tests that accelerated content triggers the creation of a GPU process """ |
211 | 377 |
212 def __init__(self, expectations): | 378 def __init__(self, expectations): |
213 super(GpuProcessTestsStorySet, self).__init__( | 379 super(GpuProcessTestsStorySet, self).__init__( |
214 serving_dirs=set(['../../../../content/test/data'])) | 380 serving_dirs=set(['../../../../content/test/data'])) |
215 | 381 |
216 urls_and_names_list = [ | 382 urls_and_names_list = [ |
217 ('file://../../data/gpu/functional_canvas_demo.html', | 383 ('file://../../data/gpu/functional_canvas_demo.html', |
218 'GpuProcess.canvas2d'), | 384 'GpuProcess.canvas2d'), |
219 ('file://../../data/gpu/functional_3d_css.html', | 385 ('file://../../data/gpu/functional_3d_css.html', |
220 'GpuProcess.css3d'), | 386 'GpuProcess.css3d'), |
221 ('file://../../data/gpu/functional_webgl.html', | 387 ('file://../../data/gpu/functional_webgl.html', |
222 'GpuProcess.webgl') | 388 'GpuProcess.webgl') |
223 ] | 389 ] |
224 | 390 |
225 for url, name in urls_and_names_list: | 391 for url, name in urls_and_names_list: |
226 self.AddStory(GpuProcessTestsPage(url, name, self, expectations)) | 392 self.AddStory(GpuProcessTestsPage(url, name, self, expectations)) |
227 | 393 |
228 self.AddStory(FunctionalVideoPage(self, expectations)) | 394 self.AddStory(FunctionalVideoPage(self, expectations)) |
229 self.AddStory(GpuInfoCompletePage(self, expectations)) | 395 self.AddStory(GpuInfoCompletePage(self, expectations)) |
230 self.AddStory(NoGpuProcessPage(self, expectations)) | 396 self.AddStory(NoGpuProcessPage(self, expectations)) |
231 self.AddStory(SoftwareGpuProcessPage(self, expectations)) | 397 self.AddStory(SoftwareGpuProcessPage(self, expectations)) |
232 self.AddStory(SkipGpuProcessPage(self, expectations)) | 398 self.AddStory(SkipGpuProcessPage(self, expectations)) |
233 self.AddStory(DriverBugWorkaroundsInGpuProcessPage(self, expectations)) | 399 self.AddStory(DriverBugWorkaroundsInGpuProcessPage(self, expectations)) |
| 400 self.AddStory(IdentifyActiveGpuPage1(self, expectations)) |
| 401 self.AddStory(IdentifyActiveGpuPage2(self, expectations)) |
| 402 self.AddStory(IdentifyActiveGpuPage3(self, expectations)) |
| 403 self.AddStory(IdentifyActiveGpuPage4(self, expectations)) |
234 | 404 |
235 @property | 405 @property |
236 def allow_mixed_story_states(self): | 406 def allow_mixed_story_states(self): |
237 # Return True here in order to be able to run pages with different browser | 407 # Return True here in order to be able to run pages with different browser |
238 # command line arguments. | 408 # command line arguments. |
239 return True | 409 return True |
OLD | NEW |