Merge topic 'ctest-memcheck-sanitizers'

f25e431d tests: set sanitizer options properly
f0661bf3 tests: fix copy/paste from tsan -> asan comments
ca9cc25c ctest: add support for additional sanitizer options
0b9ffffc ctest: update documentation for CTEST_MEMORYCHECK_TYPE
This commit is contained in:
Brad King 2014-10-07 14:45:26 -04:00 committed by CMake Topic Stage
commit fa56eb56b9
10 changed files with 40 additions and 13 deletions

View File

@ -351,6 +351,7 @@ Variables for CTest
/variable/CTEST_HG_UPDATE_OPTIONS /variable/CTEST_HG_UPDATE_OPTIONS
/variable/CTEST_MEMORYCHECK_COMMAND /variable/CTEST_MEMORYCHECK_COMMAND
/variable/CTEST_MEMORYCHECK_COMMAND_OPTIONS /variable/CTEST_MEMORYCHECK_COMMAND_OPTIONS
/variable/CTEST_MEMORYCHECK_SANITIZER_OPTIONS
/variable/CTEST_MEMORYCHECK_SUPPRESSIONS_FILE /variable/CTEST_MEMORYCHECK_SUPPRESSIONS_FILE
/variable/CTEST_MEMORYCHECK_TYPE /variable/CTEST_MEMORYCHECK_TYPE
/variable/CTEST_NIGHTLY_START_TIME /variable/CTEST_NIGHTLY_START_TIME

View File

@ -824,6 +824,18 @@ Configuration settings include:
* `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_COMMAND_OPTIONS` * `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_COMMAND_OPTIONS`
* :module:`CTest` module variable: ``MEMORYCHECK_COMMAND_OPTIONS`` * :module:`CTest` module variable: ``MEMORYCHECK_COMMAND_OPTIONS``
``MemoryCheckType``
Specify the type of memory checking to perform.
* `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_TYPE`
* :module:`CTest` module variable: ``MEMORYCHECK_TYPE``
``MemoryCheckSanitizerOptions``
Specify options to sanitizers when running with a sanitize-enabled build.
* `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_SANITIZER_OPTIONS`
* :module:`CTest` module variable: ``MEMORYCHECK_SANITIZER_OPTIONS``
``MemoryCheckSuppressionFile`` ``MemoryCheckSuppressionFile``
Specify a file containing suppression rules for the Specify a file containing suppression rules for the
``MemoryCheckCommand`` tool. It will be passed with options ``MemoryCheckCommand`` tool. It will be passed with options

View File

@ -0,0 +1,5 @@
CTEST_MEMORYCHECK_SANITIZER_OPTIONS
-----------------------------------
Specify the CTest ``MemoryCheckSanitizerOptions`` setting
in a :manual:`ctest(1)` dashboard client script.

View File

@ -1,6 +1,7 @@
CTEST_MEMORYCHECK_TYPE CTEST_MEMORYCHECK_TYPE
------------------------- ----------------------
Specify the CTest ``MemoryCheckType`` setting Specify the CTest ``MemoryCheckType`` setting
in a :manual:`ctest(1)` dashboard client script. in a :manual:`ctest(1)` dashboard client script.
Valid values are Valgrind, Purify, BoundsChecker, and ThreadSanitizer. Valid values are Valgrind, Purify, BoundsChecker, and ThreadSanitizer,
and AddressSanitizer.

View File

@ -75,6 +75,7 @@ PurifyCommand: @PURIFYCOMMAND@
ValgrindCommand: @VALGRIND_COMMAND@ ValgrindCommand: @VALGRIND_COMMAND@
ValgrindCommandOptions: @VALGRIND_COMMAND_OPTIONS@ ValgrindCommandOptions: @VALGRIND_COMMAND_OPTIONS@
MemoryCheckType: @MEMORYCHECK_TYPE@ MemoryCheckType: @MEMORYCHECK_TYPE@
MemoryCheckSanitizerOptions: @MEMORYCHECK_SANITIZER_OPTIONS@
MemoryCheckCommand: @MEMORYCHECK_COMMAND@ MemoryCheckCommand: @MEMORYCHECK_COMMAND@
MemoryCheckCommandOptions: @MEMORYCHECK_COMMAND_OPTIONS@ MemoryCheckCommandOptions: @MEMORYCHECK_COMMAND_OPTIONS@
MemoryCheckSuppressionFile: @MEMORYCHECK_SUPPRESSIONS_FILE@ MemoryCheckSuppressionFile: @MEMORYCHECK_SUPPRESSIONS_FILE@

