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