From dde6306a48e0eac9783737ca2dab3ce28e27c869 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Sat, 4 May 2013 19:03:26 +0200 Subject: CTest: use an output file for Valgrind (#14110) This makes sure Valgrind output will not screw up tests that match on the output. --- Source/CTest/cmCTestMemCheckHandler.cxx | 20 ++++++++++++++++++++ Source/CTest/cmCTestMemCheckHandler.h | 4 ++++ Source/CTest/cmCTestRunTest.cxx | 18 ++++++++++++------ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 80218ad..b320605 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -491,6 +491,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() switch ( this->MemoryTesterStyle ) { case cmCTestMemCheckHandler::VALGRIND: + { if ( this->MemoryTesterOptions.empty() ) { this->MemoryTesterOptions.push_back("-q"); @@ -516,7 +517,11 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"); this->MemoryTesterOptions.push_back(suppressions); } + std::string outputFile = "--log-file=" + + this->MemoryTesterOutputFile; + this->MemoryTesterOptions.push_back(outputFile); break; + } case cmCTestMemCheckHandler::PURIFY: { std::string outputFile; @@ -948,6 +953,21 @@ cmCTestMemCheckHandler::PostProcessPurifyTest(cmCTestTestResult& res) cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessPurifyTest for : " << res.Name.c_str() << std::endl); + appendMemTesterOutput(res); +} + +void +cmCTestMemCheckHandler::PostProcessValgrindTest(cmCTestTestResult& res) +{ + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "PostProcessValgrindTest for : " + << res.Name.c_str() << std::endl); + appendMemTesterOutput(res); +} + +void +cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res) +{ if ( !cmSystemTools::FileExists(this->MemoryTesterOutputFile.c_str()) ) { std::string log = "Cannot find memory tester output file: " diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index 1e81c89..0a8c1b3 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -119,6 +119,10 @@ private: void PostProcessPurifyTest(cmCTestTestResult& res); void PostProcessBoundsCheckerTest(cmCTestTestResult& res); + void PostProcessValgrindTest(cmCTestTestResult& res); + + ///! append MemoryTesterOutputFile to the test log + void appendMemTesterOutput(cmCTestTestHandler::cmCTestTestResult& res); }; #endif diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 5eabf3f..aa27f19 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -384,13 +384,19 @@ void cmCTestRunTest::MemCheckPostProcess() << this->TestResult.Name.c_str() << std::endl); cmCTestMemCheckHandler * handler = static_cast (this->TestHandler); - if(handler->MemoryTesterStyle == cmCTestMemCheckHandler::BOUNDS_CHECKER) + switch ( handler->MemoryTesterStyle ) { - handler->PostProcessBoundsCheckerTest(this->TestResult); - } - else if(handler->MemoryTesterStyle == cmCTestMemCheckHandler::PURIFY) - { - handler->PostProcessPurifyTest(this->TestResult); + case cmCTestMemCheckHandler::VALGRIND: + handler->PostProcessValgrindTest(this->TestResult); + break; + case cmCTestMemCheckHandler::PURIFY: + handler->PostProcessPurifyTest(this->TestResult); + break; + case cmCTestMemCheckHandler::BOUNDS_CHECKER: + handler->PostProcessBoundsCheckerTest(this->TestResult); + break; + default: + break; } } -- cgit v0.12