summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2020-04-19 11:06:59 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-04-19 11:07:13 (GMT)
commit348a2a9734d7a8dd07a44afdcee47acbf6fa3dc2 (patch)
tree257b082861f40dcdb5c414788beba4734dcb2e42
parent53b773113d8ae4accbb4493fb38c7c1556e59279 (diff)
parente03d3c08f0fbfbe119c7690e06d1c73924a792aa (diff)
downloadCMake-348a2a9734d7a8dd07a44afdcee47acbf6fa3dc2.zip
CMake-348a2a9734d7a8dd07a44afdcee47acbf6fa3dc2.tar.gz
CMake-348a2a9734d7a8dd07a44afdcee47acbf6fa3dc2.tar.bz2
Merge topic 'ctest-memcheck-sanitizers'
e03d3c08f0 CTest: Fix '-T MemCheck' command-line support for sanitizers 82b6091776 Tests: Fix RunCMake.ctest_memcheck test script syntax errors Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4618
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx13
-rw-r--r--Tests/RunCMake/CTestCommandLine/MemCheckSan.cmake7
-rw-r--r--Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake21
-rw-r--r--Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake2
-rw-r--r--Tests/RunCMake/ctest_memcheck/testAddressSanitizer.cmake2
-rw-r--r--Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake2
-rw-r--r--Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake2
-rw-r--r--Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake2
-rw-r--r--Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake2
9 files changed, 39 insertions, 14 deletions
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index 8687bb8..85b8ab1 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -298,9 +298,6 @@ void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile* mf)
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_MEMCHECK_IGNORE",
this->CustomTestsIgnore);
- std::string cmake = cmSystemTools::GetCMakeCommand();
- this->CTest->SetCTestConfiguration("CMakeCommand", cmake.c_str(),
- this->Quiet);
}
int cmCTestMemCheckHandler::GetDefectCount()
@@ -491,31 +488,31 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
}
if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
"AddressSanitizer") {
- this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand");
+ this->MemoryTester = cmSystemTools::GetCMakeCommand();
this->MemoryTesterStyle = cmCTestMemCheckHandler::ADDRESS_SANITIZER;
this->LogWithPID = true; // even if we give the log file the pid is added
}
if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
"LeakSanitizer") {
- this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand");
+ this->MemoryTester = cmSystemTools::GetCMakeCommand();
this->MemoryTesterStyle = cmCTestMemCheckHandler::LEAK_SANITIZER;
this->LogWithPID = true; // even if we give the log file the pid is added
}
if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
"ThreadSanitizer") {
- this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand");
+ this->MemoryTester = cmSystemTools::GetCMakeCommand();
this->MemoryTesterStyle = cmCTestMemCheckHandler::THREAD_SANITIZER;
this->LogWithPID = true; // even if we give the log file the pid is added
}
if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
"MemorySanitizer") {
- this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand");
+ this->MemoryTester = cmSystemTools::GetCMakeCommand();
this->MemoryTesterStyle = cmCTestMemCheckHandler::MEMORY_SANITIZER;
this->LogWithPID = true; // even if we give the log file the pid is added
}
if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
"UndefinedBehaviorSanitizer") {
- this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand");
+ this->MemoryTester = cmSystemTools::GetCMakeCommand();
this->MemoryTesterStyle = cmCTestMemCheckHandler::UB_SANITIZER;
this->LogWithPID = true; // even if we give the log file the pid is added
}
diff --git a/Tests/RunCMake/CTestCommandLine/MemCheckSan.cmake b/Tests/RunCMake/CTestCommandLine/MemCheckSan.cmake
new file mode 100644
index 0000000..192c30c
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/MemCheckSan.cmake
@@ -0,0 +1,7 @@
+set(MEMORYCHECK_COMMAND "")
+include(CTest)
+add_test(
+ NAME TestSan
+ COMMAND ${CMAKE_COMMAND}
+ -P ${CMAKE_CURRENT_LIST_DIR}/../ctest_memcheck/test${MEMORYCHECK_TYPE}.cmake
+ )
diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
index 9b9ae65..c76314a 100644
--- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
@@ -345,3 +345,24 @@ run_NoTests()
# Check the configuration type variable is passed
run_ctest(check-configuration-type)
+
+function(run_MemCheckSan case opts)
+ # Use a single build tree for a few tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/MemCheckSan${case}-build)
+ set(RunCMake_TEST_OPTIONS
+ "-DMEMORYCHECK_TYPE=${case}Sanitizer"
+ "-DMEMORYCHECK_SANITIZER_OPTIONS=${opts}"
+ )
+ run_cmake(MemCheckSan)
+ unset(RunCMake_TEST_OPTIONS)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake-stdout-file "../ctest_memcheck/Dummy${case}Sanitizer-stdout.txt")
+ run_cmake_command(MemCheckSan${case}-ctest
+ ${CMAKE_CTEST_COMMAND} -C Debug -M Experimental -T MemCheck -V
+ )
+endfunction()
+run_MemCheckSan(Address "simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55")
+run_MemCheckSan(Leak "simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55")
+run_MemCheckSan(Memory "simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55")
+run_MemCheckSan(Thread "report_bugs=1:history_size=5:exitcode=55")
+run_MemCheckSan(UndefinedBehavior "simulate_sanitizer=1")
diff --git a/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake
index ca36a7c..58c94d7 100644
--- a/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake
+++ b/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake
@@ -2,7 +2,7 @@
# options
message("ASAN_OPTIONS = [$ENV{ASAN_OPTIONS}]")
-string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}")
+string(REGEX REPLACE ".*log_path='([^']*)'.*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}")
message("LOG_FILE=[${LOG_FILE}]")
# if we are not asked to simulate AddressSanitizer don't do it
diff --git a/Tests/RunCMake/ctest_memcheck/testAddressSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testAddressSanitizer.cmake
index 1219666..8f18cd0 100644
--- a/Tests/RunCMake/ctest_memcheck/testAddressSanitizer.cmake
+++ b/Tests/RunCMake/ctest_memcheck/testAddressSanitizer.cmake
@@ -2,7 +2,7 @@
# options
message("ASAN_OPTIONS = [$ENV{ASAN_OPTIONS}]")
-string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}")
+string(REGEX REPLACE ".*log_path='([^']*)'.*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}")
message("LOG_FILE=[${LOG_FILE}]")
# if we are not asked to simulate address sanitizer don't do it
diff --git a/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake
index 6d51f83..4990792 100644
--- a/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake
+++ b/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake
@@ -2,7 +2,7 @@
# options
message("LSAN_OPTIONS = [$ENV{LSAN_OPTIONS}]")
-string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{LSAN_OPTIONS}")
+string(REGEX REPLACE ".*log_path='([^']*)'.*" "\\1" LOG_FILE "$ENV{LSAN_OPTIONS}")
message("LOG_FILE=[${LOG_FILE}]")
# if we are not asked to simulate LeakSanitizer don't do it
diff --git a/Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake
index 3b3ac22..4a6adb1 100644
--- a/Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake
+++ b/Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake
@@ -2,7 +2,7 @@
# options
message("MSAN_OPTIONS = [$ENV{MSAN_OPTIONS}]")
-string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{MSAN_OPTIONS}")
+string(REGEX REPLACE ".*log_path='([^']*)'.*" "\\1" LOG_FILE "$ENV{MSAN_OPTIONS}")
message("LOG_FILE=[${LOG_FILE}]")
# if we are not asked to simulate address sanitizer don't do it
diff --git a/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake
index e7a5c9f..96251c3 100644
--- a/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake
+++ b/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake
@@ -2,7 +2,7 @@
# options
message("TSAN_OPTIONS = [$ENV{TSAN_OPTIONS}]")
-string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{TSAN_OPTIONS}")
+string(REGEX REPLACE ".*log_path='([^']*)'.*" "\\1" LOG_FILE "$ENV{TSAN_OPTIONS}")
message("LOG_FILE=[${LOG_FILE}]")
set(error_types
diff --git a/Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake
index ba6122d..7160280 100644
--- a/Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake
+++ b/Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake
@@ -2,7 +2,7 @@
# UndefinedBehaviorSanitizer options
message("UBSAN_OPTIONS = [$ENV{UBSAN_OPTIONS}]")
-string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{UBSAN_OPTIONS}")
+string(REGEX REPLACE ".*log_path='([^']*)'.*" "\\1" LOG_FILE "$ENV{UBSAN_OPTIONS}")
message("LOG_FILE=[${LOG_FILE}]")
# if we are not asked to simulate address sanitizer don't do it