ctest_memcheck: Add QUIET option

This commit is contained in:
Zack Galbreath 2015-02-17 17:15:00 -05:00 committed by Brad King
parent fc58bdb9ad
commit 0b87b2a339
7 changed files with 65 additions and 48 deletions

View File

@ -26,3 +26,7 @@ the number of tests to be run in parallel.
The APPEND option marks results for append to those previously The APPEND option marks results for append to those previously
submitted to a dashboard server since the last ctest_start. Append submitted to a dashboard server since the last ctest_start. Append
semantics are defined by the dashboard server in use. semantics are defined by the dashboard server in use.
The QUIET option suppresses any CTest-specific non-error messages
that would have otherwise been printed to the console. Output from
the underlying tests are not affected.

View File

@ -21,16 +21,20 @@ cmCTestGenericHandler* cmCTestMemCheckCommand::InitializeActualHandler()
= this->CTest->GetInitializedHandler("memcheck"); = this->CTest->GetInitializedHandler("memcheck");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"MemoryCheckType", "CTEST_MEMORYCHECK_TYPE"); "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"MemoryCheckSanitizerOptions", "CTEST_MEMORYCHECK_SANITIZER_OPTIONS"); "MemoryCheckSanitizerOptions", "CTEST_MEMORYCHECK_SANITIZER_OPTIONS",
this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND"); "MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"MemoryCheckCommandOptions", "CTEST_MEMORYCHECK_COMMAND_OPTIONS"); "MemoryCheckCommandOptions", "CTEST_MEMORYCHECK_COMMAND_OPTIONS",
this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"MemoryCheckSuppressionFile", "CTEST_MEMORYCHECK_SUPPRESSIONS_FILE"); "MemoryCheckSuppressionFile", "CTEST_MEMORYCHECK_SUPPRESSIONS_FILE",
this->Quiet);
handler->SetQuiet(this->Quiet);
return handler; return handler;
} }

View File

