Skip to content

Commit

Permalink
Add GPU coverage tag
Browse files Browse the repository at this point in the history
Adds the clang-coverage/no-clang-coverage tag pair to the GPU
integration test harness. The former is added if the browser is
compiled with use_clang_coverage=true, otherwise the latter is added.
In practice, this should mean that the former is added when run from coverage bots but not anywhere else.

Bug: 1413845
Change-Id: I1949e853e172d3d3c2b74a64fe5b67de758ace72
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4228121
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1103044}
  • Loading branch information
Brian Sheedy authored and Chromium LUCI CQ committed Feb 9, 2023
1 parent 8f561ea commit 207bca6
Show file tree
Hide file tree
Showing 22 changed files with 160 additions and 16 deletions.
9 changes: 8 additions & 1 deletion content/test/gpu/gpu_tests/gpu_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,17 @@ def GetAsanStatus(gpu_info: tgi.GPUInfo) -> str:
return 'no-asan'


def GetTargetCpuStatus(gpu_info):
def GetTargetCpuStatus(gpu_info: tgi.GPUInfo) -> str:
return 'target-cpu-%s' % (gpu_info.aux_attributes.get('target_cpu_bits',
'unknown'), )


def GetClangCoverage(gpu_info: tgi.GPUInfo) -> str:
if gpu_info.aux_attributes.get('is_clang_coverage', False):
return 'clang-coverage'
return 'no-clang-coverage'


# TODO(rivr): Use GPU feature status for Dawn instead of command line.
def HasDawnSkiaRenderer(extra_browser_args: List[str]) -> bool:
if extra_browser_args:
Expand Down
42 changes: 40 additions & 2 deletions content/test/gpu/gpu_tests/gpu_helper_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,56 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from typing import Dict, Optional, Union
import unittest

from gpu_tests import gpu_helper
from telemetry.internal.platform import gpu_info


# pylint: disable=too-many-arguments
def CreateGpuDeviceDict(vendor_id: Optional[str] = None,
device_id: Optional[str] = None,
sub_sys_id: Optional[int] = None,
revision: Optional[int] = None,
vendor_string: Optional[str] = None,
device_string: Optional[str] = None,
driver_vendor: Optional[str] = None,
driver_version: Optional[str] = None
) -> Dict[str, Union[str, int]]:
return {
'vendor_id': vendor_id or 'vendor_id',
'device_id': device_id or 'device_id',
'sub_sys_id': sub_sys_id or 0,
'revision': revision or 0,
'vendor_string': vendor_string or 'vendor_string',
'device_string': device_string or 'device_string',
'driver_vendor': driver_vendor or 'driver_vendor',
'driver_version': driver_version or 'driver_version',
}


# pylint: enable=too-many-arguments


class TagHelpersUnittest(unittest.TestCase):

# TODO(crbug.com/1413867): Add unittests for other tag generation helpers.
def testGetClangCoverage(self) -> None:
info = gpu_info.GPUInfo([CreateGpuDeviceDict()], {}, None, None)
self.assertEqual(gpu_helper.GetClangCoverage(info), 'no-clang-coverage')
info = gpu_info.GPUInfo([CreateGpuDeviceDict()],
{'is_clang_coverage': True}, None, None)
self.assertEqual(gpu_helper.GetClangCoverage(info), 'clang-coverage')


class ReplaceTagsUnittest(unittest.TestCase):
def testSubstringReplacement(self):
def testSubstringReplacement(self) -> None:
tags = ['some_tag', 'some-nvidia-corporation', 'another_tag']
self.assertEqual(gpu_helper.ReplaceTags(tags),
['some_tag', 'some-nvidia', 'another_tag'])

