Browse Source

ENH: add test output to valgrind output and truncate output for valgrind

Bill Hoffman 18 years ago
parent
commit
3017259ac4
1 changed files with 42 additions and 3 deletions
  1. 42 3
      Source/CTest/cmCTestMemCheckHandler.cxx

+ 42 - 3
Source/CTest/cmCTestMemCheckHandler.cxx

@@ -644,7 +644,13 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
 {
 {
   std::vector<cmStdString> lines;
   std::vector<cmStdString> lines;
   cmSystemTools::Split(str.c_str(), lines);
   cmSystemTools::Split(str.c_str(), lines);
-
+  bool unlimitedOutput = false;
+  if(str.find("CTEST_FULL_OUTPUT") != str.npos ||
+    this->CustomMaximumFailedTestOutputSize == 0)
+    {
+    unlimitedOutput = true;
+    }
+  
   std::string::size_type cc;
   std::string::size_type cc;
 
 
   cmOStringStream ostr;
   cmOStringStream ostr;
@@ -680,9 +686,11 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
   cmsys::RegularExpression vgIPW("== .*Invalid write of size [0-9]");
   cmsys::RegularExpression vgIPW("== .*Invalid write of size [0-9]");
   cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is "
   cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is "
     "locked by a different thread");
     "locked by a different thread");
-
+  std::vector<std::string::size_type> nonValGrindOutput;
   double sttime = cmSystemTools::GetTime();
   double sttime = cmSystemTools::GetTime();
   cmCTestLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl);
   cmCTestLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl);
+  std::string::size_type totalOutputSize = 0;
+  bool outputFull = false;
   for ( cc = 0; cc < lines.size(); cc ++ )
   for ( cc = 0; cc < lines.size(); cc ++ )
     {
     {
     if ( valgrindLine.find(lines[cc]) )
     if ( valgrindLine.find(lines[cc]) )
@@ -747,7 +755,38 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
         results[failure] ++;
         results[failure] ++;
         defects ++;
         defects ++;
         }
         }
-      ostr << cmCTest::MakeXMLSafe(lines[cc]) << std::endl;
+      if(!outputFull)
+        {
+        totalOutputSize += lines[cc].size();
+        ostr << cmCTest::MakeXMLSafe(lines[cc]) << std::endl;
+        if(totalOutputSize > 
+           static_cast<size_t>(this->CustomMaximumFailedTestOutputSize))
+          {
+          outputFull = true;
+          }
+        }
+      } 
+    else
+      {
+      nonValGrindOutput.push_back(cc);
+      }
+    }
+  // Now put all all the non valgrind output into the test output
+  if(!outputFull)
+    {
+    for(std::vector<std::string::size_type>::iterator i = 
+          nonValGrindOutput.begin(); i != nonValGrindOutput.end(); ++i)
+      {
+      totalOutputSize += lines[*i].size();
+      ostr << cmCTest::MakeXMLSafe(lines[*i]) << std::endl;
+      if(!unlimitedOutput && totalOutputSize > 
+         static_cast<size_t>(this->CustomMaximumFailedTestOutputSize))
+        {
+        outputFull = true;
+        ostr << "....\n";
+        ostr << "Output for this test has been truncated see testing machine logs for full output,\n";
+        ostr << "or put CTEST_FULL_OUTPUT in the output of this test program.\n";
+        }
       }
       }
     }
     }
   cmCTestLog(this->CTest, DEBUG, "End test (elapsed: "
   cmCTestLog(this->CTest, DEBUG, "End test (elapsed: "