covoar/reports: Add new statistics to summary

The following new statistics have been added to the summary report:
number of unreferenced symbols, total branch paths found, number of
branch paths not executed, and percentage of branch paths covered.
This commit is contained in:
Alex White
2021-02-25 10:35:39 -06:00
committed by Joel Sherrill
parent 7d14bb83e0
commit 4aabd9bbf7
4 changed files with 91 additions and 22 deletions

View File

@@ -175,6 +175,8 @@ namespace Coverage {
s.second.stats.uncoveredBytes++; s.second.stats.uncoveredBytes++;
} }
} }
} else {
stats.unreferencedSymbols++;
} }
} }
} }
@@ -470,10 +472,18 @@ namespace Coverage {
return stats.branchesNeverTaken; return stats.branchesNeverTaken;
}; };
uint32_t DesiredSymbols::getNumberBranchesNotExecuted( void ) const {
return stats.branchesNotExecuted;
};
uint32_t DesiredSymbols::getNumberUncoveredRanges( void ) const { uint32_t DesiredSymbols::getNumberUncoveredRanges( void ) const {
return stats.uncoveredRanges; return stats.uncoveredRanges;
}; };
uint32_t DesiredSymbols::getNumberUnreferencedSymbols( void ) const {
return stats.unreferencedSymbols;
};
bool DesiredSymbols::isDesired ( bool DesiredSymbols::isDesired (
const std::string& symbolName const std::string& symbolName
) const ) const

View File