@ -251,8 +251,8 @@ void cmCTestMemCheckHandler::GenerateTestCommand(
memcheckcommand += " " + memTesterEnvironmentVariable; memcheckcommand += " " + memTesterEnvironmentVariable;
args.push_back(memTesterEnvironmentVariable); args.push_back(memTesterEnvironmentVariable);
} }
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Memory check command: " cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
<< memcheckcommand << std::endl); "Memory check command: " << memcheckcommand << std::endl, this->Quiet);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -347,7 +347,8 @@ void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile *mf)
"CTEST_CUSTOM_MEMCHECK_IGNORE", "CTEST_CUSTOM_MEMCHECK_IGNORE",
this->CustomTestsIgnore); this->CustomTestsIgnore);
std::string cmake = cmSystemTools::GetCMakeCommand(); std::string cmake = cmSystemTools::GetCMakeCommand();
this->CTest->SetCTestConfiguration("CMakeCommand", cmake.c_str()); this->CTest->SetCTestConfiguration("CMakeCommand", cmake.c_str(),
this->Quiet);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -400,8 +401,8 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
<< "</Test>" << std::endl; << "</Test>" << std::endl;
} }
os << "\t</TestList>\n"; os << "\t</TestList>\n";
cmCTestLog(this->CTest, HANDLER_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
"-- Processing memory checking output: "); "-- Processing memory checking output: ", this->Quiet);
size_t total = this->TestResults.size(); size_t total = this->TestResults.size();
size_t step = total / 10; size_t step = total / 10;
size_t current = 0; size_t current = 0;
@ -451,13 +452,14 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
this->WriteTestResultFooter(os, result); this->WriteTestResultFooter(os, result);
if ( current < cc ) if ( current < cc )
{ {
cmCTestLog(this->CTest, HANDLER_OUTPUT, "#" << std::flush); cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "#" << std::flush,
this->Quiet);
current += step; current += step;
} }
} }
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl); cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl, this->Quiet);
cmCTestLog(this->CTest, HANDLER_OUTPUT, "Memory checking results:" cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Memory checking results:"
<< std::endl); << std::endl, this->Quiet);
os << "\t<DefectList>" << std::endl; os << "\t<DefectList>" << std::endl;
for ( cc = 0; cc < this->GlobalResults.size(); cc ++ ) for ( cc = 0; cc < this->GlobalResults.size(); cc ++ )
{ {
@ -468,9 +470,9 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
#endif #endif
std::cerr.width(35); std::cerr.width(35);
#define cerr no_cerr #define cerr no_cerr
cmCTestLog(this->CTest, HANDLER_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
this->ResultStringsLong[cc] << " - " this->ResultStringsLong[cc] << " - "
<< this->GlobalResults[cc] << std::endl); << this->GlobalResults[cc] << std::endl, this->Quiet);
os << "\t\t<Defect Type=\"" << this->ResultStringsLong[cc] os << "\t\t<Defect Type=\"" << this->ResultStringsLong[cc]
<< "\"/>" << std::endl; << "\"/>" << std::endl;
} }
@ -594,10 +596,10 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
} }
if(this->MemoryTester.empty()) if(this->MemoryTester.empty())
{ {
cmCTestLog(this->CTest, WARNING, cmCTestOptionalLog(this->CTest, WARNING,
"Memory checker (MemoryCheckCommand) " "Memory checker (MemoryCheckCommand) "
"not set, or cannot find the specified program." "not set, or cannot find the specified program."
<< std::endl); << std::endl, this->Quiet);
return false; return false;
} }
@ -981,17 +983,18 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
"locked by a different thread"); "locked by a different thread");
std::vector<std::string::size_type> nonValGrindOutput; 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); cmCTestOptionalLog(this->CTest, DEBUG,
"Start test: " << lines.size() << std::endl, this->Quiet);
std::string::size_type totalOutputSize = 0; std::string::size_type totalOutputSize = 0;
for ( cc = 0; cc < lines.size(); cc ++ ) for ( cc = 0; cc < lines.size(); cc ++ )
{ {
cmCTestLog(this->CTest, DEBUG, "test line " cmCTestOptionalLog(this->CTest, DEBUG, "test line "
<< lines[cc] << std::endl); << lines[cc] << std::endl, this->Quiet);
if ( valgrindLine.find(lines[cc]) ) if ( valgrindLine.find(lines[cc]) )
{ {
cmCTestLog(this->CTest, DEBUG, "valgrind line " cmCTestOptionalLog(this->CTest, DEBUG, "valgrind line "
<< lines[cc] << std::endl); << lines[cc] << std::endl, this->Quiet);
int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT; int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT;
if ( vgFIM.find(lines[cc]) ) if ( vgFIM.find(lines[cc]) )
{ {
@ -1075,10 +1078,10 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
nonValGrindOutput.begin(); i != nonValGrindOutput.end(); ++i) nonValGrindOutput.begin(); i != nonValGrindOutput.end(); ++i)
{ {
totalOutputSize += lines[*i].size(); totalOutputSize += lines[*i].size();
cmCTestLog(this->CTest, DEBUG, "before xml safe " cmCTestOptionalLog(this->CTest, DEBUG, "before xml safe "
<< lines[*i] << std::endl); << lines[*i] << std::endl, this->Quiet);
cmCTestLog(this->CTest, DEBUG, "after xml safe " cmCTestOptionalLog(this->CTest, DEBUG, "after xml safe "
<< cmXMLSafe(lines[*i]) << std::endl); << cmXMLSafe(lines[*i]) << std::endl, this->Quiet);
ostr << cmXMLSafe(lines[*i]) << std::endl; ostr << cmXMLSafe(lines[*i]) << std::endl;
if(!unlimitedOutput && totalOutputSize > if(!unlimitedOutput && totalOutputSize >
static_cast<size_t>(this->CustomMaximumFailedTestOutputSize)) static_cast<size_t>(this->CustomMaximumFailedTestOutputSize))
@ -1091,8 +1094,8 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
break; // stop the copy of output if we are full break; // stop the copy of output if we are full
} }
} }
cmCTestLog(this->CTest, DEBUG, "End test (elapsed: " cmCTestOptionalLog(this->CTest, DEBUG, "End test (elapsed: "
<< (cmSystemTools::GetTime() - sttime) << std::endl); << (cmSystemTools::GetTime() - sttime) << std::endl, this->Quiet);
log = ostr.str(); log = ostr.str();
if ( defects ) if ( defects )
{ {
@ -1112,7 +1115,8 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
double sttime = cmSystemTools::GetTime(); double sttime = cmSystemTools::GetTime();
std::vector<std::string> lines; std::vector<std::string> lines;
cmSystemTools::Split(str.c_str(), lines); cmSystemTools::Split(str.c_str(), lines);
cmCTestLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl); cmCTestOptionalLog(this->CTest, DEBUG,
"Start test: " << lines.size() << std::endl, this->Quiet);
std::vector<std::string>::size_type cc; std::vector<std::string>::size_type cc;
for ( cc = 0; cc < lines.size(); cc ++ ) for ( cc = 0; cc < lines.size(); cc ++ )
{ {
@ -1148,8 +1152,8 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
results[parser.Errors[cc]]++; results[parser.Errors[cc]]++;
defects++; defects++;
} }
cmCTestLog(this->CTest, DEBUG, "End test (elapsed: " cmCTestOptionalLog(this->CTest, DEBUG, "End test (elapsed: "
<< (cmSystemTools::GetTime() - sttime) << std::endl); << (cmSystemTools::GetTime() - sttime) << std::endl, this->Quiet);
if(defects) if(defects)
{ {
// only put the output of Bounds Checker if there were // only put the output of Bounds Checker if there were
@ -1165,9 +1169,9 @@ void
cmCTestMemCheckHandler::PostProcessTest(cmCTestTestResult& res, cmCTestMemCheckHandler::PostProcessTest(cmCTestTestResult& res,
int test) int test)
{ {
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"PostProcessTest memcheck results for : " "PostProcessTest memcheck results for : "
<< res.Name << std::endl); << res.Name << std::endl, this->Quiet);
if(this->MemoryTesterStyle if(this->MemoryTesterStyle
== cmCTestMemCheckHandler::BOUNDS_CHECKER) == cmCTestMemCheckHandler::BOUNDS_CHECKER)
{ {
@ -1192,9 +1196,9 @@ void
cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res, cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res,
int test) int test)
{ {
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"PostProcessBoundsCheckerTest for : " "PostProcessBoundsCheckerTest for : "
<< res.Name << std::endl); << res.Name << std::endl, this->Quiet);
std::vector<std::string> files; std::vector<std::string> files;
this->TestOutputFileNames(test, files); this->TestOutputFileNames(test, files);
if (files.empty()) if (files.empty())
@ -1226,11 +1230,11 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res,
} }
cmSystemTools::Delay(1000); cmSystemTools::Delay(1000);
cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile); cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: " cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
<< this->BoundsCheckerDPBDFile << std::endl); << this->BoundsCheckerDPBDFile << std::endl, this->Quiet);
cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile); cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: " cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
<< this->BoundsCheckerXMLFile << std::endl); << this->BoundsCheckerXMLFile << std::endl, this->Quiet);
} }
void void
@ -1260,7 +1264,8 @@ cmCTestMemCheckHandler::AppendMemTesterOutput(cmCTestTestResult& res,
if(this->LogWithPID) if(this->LogWithPID)
{ {
cmSystemTools::RemoveFile(ofile); cmSystemTools::RemoveFile(ofile);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "<< ofile <<"\n"); cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Remove: "<< ofile <<"\n", this->Quiet);
} }
} }

