cmake/Source/CTest/cmCTestMemCheckHandler.h

159 lines
4.3 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. */
2021-09-14 00:13:48 +02:00
#pragma once
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-10-30 18:24:19 +01:00
2015-04-27 22:25:09 +02:00
#include <string>
2016-07-09 11:21:54 +02:00
#include <vector>
2020-02-01 23:06:01 +01:00
#include "cmCTestTestHandler.h"
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:
2020-02-01 23:06:01 +01:00
using Superclass = cmCTestTestHandler;
2018-01-26 17:06:56 +01:00
void PopulateCustomVectors(cmMakefile* mf) override;
2013-03-16 19:13:01 +02:00
cmCTestMemCheckHandler();
2018-01-26 17:06:56 +01:00
void Initialize() override;
2016-07-09 11:21:54 +02:00
2021-09-14 00:13:48 +02:00
int GetDefectCount() const;
2017-04-14 19:02:05 +02:00
protected:
2018-01-26 17:06:56 +01:00
int PreProcessHandler() override;
int PostProcessHandler() override;
void GenerateTestCommand(std::vector<std::string>& args, int test) override;
private:
2016-07-09 11:21:54 +02:00
enum
{ // Memory checkers
UNKNOWN = 0,
VALGRIND,
PURIFY,
2020-08-30 11:54:41 +02:00
DRMEMORY,
2015-04-27 22:25:09 +02:00
BOUNDS_CHECKER,
// checkers after here do not use the standard error list
2021-09-14 00:13:48 +02:00
CUDA_SANITIZER,
2015-04-27 22:25:09 +02:00
ADDRESS_SANITIZER,
2017-04-14 19:02:05 +02:00
LEAK_SANITIZER,
2015-04-27 22:25:09 +02:00
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
2017-04-14 19:02:05 +02:00
int DefectCount;
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();
2019-11-11 23:01:05 +01:00
//! Initialize memory checking subsystem.
bool InitializeMemoryChecking();
/**
* Generate the Dart compatible output
*/
2018-01-26 17:06:56 +01:00
void GenerateDartOutput(cmXMLWriter& xml) 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
2018-08-09 18:06:22 +02:00
// different memory errors.
2016-07-09 11:21:54 +02:00
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);
2020-08-30 11:54:41 +02:00
bool ProcessMemCheckDrMemoryOutput(const std::string& str, std::string& log,
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);
2021-09-14 00:13:48 +02:00
bool ProcessMemCheckCudaOutput(const std::string& str, std::string& log,
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);
2020-08-30 11:54:41 +02:00
void PostProcessDrMemoryTest(cmCTestTestResult& res, int test);
2013-11-03 12:27:13 +02:00
2019-11-11 23:01:05 +01:00
//! 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
2019-11-11 23:01:05 +01: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);
};