201
200
this->CustomMaximumPassedTestOutputSize = 0;
202
201
this->CustomMaximumFailedTestOutputSize = 0;
203
202
this->MemoryTester = "";
203
this->MemoryTesterDynamicOptions.clear();
204
204
this->MemoryTesterOptions.clear();
205
205
this->MemoryTesterStyle = UNKNOWN;
206
206
this->MemoryTesterOutputFile = "";
244
244
//----------------------------------------------------------------------
245
245
void cmCTestMemCheckHandler::GenerateTestCommand(
246
std::vector<std::string>& args)
246
std::vector<std::string>& args, int test)
248
248
std::vector<cmStdString>::size_type pp;
249
std::string memcheckcommand = "";
250
cmOStringStream stream;
251
std::string memcheckcommand
251
252
= cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str());
254
index = stream.str();
255
for ( pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp ++ )
257
cmStdString arg = this->MemoryTesterDynamicOptions[pp];
258
cmStdString::size_type pos = arg.find("??");
259
if (pos != cmStdString::npos)
261
arg.replace(pos, 2, index);
264
memcheckcommand += " \"";
265
memcheckcommand += arg;
266
memcheckcommand += "\"";
252
268
for ( pp = 0; pp < this->MemoryTesterOptions.size(); pp ++ )
254
270
args.push_back(this->MemoryTesterOptions[pp]);
464
if ( this->MemoryTester[0] == '\"' &&
465
this->MemoryTester[this->MemoryTester.size()-1] == '\"' )
468
= this->MemoryTester.substr(1, this->MemoryTester.size()-2);
471
480
// Setup the options
472
481
std::string memoryTesterOptions;
473
482
if ( this->CTest->GetCTestConfiguration(
486
495
= cmSystemTools::ParseArguments(memoryTesterOptions.c_str());
488
497
this->MemoryTesterOutputFile
489
= this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log";
498
= this->CTest->GetBinaryDir()
499
+ "/Testing/Temporary/MemoryChecker.??.log";
491
501
switch ( this->MemoryTesterStyle )
493
503
case cmCTestMemCheckHandler::VALGRIND:
494
505
if ( this->MemoryTesterOptions.empty() )
496
507
this->MemoryTesterOptions.push_back("-q");
497
508
this->MemoryTesterOptions.push_back("--tool=memcheck");
498
509
this->MemoryTesterOptions.push_back("--leak-check=yes");
499
510
this->MemoryTesterOptions.push_back("--show-reachable=yes");
500
this->MemoryTesterOptions.push_back("--workaround-gcc296-bugs=yes");
501
511
this->MemoryTesterOptions.push_back("--num-callers=50");
503
513
if ( this->CTest->GetCTestConfiguration(
516
526
+ this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
517
527
this->MemoryTesterOptions.push_back(suppressions);
529
std::string outputFile = "--log-file="
530
+ this->MemoryTesterOutputFile;
531
this->MemoryTesterDynamicOptions.push_back(outputFile);
520
534
case cmCTestMemCheckHandler::PURIFY:
522
536
std::string outputFile;
542
556
outputFile = "-log-file=";
544
558
outputFile += this->MemoryTesterOutputFile;
545
this->MemoryTesterOptions.push_back(outputFile);
559
this->MemoryTesterDynamicOptions.push_back(outputFile);
548
562
case cmCTestMemCheckHandler::BOUNDS_CHECKER:
550
564
this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile;
551
565
std::string dpbdFile = this->CTest->GetBinaryDir()
552
+ "/Testing/Temporary/MemoryChecker.DPbd";
566
+ "/Testing/Temporary/MemoryChecker.??.DPbd";
553
567
this->BoundsCheckerDPBDFile = dpbdFile;
554
this->MemoryTesterOptions.push_back("/B");
555
this->MemoryTesterOptions.push_back(dpbdFile);
556
this->MemoryTesterOptions.push_back("/X");
557
this->MemoryTesterOptions.push_back(this->MemoryTesterOutputFile);
568
this->MemoryTesterDynamicOptions.push_back("/B");
569
this->MemoryTesterDynamicOptions.push_back(dpbdFile);
570
this->MemoryTesterDynamicOptions.push_back("/X");
571
this->MemoryTesterDynamicOptions.push_back(this->MemoryTesterOutputFile);
558
572
this->MemoryTesterOptions.push_back("/M");
902
916
// This method puts the bounds checker output file into the output
905
cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res)
919
cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res,
907
922
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
908
923
"PostProcessBoundsCheckerTest for : "
909
924
<< res.Name.c_str() << std::endl);
910
if ( !cmSystemTools::FileExists(this->MemoryTesterOutputFile.c_str()) )
925
cmStdString ofile = testOutputFileName(test);
912
std::string log = "Cannot find memory tester output file: "
913
+ this->MemoryTesterOutputFile;
914
cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
917
930
// put a scope around this to close ifs so the file can be removed
919
std::ifstream ifs(this->MemoryTesterOutputFile.c_str());
932
std::ifstream ifs(ofile.c_str());
922
std::string log = "Cannot read memory tester output file: "
923
+ this->MemoryTesterOutputFile;
935
std::string log = "Cannot read memory tester output file: " + ofile;
924
936
cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
946
cmCTestMemCheckHandler::PostProcessPurifyTest(cmCTestTestResult& res)
958
cmCTestMemCheckHandler::PostProcessPurifyTest(cmCTestTestResult& res,
948
961
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
949
962
"PostProcessPurifyTest for : "
950
963
<< res.Name.c_str() << std::endl);
951
if ( !cmSystemTools::FileExists(this->MemoryTesterOutputFile.c_str()) )
964
appendMemTesterOutput(res, test);
968
cmCTestMemCheckHandler::PostProcessValgrindTest(cmCTestTestResult& res,
971
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
972
"PostProcessValgrindTest for : "
973
<< res.Name.c_str() << std::endl);
974
appendMemTesterOutput(res, test);
978
cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res,
981
cmStdString ofile = testOutputFileName(test);
953
std::string log = "Cannot find memory tester output file: "
954
+ this->MemoryTesterOutputFile;
955
cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
958
std::ifstream ifs(this->MemoryTesterOutputFile.c_str());
987
std::ifstream ifs(ofile.c_str());
961
std::string log = "Cannot read memory tester output file: "
962
+ this->MemoryTesterOutputFile;
990
std::string log = "Cannot read memory tester output file: " + ofile;
963
991
cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
970
998
res.Output += "\n";
1003
cmCTestMemCheckHandler::testOutputFileName(int test)
1006
cmOStringStream stream;
1008
index = stream.str();
1009
cmStdString ofile = this->MemoryTesterOutputFile;
1010
cmStdString::size_type pos = ofile.find("??");
1011
ofile.replace(pos, 2, index);
1013
if ( !cmSystemTools::FileExists(ofile.c_str()) )
1015
std::string log = "Cannot find memory tester output file: "
1017
cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);