def testRegexReplacement(self):
def testRegexReplacement(self) -> None:
tags = [
'some_tag',
'google-Vulkan-1.3.0-(SwiftShader-Device-(LLVM-10.0.0)-(0x0000C0DE))',
Expand Down
1 change: 1 addition & 0 deletions content/test/gpu/gpu_tests/gpu_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ def GetPlatformTags(cls, browser: ct.Browser) -> List[str]:
gpu_tags.append(gpu_helper.GetCommandDecoder(gpu_info))
gpu_tags.append(gpu_helper.GetOOPCanvasStatus(gpu_info.feature_status))
gpu_tags.append(gpu_helper.GetAsanStatus(gpu_info))
gpu_tags.append(gpu_helper.GetClangCoverage(gpu_info))
gpu_tags.append(gpu_helper.GetTargetCpuStatus(gpu_info))
if gpu_info and gpu_info.devices:
for ii in range(0, len(gpu_info.devices)):
Expand Down
72 changes: 62 additions & 10 deletions content/test/gpu/gpu_tests/gpu_integration_test_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def _GetSystemInfo( # pylint: disable=too-many-arguments
passthrough: bool = False,
gl_renderer: str = '',
is_asan: bool = False,
is_clang_coverage: bool = False,
target_cpu_bits: int = 64) -> system_info.SystemInfo:
sys_info = {
'model_name': '',
Expand All @@ -73,6 +74,7 @@ def _GetSystemInfo( # pylint: disable=too-many-arguments
'aux_attributes': {
'passthrough_cmd_decoder': passthrough,
'is_asan': is_asan,
'is_clang_coverage': is_clang_coverage,
'target_cpu_bits': target_cpu_bits
},
'feature_status': {
Expand Down Expand Up @@ -101,6 +103,7 @@ def _GenerateNvidiaExampleTagsForTestClassAndArgs(
test_class: GpuTestClassType,
args: mock.MagicMock,
is_asan: bool = False,
is_clang_coverage: bool = False,
target_cpu_bits: int = 64,
) -> Set[str]:
tags = None
Expand All @@ -114,6 +117,7 @@ def _GenerateNvidiaExampleTagsForTestClassAndArgs(
device=0x1cb3,
gl_renderer='ANGLE Direct3D9',
is_asan=is_asan,
is_clang_coverage=is_clang_coverage,
target_cpu_bits=target_cpu_bits)
tags = _GetTagsToTest(browser, test_class)
return tags
Expand Down Expand Up @@ -190,19 +194,22 @@ def testTestNamePrefixGenerationInRunGpuIntegrationTests(self) -> None:
self._RunGpuIntegrationTests('simple_integration_unittest')
self.assertIn('expected_failure', self._test_result['tests'])

# pylint: disable=too-many-arguments
def _TestTagGenerationForMockPlatform(self,
test_class: GpuTestClassType,
args: mock.MagicMock,
is_asan: bool = False,
is_clang_coverage: bool = False,
target_cpu_bits: int = 64) -> Set[str]:
tag_set = _GenerateNvidiaExampleTagsForTestClassAndArgs(
test_class, args, is_asan, target_cpu_bits)
test_class, args, is_asan, is_clang_coverage, target_cpu_bits)
self.assertTrue(
set([
'win', 'win10', 'angle-d3d9', 'release', 'nvidia', 'nvidia-0x1cb3',
'no-passthrough'
]).issubset(tag_set))
return tag_set
# pylint: enable=too-many-arguments

def testGenerateContextLostExampleTagsForAsan(self) -> None:
args = gpu_helper.GetMockArgs()
Expand All @@ -222,6 +229,24 @@ def testGenerateContextLostExampleTagsForNoAsan(self) -> None:
self.assertIn('no-asan', tag_set)
self.assertNotIn('asan', tag_set)

def testGenerateContextLostExampleTagsForClangCoverage(self) -> None:
args = gpu_helper.GetMockArgs()
tag_set = self._TestTagGenerationForMockPlatform(
context_lost_integration_test.ContextLostIntegrationTest,
args,
is_clang_coverage=True)
self.assertIn('clang-coverage', tag_set)
self.assertNotIn('no-clang-coverage', tag_set)

def testGenerateContextLostExampleTagsForNoClangCoverage(self) -> None:
args = gpu_helper.GetMockArgs()
tag_set = self._TestTagGenerationForMockPlatform(
context_lost_integration_test.ContextLostIntegrationTest,
args,
is_clang_coverage=False)
self.assertIn('no-clang-coverage', tag_set)
self.assertNotIn('clang-coverage', tag_set)

def testGenerateContextLostExampleTagsForTargetCpu(self) -> None:
args = gpu_helper.GetMockArgs()
self.assertIn(
Expand Down Expand Up @@ -280,9 +305,18 @@ def testGenerateNvidiaExampleTags(self) -> None:
self.assertEqual(
_GetTagsToTest(browser),
set([
'win', 'win10', 'release', 'nvidia', 'nvidia-0x1cb3', 'angle-d3d9',
'no-passthrough', 'renderer-skia-gl', 'no-oop-c', 'no-asan',
'target-cpu-64'
'win',
'win10',
'release',
'nvidia',
'nvidia-0x1cb3',
'angle-d3d9',
'no-passthrough',
'renderer-skia-gl',
'no-oop-c',
'no-asan',
'target-cpu-64',
'no-clang-coverage',
]))

@mock.patch('sys.platform', 'darwin')
Expand All @@ -297,9 +331,18 @@ def testGenerateVendorTagUsingVendorString(self) -> None:
self.assertEqual(
_GetTagsToTest(browser),
set([
'mac', 'mojave', 'release', 'imagination', 'no-asan',
'target-cpu-64', 'imagination-PowerVR-SGX-554', 'angle-opengles',
'passthrough', 'renderer-skia-gl', 'no-oop-c'
'mac',
'mojave',
'release',
'imagination',
'no-asan',
'target-cpu-64',
'imagination-PowerVR-SGX-554',
'angle-opengles',
'passthrough',
'renderer-skia-gl',
'no-oop-c',
'no-clang-coverage',
]))

@mock.patch('sys.platform', 'darwin')
Expand All @@ -312,9 +355,18 @@ def testGenerateVendorTagUsingDeviceString(self) -> None:
self.assertEqual(
_GetTagsToTest(browser),
set([
'mac', 'mojave', 'release', 'imagination', 'no-asan',
'target-cpu-64', 'imagination-Triangle-Monster-3000',
'angle-disabled', 'no-passthrough', 'renderer-skia-gl', 'no-oop-c'
'mac',
'mojave',
'release',
'imagination',
'no-asan',
'target-cpu-64',
'imagination-Triangle-Monster-3000',
'angle-disabled',
'no-passthrough',
'renderer-skia-gl',
'no-oop-c',
'no-clang-coverage',
]))

@mock.patch.dict(os.environ, clear=True)
Expand Down
8 changes: 7 additions & 1 deletion content/test/gpu/gpu_tests/info_collection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def GenerateGpuTests(cls, options: ct.ParsedCmdArgs) -> ct.TestGenerator:
InfoCollectionTestArgs()])
yield ('InfoCollection_asan_info_surfaced', '_',
['_RunAsanInfoTest', InfoCollectionTestArgs()])
yield ('InfoCollection_clang_coverage_info_surfaced', '_',
['_RunClangCoverageInfoTest',
InfoCollectionTestArgs()])

@classmethod
def SetUpProcess(cls) -> None:
Expand All @@ -78,7 +81,6 @@ def RunActualGpuTest(self, test_path: str, args: ct.TestArgs) -> None:
assert len(args) == 2
test_func = args[0]
test_args = args[1]
assert test_args.gpu is None
test_args.gpu = system_info.gpu
getattr(self, test_func)(test_args)

Expand Down Expand Up @@ -155,6 +157,10 @@ def _RunAsanInfoTest(self, _: InfoCollectionTestArgs) -> None:
gpu_info = self.browser.GetSystemInfo().gpu
self.assertIn('is_asan', gpu_info.aux_attributes)

def _RunClangCoverageInfoTest(self, _: InfoCollectionTestArgs) -> None:
gpu_info = self.browser.GetSystemInfo().gpu
self.assertIn('is_clang_coverage', gpu_info.aux_attributes)

@staticmethod
def _ValueToStr(value: Union[str, bool]) -> str:
if isinstance(value, six.string_types):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
# END TAG HEADER
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
# END TAG HEADER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
# END TAG HEADER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
# END TAG HEADER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
# END TAG HEADER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
# END TAG HEADER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
# END TAG HEADER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
# END TAG HEADER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
# END TAG HEADER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
# END TAG HEADER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
# END TAG HEADER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
# END TAG HEADER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
# END TAG HEADER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
# END TAG HEADER

Expand Down
2 changes: 2 additions & 0 deletions content/test/gpu/validate_tag_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
# tags: [ oop-c no-oop-c ]
# WebGPU Backend Validation
# tags: [ dawn-backend-validation dawn-no-backend-validation ]
# Clang coverage
# tags: [ clang-coverage no-clang-coverage ]
# results: [ Failure RetryOnFailure Skip Slow ]
"""

Expand Down

0 comments on commit 207bca6

Please sign in to comment.