Add minimal LLVM sanity coverage (sancov) reporting for unittests.
This CL enables generating *.sancov data. Blacklist for sancov tool is provided, too. Sancov tool for report generation needs to be build from llvm compiler-rt sources (llvm 3.9.0 or newer). See http://clang.llvm.org/docs/SanitizerCoverage.html . BUG=webrtc:6136 R=phoglund@webrtc.org TBR=kjellander@webrtc.org Review URL: https://codereview.webrtc.org/2144273002 . Cr-Commit-Position: refs/heads/master@{#13506}
This commit is contained in:
parent
8dc945cd3b
commit
9ddac18d1c
9
tools/sancov/README
Normal file
9
tools/sancov/README
Normal file
@ -0,0 +1,9 @@
|
||||
Blacklist for llvm's sancov
|
||||
|
||||
See http://clang.llvm.org/docs/SanitizerCoverage.html .
|
||||
|
||||
Example usage:
|
||||
> cd out/Debug
|
||||
> UBSAN_OPTIONS="coverage=1" ./peerconnection_unittests
|
||||
> sancov -html-report -blacklist ../../tools/sancov/blacklist.txt \
|
||||
> peerconnection_unittests peerconnection_unittests.123.sancov
|
||||
21
tools/sancov/blacklist.txt
Normal file
21
tools/sancov/blacklist.txt
Normal file
@ -0,0 +1,21 @@
|
||||
#############################################################################
|
||||
# sancov blacklist.
|
||||
# Please think twice before you add or remove these rules.
|
||||
|
||||
#############################################################################
|
||||
# no coverage report for third party
|
||||
src:*/chromium/*
|
||||
src:*/third_party/*
|
||||
|
||||
# OpenH264 triggers some errors that are out of our control.
|
||||
src:*/third_party/ffmpeg/libavcodec/*
|
||||
src:*/third_party/openh264/*
|
||||
|
||||
#############################################################################
|
||||
# Ignore system libraries.
|
||||
src:*/usr/*
|
||||
|
||||
#############################################################################
|
||||
# Ignore test source.
|
||||
src:*/test/*
|
||||
src:*_unittest.cc
|
||||
@ -18,6 +18,8 @@ import("//third_party/protobuf/proto_library.gni")
|
||||
# target_defaults and direct_dependent_settings.
|
||||
config("common_inherited_config") {
|
||||
defines = []
|
||||
cflags = []
|
||||
ldflags = []
|
||||
if (build_with_mozilla) {
|
||||
defines += [ "WEBRTC_MOZILLA_BUILD" ]
|
||||
}
|
||||
@ -77,6 +79,12 @@ config("common_inherited_config") {
|
||||
defines += [ "CHROMEOS" ]
|
||||
}
|
||||
|
||||
if (rtc_sanitize_coverage != "") {
|
||||
assert(is_clang, "sanitizer coverage requires clang")
|
||||
cflags += [ "-fsanitize-coverage=${rtc_sanitize_coverage}" ]
|
||||
ldflags += [ "-fsanitize-coverage=${rtc_sanitize_coverage}" ]
|
||||
}
|
||||
|
||||
# TODO(GYP): Support these in GN.
|
||||
# if (is_bsd) {
|
||||
# defines += [ "BSD" ]
|
||||
|
||||
@ -98,6 +98,13 @@
|
||||
# Set to 1 to enable code coverage on Linux using the gcov library.
|
||||
'coverage%': 0,
|
||||
|
||||
# Set to "func", "block", "edge" for coverage generation.
|
||||
# At unit test runtime set UBSAN_OPTIONS="coverage=1".
|
||||
# It is recommend to set include_examples=0.
|
||||
# Use llvm's sancov -html-report for human readable reports.
|
||||
# See http://clang.llvm.org/docs/SanitizerCoverage.html .
|
||||
'webrtc_sanitize_coverage%': "",
|
||||
|
||||
# Remote bitrate estimator logging/plotting.
|
||||
'enable_bwe_test_logging%': 0,
|
||||
|
||||
@ -399,6 +406,17 @@
|
||||
'ldflags': [ '--coverage' ],
|
||||
'link_settings': { 'libraries': [ '-lgcov' ] },
|
||||
}],
|
||||
['webrtc_sanitize_coverage!=""', {
|
||||
'cflags': [ '-fsanitize-coverage=<(webrtc_sanitize_coverage)' ],
|
||||
'ldflags': [ '-fsanitize-coverage=<(webrtc_sanitize_coverage)' ],
|
||||
}],
|
||||
['webrtc_sanitize_coverage!="" and OS=="mac"', {
|
||||
'xcode_settings': {
|
||||
'OTHER_CFLAGS': [
|
||||
'-fsanitize-coverage=func',
|
||||
],
|
||||
},
|
||||
}],
|
||||
['os_posix==1', {
|
||||
# For access to standard POSIXish features, use WEBRTC_POSIX instead of
|
||||
# a more specific macro.
|
||||
|
||||
@ -64,6 +64,13 @@ declare_args() {
|
||||
|
||||
rtc_restrict_logging = true
|
||||
|
||||
# Set to "func", "block", "edge" for coverage generation.
|
||||
# At unit test runtime set UBSAN_OPTIONS="coverage=1".
|
||||
# It is recommend to set include_examples=0.
|
||||
# Use llvm's sancov -html-report for human readable reports.
|
||||
# See http://clang.llvm.org/docs/SanitizerCoverage.html .
|
||||
rtc_sanitize_coverage = ""
|
||||
|
||||
# Enable libevent task queues on platforms that support it.
|
||||
if (is_win || is_mac || is_ios || is_nacl) {
|
||||
rtc_enable_libevent = false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user