[rtems-tools commit] covoar/reports: Add new statistics to summary

Joel Sherrill joel at rtems.org
Tue Mar 30 18:20:47 UTC 2021


Module:    rtems-tools
Branch:    master
Commit:    4aabd9bbf742f04a53331064dc0692b91d4d3a6c
Changeset: http://git.rtems.org/rtems-tools/commit/?id=4aabd9bbf742f04a53331064dc0692b91d4d3a6c

Author:    Alex White <alex.white at oarcorp.com>
Date:      Thu Feb 25 10:35:39 2021 -0600

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.

---

 tester/covoar/DesiredSymbols.cc | 10 +++++++++
 tester/covoar/DesiredSymbols.h  | 24 ++++++++++++++++++++-
 tester/covoar/ReportsBase.cc    | 46 ++++++++++++++++++++++++++++++++++-------
 tester/rt/coverage.py           | 33 +++++++++++++++++------------
 4 files changed, 91 insertions(+), 22 deletions(-)

diff --git a/tester/covoar/DesiredSymbols.cc b/tester/covoar/DesiredSymbols.cc
index c97b25c..ffc4f86 100644
--- a/tester/covoar/DesiredSymbols.cc
+++ b/tester/covoar/DesiredSymbols.cc
@@ -175,6 +175,8 @@ namespace Coverage {
             s.second.stats.uncoveredBytes++;
           }
         }
+      } else {
+        stats.unreferencedSymbols++;
       }
     }
   }
@@ -470,10 +472,18 @@ namespace Coverage {
     return stats.branchesNeverTaken;
   };
 
+  uint32_t DesiredSymbols::getNumberBranchesNotExecuted( void ) const {
+    return stats.branchesNotExecuted;
+  };
+
   uint32_t DesiredSymbols::getNumberUncoveredRanges( void ) const {
     return stats.uncoveredRanges;
   };
 
+  uint32_t DesiredSymbols::getNumberUnreferencedSymbols( void ) const {
+    return stats.unreferencedSymbols;
+  };
+
   bool DesiredSymbols::isDesired (
     const std::string& symbolName
   ) const