View File

@ -22,6 +22,8 @@ cmCTestGenericHandler* cmCTestMemCheckCommand::InitializeActualHandler()
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"MemoryCheckType", "CTEST_MEMORYCHECK_TYPE"); "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"MemoryCheckSanitizerOptions", "CTEST_MEMORYCHECK_SANITIZER_OPTIONS");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND"); "MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,

View File

@ -686,15 +686,21 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
// TSAN_OPTIONS string with the log_path in it. // TSAN_OPTIONS string with the log_path in it.
this->MemoryTesterDynamicOptions.push_back("-E"); this->MemoryTesterDynamicOptions.push_back("-E");
this->MemoryTesterDynamicOptions.push_back("env"); this->MemoryTesterDynamicOptions.push_back("env");
std::string envVar = "TSAN_OPTIONS"; std::string envVar;
std::string extraOptions; std::string extraOptions =
if(this->MemoryTesterStyle == cmCTestMemCheckHandler::ADDRESS_SANITIZER) this->CTest->GetCTestConfiguration("MemoryCheckSanitizerOptions");
if(this->MemoryTesterStyle == cmCTestMemCheckHandler::THREAD_SANITIZER)
{
envVar = "TSAN_OPTIONS";
}
else if(this->MemoryTesterStyle ==
cmCTestMemCheckHandler::ADDRESS_SANITIZER)
{ {
envVar = "ASAN_OPTIONS"; envVar = "ASAN_OPTIONS";
extraOptions = " detect_leaks=1"; extraOptions += " detect_leaks=1";
} }
std::string outputFile = envVar + "=log_path=\"" std::string outputFile = envVar + "=log_path=\""
+ this->MemoryTesterOutputFile + "\""; + this->MemoryTesterOutputFile + "\" ";
this->MemoryTesterEnvironmentVariable = outputFile + extraOptions; this->MemoryTesterEnvironmentVariable = outputFile + extraOptions;
break; break;
} }

View File

@ -49,7 +49,7 @@ private:
VALGRIND, VALGRIND,
PURIFY, PURIFY,
BOUNDS_CHECKER, BOUNDS_CHECKER,
// checkers after hear do not use the standard error list // checkers after here do not use the standard error list
THREAD_SANITIZER, THREAD_SANITIZER,
ADDRESS_SANITIZER ADDRESS_SANITIZER
}; };

View File

@ -121,7 +121,7 @@ set(CTEST_EXTRA_CODE)
# add LeakSanitizer test # add LeakSanitizer test
set(CTEST_EXTRA_CODE set(CTEST_EXTRA_CODE
"set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\") "set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\")
") ")
set(CMAKELISTS_EXTRA_CODE set(CMAKELISTS_EXTRA_CODE
@ -136,7 +136,7 @@ set_tests_properties(CTestTestMemcheckDummyLeakSanitizer PROPERTIES
".*Memory checking results:.*Direct leak - 2.*Indirect leak - 1.*") ".*Memory checking results:.*Direct leak - 2.*Indirect leak - 1.*")
# add AddressSanitizer test # add AddressSanitizer test
set(CTEST_EXTRA_CODE set(CTEST_EXTRA_CODE
"set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\") "set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\")
") ")
set(CMAKELISTS_EXTRA_CODE set(CMAKELISTS_EXTRA_CODE

View File

@ -1,4 +1,4 @@
# this file simulates a program that has been built with thread sanitizer # this file simulates a program that has been built with address sanitizer
# options # options
message("ASAN_OPTIONS = [$ENV{ASAN_OPTIONS}]") message("ASAN_OPTIONS = [$ENV{ASAN_OPTIONS}]")
@ -12,8 +12,7 @@ endif()
# clear the log file # clear the log file
file(REMOVE "${LOG_FILE}.2343") file(REMOVE "${LOG_FILE}.2343")
# create an error of each type of thread santizer # create an example error from address santizer
# these names come from tsan_report.cc in llvm
file(APPEND "${LOG_FILE}.2343" file(APPEND "${LOG_FILE}.2343"
"================================================================= "=================================================================