Internals: Fix misc internal coverage holes. No functional change intended.

This commit is contained in:
Wilson Snyder 2020-06-04 21:40:40 -04:00
parent 8d61cd9029
commit 3243651c63
6 changed files with 26 additions and 10 deletions

View File

@ -3,3 +3,4 @@ exclude_paths:
- '.github/**'
- 'ci/build_verilator.sh'
- 'include/vltstd/**'
- 'nodist/fastcov.py'

View File

@ -18,6 +18,7 @@ use vars qw($Debug);
our $Opt_Stop = 1;
our $Opt_Fastcov = 1;
our $Exclude_Branch_Regexp;
our $Exclude_Line_Regexp;
our $Remove_Gcda_Regexp;
@ -312,6 +313,7 @@ sub test {
sub clone_sources {
my $cc_dir = shift;
my $excluded_lines = 0;
my $excluded_br_lines = 0;
foreach my $glob (@Source_Globs) {
foreach my $infile (glob $glob) {
$infile !~ m!^/!
@ -334,10 +336,15 @@ sub clone_sources {
elsif ($line =~ /LCOV_EXCL_STOP/) {
$line .= " LCOV_EXCL_BR_STOP";
}
elsif ($line !~ m!// LCOV_EXCL_LINE!
&& $line =~ /$Exclude_Line_Regexp/) {
elsif ($line =~ /$Exclude_Line_Regexp/) {
$line .= " //code_coverage: // LCOV_EXCL_LINE LCOV_EXCL_BR_LINE";
$excluded_lines++;
$excluded_br_lines++;
#print "$infile:$lineno: $line";
}
elsif ($line =~ /$Exclude_Branch_Regexp/) {
$line .= " //code_coverage: // LCOV_EXCL_BR_LINE";
$excluded_br_lines++;
#print "$infile:$lineno: $line";
}
$ofh->print("$line\n");
@ -345,6 +352,7 @@ sub clone_sources {
}
}
print "Number of source lines automatically LCOV_EXCL_LINE'ed: $excluded_lines\n";
print "Number of source lines automatically LCOV_EXCL_BR_LINE'ed: $excluded_br_lines\n";
}
sub cleanup_abs_paths_info {
@ -388,6 +396,9 @@ sub cleanup_abs_paths_json {
#######################################################################
# .dat file callbacks
sub exclude_branch_regexp {
$Exclude_Branch_Regexp = shift;
}
sub exclude_line_regexp {
$Exclude_Line_Regexp = shift;
}

View File

@ -42,6 +42,7 @@ remove_source("*examples/*");
# Would just be removed with remove_source in later step
remove_gcda_regexp(qr!test_regress/.*/(Vt_|Vtop_).*\.gcda!);
# Exclude line entirely, also excludes from function and branch coverage
exclude_line_regexp(qr/(\bv3fatalSrc\b
|\bfatalSrc\b
|\bVL_UNCOVERABLE\b
@ -51,4 +52,7 @@ exclude_line_regexp(qr/(\bv3fatalSrc\b
|\bV3ERROR_NA
|\bUINFO\b)/x);
# Exclude for branch coverage only
exclude_branch_regexp(qr/(\bdebug\(\))/x);
1;

View File

@ -280,13 +280,13 @@ private:
// IF(msb-1, 01, 00))
AstNode* cexprp = nodep->exprp()->unlinkFrBack();
if (debug() >= 9) {
if (debug() >= 9) { // LCOV_EXCL_START
for (uint32_t i = 0; i < (1UL << m_caseWidth); ++i) {
if (AstNode* itemp = m_valueItem[i]) {
UINFO(9, "Value " << std::hex << i << " " << itemp << endl);
}
}
}
} // LCOV_EXCL_STOP
// Handle any assertions
replaceCaseParallel(nodep, m_caseNoOverlapsAllCovered);

View File

@ -390,14 +390,14 @@ string FileLine::warnOther() const {
}
string FileLine::source() const {
if (VL_UNCOVERABLE(!m_contentp)) {
if (VL_UNCOVERABLE(!m_contentp)) { // LCOV_EXCL_START
if (debug() || v3Global.opt.debugCheck()) {
// The newline here is to work around the " <line#> | "
return "\n%Error: internal tracking of file contents failed";
} else {
return "";
}
}
} // LCOV_EXCL_STOP
return m_contentp->getLine(m_contentLineno);
}
string FileLine::prettySource() const {

View File

@ -329,9 +329,9 @@ void V3Options::fileNfsFlush(const string& filename) {
// NFS caches stat() calls so to get up-to-date information must
// do a open or opendir on the filename.
// Faster to just try both rather than check if a file is a dir.
if (DIR* dirp = opendir(filename.c_str())) {
if (DIR* dirp = opendir(filename.c_str())) { // LCOV_EXCL_BR_LINE
closedir(dirp); // LCOV_EXCL_LINE
} else if (int fd = ::open(filename.c_str(), O_RDONLY)) {
} else if (int fd = ::open(filename.c_str(), O_RDONLY)) { // LCOV_EXCL_BR_LINE
if (fd > 0) ::close(fd);
}
}
@ -667,13 +667,13 @@ string V3Options::protectKeyDefaulted() {
return m_protectKey;
}
void V3Options::throwSigsegv() {
void V3Options::throwSigsegv() { // LCOV_EXCL_START
#if !(defined(VL_CPPCHECK) || defined(__clang_analyzer__))
// clang-format off
{ char* zp = NULL; *zp = 0; } // Intentional core dump, ignore warnings here
// clang-format on
#endif
}
} // LCOV_EXCL_STOP
VTimescale V3Options::timeComputePrec(const VTimescale& flag) const {
if (!timeOverridePrec().isNone()) {