diff --git a/tester/covoar/DesiredSymbols.h b/tester/covoar/DesiredSymbols.h
index 367ca95..5cf96e9 100644
--- a/tester/covoar/DesiredSymbols.h
+++ b/tester/covoar/DesiredSymbols.h
@@ -83,6 +83,11 @@ namespace Coverage {
     int uncoveredRanges;
 
     /*!
+     *  This member variable contains the total number of unreferenced symbols.
+     */
+    int unreferencedSymbols;
+
+    /*!
      *  This method returns the percentage of uncovered instructions.
      *
      *  @return Returns the percent uncovered instructions
@@ -109,7 +114,8 @@ namespace Coverage {
        sizeInInstructions(0),
        uncoveredBytes(0),
        uncoveredInstructions(0),
-       uncoveredRanges(0)
+       uncoveredRanges(0),
+       unreferencedSymbols(0)
      {
      }
 
@@ -279,6 +285,14 @@ namespace Coverage {
     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
      *  for all analyzed symbols.
      *
@@ -287,6 +301,14 @@ namespace Coverage {
     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
      *  symbol is a symbol to analyze.
      *
diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc
index 0244601..0be5567 100644
--- a/tester/covoar/ReportsBase.cc
+++ b/tester/covoar/ReportsBase.cc
@@ -441,6 +441,7 @@ void  ReportsBase::WriteSummaryReport(
   Coverage::DesiredSymbols::symbolSet_t::iterator itr;
   uint32_t                                        notExecuted = 0;
   double                                          percentage;
+  double                                          percentageBranches;
   Coverage::CoverageMapBase*                      theCoverageMap;
   uint32_t                                        totalBytes = 0;
   FILE*                                           report;
@@ -475,13 +476,26 @@ void  ReportsBase::WriteSummaryReport(
   percentage /= (double) totalBytes;
   percentage *= 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  );
+  percentageBranches = (double) (
+    SymbolsToAnalyze->getNumberBranchesAlwaysTaken() +
+      SymbolsToAnalyze->getNumberBranchesNeverTaken() +
+      (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(
     report,
-    "Uncovered ranges found   : %d\n",
+    "Unreferenced Symbols             : %d\n",
+    SymbolsToAnalyze->getNumberUnreferencedSymbols()
+  );
+  fprintf(
+    report,
+    "Uncovered ranges found           : %d\n\n",
     SymbolsToAnalyze->getNumberUncoveredRanges()
   );
   if ((SymbolsToAnalyze->getNumberBranchesFound() == 0) ||
@@ -490,14 +504,20 @@ void  ReportsBase::WriteSummaryReport(
   } else {
     fprintf(
       report,
-      "Total branches found     : %d\n",
+      "Total conditional branches found : %d\n",
       SymbolsToAnalyze->getNumberBranchesFound()
     );
     fprintf(
       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->getNumberBranchesNeverTaken()
+       SymbolsToAnalyze->getNumberBranchesNeverTaken() +
+       (SymbolsToAnalyze->getNumberBranchesNotExecuted() * 2)
     );
     fprintf(
       report,
@@ -509,6 +529,16 @@ void  ReportsBase::WriteSummaryReport(
       "   %d branches never taken\n",
       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
+    );
   }
 }
 
diff --git a/tester/rt/coverage.py b/tester/rt/coverage.py
index e2a5161..8d176c3 100644
--- a/tester/rt/coverage.py
+++ b/tester/rt/coverage.py
@@ -56,6 +56,7 @@ class summary:
         self.bytes_not_executed = 0
         self.percentage_executed = 0.0
         self.percentage_not_executed = 100.0
+        self.unreferenced_symbols = 0
         self.ranges_uncovered = 0
         self.branches_uncovered = 0
         self.branches_total = 0
@@ -74,7 +75,10 @@ class summary:
            self.bytes_not_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.unreferenced_symbols = 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_uncovered = self._get_next_with_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
             row += ' <td>' + summary.bytes_analyzed + '</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.percentage_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):
         row = "<tr>" + os.linesep
-        row += " <th> Symbols set name </th>" + os.linesep
-        row += " <th> Index file </th>" + os.linesep
-        row += " <th> Summary file </th>" + os.linesep
-        row += " <th> Bytes analyzed </th>" + os.linesep
-        row += " <th> Bytes not executed </th>" + os.linesep
-        row += " <th> Uncovered ranges </th>" + os.linesep
-        row += " <th> Percentage covered </th>" + os.linesep
-        row += " <th> Percentage uncovered </th>" + os.linesep
-        row += " <th> Instruction coverage </th>" + os.linesep
-        row += " <th> Branches uncovered </th>" + os.linesep
-        row += " <th> Branches total </th>" + os.linesep
-        row += " <th> Branches covered percentage </th>" + os.linesep
-        row += " <th> Branches coverage </th>" + os.linesep
+        rowAttributes = "class=\"table-sortable:default table-sortable\" title=\"Click to sort\""
+        row += " <th " + rowAttributes + "> Symbols set name </th>" + os.linesep
+        row += " <th " + rowAttributes + "> Index file </th>" + os.linesep
+        row += " <th " + rowAttributes + "> Summary file </th>" + os.linesep
+        row += " <th " + rowAttributes + "> Bytes analyzed </th>" + os.linesep
+        row += " <th " + rowAttributes + "> Bytes not executed </th>" + os.linesep
+        row += " <th " + rowAttributes + "> Unreferenced symbols </th>" + os.linesep
+        row += " <th " + rowAttributes + "> Uncovered ranges </th>" + os.linesep
+        row += " <th " + rowAttributes + "> Percentage covered </th>" + os.linesep
+        row += " <th " + rowAttributes + "> Percentage uncovered </th>" + os.linesep
+        row += " <th " + rowAttributes + "> Instruction coverage </th>" + os.linesep
+        row += " <th " + rowAttributes + "> Branches uncovered </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>"
         self.number_of_columns = row.count('<th>')
         return row



More information about the vc mailing list