View File

@ -386,10 +386,11 @@ void cmCTestRunTest::MemCheckPostProcess()
{ {
return; return;
} }
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
<< ": process test output now: " << ": process test output now: "
<< this->TestProperties->Name << " " << this->TestProperties->Name << " "
<< this->TestResult.Name << std::endl); << this->TestResult.Name << std::endl,
this->TestHandler->GetQuiet());
cmCTestMemCheckHandler * handler = static_cast<cmCTestMemCheckHandler*> cmCTestMemCheckHandler * handler = static_cast<cmCTestMemCheckHandler*>
(this->TestHandler); (this->TestHandler);
handler->PostProcessTest(this->TestResult, this->Index); handler->PostProcessTest(this->TestResult, this->Index);
@ -661,8 +662,9 @@ bool cmCTestRunTest::ForkProcess(double testTimeOut, bool explicitTimeout,
{ {
timeout = 0; timeout = 0;
} }
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": " cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": "
<< "Test timeout computed to be: " << timeout << "\n"); << "Test timeout computed to be: " << timeout << "\n",
this->TestHandler->GetQuiet());
this->TestProcess->SetTimeout(timeout); this->TestProcess->SetTimeout(timeout);

View File

@ -0,0 +1 @@
0 tests failed out of 1$

View File

@ -130,3 +130,4 @@ run_mc_test(DummyValgrindNoLogFile "${PSEUDO_VALGRIND_NOLOG}")
run_mc_test(DummyBCNoLogFile "${PSEUDO_BC_NOLOG}") run_mc_test(DummyBCNoLogFile "${PSEUDO_BC_NOLOG}")
run_mc_test(NotExist "\${CTEST_BINARY_DIRECTORY}/no-memcheck-exe") run_mc_test(NotExist "\${CTEST_BINARY_DIRECTORY}/no-memcheck-exe")
run_mc_test(Unknown "\${CMAKE_COMMAND}") run_mc_test(Unknown "\${CMAKE_COMMAND}")
run_mc_test(DummyQuiet "${PSEUDO_VALGRIND}" -DMEMCHECK_ARGS=QUIET)

View File

@ -21,4 +21,4 @@ set(CTEST_MEMORYCHECK_TYPE "${MEMCHECK_TYPE}")
CTEST_START(Experimental) CTEST_START(Experimental)
CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res ${MEMCHECK_ARGS})