@@ -82,6 +82,11 @@ namespace Coverage {
*/ */
int uncoveredRanges; int uncoveredRanges;
/*!
* This member variable contains the total number of unreferenced symbols.
*/
int unreferencedSymbols;
/*! /*!
* This method returns the percentage of uncovered instructions. * This method returns the percentage of uncovered instructions.
* *
@@ -109,7 +114,8 @@ namespace Coverage {
sizeInInstructions(0), sizeInInstructions(0),
uncoveredBytes(0), uncoveredBytes(0),
uncoveredInstructions(0), uncoveredInstructions(0),
uncoveredRanges(0) uncoveredRanges(0),
unreferencedSymbols(0)
{ {
} }
@@ -278,6 +284,14 @@ namespace Coverage {
*/ */
uint32_t getNumberBranchesNeverTaken( void ) const; uint32_t getNumberBranchesNeverTaken( void ) const;
/*!
* This method returns the total number of branches not executed
* for all analyzed symbols.
*
* @return Returns the total number of branches not executed
*/
uint32_t getNumberBranchesNotExecuted( void ) const;
/*! /*!
* This method returns the total number of uncovered ranges * This method returns the total number of uncovered ranges
* for all analyzed symbols. * for all analyzed symbols.
@@ -286,6 +300,14 @@ namespace Coverage {
*/ */
uint32_t getNumberUncoveredRanges( void ) const; uint32_t getNumberUncoveredRanges( void ) const;
/*!
* This method returns the total number of unreferenced symbols
* for all analyzed symbols.
*
* @return Returns the total number of unreferenced symbols
*/
uint32_t getNumberUnreferencedSymbols( void ) const;
/*! /*!
* This method returns an indication of whether or not the specified * This method returns an indication of whether or not the specified
* symbol is a symbol to analyze. * symbol is a symbol to analyze.

View File

@@ -441,6 +441,7 @@ void ReportsBase::WriteSummaryReport(
Coverage::DesiredSymbols::symbolSet_t::iterator itr; Coverage::DesiredSymbols::symbolSet_t::iterator itr;
uint32_t notExecuted = 0; uint32_t notExecuted = 0;
double percentage; double percentage;
double percentageBranches;
Coverage::CoverageMapBase* theCoverageMap; Coverage::CoverageMapBase* theCoverageMap;
uint32_t totalBytes = 0; uint32_t totalBytes = 0;
FILE* report; FILE* report;
@@ -475,13 +476,26 @@ void ReportsBase::WriteSummaryReport(
percentage /= (double) totalBytes; percentage /= (double) totalBytes;
percentage *= 100.0; percentage *= 100.0;
fprintf( report, "Bytes Analyzed : %d\n", totalBytes ); percentageBranches = (double) (
fprintf( report, "Bytes Not Executed : %d\n", notExecuted ); SymbolsToAnalyze->getNumberBranchesAlwaysTaken() +
fprintf( report, "Percentage Executed : %5.4g\n", 100.0 - percentage ); SymbolsToAnalyze->getNumberBranchesNeverTaken() +
fprintf( report, "Percentage Not Executed : %5.4g\n", percentage ); (SymbolsToAnalyze->getNumberBranchesNotExecuted() * 2)
);
percentageBranches /= (double) SymbolsToAnalyze->getNumberBranchesFound() * 2;
percentageBranches *= 100.0;
fprintf( report, "Bytes Analyzed : %d\n", totalBytes );
fprintf( report, "Bytes Not Executed : %d\n", notExecuted );
fprintf( report, "Percentage Executed : %5.4g\n", 100.0 - percentage );
fprintf( report, "Percentage Not Executed : %5.4g\n", percentage );
fprintf( fprintf(
report, report,
"Uncovered ranges found : %d\n", "Unreferenced Symbols : %d\n",
SymbolsToAnalyze->getNumberUnreferencedSymbols()
);
fprintf(
report,
"Uncovered ranges found : %d\n\n",
SymbolsToAnalyze->getNumberUncoveredRanges() SymbolsToAnalyze->getNumberUncoveredRanges()
); );
if ((SymbolsToAnalyze->getNumberBranchesFound() == 0) || if ((SymbolsToAnalyze->getNumberBranchesFound() == 0) ||
@@ -490,14 +504,20 @@ void ReportsBase::WriteSummaryReport(
} else { } else {
fprintf( fprintf(
report, report,
"Total branches found : %d\n", "Total conditional branches found : %d\n",
SymbolsToAnalyze->getNumberBranchesFound() SymbolsToAnalyze->getNumberBranchesFound()
); );
fprintf( fprintf(
report, report,
"Uncovered branches found : %d\n", "Total branch paths found : %d\n",
SymbolsToAnalyze->getNumberBranchesFound() * 2
);
fprintf(
report,
"Uncovered branch paths found : %d\n",
SymbolsToAnalyze->getNumberBranchesAlwaysTaken() + SymbolsToAnalyze->getNumberBranchesAlwaysTaken() +
SymbolsToAnalyze->getNumberBranchesNeverTaken() SymbolsToAnalyze->getNumberBranchesNeverTaken() +
(SymbolsToAnalyze->getNumberBranchesNotExecuted() * 2)
); );
fprintf( fprintf(
report, report,
@@ -509,6 +529,16 @@ void ReportsBase::WriteSummaryReport(
" %d branches never taken\n", " %d branches never taken\n",
SymbolsToAnalyze->getNumberBranchesNeverTaken() SymbolsToAnalyze->getNumberBranchesNeverTaken()
); );
fprintf(
report,
" %d branch paths not executed\n",
SymbolsToAnalyze->getNumberBranchesNotExecuted() * 2
);
fprintf(
report,
"Percentage branch paths covered : %4.4g\n",
100.0 - percentageBranches
);
} }
} }

View File

@@ -56,6 +56,7 @@ class summary:
self.bytes_not_executed = 0 self.bytes_not_executed = 0
self.percentage_executed = 0.0 self.percentage_executed = 0.0
self.percentage_not_executed = 100.0 self.percentage_not_executed = 100.0
self.unreferenced_symbols = 0
self.ranges_uncovered = 0 self.ranges_uncovered = 0
self.branches_uncovered = 0 self.branches_uncovered = 0
self.branches_total = 0 self.branches_total = 0
@@ -74,7 +75,10 @@ class summary:
self.bytes_not_executed = self._get_next_with_colon(summary_file) self.bytes_not_executed = self._get_next_with_colon(summary_file)
self.percentage_executed = self._get_next_with_colon(summary_file) self.percentage_executed = self._get_next_with_colon(summary_file)
self.percentage_not_executed = self._get_next_with_colon(summary_file) self.percentage_not_executed = self._get_next_with_colon(summary_file)
self.unreferenced_symbols = self._get_next_with_colon(summary_file)
self.ranges_uncovered = self._get_next_with_colon(summary_file) self.ranges_uncovered = self._get_next_with_colon(summary_file)
summary_file.readline()
summary_file.readline()
self.branches_total = self._get_next_with_colon(summary_file) self.branches_total = self._get_next_with_colon(summary_file)
self.branches_uncovered = self._get_next_with_colon(summary_file) self.branches_uncovered = self._get_next_with_colon(summary_file)
self.branches_always_taken = self._get_next_without_colon(summary_file) self.branches_always_taken = self._get_next_without_colon(summary_file)
@@ -153,6 +157,7 @@ class report_gen_html:
+ '</td>' + os.linesep + '</td>' + os.linesep
row += ' <td>' + summary.bytes_analyzed + '</td>' + os.linesep row += ' <td>' + summary.bytes_analyzed + '</td>' + os.linesep
row += ' <td>' + summary.bytes_not_executed + '</td>' + os.linesep row += ' <td>' + summary.bytes_not_executed + '</td>' + os.linesep
row += ' <td>' + summary.unreferenced_symbols + '</td>' + os.linesep
row += ' <td>' + summary.ranges_uncovered + '</td>' + os.linesep row += ' <td>' + summary.ranges_uncovered + '</td>' + os.linesep
row += ' <td>' + summary.percentage_executed + '%</td>' + os.linesep row += ' <td>' + summary.percentage_executed + '%</td>' + os.linesep
row += ' <td>' + summary.percentage_not_executed + '%</td>' + os.linesep row += ' <td>' + summary.percentage_not_executed + '%</td>' + os.linesep
@@ -168,19 +173,21 @@ class report_gen_html:
def _header_row(self): def _header_row(self):
row = "<tr>" + os.linesep row = "<tr>" + os.linesep
row += " <th> Symbols set name </th>" + os.linesep rowAttributes = "class=\"table-sortable:default table-sortable\" title=\"Click to sort\""
row += " <th> Index file </th>" + os.linesep row += " <th " + rowAttributes + "> Symbols set name </th>" + os.linesep
row += " <th> Summary file </th>" + os.linesep row += " <th " + rowAttributes + "> Index file </th>" + os.linesep
row += " <th> Bytes analyzed </th>" + os.linesep row += " <th " + rowAttributes + "> Summary file </th>" + os.linesep
row += " <th> Bytes not executed </th>" + os.linesep row += " <th " + rowAttributes + "> Bytes analyzed </th>" + os.linesep
row += " <th> Uncovered ranges </th>" + os.linesep row += " <th " + rowAttributes + "> Bytes not executed </th>" + os.linesep
row += " <th> Percentage covered </th>" + os.linesep row += " <th " + rowAttributes + "> Unreferenced symbols </th>" + os.linesep
row += " <th> Percentage uncovered </th>" + os.linesep row += " <th " + rowAttributes + "> Uncovered ranges </th>" + os.linesep
row += " <th> Instruction coverage </th>" + os.linesep row += " <th " + rowAttributes + "> Percentage covered </th>" + os.linesep
row += " <th> Branches uncovered </th>" + os.linesep row += " <th " + rowAttributes + "> Percentage uncovered </th>" + os.linesep
row += " <th> Branches total </th>" + os.linesep row += " <th " + rowAttributes + "> Instruction coverage </th>" + os.linesep
row += " <th> Branches covered percentage </th>" + os.linesep row += " <th " + rowAttributes + "> Branches uncovered </th>" + os.linesep
row += " <th> Branches coverage </th>" + os.linesep row += " <th " + rowAttributes + "> Branches total </th>" + os.linesep
row += " <th " + rowAttributes + "> Branches covered percentage </th>" + os.linesep
row += " <th " + rowAttributes + "> Branch coverage </th>" + os.linesep
row += "</tr>" row += "</tr>"
self.number_of_columns = row.count('<th>') self.number_of_columns = row.count('<th>')
return row return row