| 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): |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 return | 113 return |
| 114 | 114 |
| 115 if self.expected_workaround: | 115 if self.expected_workaround: |
| 116 self._Validate(tab, "browser_process", True, self.expected_workaround) | 116 self._Validate(tab, "browser_process", True, self.expected_workaround) |
| 117 self._Validate(tab, "gpu_process", True, self.expected_workaround) | 117 self._Validate(tab, "gpu_process", True, self.expected_workaround) |
| 118 | 118 |
| 119 if self.unexpected_workaround: | 119 if self.unexpected_workaround: |
| 120 self._Validate(tab, "browser_process", False, self.unexpected_workaround) | 120 self._Validate(tab, "browser_process", False, self.unexpected_workaround) |
| 121 self._Validate(tab, "gpu_process", False, self.unexpected_workaround) | 121 self._Validate(tab, "gpu_process", False, self.unexpected_workaround) |
| 122 | 122 |
| 123 | |
| 124 class EqualBugWorkaroundsBasePage(gpu_test_base.PageBase): | |
| 125 def __init__(self, name=None, page_set=None, shared_page_state_class=None, | |
| 126 expectations=None): | |
| 127 super(EqualBugWorkaroundsBasePage, self).__init__( | |
| 128 url='chrome:gpu', | |
| 129 name=name, | |
| 130 page_set=page_set, | |
| 131 shared_page_state_class=shared_page_state_class, | |
| 132 expectations=expectations) | |
| 133 | |
| 134 def Validate(self, tab, results): | |
| 135 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' | |
| 136 if not tab.EvaluateJavaScript(has_gpu_process_js): | |
| 137 raise page_test.Failure('No GPU process detected') | |
| 138 | |
| 139 has_gpu_channel_js = 'chrome.gpuBenchmarking.hasGpuChannel()' | |
| 140 if not tab.EvaluateJavaScript(has_gpu_channel_js): | |
| 141 raise page_test.Failure('No GPU channel detected') | |
| 142 | |
| 143 browser_list = tab.EvaluateJavaScript('GetDriverBugWorkarounds()') | |
| 144 gpu_list = tab.EvaluateJavaScript( \ | |
| 145 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()') | |
| 146 | |
| 147 diff = set(browser_list).symmetric_difference(set(gpu_list)) | |
| 148 if len(diff) > 0: | |
| 149 print 'Test failed. Printing page contents:' | |
| 150 print tab.EvaluateJavaScript('document.body.innerHTML') | |
| 151 raise page_test.Failure('Browser and GPU process list of driver bug' \ | |
| 152 'workarounds are not equal: %s != %s, diff: %s' % \ | |
| 153 (browser_list, gpu_list, list(diff))) | |
| 154 | |
| 155 return gpu_list | |
| 156 | |
| 157 | |
| 158 class GpuProcessTestsPage(gpu_test_base.PageBase): | 123 class GpuProcessTestsPage(gpu_test_base.PageBase): |
| 159 def __init__(self, url, name, story_set, expectations): | 124 def __init__(self, url, name, story_set, expectations): |
| 160 super(GpuProcessTestsPage, self).__init__(url=url, | 125 super(GpuProcessTestsPage, self).__init__(url=url, |
| 161 shared_page_state_class=gpu_test_base.GpuSharedPageState, | 126 shared_page_state_class=gpu_test_base.GpuSharedPageState, |
| 162 page_set=story_set, | 127 page_set=story_set, |
| 163 name=name, | 128 name=name, |
| 164 expectations=expectations) | 129 expectations=expectations) |
| 165 | 130 |
| 166 | 131 |
| 167 class FunctionalVideoPage(GpuProcessTestsPage): | 132 class FunctionalVideoPage(GpuProcessTestsPage): |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 result = result and status == 'disabled_software' | 509 result = result and status == 'disabled_software' |
| 545 elif name == 'webgl': | 510 elif name == 'webgl': |
| 546 result = result and status == 'enabled_readback' | 511 result = result and status == 'enabled_readback' |
| 547 else: | 512 else: |
| 548 result = result and status == 'unavailable_software' | 513 result = result and status == 'unavailable_software' |
| 549 if not result: | 514 if not result: |
| 550 raise page_test.Failure('WebGL readback setup failed: %s' \ | 515 raise page_test.Failure('WebGL readback setup failed: %s' \ |
| 551 % feature_status_list) | 516 % feature_status_list) |
| 552 | 517 |
| 553 | 518 |
| 519 class EqualBugWorkaroundsInBrowserAndGpuProcessPage(gpu_test_base.PageBase): |
| 520 def __init__(self, story_set, expectations): |
| 521 super(EqualBugWorkaroundsInBrowserAndGpuProcessPage, self).__init__( |
| 522 url='chrome:gpu', |
| 523 name='GpuProcess.equal_bug_workarounds_in_browser_and_gpu_process', |
| 524 page_set=story_set, |
| 525 shared_page_state_class=GpuProcessSharedPageState, |
| 526 expectations=expectations) |
| 527 |
| 528 def Validate(self, tab, results): |
| 529 browser_list = tab.EvaluateJavaScript('GetDriverBugWorkarounds()') |
| 530 gpu_list = tab.EvaluateJavaScript( \ |
| 531 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()') |
| 532 |
| 533 diff = set(browser_list).symmetric_difference(set(gpu_list)) |
| 534 if len(diff) > 0: |
| 535 print 'Test failed. Printing page contents:' |
| 536 print tab.EvaluateJavaScript('document.body.innerHTML') |
| 537 raise page_test.Failure('Browser and GPU process list of driver bug' \ |
| 538 'workarounds are not equal: %s != %s, diff: %s' % \ |
| 539 (browser_list, gpu_list, list(diff))) |
| 540 |
| 541 |
| 554 class HasTransparentVisualsShared(GpuProcessSharedPageState): | 542 class HasTransparentVisualsShared(GpuProcessSharedPageState): |
| 555 def __init__(self, test, finder_options, story_set): | 543 def __init__(self, test, finder_options, story_set): |
| 556 super(HasTransparentVisualsShared, self).__init__( | 544 super(HasTransparentVisualsShared, self).__init__( |
| 557 test, finder_options, story_set) | 545 test, finder_options, story_set) |
| 558 options = finder_options.browser_options | 546 options = finder_options.browser_options |
| 559 if sys.platform.startswith('linux'): | 547 if sys.platform.startswith('linux'): |
| 560 # Hit id 173 from kGpuDriverBugListJson. | 548 # Hit id 173 from kGpuDriverBugListJson. |
| 561 options.AppendExtraBrowserArgs('--gpu-testing-gl-version=3.0 Mesa ' \ | 549 options.AppendExtraBrowserArgs('--gpu-testing-gl-version=3.0 Mesa ' \ |
| 562 '12.1') | 550 '12.1') |
| 563 | 551 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 592 shared_page_state_class=NoTransparentVisualsShared, | 580 shared_page_state_class=NoTransparentVisualsShared, |
| 593 expectations=expectations, | 581 expectations=expectations, |
| 594 expected_workaround='disable_transparent_visuals', | 582 expected_workaround='disable_transparent_visuals', |
| 595 unexpected_workaround=None) | 583 unexpected_workaround=None) |
| 596 | 584 |
| 597 def Validate(self, tab, results): | 585 def Validate(self, tab, results): |
| 598 if sys.platform.startswith('linux'): | 586 if sys.platform.startswith('linux'): |
| 599 super(NoTransparentVisualsGpuProcessPage, self).Validate(tab, results) | 587 super(NoTransparentVisualsGpuProcessPage, self).Validate(tab, results) |
| 600 | 588 |
| 601 | 589 |
| 602 class TransferWorkaroundSharedPageState(GpuProcessSharedPageState): | |
| 603 def __init__(self, test, finder_options, story_set): | |
| 604 super(TransferWorkaroundSharedPageState, self).__init__( | |
| 605 test, finder_options, story_set) | |
| 606 | |
| 607 # Extra browser args need to be added here. Adding them in RunStory would be | |
| 608 # too late. | |
| 609 def WillRunStory(self, results): | |
| 610 if self.WarmUpDone(): | |
| 611 options = self._finder_options.browser_options | |
| 612 options.AppendExtraBrowserArgs('--use_gpu_driver_workaround_for_testing') | |
| 613 options.AppendExtraBrowserArgs('--disable-gpu-driver-bug-workarounds') | |
| 614 | |
| 615 # Inject some info to make sure the flag above is effective. | |
| 616 if sys.platform == 'darwin': | |
| 617 # Hit id 33 from kGpuDriverBugListJson. | |
| 618 options.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=Imagination') | |
| 619 else: | |
| 620 # Hit id 5 from kGpuDriverBugListJson. | |
| 621 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x10de') | |
| 622 options.AppendExtraBrowserArgs('--gpu-testing-device-id=0x0001') | |
| 623 # no multi gpu on Android. | |
| 624 if not options.browser_type.startswith('android'): | |
| 625 options.AppendExtraBrowserArgs('--gpu-testing-secondary-vendor-ids=') | |
| 626 options.AppendExtraBrowserArgs('--gpu-testing-secondary-device-ids=') | |
| 627 | |
| 628 for workaround in self.RecordedWorkarounds(): | |
| 629 options.AppendExtraBrowserArgs('--' + workaround) | |
| 630 super(TransferWorkaroundSharedPageState, self).WillRunStory(results) | |
| 631 | |
| 632 # self._current_page is None in WillRunStory so do the transfer here. | |
| 633 def RunStory(self, results): | |
| 634 if self.WarmUpDone(): | |
| 635 self._current_page.expected_workarounds = self.RecordedWorkarounds() | |
| 636 self.AddTestingWorkaround(self._current_page.expected_workarounds) | |
| 637 super(TransferWorkaroundSharedPageState, self).RunStory(results) | |
| 638 | |
| 639 def WarmUpDone(self): | |
| 640 return self._previous_page is not None and \ | |
| 641 self.RecordedWorkarounds() is not None | |
| 642 | |
| 643 def RecordedWorkarounds(self): | |
| 644 return self._previous_page.recorded_workarounds | |
| 645 | |
| 646 def AddTestingWorkaround(self, workarounds): | |
| 647 if workarounds is not None: | |
| 648 workarounds.append('use_gpu_driver_workaround_for_testing') | |
| 649 | |
| 650 | |
| 651 class EqualBugWorkaroundsPage(EqualBugWorkaroundsBasePage): | |
| 652 def __init__(self, story_set, expectations): | |
| 653 super(EqualBugWorkaroundsPage, self).__init__( | |
| 654 name='GpuProcess.equal_bug_workarounds_in_browser_and_gpu_process', | |
| 655 page_set=story_set, | |
| 656 shared_page_state_class=TransferWorkaroundSharedPageState, | |
| 657 expectations=expectations) | |
| 658 self.recorded_workarounds = None | |
| 659 | |
| 660 def Validate(self, tab, results): | |
| 661 gpu_list = super(EqualBugWorkaroundsPage, self).Validate(tab, results) | |
| 662 self.recorded_workarounds = gpu_list | |
| 663 | |
| 664 | |
| 665 class OnlyOneWorkaroundPage(EqualBugWorkaroundsBasePage): | |
| 666 def __init__(self, story_set, expectations): | |
| 667 super(OnlyOneWorkaroundPage, self).__init__( | |
| 668 name='GpuProcess.only_one_workaround', | |
| 669 page_set=story_set, | |
| 670 shared_page_state_class=TransferWorkaroundSharedPageState, | |
| 671 expectations=expectations) | |
| 672 self.expected_workarounds = None | |
| 673 | |
| 674 def Validate(self, tab, results): | |
| 675 # Requires EqualBugWorkaroundsPage to succeed. If it has failed then just | |
| 676 # pass to not overload the logs. | |
| 677 if self.expected_workarounds is None: | |
| 678 return | |
| 679 | |
| 680 gpu_list = super(OnlyOneWorkaroundPage, self).Validate(tab, results) | |
| 681 | |
| 682 diff = set(self.expected_workarounds).symmetric_difference(set(gpu_list)) | |
| 683 if len(diff) > 0: | |
| 684 print 'Test failed. Printing page contents:' | |
| 685 print tab.EvaluateJavaScript('document.body.innerHTML') | |
| 686 raise page_test.Failure('GPU process and expected list of driver bug' \ | |
| 687 'workarounds are not equal: %s != %s, diff: %s' % \ | |
| 688 (self.expected_workarounds, gpu_list, list(diff))) | |
| 689 | |
| 690 | |
| 691 class GpuProcessTestsStorySet(story_set_module.StorySet): | 590 class GpuProcessTestsStorySet(story_set_module.StorySet): |
| 692 | 591 |
| 693 """ Tests that accelerated content triggers the creation of a GPU process """ | 592 """ Tests that accelerated content triggers the creation of a GPU process """ |
| 694 | 593 |
| 695 def __init__(self, expectations, is_platform_android): | 594 def __init__(self, expectations, is_platform_android): |
| 696 super(GpuProcessTestsStorySet, self).__init__( | 595 super(GpuProcessTestsStorySet, self).__init__( |
| 697 serving_dirs=set(['../../../../content/test/data'])) | 596 serving_dirs=set(['../../../../content/test/data'])) |
| 698 | 597 |
| 699 urls_and_names_list = [ | 598 urls_and_names_list = [ |
| 700 ('file://../../data/gpu/functional_canvas_demo.html', | 599 ('file://../../data/gpu/functional_canvas_demo.html', |
| 701 'GpuProcess.canvas2d'), | 600 'GpuProcess.canvas2d'), |
| 702 ('file://../../data/gpu/functional_3d_css.html', | 601 ('file://../../data/gpu/functional_3d_css.html', |
| 703 'GpuProcess.css3d'), | 602 'GpuProcess.css3d'), |
| 704 ('file://../../data/gpu/functional_webgl.html', | 603 ('file://../../data/gpu/functional_webgl.html', |
| 705 'GpuProcess.webgl') | 604 'GpuProcess.webgl') |
| 706 ] | 605 ] |
| 707 | 606 |
| 708 for url, name in urls_and_names_list: | 607 for url, name in urls_and_names_list: |
| 709 self.AddStory(GpuProcessTestsPage(url, name, self, expectations)) | 608 self.AddStory(GpuProcessTestsPage(url, name, self, expectations)) |
| 710 | 609 |
| 711 self.AddStory(FunctionalVideoPage(self, expectations)) | 610 self.AddStory(FunctionalVideoPage(self, expectations)) |
| 712 self.AddStory(GpuInfoCompletePage(self, expectations)) | 611 self.AddStory(GpuInfoCompletePage(self, expectations)) |
| 713 self.AddStory(NoGpuProcessPage(self, expectations)) | 612 self.AddStory(NoGpuProcessPage(self, expectations)) |
| 714 self.AddStory(DriverBugWorkaroundsInGpuProcessPage(self, expectations)) | 613 self.AddStory(DriverBugWorkaroundsInGpuProcessPage(self, expectations)) |
| 715 self.AddStory(ReadbackWebGLGpuProcessPage(self, expectations, | 614 self.AddStory(ReadbackWebGLGpuProcessPage(self, expectations, |
| 716 is_platform_android)) | 615 is_platform_android)) |
| 717 self.AddStory(DriverBugWorkaroundsUponGLRendererPage(self, expectations, | 616 self.AddStory(DriverBugWorkaroundsUponGLRendererPage(self, expectations, |
| 718 is_platform_android)) | 617 is_platform_android)) |
| 719 self.AddStory(EqualBugWorkaroundsPage(self, expectations)) | 618 self.AddStory(EqualBugWorkaroundsInBrowserAndGpuProcessPage(self, |
| 720 self.AddStory(OnlyOneWorkaroundPage(self, expectations)) | 619 expectations)) |
| 721 | |
| 722 if not is_platform_android: | 620 if not is_platform_android: |
| 723 self.AddStory(SkipGpuProcessPage(self, expectations)) | 621 self.AddStory(SkipGpuProcessPage(self, expectations)) |
| 724 self.AddStory(HasTransparentVisualsGpuProcessPage(self, expectations)) | 622 self.AddStory(HasTransparentVisualsGpuProcessPage(self, expectations)) |
| 725 self.AddStory(NoTransparentVisualsGpuProcessPage(self, expectations)) | 623 self.AddStory(NoTransparentVisualsGpuProcessPage(self, expectations)) |
| 726 | 624 |
| 727 # There is no Android multi-gpu configuration and the helper | 625 # There is no Android multi-gpu configuration and the helper |
| 728 # gpu_info_collector.cc::IdentifyActiveGPU is not even called. | 626 # gpu_info_collector.cc::IdentifyActiveGPU is not even called. |
| 729 self.AddStory(IdentifyActiveGpuPage1(self, expectations)) | 627 self.AddStory(IdentifyActiveGpuPage1(self, expectations)) |
| 730 self.AddStory(IdentifyActiveGpuPage2(self, expectations)) | 628 self.AddStory(IdentifyActiveGpuPage2(self, expectations)) |
| 731 self.AddStory(IdentifyActiveGpuPage3(self, expectations)) | 629 self.AddStory(IdentifyActiveGpuPage3(self, expectations)) |
| 732 self.AddStory(IdentifyActiveGpuPage4(self, expectations)) | 630 self.AddStory(IdentifyActiveGpuPage4(self, expectations)) |
| 733 | 631 |
| 734 # There is currently no entry in kSoftwareRenderingListJson that enables | 632 # There is currently no entry in kSoftwareRenderingListJson that enables |
| 735 # a software GL driver on Android. | 633 # a software GL driver on Android. |
| 736 self.AddStory(SoftwareGpuProcessPage(self, expectations)) | 634 self.AddStory(SoftwareGpuProcessPage(self, expectations)) |
| 737 | 635 |
| 738 @property | 636 @property |
| 739 def allow_mixed_story_states(self): | 637 def allow_mixed_story_states(self): |
| 740 # Return True here in order to be able to run pages with different browser | 638 # Return True here in order to be able to run pages with different browser |
| 741 # command line arguments. | 639 # command line arguments. |
| 742 return True | 640 return True |
| OLD | NEW |