From 9a26d2a57b3f135c46ca30f23d21dc45a522a54b Mon Sep 17 00:00:00 2001 From: Ryan Long Date: Tue, 13 Jul 2021 14:05:33 -0400 Subject: ReportsHtml.cc: Fix formatting --- tester/covoar/ReportsHtml.cc | 232 ++++++++++++++++++++++--------------------- 1 file changed, 120 insertions(+), 112 deletions(-) diff --git a/tester/covoar/ReportsHtml.cc b/tester/covoar/ReportsHtml.cc index f9bd21f..53ee0c1 100644 --- a/tester/covoar/ReportsHtml.cc +++ b/tester/covoar/ReportsHtml.cc @@ -34,8 +34,10 @@ namespace Coverage { - ReportsHtml::ReportsHtml( time_t timestamp, const std::string& symbolSetName ): - ReportsBase( timestamp, symbolSetName ) + ReportsHtml::ReportsHtml( + time_t timestamp, + const std::string& symbolSetName + ): ReportsBase( timestamp, symbolSetName ) { reportExtension_m = ".html"; } @@ -44,9 +46,7 @@ namespace Coverage { { } - void ReportsHtml::WriteIndex( - const std::string& fileName - ) + void ReportsHtml::WriteIndex( const std::string& fileName ) { std::ofstream aFile; #define PRINT_ITEM( _t, _n ) \ @@ -61,13 +61,14 @@ namespace Coverage { // Open the file - OpenFile(fileName, aFile); + OpenFile( fileName, aFile ); aFile << "Index" << std::endl << "
"; - if (projectName) + if ( projectName ) { aFile << projectName << "
"; + } aFile << "Coverage Analysis Reports
" << std::endl << "
" @@ -98,7 +99,7 @@ namespace Coverage { ) { // Open the file - ReportsBase::OpenFile(fileName, symbolSetName_m, aFile); + ReportsBase::OpenFile( fileName, symbolSetName_m, aFile ); // Put Header information on the file aFile << "" << std::endl @@ -118,13 +119,14 @@ namespace Coverage { ) { // Open the file - OpenFile(fileName, aFile); + OpenFile( fileName, aFile ); aFile << "Annotated Report" << std::endl << "
"; - if (projectName) + if ( projectName ) { aFile << projectName << "
"; + } aFile << "Annotated Report
" << std::endl << "
" @@ -140,14 +142,15 @@ namespace Coverage { ) { // Open the file - OpenFile(fileName, aFile); + OpenFile( fileName, aFile ); // Put header information into the file aFile << "Branch Report" << std::endl << "
"; - if (projectName) + if ( projectName ) { aFile << projectName << "
"; + } aFile << "Branch Report
" << std::endl << "
" @@ -185,14 +188,15 @@ namespace Coverage { ) { // Open the file - OpenFile(fileName, aFile); + OpenFile( fileName, aFile ); // Put header information into the file aFile << "Coverage Report" << std::endl << "
"; - if (projectName) + if ( projectName ) { aFile << projectName << "
"; + } aFile << "Coverage Report
" << std::endl << "
" @@ -227,14 +231,15 @@ namespace Coverage { ) { // Open the file - OpenFile(fileName, aFile); + OpenFile( fileName, aFile ); // Put header information into the file aFile << " Report" << std::endl << "
"; - if (projectName) + if ( projectName ) { aFile << projectName << "
"; + } aFile << "No Range Report
" << std::endl << "
" @@ -259,14 +264,15 @@ namespace Coverage { ) { // Open the file - OpenFile(fileName, aFile); + OpenFile( fileName, aFile ); // Put header information into the file aFile << "Uncovered Range Size Report" << std::endl << "
"; - if (projectName) + if ( projectName ) { aFile << projectName << "
"; + } aFile << "Uncovered Range Size Report
" << std::endl << "
" @@ -295,14 +301,15 @@ namespace Coverage { ) { // Open the file - OpenFile(fileName, aFile); + OpenFile( fileName, aFile ); // Put header information into the file aFile << "Symbol Summary Report" << std::endl << "
"; - if (projectName) + if ( projectName ) { aFile << projectName << "
"; + } aFile << "Symbol Summary Report
" << std::endl << "
" @@ -361,33 +368,33 @@ namespace Coverage { number = std::to_string( id ); // Set the stateText based upon the current state. - switch (state) { - case A_SOURCE: + switch ( state ) { + case A_SOURCE: stateText = "\n
\n";
         break;
-      case  A_EXECUTED:
+      case A_EXECUTED:
         stateText = "
\n
\n";
         break;
-      case  A_NEVER_EXECUTED:
+      case A_NEVER_EXECUTED:
         stateText = "
\n"; stateText += "
\n";
         break;
-      case  A_BRANCH_TAKEN:
+      case A_BRANCH_TAKEN:
         stateText = "
\n"; stateText += "
\n";
         break;
-      case  A_BRANCH_NOT_TAKEN:
+      case A_BRANCH_NOT_TAKEN:
         stateText = "
\n"; stateText += "
\n";
         break;
       default:
-        throw rld::error("Unknown state", "ReportsHtml::PutAnnotatedLine");
+        throw rld::error( "Unknown state", "ReportsHtml::PutAnnotatedLine" );
         break;
     }
 
@@ -402,33 +409,36 @@ namespace Coverage {
     // For all the characters in the line replace html reserved special
     // characters and output the line. Note that for a /pre block this
     // is only a '<' symbol.
-    for (unsigned int i=0; igetNumberBranchesFound(symbolSetName_m) != 0)
+    if (
+      BranchInfoAvailable &&
+      SymbolsToAnalyze->getNumberBranchesFound( symbolSetName_m ) != 0
+    ) {
       report << "All branch paths taken." << std::endl;
-    else
+    } else {
       report << "No branch information found." << std::endl;
+    }
+
     return true;
   }
 
   bool ReportsHtml::PutBranchEntry(
-    std::ofstream&                                   report,
-    unsigned int                                     count,
-    const std::string&                               symbolName,
-    const SymbolInformation&                         symbolInfo,
-    const CoverageRanges::coverageRange_t&           range
+    std::ofstream&                         report,
+    unsigned int                           count,
+    const std::string&                     symbolName,
+    const SymbolInformation&               symbolInfo,
+    const CoverageRanges::coverageRange_t& range
   )
   {
     const Coverage::Explanation* explanation;
@@ -439,10 +449,11 @@ namespace Coverage {
     Coverage::CoverageMapBase*   theCoverageMap = NULL;
 
     // Mark the background color different for odd and even lines.
-    if ( ( count%2 ) != 0 )
+    if ( ( count % 2 ) != 0 ) {
       report << "\n";
-    else
+    } else {
       report << "" << std::endl;
+    }
 
     // symbol
     report << ""
@@ -454,8 +465,8 @@ namespace Coverage {
            << range.lowSourceLine << "" << std::endl;
 
     // File
-    i = range.lowSourceLine.find(":");
-    temp =  range.lowSourceLine.substr (0, i);
+    i = range.lowSourceLine.find( ":" );
+    temp = range.lowSourceLine.substr( 0, i );
     report << ""
            << temp << "" << std::endl;
 
@@ -464,18 +475,23 @@ namespace Coverage {
            << range.highAddress - range.lowAddress + 1 << "" << std::endl;
 
     // Reason Branch was uncovered
-    if (range.reason ==
-      Coverage::CoverageRanges::UNCOVERED_REASON_BRANCH_ALWAYS_TAKEN)
+    if (
+      range.reason ==
+      Coverage::CoverageRanges::UNCOVERED_REASON_BRANCH_ALWAYS_TAKEN
+    ) {
       report << "Always Taken"
              << std::endl;
-    else if (range.reason ==
-      Coverage::CoverageRanges::UNCOVERED_REASON_BRANCH_NEVER_TAKEN)
+    } else if (
+      range.reason ==
+      Coverage::CoverageRanges::UNCOVERED_REASON_BRANCH_NEVER_TAKEN
+    ) {
       report << "Never Taken"
              << std::endl;
+    }
 
     // Taken / Not taken counts
-    lowAddress = range.lowAddress;
-    bAddress = symbolInfo.baseAddress;
+    lowAddress     = range.lowAddress;
+    bAddress       = symbolInfo.baseAddress;
     theCoverageMap = symbolInfo.unifiedCoverageMap;
 
     report << ""
@@ -519,9 +535,9 @@ namespace Coverage {
   {
     std::ofstream report;
 
-    OpenFile(fileName, report);
+    OpenFile( fileName, report );
 
-    for ( unsigned int i=0 ; i < explanation->explanation.size(); i++) {
+    for ( unsigned int i=0 ; i < explanation->explanation.size(); i++ ) {
       report << explanation->explanation[i] << std::endl;
     }
     CloseFile( report );
@@ -531,7 +547,7 @@ namespace Coverage {
   void ReportsHtml::putCoverageNoRange(
     std::ofstream&     report,
     std::ofstream&     noRangeFile,
-    unsigned int  count,
+    unsigned int       count,
     const std::string& symbol
   )
   {
@@ -547,7 +563,7 @@ namespace Coverage {
     );
 
     // Mark the background color different for odd and even lines.
-    if ( ( count%2 ) != 0 ){
+    if ( ( count % 2 ) != 0 ) {
       report << "" << std::endl;
       noRangeFile << "" << std::endl;
     } else {
@@ -591,22 +607,23 @@ namespace Coverage {
   }
 
   bool ReportsHtml::PutCoverageLine(
-    std::ofstream&                                   report,
-    unsigned int                                     count,
-    const std::string&                               symbolName,
-    const SymbolInformation&                         symbolInfo,
-    const CoverageRanges::coverageRange_t&           range
+    std::ofstream&                         report,
+    unsigned int                           count,
+    const std::string&                     symbolName,
+    const SymbolInformation&               symbolInfo,
+    const CoverageRanges::coverageRange_t& range
   )
   {
-    const Coverage::Explanation*   explanation;
-    std::string                    temp;
-    int                            i;
+    const Coverage::Explanation* explanation;
+    std::string                  temp;
+    int                          i;
 
     // Mark the background color different for odd and even lines.
-    if ( ( count% 2) != 0 )
+    if ( ( count % 2) != 0 ) {
       report << "" << std::endl;
-    else
+    } else {
       report << "" << std::endl;
+    }
 
     // symbol
     report << ""
@@ -619,8 +636,8 @@ namespace Coverage {
            << range.highSourceLine << "" << std::endl;
 
     // File
-    i = range.lowSourceLine.find(":");
-    temp =  range.lowSourceLine.substr (0, i);
+    i = range.lowSourceLine.find( ":" );
+    temp = range.lowSourceLine.substr( 0, i );
 
     report << ""
            << temp << "" << std::endl;
@@ -661,20 +678,21 @@ namespace Coverage {
   }
 
   bool  ReportsHtml::PutSizeLine(
-    std::ofstream&                                  report,
-    unsigned int                                    count,
-    const std::string&                              symbolName,
-    const CoverageRanges::coverageRange_t&          range
+    std::ofstream&                         report,
+    unsigned int                           count,
+    const std::string&                     symbolName,
+    const CoverageRanges::coverageRange_t& range
   )
   {
-    std::string  temp;
-    int          i;
+    std::string temp;
+    int         i;
 
     // Mark the background color different for odd and even lines.
-    if ( ( count%2 ) != 0 )
+    if ( ( count % 2 ) != 0 ) {
       report << "" << std::endl;
-    else
+    } else {
       report << "" << std::endl;
+    }
 
     // size
     report << ""
@@ -690,8 +708,8 @@ namespace Coverage {
            << range.lowSourceLine << "" << std::endl;
 
     // File
-    i = range.lowSourceLine.find(":");
-    temp =  range.lowSourceLine.substr (0, i);
+    i = range.lowSourceLine.find( ":" );
+    temp =  range.lowSourceLine.substr( 0, i );
     report << ""
            << temp << "" << std::endl
            << "" << std::endl;
@@ -700,24 +718,25 @@ namespace Coverage {
   }
 
   bool  ReportsHtml::PutSymbolSummaryLine(
-    std::ofstream&                                  report,
-    unsigned int                                    count,
-    const std::string&                              symbolName,
-    const SymbolInformation&                        symbolInfo
+    std::ofstream&           report,
+    unsigned int             count,
+    const std::string&       symbolName,
+    const SymbolInformation& symbolInfo
   )
   {
 
     // Mark the background color different for odd and even lines.
-    if ( ( count%2 ) != 0 )
+    if ( ( count % 2 ) != 0 ) {
       report << "" << std::endl;
-    else
+    } else {
       report << "" << std::endl;
+    }
 
     // symbol
     report << ""
            << symbolName << "" << std::endl;
 
-    if (symbolInfo.stats.sizeInBytes == 0) {
+    if ( symbolInfo.stats.sizeInBytes == 0 ) {
       // The symbol has never been seen. Write "unknown" for all columns.
       report << "unknown"
              << std::endl
@@ -775,57 +794,52 @@ namespace Coverage {
              << symbolInfo.stats.branchesNeverTaken << "" << std::endl;
 
       // % Uncovered Instructions
-      if ( symbolInfo.stats.sizeInInstructions == 0 )
+      if ( symbolInfo.stats.sizeInInstructions == 0 ) {
         report << "100.00"
                << std::endl;
-      else
+      } else {
         report << ""
                << std::fixed << std::setprecision( 2 )
                << ( symbolInfo.stats.uncoveredInstructions * 100.0 ) /
                     symbolInfo.stats.sizeInInstructions
                << "" << std::endl;
+      }
 
       // % Uncovered Bytes
-      if ( symbolInfo.stats.sizeInBytes == 0 )
+      if ( symbolInfo.stats.sizeInBytes == 0 ) {
         report << "100.00"
                << std::endl;
-      else
+      } else {
         report << ""
                << ( symbolInfo.stats.uncoveredBytes * 100.0 ) /
                     symbolInfo.stats.sizeInBytes
                << "" << std::endl;
+      }
     }
 
     report << "" << std::endl;
     return true;
   }
 
-  void ReportsHtml::CloseAnnotatedFile(
-    std::ofstream& aFile
-  )
+  void ReportsHtml::CloseAnnotatedFile( std::ofstream& aFile )
   {
     aFile << "
" << std::endl << "" << std::endl << "" << std::endl; - CloseFile(aFile); + CloseFile( aFile ); } - void ReportsHtml::CloseBranchFile( - std::ofstream& aFile, - bool hasBranches - ) + void ReportsHtml::CloseBranchFile( std::ofstream& aFile, bool hasBranches ) { aFile << TABLE_FOOTER << "" << std::endl << "" << std::endl; - CloseFile(aFile); + CloseFile( aFile ); } - void ReportsHtml::CloseCoverageFile( - std::ofstream& aFile - ) + void ReportsHtml::CloseCoverageFile( std::ofstream& aFile ) { aFile << TABLE_FOOTER << "" << std::endl @@ -834,12 +848,10 @@ namespace Coverage { << "" << std::endl << ""; - CloseFile(aFile); + CloseFile( aFile ); } - void ReportsHtml::CloseNoRangeFile( - std::ofstream& aFile - ) + void ReportsHtml::CloseNoRangeFile( std::ofstream& aFile ) { aFile << TABLE_FOOTER << "" << std::endl @@ -848,13 +860,11 @@ namespace Coverage { << "" << std::endl << ""; - CloseFile(aFile); + CloseFile( aFile ); } - void ReportsHtml::CloseSizeFile( - std::ofstream& aFile - ) + void ReportsHtml::CloseSizeFile( std::ofstream& aFile ) { aFile << TABLE_FOOTER << "" << std::endl @@ -863,12 +873,10 @@ namespace Coverage { << "" << std::endl << ""; - CloseFile(aFile); + CloseFile( aFile ); } - void ReportsHtml::CloseSymbolSummaryFile( - std::ofstream& aFile - ) + void ReportsHtml::CloseSymbolSummaryFile( std::ofstream& aFile ) { aFile << TABLE_FOOTER << "" << std::endl -- cgit v1.2.3