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
submitted to a dashboard server since the last ctest_start. Append
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->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"MemoryCheckType", "CTEST_MEMORYCHECK_TYPE");
"MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"MemoryCheckSanitizerOptions", "CTEST_MEMORYCHECK_SANITIZER_OPTIONS");
"MemoryCheckSanitizerOptions", "CTEST_MEMORYCHECK_SANITIZER_OPTIONS",
this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND");
"MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"MemoryCheckCommandOptions", "CTEST_MEMORYCHECK_COMMAND_OPTIONS");
"MemoryCheckCommandOptions", "CTEST_MEMORYCHECK_COMMAND_OPTIONS",
this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"MemoryCheckSuppressionFile", "CTEST_MEMORYCHECK_SUPPRESSIONS_FILE");
"MemoryCheckSuppressionFile", "CTEST_MEMORYCHECK_SUPPRESSIONS_FILE",
this->Quiet);
handler->SetQuiet(this->Quiet);
return handler;
}

View File

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