Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(870)

Side by Side Diff: content/test/gpu/gpu_tests/gpu_process_integration_test.py

Issue 2672803002: [Telemetry refactor] Migrate clients to new JavaScript API (batch 3) (Closed)
Patch Set: add comment on tools/android Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 url = self.UrlOfStaticFilePath(test_path) 135 url = self.UrlOfStaticFilePath(test_path)
136 # It's crucial to use the action_runner, rather than the tab's 136 # It's crucial to use the action_runner, rather than the tab's
137 # Navigate method directly. It waits for the document ready state 137 # Navigate method directly. It waits for the document ready state
138 # to become interactive or better, avoiding critical race 138 # to become interactive or better, avoiding critical race
139 # conditions. 139 # conditions.
140 self.tab.action_runner.Navigate( 140 self.tab.action_runner.Navigate(
141 url, script_to_evaluate_on_commit=test_harness_script) 141 url, script_to_evaluate_on_commit=test_harness_script)
142 142
143 def _NavigateAndWait(self, test_path): 143 def _NavigateAndWait(self, test_path):
144 self._Navigate(test_path) 144 self._Navigate(test_path)
145 self.tab.action_runner.WaitForJavaScriptCondition( 145 self.tab.action_runner.WaitForJavaScriptCondition2(
146 'window.domAutomationController._finished', timeout_in_seconds=10) 146 'window.domAutomationController._finished', timeout=10)
147 147
148 def _VerifyGpuProcessPresent(self): 148 def _VerifyGpuProcessPresent(self):
149 tab = self.tab 149 tab = self.tab
150 has_gpu_channel_js = 'chrome.gpuBenchmarking.hasGpuChannel()' 150 if not tab.EvaluateJavaScript2('chrome.gpuBenchmarking.hasGpuChannel()'):
151 has_gpu_channel = tab.EvaluateJavaScript(has_gpu_channel_js)
152 if not has_gpu_channel:
153 self.fail('No GPU channel detected') 151 self.fail('No GPU channel detected')
154 152
155 def _ValidateDriverBugWorkaroundsImpl(self, process_kind, is_expected, 153 def _ValidateDriverBugWorkaroundsImpl(self, process_kind, is_expected,
156 workaround_name): 154 workaround_name):
157 tab = self.tab 155 tab = self.tab
158 if process_kind == "browser_process": 156 if process_kind == "browser_process":
159 gpu_driver_bug_workarounds = tab.EvaluateJavaScript( 157 gpu_driver_bug_workarounds = tab.EvaluateJavaScript2(
160 'GetDriverBugWorkarounds()') 158 'GetDriverBugWorkarounds()')
161 elif process_kind == "gpu_process": 159 elif process_kind == "gpu_process":
162 gpu_driver_bug_workarounds = tab.EvaluateJavaScript( 160 gpu_driver_bug_workarounds = tab.EvaluateJavaScript2(
163 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()') 161 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()')
164 162
165 is_present = workaround_name in gpu_driver_bug_workarounds 163 is_present = workaround_name in gpu_driver_bug_workarounds
166 failure = False 164 failure = False
167 if is_expected and not is_present: 165 if is_expected and not is_present:
168 failure = True 166 failure = True
169 error_message = "is missing" 167 error_message = "is missing"
170 elif not is_expected and is_present: 168 elif not is_expected and is_present:
171 failure = True 169 failure = True
172 error_message = "is not expected" 170 error_message = "is not expected"
173 171
174 if failure: 172 if failure:
175 print 'Test failed. Printing page contents:' 173 print 'Test failed. Printing page contents:'
176 print tab.EvaluateJavaScript('document.body.innerHTML') 174 print tab.EvaluateJavaScript2('document.body.innerHTML')
177 self.fail('%s %s in %s workarounds: %s' 175 self.fail('%s %s in %s workarounds: %s'
178 % (workaround_name, error_message, process_kind, 176 % (workaround_name, error_message, process_kind,
179 gpu_driver_bug_workarounds)) 177 gpu_driver_bug_workarounds))
180 178
181 def _ValidateDriverBugWorkarounds(self, expected_workaround, 179 def _ValidateDriverBugWorkarounds(self, expected_workaround,
182 unexpected_workaround): 180 unexpected_workaround):
183 if not expected_workaround and not unexpected_workaround: 181 if not expected_workaround and not unexpected_workaround:
184 return 182 return
185 if expected_workaround: 183 if expected_workaround:
186 self._ValidateDriverBugWorkaroundsImpl( 184 self._ValidateDriverBugWorkaroundsImpl(
187 "browser_process", True, expected_workaround) 185 "browser_process", True, expected_workaround)
188 self._ValidateDriverBugWorkaroundsImpl( 186 self._ValidateDriverBugWorkaroundsImpl(
189 "gpu_process", True, expected_workaround) 187 "gpu_process", True, expected_workaround)
190 if unexpected_workaround: 188 if unexpected_workaround:
191 self._ValidateDriverBugWorkaroundsImpl( 189 self._ValidateDriverBugWorkaroundsImpl(
192 "browser_process", False, unexpected_workaround) 190 "browser_process", False, unexpected_workaround)
193 self._ValidateDriverBugWorkaroundsImpl( 191 self._ValidateDriverBugWorkaroundsImpl(
194 "gpu_process", False, unexpected_workaround) 192 "gpu_process", False, unexpected_workaround)
195 193
196 # This can only be called from one of the tests, i.e., after the 194 # This can only be called from one of the tests, i.e., after the
197 # browser's been brought up once. 195 # browser's been brought up once.
198 def _RunningOnAndroid(self): 196 def _RunningOnAndroid(self):
199 options = self.__class__._original_finder_options.browser_options 197 options = self.__class__._original_finder_options.browser_options
200 return options.browser_type.startswith('android') 198 return options.browser_type.startswith('android')
201 199
202 def _CompareAndCaptureDriverBugWorkarounds(self): 200 def _CompareAndCaptureDriverBugWorkarounds(self):
203 tab = self.tab 201 tab = self.tab
204 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' 202 if not tab.EvaluateJavaScript2('chrome.gpuBenchmarking.hasGpuProcess()'):
205 if not tab.EvaluateJavaScript(has_gpu_process_js):
206 self.fail('No GPU process detected') 203 self.fail('No GPU process detected')
207 204
208 has_gpu_channel_js = 'chrome.gpuBenchmarking.hasGpuChannel()' 205 if not tab.EvaluateJavaScript2('chrome.gpuBenchmarking.hasGpuChannel()'):
209 if not tab.EvaluateJavaScript(has_gpu_channel_js):
210 self.fail('No GPU channel detected') 206 self.fail('No GPU channel detected')
211 207
212 browser_list = tab.EvaluateJavaScript('GetDriverBugWorkarounds()') 208 browser_list = tab.EvaluateJavaScript2('GetDriverBugWorkarounds()')
213 gpu_list = tab.EvaluateJavaScript( 209 gpu_list = tab.EvaluateJavaScript2(
214 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()') 210 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()')
215 211
216 diff = set(browser_list).symmetric_difference(set(gpu_list)) 212 diff = set(browser_list).symmetric_difference(set(gpu_list))
217 if len(diff) > 0: 213 if len(diff) > 0:
218 print 'Test failed. Printing page contents:' 214 print 'Test failed. Printing page contents:'
219 print tab.EvaluateJavaScript('document.body.innerHTML') 215 print tab.EvaluateJavaScript2('document.body.innerHTML')
220 self.fail('Browser and GPU process list of driver bug' 216 self.fail('Browser and GPU process list of driver bug'
221 'workarounds are not equal: %s != %s, diff: %s' % 217 'workarounds are not equal: %s != %s, diff: %s' %
222 (browser_list, gpu_list, list(diff))) 218 (browser_list, gpu_list, list(diff)))
223 219
224 basic_infos = tab.EvaluateJavaScript('browserBridge.gpuInfo.basic_info') 220 basic_infos = tab.EvaluateJavaScript2('browserBridge.gpuInfo.basic_info')
225 disabled_gl_extensions = None 221 disabled_gl_extensions = None
226 for info in basic_infos: 222 for info in basic_infos:
227 if info['description'].startswith('Disabled Extensions'): 223 if info['description'].startswith('Disabled Extensions'):
228 disabled_gl_extensions = info['value'] 224 disabled_gl_extensions = info['value']
229 break 225 break
230 226
231 return gpu_list, disabled_gl_extensions 227 return gpu_list, disabled_gl_extensions
232 228
233 def _VerifyActiveAndInactiveGPUs( 229 def _VerifyActiveAndInactiveGPUs(
234 self, expected_active_gpu, expected_inactive_gpus): 230 self, expected_active_gpu, expected_inactive_gpus):
235 tab = self.tab 231 tab = self.tab
236 basic_infos = tab.EvaluateJavaScript('browserBridge.gpuInfo.basic_info') 232 basic_infos = tab.EvaluateJavaScript2('browserBridge.gpuInfo.basic_info')
237 active_gpu = [] 233 active_gpu = []
238 inactive_gpus = [] 234 inactive_gpus = []
239 index = 0 235 index = 0
240 for info in basic_infos: 236 for info in basic_infos:
241 description = info['description'] 237 description = info['description']
242 value = info['value'] 238 value = info['value']
243 if description.startswith('GPU%d' % index) and value.startswith('VENDOR'): 239 if description.startswith('GPU%d' % index) and value.startswith('VENDOR'):
244 if value.endswith('*ACTIVE*'): 240 if value.endswith('*ACTIVE*'):
245 active_gpu.append(value) 241 active_gpu.append(value)
246 else: 242 else:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 '--gpu-testing-device-id=0x0de1', 310 '--gpu-testing-device-id=0x0de1',
315 '--gpu-testing-gl-vendor=VMware', 311 '--gpu-testing-gl-vendor=VMware',
316 '--gpu-testing-gl-renderer=softpipe', 312 '--gpu-testing-gl-renderer=softpipe',
317 '--gpu-testing-gl-version="2.1 Mesa 10.1"']) 313 '--gpu-testing-gl-version="2.1 Mesa 10.1"'])
318 elif sys.platform == 'darwin': 314 elif sys.platform == 'darwin':
319 # Hit id 112 from kSoftwareRenderingListJson. 315 # Hit id 112 from kSoftwareRenderingListJson.
320 self.RestartBrowserIfNecessaryWithArgs([ 316 self.RestartBrowserIfNecessaryWithArgs([
321 '--gpu-testing-vendor-id=0x8086', 317 '--gpu-testing-vendor-id=0x8086',
322 '--gpu-testing-device-id=0x0116']) 318 '--gpu-testing-device-id=0x0116'])
323 self._Navigate(test_path) 319 self._Navigate(test_path)
324 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' 320 if self.tab.EvaluateJavaScript2('chrome.gpuBenchmarking.hasGpuProcess()'):
325 has_gpu_process = self.tab.EvaluateJavaScript(has_gpu_process_js)
326 if has_gpu_process:
327 self.fail('GPU process detected') 321 self.fail('GPU process detected')
328 322
329 def _GpuProcess_driver_bug_workarounds_in_gpu_process(self, test_path): 323 def _GpuProcess_driver_bug_workarounds_in_gpu_process(self, test_path):
330 self.RestartBrowserIfNecessaryWithArgs([ 324 self.RestartBrowserIfNecessaryWithArgs([
331 '--use_gpu_driver_workaround_for_testing']) 325 '--use_gpu_driver_workaround_for_testing'])
332 self._Navigate(test_path) 326 self._Navigate(test_path)
333 self._ValidateDriverBugWorkarounds( 327 self._ValidateDriverBugWorkarounds(
334 'use_gpu_driver_workaround_for_testing', None) 328 'use_gpu_driver_workaround_for_testing', None)
335 329
336 def _GpuProcess_readback_webgl_gpu_process(self, test_path): 330 def _GpuProcess_readback_webgl_gpu_process(self, test_path):
337 # This test was designed to only run on desktop Linux. 331 # This test was designed to only run on desktop Linux.
338 options = self.__class__._original_finder_options.browser_options 332 options = self.__class__._original_finder_options.browser_options
339 is_platform_android = options.browser_type.startswith('android') 333 is_platform_android = options.browser_type.startswith('android')
340 if sys.platform.startswith('linux') and not is_platform_android: 334 if sys.platform.startswith('linux') and not is_platform_android:
341 # Hit id 110 from kSoftwareRenderingListJson. 335 # Hit id 110 from kSoftwareRenderingListJson.
342 self.RestartBrowserIfNecessaryWithArgs([ 336 self.RestartBrowserIfNecessaryWithArgs([
343 '--gpu-testing-vendor-id=0x10de', 337 '--gpu-testing-vendor-id=0x10de',
344 '--gpu-testing-device-id=0x0de1', 338 '--gpu-testing-device-id=0x0de1',
345 '--gpu-testing-gl-vendor=VMware', 339 '--gpu-testing-gl-vendor=VMware',
346 '--gpu-testing-gl-renderer=Gallium 0.4 ' \ 340 '--gpu-testing-gl-renderer=Gallium 0.4 ' \
347 'on llvmpipe (LLVM 3.4, 256 bits)', 341 'on llvmpipe (LLVM 3.4, 256 bits)',
348 '--gpu-testing-gl-version="3.0 Mesa 11.2"']) 342 '--gpu-testing-gl-version="3.0 Mesa 11.2"'])
349 self._Navigate(test_path) 343 self._Navigate(test_path)
350 feature_status_js = 'browserBridge.gpuInfo.featureStatus.featureStatus' 344 feature_status_list = self.tab.EvaluateJavaScript2(
351 feature_status_list = self.tab.EvaluateJavaScript(feature_status_js) 345 'browserBridge.gpuInfo.featureStatus.featureStatus')
352 result = True 346 result = True
353 for name, status in feature_status_list.items(): 347 for name, status in feature_status_list.items():
354 if name == 'multiple_raster_threads': 348 if name == 'multiple_raster_threads':
355 result = result and status == 'enabled_on' 349 result = result and status == 'enabled_on'
356 elif name == 'native_gpu_memory_buffers': 350 elif name == 'native_gpu_memory_buffers':
357 result = result and status == 'disabled_software' 351 result = result and status == 'disabled_software'
358 elif name == 'webgl': 352 elif name == 'webgl':
359 result = result and status == 'enabled_readback' 353 result = result and status == 'enabled_readback'
360 elif name == 'webgl2': 354 elif name == 'webgl2':
361 result = result and status == 'unavailable_off' 355 result = result and status == 'unavailable_off'
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 recorded_disabled_gl_extensions) 429 recorded_disabled_gl_extensions)
436 self.RestartBrowserIfNecessaryWithArgs(browser_args) 430 self.RestartBrowserIfNecessaryWithArgs(browser_args)
437 self._Navigate(test_path) 431 self._Navigate(test_path)
438 self._VerifyGpuProcessPresent() 432 self._VerifyGpuProcessPresent()
439 new_workarounds, new_disabled_gl_extensions = ( 433 new_workarounds, new_disabled_gl_extensions = (
440 self._CompareAndCaptureDriverBugWorkarounds()) 434 self._CompareAndCaptureDriverBugWorkarounds())
441 diff = set(recorded_workarounds).symmetric_difference(new_workarounds) 435 diff = set(recorded_workarounds).symmetric_difference(new_workarounds)
442 tab = self.tab 436 tab = self.tab
443 if len(diff) > 0: 437 if len(diff) > 0:
444 print 'Test failed. Printing page contents:' 438 print 'Test failed. Printing page contents:'
445 print tab.EvaluateJavaScript('document.body.innerHTML') 439 print tab.EvaluateJavaScript2('document.body.innerHTML')
446 self.fail( 440 self.fail(
447 'GPU process and expected list of driver bug ' 441 'GPU process and expected list of driver bug '
448 'workarounds are not equal: %s != %s, diff: %s' % 442 'workarounds are not equal: %s != %s, diff: %s' %
449 (recorded_workarounds, new_workarounds, list(diff))) 443 (recorded_workarounds, new_workarounds, list(diff)))
450 if recorded_disabled_gl_extensions != new_disabled_gl_extensions: 444 if recorded_disabled_gl_extensions != new_disabled_gl_extensions:
451 print 'Test failed. Printing page contents:' 445 print 'Test failed. Printing page contents:'
452 print tab.EvaluateJavaScript('document.body.innerHTML') 446 print tab.EvaluateJavaScript2('document.body.innerHTML')
453 self.fail( 447 self.fail(
454 'The expected disabled gl extensions are ' 448 'The expected disabled gl extensions are '
455 'incorrect: %s != %s:' % 449 'incorrect: %s != %s:' %
456 (recorded_disabled_gl_extensions, new_disabled_gl_extensions)) 450 (recorded_disabled_gl_extensions, new_disabled_gl_extensions))
457 451
458 def _GpuProcess_skip_gpu_process(self, test_path): 452 def _GpuProcess_skip_gpu_process(self, test_path):
459 self.RestartBrowserIfNecessaryWithArgs([ 453 self.RestartBrowserIfNecessaryWithArgs([
460 '--disable-gpu', 454 '--disable-gpu',
461 '--skip-gpu-data-loading']) 455 '--skip-gpu-data-loading'])
462 self._Navigate(test_path) 456 self._Navigate(test_path)
463 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' 457 if self.tab.EvaluateJavaScript2('chrome.gpuBenchmarking.hasGpuProcess()'):
464 has_gpu_process = self.tab.EvaluateJavaScript(has_gpu_process_js)
465 if has_gpu_process:
466 self.fail('GPU process detected') 458 self.fail('GPU process detected')
467 459
468 def _GpuProcess_identify_active_gpu1(self, test_path): 460 def _GpuProcess_identify_active_gpu1(self, test_path):
469 self.RestartBrowserIfNecessaryWithArgs([ 461 self.RestartBrowserIfNecessaryWithArgs([
470 '--gpu-testing-vendor-id=0x8086', 462 '--gpu-testing-vendor-id=0x8086',
471 '--gpu-testing-device-id=0x040a', 463 '--gpu-testing-device-id=0x040a',
472 '--gpu-testing-secondary-vendor-ids=0x10de', 464 '--gpu-testing-secondary-vendor-ids=0x10de',
473 '--gpu-testing-secondary-device-ids=0x0de1', 465 '--gpu-testing-secondary-device-ids=0x0de1',
474 '--gpu-testing-gl-vendor=nouveau']) 466 '--gpu-testing-gl-vendor=nouveau'])
475 self._Navigate(test_path) 467 self._Navigate(test_path)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 '--gpu-testing-device-id=0x0de1', 514 '--gpu-testing-device-id=0x0de1',
523 '--gpu-testing-gl-vendor=VMware', 515 '--gpu-testing-gl-vendor=VMware',
524 '--gpu-testing-gl-renderer=SVGA3D', 516 '--gpu-testing-gl-renderer=SVGA3D',
525 '--gpu-testing-gl-version=2.1 Mesa 10.1']) 517 '--gpu-testing-gl-version=2.1 Mesa 10.1'])
526 self._Navigate(test_path) 518 self._Navigate(test_path)
527 self._VerifyGpuProcessPresent() 519 self._VerifyGpuProcessPresent()
528 520
529 def load_tests(loader, tests, pattern): 521 def load_tests(loader, tests, pattern):
530 del loader, tests, pattern # Unused. 522 del loader, tests, pattern # Unused.
531 return gpu_integration_test.LoadAllTestsInModule(sys.modules[__name__]) 523 return gpu_integration_test.LoadAllTestsInModule(sys.modules[__name__])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698