cmake/Source/CTest/cmCTestMemCheckHandler.h

153 lines
4.0 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmCTestMemCheckHandler_h
#define cmCTestMemCheckHandler_h
2016-10-30 18:24:19 +01:00
#include <cmConfigure.h>
#include "cmCTestTestHandler.h"
2016-10-30 18:24:19 +01:00
#include "cmTypeMacro.h"
2016-07-09 11:21:54 +02:00
2015-04-27 22:25:09 +02:00
#include <string>
2016-07-09 11:21:54 +02:00
#include <vector>
class cmMakefile;
2015-08-17 11:37:30 +02:00
class cmXMLWriter;
/** \class cmCTestMemCheckHandler
* \brief A class that handles ctest -S invocations
*
*/
class cmCTestMemCheckHandler : public cmCTestTestHandler
{
2009-10-04 10:30:41 +03:00
friend class cmCTestRunTest;
2016-07-09 11:21:54 +02:00
public:
cmTypeMacro(cmCTestMemCheckHandler, cmCTestTestHandler);
2016-10-30 18:24:19 +01:00
void PopulateCustomVectors(cmMakefile* mf) CM_OVERRIDE;
2013-03-16 19:13:01 +02:00
cmCTestMemCheckHandler();
2016-10-30 18:24:19 +01:00
void Initialize() CM_OVERRIDE;
2016-07-09 11:21:54 +02:00
protected:
2016-10-30 18:24:19 +01:00
int PreProcessHandler() CM_OVERRIDE;
int PostProcessHandler() CM_OVERRIDE;
void GenerateTestCommand(std::vector<std::string>& args,
int test) CM_OVERRIDE;
private:
2016-07-09 11:21:54 +02:00
enum
{ // Memory checkers
UNKNOWN = 0,
VALGRIND,
PURIFY,
2015-04-27 22:25:09 +02:00
BOUNDS_CHECKER,
// checkers after here do not use the standard error list
ADDRESS_SANITIZER,
THREAD_SANITIZER,
MEMORY_SANITIZER,
UB_SANITIZER
};
2016-07-09 11:21:54 +02:00
public:
2016-07-09 11:21:54 +02:00
enum
{ // Memory faults
ABR = 0,
ABW,
ABWL,
COR,
EXU,
FFM,
FIM,
FMM,
FMR,
FMW,
FUM,
IPR,
IPW,
MAF,
MLK,
MPK,
NPR,
ODS,
PAR,
PLK,
UMC,
UMR,
NO_MEMORY_FAULT
};
2016-07-09 11:21:54 +02:00
private:
2016-07-09 11:21:54 +02:00
enum
{ // Program statuses
NOT_RUN = 0,
TIMEOUT,
SEGFAULT,
ILLEGAL,
INTERRUPT,
NUMERICAL,
OTHER_FAULT,
FAILED,
BAD_COMMAND,
COMPLETED
};
2016-07-09 11:21:54 +02:00
std::string BoundsCheckerDPBDFile;
std::string BoundsCheckerXMLFile;
std::string MemoryTester;
2015-04-27 22:25:09 +02:00
std::vector<std::string> MemoryTesterDynamicOptions;
std::vector<std::string> MemoryTesterOptions;
2016-07-09 11:21:54 +02:00
int MemoryTesterStyle;
std::string MemoryTesterOutputFile;
std::string MemoryTesterEnvironmentVariable;
2015-04-27 22:25:09 +02:00
// these are used to store the types of errors that can show up
std::vector<std::string> ResultStrings;
std::vector<std::string> ResultStringsLong;
2016-07-09 11:21:54 +02:00
std::vector<int> GlobalResults;
bool LogWithPID; // does log file add pid
2015-04-27 22:25:09 +02:00
std::vector<int>::size_type FindOrAddWarning(const std::string& warning);
// initialize the ResultStrings and ResultStringsLong for
// this type of checker
void InitializeResultsVectors();
///! Initialize memory checking subsystem.
bool InitializeMemoryChecking();
/**
* Generate the Dart compatible output
*/
2016-10-30 18:24:19 +01:00
void GenerateDartOutput(cmXMLWriter& xml) CM_OVERRIDE;
2015-04-27 22:25:09 +02:00
std::vector<std::string> CustomPreMemCheck;
std::vector<std::string> CustomPostMemCheck;
//! Parse Valgrind/Purify/Bounds Checker result out of the output
2016-07-09 11:21:54 +02:00
// string. After running, log holds the output and results hold the
// different memmory errors.
bool ProcessMemCheckOutput(const std::string& str, std::string& log,
std::vector<int>& results);
bool ProcessMemCheckValgrindOutput(const std::string& str, std::string& log,
2015-04-27 22:25:09 +02:00
std::vector<int>& results);
2016-07-09 11:21:54 +02:00
bool ProcessMemCheckPurifyOutput(const std::string& str, std::string& log,
2015-04-27 22:25:09 +02:00
std::vector<int>& results);
2016-07-09 11:21:54 +02:00
bool ProcessMemCheckSanitizerOutput(const std::string& str, std::string& log,
2015-04-27 22:25:09 +02:00
std::vector<int>& results);
2013-03-16 19:13:01 +02:00
bool ProcessMemCheckBoundsCheckerOutput(const std::string& str,
2015-04-27 22:25:09 +02:00
std::string& log,
std::vector<int>& results);
2009-10-04 10:30:41 +03:00
2015-04-27 22:25:09 +02:00
void PostProcessTest(cmCTestTestResult& res, int test);
2013-11-03 12:27:13 +02:00
void PostProcessBoundsCheckerTest(cmCTestTestResult& res, int test);
///! append MemoryTesterOutputFile to the test log
2015-04-27 22:25:09 +02:00
void AppendMemTesterOutput(cmCTestTestHandler::cmCTestTestResult& res,
std::string const& filename);
2013-11-03 12:27:13 +02:00
///! generate the output filename for the given test index
2015-04-27 22:25:09 +02:00
void TestOutputFileNames(int test, std::vector<std::string>& files);
};
#endif