0

Add GPU coverage tag

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}
This commit is contained in:
Brian Sheedy
2023-02-09 01:04:03 +00:00
committed by Chromium LUCI CQ
parent 8f561ea522
commit 207bca6048
22 changed files with 161 additions and 17 deletions

@ -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:

@ -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))',

@ -832,6 +832,7 @@ class GpuIntegrationTest(
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)):

@ -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': '',
@ -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': {
@ -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
@ -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
@ -190,19 +194,22 @@ class GpuIntegrationTestUnittest(unittest.TestCase):
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()
@ -222,6 +229,24 @@ class GpuIntegrationTestUnittest(unittest.TestCase):
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(
@ -280,9 +305,18 @@ class GpuIntegrationTestUnittest(unittest.TestCase):
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')
@ -297,9 +331,18 @@ class GpuIntegrationTestUnittest(unittest.TestCase):
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')
@ -312,9 +355,18 @@ class GpuIntegrationTestUnittest(unittest.TestCase):
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)

@ -58,6 +58,9 @@ class InfoCollectionTest(gpu_integration_test.GpuIntegrationTest):
InfoCollectionTestArgs()])
yield ('InfoCollection_asan_info_surfaced', '_',
['_RunAsanInfoTest', InfoCollectionTestArgs()])
yield ('InfoCollection_clang_coverage_info_surfaced', '_',
['_RunClangCoverageInfoTest',
InfoCollectionTestArgs()])
@classmethod
def SetUpProcess(cls) -> None:
@ -78,7 +81,6 @@ class InfoCollectionTest(gpu_integration_test.GpuIntegrationTest):
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)
@ -155,6 +157,10 @@ class InfoCollectionTest(gpu_integration_test.GpuIntegrationTest):
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):

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -72,6 +72,8 @@ TAG_HEADER = """\
# 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 ]
"""

@ -306,7 +306,7 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
std::string max_msaa_samples;
std::string machine_model_name;
std::string machine_model_version;
std::string gl_version_string;
std::string gl_version;
std::string gl_vendor;
std::string gl_renderer;
std::string gl_extensions;
@ -319,9 +319,10 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
bool sandboxed;
bool in_process_gpu;
bool passthrough_cmd_decoder;
bool is_asan;
uint32_t target_cpu_bits;
bool can_support_threaded_texture_mailbox;
bool is_asan;
bool is_clang_coverage;
uint32_t target_cpu_bits;
#if BUILDFLAG(IS_MAC)
uint32_t macos_specific_texture_target;
#endif // BUILDFLAG(IS_MAC)
@ -389,6 +390,7 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
enumerator->AddBool("inProcessGpu", in_process_gpu);
enumerator->AddBool("passthroughCmdDecoder", passthrough_cmd_decoder);
enumerator->AddBool("isAsan", is_asan);
enumerator->AddBool("isClangCoverage", is_clang_coverage);
enumerator->AddInt("targetCpuBits", static_cast<int>(target_cpu_bits));
enumerator->AddBool("canSupportThreadedTextureMailbox",
can_support_threaded_texture_mailbox);

@ -13,6 +13,7 @@
#include <string>
#include <vector>
#include "base/clang_profiling_buildflags.h"
#include "base/containers/flat_map.h"
#include "base/containers/span.h"
#include "base/time/time.h"
@ -420,6 +421,13 @@ struct GPU_EXPORT GPUInfo {
bool is_asan = false;
#endif
// Whether the browser was built with Clang coverage enabled or not.
#if BUILDFLAG(USE_CLANG_COVERAGE) || BUILDFLAG(CLANG_PROFILING)
bool is_clang_coverage = true;
#else
bool is_clang_coverage = false;
#endif
#if defined(ARCH_CPU_64_BITS)
uint32_t target_cpu_bits = 64;
#elif defined(ARCH_CPU_32_BITS)