cmCTestMemCheckHandler.cxx 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmCTestMemCheckHandler.h"
  11. #include "cmXMLParser.h"
  12. #include "cmCTest.h"
  13. #include "cmake.h"
  14. #include "cmGeneratedFileStream.h"
  15. #include <cmsys/Process.h>
  16. #include <cmsys/RegularExpression.hxx>
  17. #include <cmsys/Base64.h>
  18. #include <cmsys/Glob.hxx>
  19. #include <cmsys/FStream.hxx>
  20. #include "cmMakefile.h"
  21. #include "cmXMLSafe.h"
  22. #include <stdlib.h>
  23. #include <math.h>
  24. #include <float.h>
  25. struct CatToErrorType
  26. {
  27. const char* ErrorCategory;
  28. int ErrorCode;
  29. };
  30. static CatToErrorType cmCTestMemCheckBoundsChecker[] = {
  31. // Error tags
  32. {"Write Overrun", cmCTestMemCheckHandler::ABW},
  33. {"Read Overrun", cmCTestMemCheckHandler::ABR},
  34. {"Memory Overrun", cmCTestMemCheckHandler::ABW},
  35. {"Allocation Conflict", cmCTestMemCheckHandler::FMM},
  36. {"Bad Pointer Use", cmCTestMemCheckHandler::FMW},
  37. {"Dangling Pointer", cmCTestMemCheckHandler::FMR},
  38. {0,0}
  39. };
  40. // parse the xml file containing the results of last BoundsChecker run
  41. class cmBoundsCheckerParser : public cmXMLParser
  42. {
  43. public:
  44. cmBoundsCheckerParser(cmCTest* c) { this->CTest = c;}
  45. void StartElement(const std::string& name, const char** atts)
  46. {
  47. if(name == "MemoryLeak" ||
  48. name == "ResourceLeak")
  49. {
  50. this->Errors.push_back(cmCTestMemCheckHandler::MLK);
  51. }
  52. else if(name == "Error" ||
  53. name == "Dangling Pointer")
  54. {
  55. this->ParseError(atts);
  56. }
  57. // Create the log
  58. cmOStringStream ostr;
  59. ostr << name << ":\n";
  60. int i = 0;
  61. for(; atts[i] != 0; i+=2)
  62. {
  63. ostr << " " << cmXMLSafe(atts[i])
  64. << " - " << cmXMLSafe(atts[i+1]) << "\n";
  65. }
  66. ostr << "\n";
  67. this->Log += ostr.str();
  68. }
  69. void EndElement(const std::string& )
  70. {
  71. }
  72. const char* GetAttribute(const char* name, const char** atts)
  73. {
  74. int i = 0;
  75. for(; atts[i] != 0; ++i)
  76. {
  77. if(strcmp(name, atts[i]) == 0)
  78. {
  79. return atts[i+1];
  80. }
  81. }
  82. return 0;
  83. }
  84. void ParseError(const char** atts)
  85. {
  86. CatToErrorType* ptr = cmCTestMemCheckBoundsChecker;
  87. const char* cat = this->GetAttribute("ErrorCategory", atts);
  88. if(!cat)
  89. {
  90. this->Errors.push_back(cmCTestMemCheckHandler::ABW); // do not know
  91. cmCTestLog(this->CTest, ERROR_MESSAGE,
  92. "No Category found in Bounds checker XML\n" );
  93. return;
  94. }
  95. while(ptr->ErrorCategory && cat)
  96. {
  97. if(strcmp(ptr->ErrorCategory, cat) == 0)
  98. {
  99. this->Errors.push_back(ptr->ErrorCode);
  100. return; // found it we are done
  101. }
  102. ptr++;
  103. }
  104. if(ptr->ErrorCategory)
  105. {
  106. this->Errors.push_back(cmCTestMemCheckHandler::ABW); // do not know
  107. cmCTestLog(this->CTest, ERROR_MESSAGE,
  108. "Found unknown Bounds Checker error "
  109. << ptr->ErrorCategory << std::endl);
  110. }
  111. }
  112. cmCTest* CTest;
  113. std::vector<int> Errors;
  114. std::string Log;
  115. };
  116. #define BOUNDS_CHECKER_MARKER \
  117. "******######*****Begin BOUNDS CHECKER XML******######******"
  118. //----------------------------------------------------------------------
  119. cmCTestMemCheckHandler::cmCTestMemCheckHandler()
  120. {
  121. this->MemCheck = true;
  122. this->CustomMaximumPassedTestOutputSize = 0;
  123. this->CustomMaximumFailedTestOutputSize = 0;
  124. this->LogWithPID = false;
  125. }
  126. //----------------------------------------------------------------------
  127. void cmCTestMemCheckHandler::Initialize()
  128. {
  129. this->Superclass::Initialize();
  130. this->LogWithPID = false;
  131. this->CustomMaximumPassedTestOutputSize = 0;
  132. this->CustomMaximumFailedTestOutputSize = 0;
  133. this->MemoryTester = "";
  134. this->MemoryTesterDynamicOptions.clear();
  135. this->MemoryTesterOptions.clear();
  136. this->MemoryTesterStyle = UNKNOWN;
  137. this->MemoryTesterOutputFile = "";
  138. }
  139. //----------------------------------------------------------------------
  140. int cmCTestMemCheckHandler::PreProcessHandler()
  141. {
  142. if ( !this->InitializeMemoryChecking() )
  143. {
  144. return 0;
  145. }
  146. if ( !this->ExecuteCommands(this->CustomPreMemCheck) )
  147. {
  148. cmCTestLog(this->CTest, ERROR_MESSAGE,
  149. "Problem executing pre-memcheck command(s)." << std::endl);
  150. return 0;
  151. }
  152. return 1;
  153. }
  154. //----------------------------------------------------------------------
  155. int cmCTestMemCheckHandler::PostProcessHandler()
  156. {
  157. if ( !this->ExecuteCommands(this->CustomPostMemCheck) )
  158. {
  159. cmCTestLog(this->CTest, ERROR_MESSAGE,
  160. "Problem executing post-memcheck command(s)." << std::endl);
  161. return 0;
  162. }
  163. return 1;
  164. }
  165. //----------------------------------------------------------------------
  166. void cmCTestMemCheckHandler::GenerateTestCommand(
  167. std::vector<std::string>& args, int test)
  168. {
  169. std::vector<std::string>::size_type pp;
  170. std::string index;
  171. cmOStringStream stream;
  172. std::string memcheckcommand
  173. = cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str());
  174. stream << test;
  175. index = stream.str();
  176. for ( pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp ++ )
  177. {
  178. std::string arg = this->MemoryTesterDynamicOptions[pp];
  179. std::string::size_type pos = arg.find("??");
  180. if (pos != std::string::npos)
  181. {
  182. arg.replace(pos, 2, index);
  183. }
  184. args.push_back(arg);
  185. memcheckcommand += " \"";
  186. memcheckcommand += arg;
  187. memcheckcommand += "\"";
  188. }
  189. // Create a copy of the memory tester environment variable.
  190. // This is used for memory testing programs that pass options
  191. // via environment varaibles.
  192. std::string memTesterEnvironmentVariable =
  193. this->MemoryTesterEnvironmentVariable;
  194. for ( pp = 0; pp < this->MemoryTesterOptions.size(); pp ++ )
  195. {
  196. if(memTesterEnvironmentVariable.size())
  197. {
  198. // If we are using env to pass options, append all the options to
  199. // this string with space separation.
  200. memTesterEnvironmentVariable += " " + this->MemoryTesterOptions[pp];
  201. }
  202. // for regular options just add them to args and memcheckcommand
  203. // which is just used for display
  204. else
  205. {
  206. args.push_back(this->MemoryTesterOptions[pp]);
  207. memcheckcommand += " \"";
  208. memcheckcommand += this->MemoryTesterOptions[pp];
  209. memcheckcommand += "\"";
  210. }
  211. }
  212. // if this is an env option type, then add the env string as a single
  213. // argument.
  214. if(memTesterEnvironmentVariable.size())
  215. {
  216. std::string::size_type pos = memTesterEnvironmentVariable.find("??");
  217. if (pos != std::string::npos)
  218. {
  219. memTesterEnvironmentVariable.replace(pos, 2, index);
  220. }
  221. memcheckcommand += " " + memTesterEnvironmentVariable;
  222. args.push_back(memTesterEnvironmentVariable);
  223. }
  224. cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Memory check command: "
  225. << memcheckcommand << std::endl);
  226. }
  227. //----------------------------------------------------------------------
  228. void cmCTestMemCheckHandler::InitializeResultsVectors()
  229. {
  230. // fill these members
  231. // cmsys::vector<std::string> ResultStrings;
  232. // cmsys::vector<std::string> ResultStringsLong;
  233. // cmsys::vector<int> GlobalResults;
  234. this->ResultStringsLong.clear();
  235. this->ResultStrings.clear();
  236. this->GlobalResults.clear();
  237. // If we are working with style checkers that dynamically fill
  238. // the results strings then return.
  239. if(this->MemoryTesterStyle > cmCTestMemCheckHandler::BOUNDS_CHECKER)
  240. {
  241. return;
  242. }
  243. // define the standard set of errors
  244. //----------------------------------------------------------------------
  245. static const char* cmCTestMemCheckResultStrings[] = {
  246. "ABR",
  247. "ABW",
  248. "ABWL",
  249. "COR",
  250. "EXU",
  251. "FFM",
  252. "FIM",
  253. "FMM",
  254. "FMR",
  255. "FMW",
  256. "FUM",
  257. "IPR",
  258. "IPW",
  259. "MAF",
  260. "MLK",
  261. "MPK",
  262. "NPR",
  263. "ODS",
  264. "PAR",
  265. "PLK",
  266. "UMC",
  267. "UMR",
  268. 0
  269. };
  270. //----------------------------------------------------------------------
  271. static const char* cmCTestMemCheckResultLongStrings[] = {
  272. "Threading Problem",
  273. "ABW",
  274. "ABWL",
  275. "COR",
  276. "EXU",
  277. "FFM",
  278. "FIM",
  279. "Mismatched deallocation",
  280. "FMR",
  281. "FMW",
  282. "FUM",
  283. "IPR",
  284. "IPW",
  285. "MAF",
  286. "Memory Leak",
  287. "Potential Memory Leak",
  288. "NPR",
  289. "ODS",
  290. "Invalid syscall param",
  291. "PLK",
  292. "Uninitialized Memory Conditional",
  293. "Uninitialized Memory Read",
  294. 0
  295. };
  296. this->GlobalResults.clear();
  297. for(int i =0; cmCTestMemCheckResultStrings[i] != 0; ++i)
  298. {
  299. this->ResultStrings.push_back(cmCTestMemCheckResultStrings[i]);
  300. this->ResultStringsLong.push_back(cmCTestMemCheckResultLongStrings[i]);
  301. this->GlobalResults.push_back(0);
  302. }
  303. }
  304. //----------------------------------------------------------------------
  305. void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile *mf)
  306. {
  307. this->cmCTestTestHandler::PopulateCustomVectors(mf);
  308. this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_MEMCHECK",
  309. this->CustomPreMemCheck);
  310. this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_POST_MEMCHECK",
  311. this->CustomPostMemCheck);
  312. this->CTest->PopulateCustomVector(mf,
  313. "CTEST_CUSTOM_MEMCHECK_IGNORE",
  314. this->CustomTestsIgnore);
  315. this->CTest->SetCTestConfigurationFromCMakeVariable(
  316. mf, "CMakeCommand", "CMAKE_COMMAND");
  317. }
  318. //----------------------------------------------------------------------
  319. void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
  320. {
  321. if ( !this->CTest->GetProduceXML() )
  322. {
  323. return;
  324. }
  325. this->CTest->StartXML(os, this->AppendXML);
  326. os << "<DynamicAnalysis Checker=\"";
  327. switch ( this->MemoryTesterStyle )
  328. {
  329. case cmCTestMemCheckHandler::VALGRIND:
  330. os << "Valgrind";
  331. break;
  332. case cmCTestMemCheckHandler::PURIFY:
  333. os << "Purify";
  334. break;
  335. case cmCTestMemCheckHandler::BOUNDS_CHECKER:
  336. os << "BoundsChecker";
  337. break;
  338. case cmCTestMemCheckHandler::THREAD_SANITIZER:
  339. os << "ThreadSanitizer";
  340. break;
  341. default:
  342. os << "Unknown";
  343. }
  344. os << "\">" << std::endl;
  345. os << "\t<StartDateTime>" << this->StartTest << "</StartDateTime>\n"
  346. << "\t<StartTestTime>" << this->StartTestTime << "</StartTestTime>\n"
  347. << "\t<TestList>\n";
  348. cmCTestMemCheckHandler::TestResultsVector::size_type cc;
  349. for ( cc = 0; cc < this->TestResults.size(); cc ++ )
  350. {
  351. cmCTestTestResult *result = &this->TestResults[cc];
  352. std::string testPath = result->Path + "/" + result->Name;
  353. os << "\t\t<Test>" << cmXMLSafe(
  354. this->CTest->GetShortPathToFile(testPath.c_str()))
  355. << "</Test>" << std::endl;
  356. }
  357. os << "\t</TestList>\n";
  358. cmCTestLog(this->CTest, HANDLER_OUTPUT,
  359. "-- Processing memory checking output: ");
  360. size_t total = this->TestResults.size();
  361. size_t step = total / 10;
  362. size_t current = 0;
  363. for ( cc = 0; cc < this->TestResults.size(); cc ++ )
  364. {
  365. cmCTestTestResult *result = &this->TestResults[cc];
  366. std::string memcheckstr;
  367. std::vector<int> memcheckresults(this->ResultStrings.size(), 0);
  368. bool res = this->ProcessMemCheckOutput(result->Output, memcheckstr,
  369. memcheckresults);
  370. if ( res && result->Status == cmCTestMemCheckHandler::COMPLETED )
  371. {
  372. continue;
  373. }
  374. this->CleanTestOutput(memcheckstr,
  375. static_cast<size_t>(this->CustomMaximumFailedTestOutputSize));
  376. this->WriteTestResultHeader(os, result);
  377. os << "\t\t<Results>" << std::endl;
  378. for(std::vector<int>::size_type kk = 0;
  379. kk < memcheckresults.size(); ++kk)
  380. {
  381. if ( memcheckresults[kk] )
  382. {
  383. os << "\t\t\t<Defect type=\"" << this->ResultStringsLong[kk]
  384. << "\">"
  385. << memcheckresults[kk]
  386. << "</Defect>" << std::endl;
  387. }
  388. this->GlobalResults[kk] += memcheckresults[kk];
  389. }
  390. std::string logTag;
  391. if(this->CTest->ShouldCompressMemCheckOutput())
  392. {
  393. this->CTest->CompressString(memcheckstr);
  394. logTag = "\t<Log compression=\"gzip\" encoding=\"base64\">\n";
  395. }
  396. else
  397. {
  398. logTag = "\t<Log>\n";
  399. }
  400. os
  401. << "\t\t</Results>\n"
  402. << logTag << cmXMLSafe(memcheckstr) << std::endl
  403. << "\t</Log>\n";
  404. this->WriteTestResultFooter(os, result);
  405. if ( current < cc )
  406. {
  407. cmCTestLog(this->CTest, HANDLER_OUTPUT, "#" << std::flush);
  408. current += step;
  409. }
  410. }
  411. cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
  412. cmCTestLog(this->CTest, HANDLER_OUTPUT, "Memory checking results:"
  413. << std::endl);
  414. os << "\t<DefectList>" << std::endl;
  415. for ( cc = 0; cc < this->GlobalResults.size(); cc ++ )
  416. {
  417. if ( this->GlobalResults[cc] )
  418. {
  419. #ifdef cerr
  420. # undef cerr
  421. #endif
  422. std::cerr.width(35);
  423. #define cerr no_cerr
  424. cmCTestLog(this->CTest, HANDLER_OUTPUT,
  425. this->ResultStringsLong[cc] << " - "
  426. << this->GlobalResults[cc] << std::endl);
  427. os << "\t\t<Defect Type=\"" << this->ResultStringsLong[cc]
  428. << "\"/>" << std::endl;
  429. }
  430. }
  431. os << "\t</DefectList>" << std::endl;
  432. os << "\t<EndDateTime>" << this->EndTest << "</EndDateTime>" << std::endl;
  433. os << "\t<EndTestTime>" << this->EndTestTime
  434. << "</EndTestTime>" << std::endl;
  435. os << "<ElapsedMinutes>"
  436. << static_cast<int>(this->ElapsedTestingTime/6)/10.0
  437. << "</ElapsedMinutes>\n";
  438. os << "</DynamicAnalysis>" << std::endl;
  439. this->CTest->EndXML(os);
  440. }
  441. //----------------------------------------------------------------------
  442. bool cmCTestMemCheckHandler::InitializeMemoryChecking()
  443. {
  444. this->MemoryTesterEnvironmentVariable = "";
  445. this->MemoryTester = "";
  446. // Setup the command
  447. if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
  448. "MemoryCheckCommand").c_str()) )
  449. {
  450. this->MemoryTester
  451. = this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str();
  452. std::string testerName =
  453. cmSystemTools::GetFilenameName(this->MemoryTester);
  454. // determine the checker type
  455. if ( testerName.find("valgrind") != std::string::npos ||
  456. this->CTest->GetCTestConfiguration("MemoryCheckType")
  457. == "Valgrind")
  458. {
  459. this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
  460. }
  461. else if ( testerName.find("purify") != std::string::npos )
  462. {
  463. this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
  464. }
  465. else if ( testerName.find("BC") != std::string::npos )
  466. {
  467. this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
  468. }
  469. else
  470. {
  471. this->MemoryTesterStyle = cmCTestMemCheckHandler::UNKNOWN;
  472. }
  473. }
  474. else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
  475. "PurifyCommand").c_str()) )
  476. {
  477. this->MemoryTester
  478. = this->CTest->GetCTestConfiguration("PurifyCommand").c_str();
  479. this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
  480. }
  481. else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
  482. "ValgrindCommand").c_str()) )
  483. {
  484. this->MemoryTester
  485. = this->CTest->GetCTestConfiguration("ValgrindCommand").c_str();
  486. this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
  487. }
  488. else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
  489. "BoundsCheckerCommand").c_str()) )
  490. {
  491. this->MemoryTester
  492. = this->CTest->GetCTestConfiguration("BoundsCheckerCommand").c_str();
  493. this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
  494. }
  495. if ( this->CTest->GetCTestConfiguration("MemoryCheckType")
  496. == "ThreadSanitizer")
  497. {
  498. this->MemoryTester
  499. = this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
  500. this->MemoryTesterStyle = cmCTestMemCheckHandler::THREAD_SANITIZER;
  501. this->LogWithPID = true; // even if we give the log file the pid is added
  502. }
  503. // Check the MemoryCheckType
  504. if(this->MemoryTesterStyle == cmCTestMemCheckHandler::UNKNOWN)
  505. {
  506. std::string checkType =
  507. this->CTest->GetCTestConfiguration("MemoryCheckType");
  508. if(checkType == "Purify")
  509. {
  510. this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
  511. }
  512. else if(checkType == "BoundsChecker")
  513. {
  514. this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
  515. }
  516. else if(checkType == "Valgrind")
  517. {
  518. this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
  519. }
  520. }
  521. if(this->MemoryTester.size() == 0 )
  522. {
  523. cmCTestLog(this->CTest, WARNING,
  524. "Memory checker (MemoryCheckCommand) "
  525. "not set, or cannot find the specified program."
  526. << std::endl);
  527. return false;
  528. }
  529. // Setup the options
  530. std::string memoryTesterOptions;
  531. if ( this->CTest->GetCTestConfiguration(
  532. "MemoryCheckCommandOptions").size() )
  533. {
  534. memoryTesterOptions = this->CTest->GetCTestConfiguration(
  535. "MemoryCheckCommandOptions");
  536. }
  537. else if ( this->CTest->GetCTestConfiguration(
  538. "ValgrindCommandOptions").size() )
  539. {
  540. memoryTesterOptions = this->CTest->GetCTestConfiguration(
  541. "ValgrindCommandOptions");
  542. }
  543. this->MemoryTesterOptions
  544. = cmSystemTools::ParseArguments(memoryTesterOptions.c_str());
  545. this->MemoryTesterOutputFile
  546. = this->CTest->GetBinaryDir()
  547. + "/Testing/Temporary/MemoryChecker.??.log";
  548. switch ( this->MemoryTesterStyle )
  549. {
  550. case cmCTestMemCheckHandler::VALGRIND:
  551. {
  552. if ( this->MemoryTesterOptions.empty() )
  553. {
  554. this->MemoryTesterOptions.push_back("-q");
  555. this->MemoryTesterOptions.push_back("--tool=memcheck");
  556. this->MemoryTesterOptions.push_back("--leak-check=yes");
  557. this->MemoryTesterOptions.push_back("--show-reachable=yes");
  558. this->MemoryTesterOptions.push_back("--num-callers=50");
  559. }
  560. if ( this->CTest->GetCTestConfiguration(
  561. "MemoryCheckSuppressionFile").size() )
  562. {
  563. if ( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
  564. "MemoryCheckSuppressionFile").c_str()) )
  565. {
  566. cmCTestLog(this->CTest, ERROR_MESSAGE,
  567. "Cannot find memory checker suppression file: "
  568. << this->CTest->GetCTestConfiguration(
  569. "MemoryCheckSuppressionFile") << std::endl);
  570. return false;
  571. }
  572. std::string suppressions = "--suppressions="
  573. + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
  574. this->MemoryTesterOptions.push_back(suppressions);
  575. }
  576. std::string outputFile = "--log-file="
  577. + this->MemoryTesterOutputFile;
  578. this->MemoryTesterDynamicOptions.push_back(outputFile);
  579. break;
  580. }
  581. case cmCTestMemCheckHandler::PURIFY:
  582. {
  583. std::string outputFile;
  584. #ifdef _WIN32
  585. if( this->CTest->GetCTestConfiguration(
  586. "MemoryCheckSuppressionFile").size() )
  587. {
  588. if( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
  589. "MemoryCheckSuppressionFile").c_str()) )
  590. {
  591. cmCTestLog(this->CTest, ERROR_MESSAGE,
  592. "Cannot find memory checker suppression file: "
  593. << this->CTest->GetCTestConfiguration(
  594. "MemoryCheckSuppressionFile").c_str() << std::endl);
  595. return false;
  596. }
  597. std::string filterFiles = "/FilterFiles="
  598. + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
  599. this->MemoryTesterOptions.push_back(filterFiles);
  600. }
  601. outputFile = "/SAVETEXTDATA=";
  602. #else
  603. outputFile = "-log-file=";
  604. #endif
  605. outputFile += this->MemoryTesterOutputFile;
  606. this->MemoryTesterDynamicOptions.push_back(outputFile);
  607. break;
  608. }
  609. case cmCTestMemCheckHandler::BOUNDS_CHECKER:
  610. {
  611. this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile;
  612. std::string dpbdFile = this->CTest->GetBinaryDir()
  613. + "/Testing/Temporary/MemoryChecker.??.DPbd";
  614. this->BoundsCheckerDPBDFile = dpbdFile;
  615. this->MemoryTesterDynamicOptions.push_back("/B");
  616. this->MemoryTesterDynamicOptions.push_back(dpbdFile);
  617. this->MemoryTesterDynamicOptions.push_back("/X");
  618. this->MemoryTesterDynamicOptions.push_back(this->MemoryTesterOutputFile);
  619. this->MemoryTesterOptions.push_back("/M");
  620. break;
  621. }
  622. case cmCTestMemCheckHandler::THREAD_SANITIZER:
  623. {
  624. // To pass arguments to ThreadSanitizer the environment variable
  625. // TSAN_OPTIONS is used. This is done with the cmake -E env command.
  626. // The MemoryTesterDynamicOptions is setup with the -E env
  627. // Then the MemoryTesterEnvironmentVariable gets the
  628. // TSAN_OPTIONS string with the log_path in it.
  629. this->MemoryTesterDynamicOptions.push_back("-E");
  630. this->MemoryTesterDynamicOptions.push_back("env");
  631. std::string outputFile = "TSAN_OPTIONS=log_path=\""
  632. + this->MemoryTesterOutputFile + "\"";
  633. this->MemoryTesterEnvironmentVariable = outputFile;
  634. break;
  635. }
  636. default:
  637. cmCTestLog(this->CTest, ERROR_MESSAGE,
  638. "Do not understand memory checker: " << this->MemoryTester
  639. << std::endl);
  640. return false;
  641. }
  642. this->InitializeResultsVectors();
  643. // std::vector<std::string>::size_type cc;
  644. // for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ )
  645. // {
  646. // this->MemoryTesterGlobalResults[cc] = 0;
  647. // }
  648. return true;
  649. }
  650. //----------------------------------------------------------------------
  651. bool cmCTestMemCheckHandler::
  652. ProcessMemCheckOutput(const std::string& str,
  653. std::string& log, std::vector<int>& results)
  654. {
  655. if ( this->MemoryTesterStyle == cmCTestMemCheckHandler::VALGRIND )
  656. {
  657. return this->ProcessMemCheckValgrindOutput(str, log, results);
  658. }
  659. else if ( this->MemoryTesterStyle == cmCTestMemCheckHandler::PURIFY )
  660. {
  661. return this->ProcessMemCheckPurifyOutput(str, log, results);
  662. }
  663. else if ( this->MemoryTesterStyle ==
  664. cmCTestMemCheckHandler::THREAD_SANITIZER )
  665. {
  666. return this->ProcessMemCheckThreadSanitizerOutput(str, log, results);
  667. }
  668. else if ( this->MemoryTesterStyle ==
  669. cmCTestMemCheckHandler::BOUNDS_CHECKER )
  670. {
  671. return this->ProcessMemCheckBoundsCheckerOutput(str, log, results);
  672. }
  673. else
  674. {
  675. log.append("\nMemory checking style used was: ");
  676. log.append("None that I know");
  677. log = str;
  678. }
  679. return true;
  680. }
  681. std::vector<int>::size_type cmCTestMemCheckHandler::FindOrAddWarning(
  682. const std::string& warning)
  683. {
  684. for(std::vector<std::string>::size_type i =0;
  685. i < this->ResultStrings.size(); ++i)
  686. {
  687. if(this->ResultStrings[i] == warning)
  688. {
  689. return i;
  690. }
  691. }
  692. this->GlobalResults.push_back(0); // this must stay the same size
  693. this->ResultStrings.push_back(warning);
  694. this->ResultStringsLong.push_back(warning);
  695. return this->ResultStrings.size()-1;
  696. }
  697. //----------------------------------------------------------------------
  698. bool cmCTestMemCheckHandler::ProcessMemCheckThreadSanitizerOutput(
  699. const std::string& str, std::string& log,
  700. std::vector<int>& result)
  701. {
  702. cmsys::RegularExpression
  703. sanitizerWarning("WARNING: ThreadSanitizer: (.*) \\(pid=.*\\)");
  704. int defects = 0;
  705. std::vector<std::string> lines;
  706. cmSystemTools::Split(str.c_str(), lines);
  707. cmOStringStream ostr;
  708. log = "";
  709. for( std::vector<std::string>::iterator i = lines.begin();
  710. i != lines.end(); ++i)
  711. {
  712. if(sanitizerWarning.find(*i))
  713. {
  714. std::string warning = sanitizerWarning.match(1);
  715. std::vector<int>::size_type idx = this->FindOrAddWarning(warning);
  716. if(result.size() == 0 || idx > result.size()-1)
  717. {
  718. result.push_back(1);
  719. }
  720. else
  721. {
  722. result[idx]++;
  723. }
  724. defects++;
  725. ostr << "<b>" << this->ResultStrings[idx] << "</b> ";
  726. }
  727. ostr << cmXMLSafe(*i) << std::endl;
  728. }
  729. log = ostr.str();
  730. if(defects)
  731. {
  732. return false;
  733. }
  734. return true;
  735. }
  736. //----------------------------------------------------------------------
  737. bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
  738. const std::string& str, std::string& log,
  739. std::vector<int>& results)
  740. {
  741. std::vector<std::string> lines;
  742. cmSystemTools::Split(str.c_str(), lines);
  743. cmOStringStream ostr;
  744. log = "";
  745. cmsys::RegularExpression pfW("^\\[[WEI]\\] ([A-Z][A-Z][A-Z][A-Z]*): ");
  746. int defects = 0;
  747. for( std::vector<std::string>::iterator i = lines.begin();
  748. i != lines.end(); ++i)
  749. {
  750. std::vector<int>::size_type failure = this->ResultStrings.size();
  751. if ( pfW.find(*i) )
  752. {
  753. std::vector<int>::size_type cc;
  754. for ( cc = 0; cc < this->ResultStrings.size(); cc ++ )
  755. {
  756. if ( pfW.match(1) == this->ResultStrings[cc] )
  757. {
  758. failure = cc;
  759. break;
  760. }
  761. }
  762. if ( cc == this->ResultStrings.size() )
  763. {
  764. cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown Purify memory fault: "
  765. << pfW.match(1) << std::endl);
  766. ostr << "*** Unknown Purify memory fault: " << pfW.match(1)
  767. << std::endl;
  768. }
  769. }
  770. if ( failure != this->ResultStrings.size() )
  771. {
  772. ostr << "<b>" << this->ResultStrings[failure] << "</b> ";
  773. results[failure] ++;
  774. defects ++;
  775. }
  776. ostr << cmXMLSafe(*i) << std::endl;
  777. }
  778. log = ostr.str();
  779. if ( defects )
  780. {
  781. return false;
  782. }
  783. return true;
  784. }
  785. //----------------------------------------------------------------------
  786. bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
  787. const std::string& str, std::string& log,
  788. std::vector<int>& results)
  789. {
  790. std::vector<std::string> lines;
  791. cmSystemTools::Split(str.c_str(), lines);
  792. bool unlimitedOutput = false;
  793. if(str.find("CTEST_FULL_OUTPUT") != str.npos ||
  794. this->CustomMaximumFailedTestOutputSize == 0)
  795. {
  796. unlimitedOutput = true;
  797. }
  798. std::string::size_type cc;
  799. cmOStringStream ostr;
  800. log = "";
  801. int defects = 0;
  802. cmsys::RegularExpression valgrindLine("^==[0-9][0-9]*==");
  803. cmsys::RegularExpression vgFIM(
  804. "== .*Invalid free\\(\\) / delete / delete\\[\\]");
  805. cmsys::RegularExpression vgFMM(
  806. "== .*Mismatched free\\(\\) / delete / delete \\[\\]");
  807. cmsys::RegularExpression vgMLK1(
  808. "== .*[0-9,]+ bytes in [0-9,]+ blocks are definitely lost"
  809. " in loss record [0-9,]+ of [0-9,]+");
  810. cmsys::RegularExpression vgMLK2(
  811. "== .*[0-9,]+ \\([0-9,]+ direct, [0-9,]+ indirect\\)"
  812. " bytes in [0-9,]+ blocks are definitely lost"
  813. " in loss record [0-9,]+ of [0-9,]+");
  814. cmsys::RegularExpression vgPAR(
  815. "== .*Syscall param .* (contains|points to) unaddressable byte\\(s\\)");
  816. cmsys::RegularExpression vgMPK1(
  817. "== .*[0-9,]+ bytes in [0-9,]+ blocks are possibly lost in"
  818. " loss record [0-9,]+ of [0-9,]+");
  819. cmsys::RegularExpression vgMPK2(
  820. "== .*[0-9,]+ bytes in [0-9,]+ blocks are still reachable"
  821. " in loss record [0-9,]+ of [0-9,]+");
  822. cmsys::RegularExpression vgUMC(
  823. "== .*Conditional jump or move depends on uninitialised value\\(s\\)");
  824. cmsys::RegularExpression vgUMR1(
  825. "== .*Use of uninitialised value of size [0-9,]+");
  826. cmsys::RegularExpression vgUMR2("== .*Invalid read of size [0-9,]+");
  827. cmsys::RegularExpression vgUMR3("== .*Jump to the invalid address ");
  828. cmsys::RegularExpression vgUMR4("== .*Syscall param .* contains "
  829. "uninitialised or unaddressable byte\\(s\\)");
  830. cmsys::RegularExpression vgUMR5("== .*Syscall param .* uninitialised");
  831. cmsys::RegularExpression vgIPW("== .*Invalid write of size [0-9,]+");
  832. cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is "
  833. "locked by a different thread");
  834. std::vector<std::string::size_type> nonValGrindOutput;
  835. double sttime = cmSystemTools::GetTime();
  836. cmCTestLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl);
  837. std::string::size_type totalOutputSize = 0;
  838. bool outputFull = false;
  839. for ( cc = 0; cc < lines.size(); cc ++ )
  840. {
  841. cmCTestLog(this->CTest, DEBUG, "test line "
  842. << lines[cc] << std::endl);
  843. if ( valgrindLine.find(lines[cc]) )
  844. {
  845. cmCTestLog(this->CTest, DEBUG, "valgrind line "
  846. << lines[cc] << std::endl);
  847. int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT;
  848. if ( vgFIM.find(lines[cc]) )
  849. {
  850. failure = cmCTestMemCheckHandler::FIM;
  851. }
  852. else if ( vgFMM.find(lines[cc]) )
  853. {
  854. failure = cmCTestMemCheckHandler::FMM;
  855. }
  856. else if ( vgMLK1.find(lines[cc]) )
  857. {
  858. failure = cmCTestMemCheckHandler::MLK;
  859. }
  860. else if ( vgMLK2.find(lines[cc]) )
  861. {
  862. failure = cmCTestMemCheckHandler::MLK;
  863. }
  864. else if ( vgPAR.find(lines[cc]) )
  865. {
  866. failure = cmCTestMemCheckHandler::PAR;
  867. }
  868. else if ( vgMPK1.find(lines[cc]) )
  869. {
  870. failure = cmCTestMemCheckHandler::MPK;
  871. }
  872. else if ( vgMPK2.find(lines[cc]) )
  873. {
  874. failure = cmCTestMemCheckHandler::MPK;
  875. }
  876. else if ( vgUMC.find(lines[cc]) )
  877. {
  878. failure = cmCTestMemCheckHandler::UMC;
  879. }
  880. else if ( vgUMR1.find(lines[cc]) )
  881. {
  882. failure = cmCTestMemCheckHandler::UMR;
  883. }
  884. else if ( vgUMR2.find(lines[cc]) )
  885. {
  886. failure = cmCTestMemCheckHandler::UMR;
  887. }
  888. else if ( vgUMR3.find(lines[cc]) )
  889. {
  890. failure = cmCTestMemCheckHandler::UMR;
  891. }
  892. else if ( vgUMR4.find(lines[cc]) )
  893. {
  894. failure = cmCTestMemCheckHandler::UMR;
  895. }
  896. else if ( vgUMR5.find(lines[cc]) )
  897. {
  898. failure = cmCTestMemCheckHandler::UMR;
  899. }
  900. else if ( vgIPW.find(lines[cc]) )
  901. {
  902. failure = cmCTestMemCheckHandler::IPW;
  903. }
  904. else if ( vgABR.find(lines[cc]) )
  905. {
  906. failure = cmCTestMemCheckHandler::ABR;
  907. }
  908. if ( failure != cmCTestMemCheckHandler::NO_MEMORY_FAULT )
  909. {
  910. ostr << "<b>" << this->ResultStrings[failure] << "</b> ";
  911. results[failure] ++;
  912. defects ++;
  913. }
  914. totalOutputSize += lines[cc].size();
  915. ostr << cmXMLSafe(lines[cc]) << std::endl;
  916. }
  917. else
  918. {
  919. nonValGrindOutput.push_back(cc);
  920. }
  921. }
  922. // Now put all all the non valgrind output into the test output
  923. if(!outputFull)
  924. {
  925. for(std::vector<std::string::size_type>::iterator i =
  926. nonValGrindOutput.begin(); i != nonValGrindOutput.end(); ++i)
  927. {
  928. totalOutputSize += lines[*i].size();
  929. cmCTestLog(this->CTest, DEBUG, "before xml safe "
  930. << lines[*i] << std::endl);
  931. cmCTestLog(this->CTest, DEBUG, "after xml safe "
  932. << cmXMLSafe(lines[*i]) << std::endl);
  933. ostr << cmXMLSafe(lines[*i]) << std::endl;
  934. if(!unlimitedOutput && totalOutputSize >
  935. static_cast<size_t>(this->CustomMaximumFailedTestOutputSize))
  936. {
  937. outputFull = true;
  938. ostr << "....\n";
  939. ostr << "Test Output for this test has been truncated see testing"
  940. " machine logs for full output,\n";
  941. ostr << "or put CTEST_FULL_OUTPUT in the output of "
  942. "this test program.\n";
  943. }
  944. }
  945. }
  946. cmCTestLog(this->CTest, DEBUG, "End test (elapsed: "
  947. << (cmSystemTools::GetTime() - sttime) << std::endl);
  948. log = ostr.str();
  949. if ( defects )
  950. {
  951. return false;
  952. }
  953. return true;
  954. }
  955. //----------------------------------------------------------------------
  956. bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
  957. const std::string& str, std::string& log,
  958. std::vector<int>& results)
  959. {
  960. log = "";
  961. double sttime = cmSystemTools::GetTime();
  962. std::vector<std::string> lines;
  963. cmSystemTools::Split(str.c_str(), lines);
  964. cmCTestLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl);
  965. std::vector<std::string>::size_type cc;
  966. for ( cc = 0; cc < lines.size(); cc ++ )
  967. {
  968. if(lines[cc] == BOUNDS_CHECKER_MARKER)
  969. {
  970. break;
  971. }
  972. }
  973. cmBoundsCheckerParser parser(this->CTest);
  974. parser.InitializeParser();
  975. if(cc < lines.size())
  976. {
  977. for(cc++; cc < lines.size(); ++cc)
  978. {
  979. std::string& theLine = lines[cc];
  980. // check for command line arguments that are not escaped
  981. // correctly by BC
  982. if(theLine.find("TargetArgs=") != theLine.npos)
  983. {
  984. // skip this because BC gets it wrong and we can't parse it
  985. }
  986. else if(!parser.ParseChunk(theLine.c_str(), theLine.size()))
  987. {
  988. cmCTestLog(this->CTest, ERROR_MESSAGE,
  989. "Error in ParseChunk: " << theLine
  990. << std::endl);
  991. }
  992. }
  993. }
  994. int defects = 0;
  995. for(cc =0; cc < parser.Errors.size(); ++cc)
  996. {
  997. results[parser.Errors[cc]]++;
  998. defects++;
  999. }
  1000. cmCTestLog(this->CTest, DEBUG, "End test (elapsed: "
  1001. << (cmSystemTools::GetTime() - sttime) << std::endl);
  1002. if(defects)
  1003. {
  1004. // only put the output of Bounds Checker if there were
  1005. // errors or leaks detected
  1006. log = parser.Log;
  1007. return false;
  1008. }
  1009. return true;
  1010. }
  1011. // PostProcessTest memcheck results
  1012. void
  1013. cmCTestMemCheckHandler::PostProcessTest(cmCTestTestResult& res,
  1014. int test)
  1015. {
  1016. cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  1017. "PostProcessTest memcheck results for : "
  1018. << res.Name << std::endl);
  1019. if(this->MemoryTesterStyle
  1020. == cmCTestMemCheckHandler::BOUNDS_CHECKER)
  1021. {
  1022. this->PostProcessBoundsCheckerTest(res, test);
  1023. }
  1024. else
  1025. {
  1026. this->AppendMemTesterOutput(res, test);
  1027. }
  1028. }
  1029. // This method puts the bounds checker output file into the output
  1030. // for the test
  1031. void
  1032. cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res,
  1033. int test)
  1034. {
  1035. cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  1036. "PostProcessBoundsCheckerTest for : "
  1037. << res.Name << std::endl);
  1038. std::string ofile = this->TestOutputFileName(test);
  1039. if ( ofile.empty() )
  1040. {
  1041. return;
  1042. }
  1043. // put a scope around this to close ifs so the file can be removed
  1044. {
  1045. cmsys::ifstream ifs(ofile.c_str());
  1046. if ( !ifs )
  1047. {
  1048. std::string log = "Cannot read memory tester output file: " + ofile;
  1049. cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
  1050. return;
  1051. }
  1052. res.Output += BOUNDS_CHECKER_MARKER;
  1053. res.Output += "\n";
  1054. std::string line;
  1055. while ( cmSystemTools::GetLineFromStream(ifs, line) )
  1056. {
  1057. res.Output += line;
  1058. res.Output += "\n";
  1059. }
  1060. }
  1061. cmSystemTools::Delay(1000);
  1062. cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile.c_str());
  1063. cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
  1064. << this->BoundsCheckerDPBDFile << std::endl);
  1065. cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile.c_str());
  1066. cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
  1067. << this->BoundsCheckerXMLFile << std::endl);
  1068. }
  1069. void
  1070. cmCTestMemCheckHandler::AppendMemTesterOutput(cmCTestTestResult& res,
  1071. int test)
  1072. {
  1073. std::string ofile = this->TestOutputFileName(test);
  1074. if ( ofile.empty() )
  1075. {
  1076. return;
  1077. }
  1078. // put ifs in scope so file can be deleted if needed
  1079. {
  1080. cmsys::ifstream ifs(ofile.c_str());
  1081. if ( !ifs )
  1082. {
  1083. std::string log = "Cannot read memory tester output file: " + ofile;
  1084. cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
  1085. return;
  1086. }
  1087. std::string line;
  1088. while ( cmSystemTools::GetLineFromStream(ifs, line) )
  1089. {
  1090. res.Output += line;
  1091. res.Output += "\n";
  1092. }
  1093. }
  1094. if(this->LogWithPID)
  1095. {
  1096. cmSystemTools::RemoveFile(ofile.c_str());
  1097. cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "<< ofile <<"\n");
  1098. }
  1099. }
  1100. std::string
  1101. cmCTestMemCheckHandler::TestOutputFileName(int test)
  1102. {
  1103. std::string index;
  1104. cmOStringStream stream;
  1105. stream << test;
  1106. index = stream.str();
  1107. std::string ofile = this->MemoryTesterOutputFile;
  1108. std::string::size_type pos = ofile.find("??");
  1109. ofile.replace(pos, 2, index);
  1110. if(this->LogWithPID)
  1111. {
  1112. ofile += ".*";
  1113. cmsys::Glob g;
  1114. g.FindFiles(ofile);
  1115. if(g.GetFiles().size() == 0)
  1116. {
  1117. std::string log = "Cannot find memory tester output file: "
  1118. + ofile;
  1119. cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
  1120. ofile = "";
  1121. }
  1122. else
  1123. {
  1124. ofile = g.GetFiles()[0];
  1125. }
  1126. }
  1127. else if ( !cmSystemTools::FileExists(ofile.c_str()) )
  1128. {
  1129. std::string log = "Cannot find memory tester output file: "
  1130. + ofile;
  1131. cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
  1132. ofile = "";
  1133. }
  1134. return ofile;
  1135. }