From 522e1588ec7bfdbc86199cc1991e706ebafc02fd Mon Sep 17 00:00:00 2001 From: Jamie Snape Date: Mon, 23 Jan 2017 09:13:26 -0500 Subject: [PATCH 1/2] Tests: Use CTEST_MEMORYCHECK_SANITIZER_OPTIONS where appropriate Previously the ThreadSanitizer and MemorySanitizer tests erroneously used `CTEST_MEMORYCHECK_COMMAND_OPTIONS`. --- Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake b/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake index 352a381635..ab4c5abe58 100644 --- a/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake @@ -19,7 +19,7 @@ unset(CMAKELISTS_EXTRA_CODE) #----------------------------------------------------------------------------- # add ThreadSanitizer test set(CTEST_EXTRA_CODE -"set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"report_bugs=1 history_size=5 exitcode=55\") +"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"report_bugs=1:history_size=5:exitcode=55\") ") set(CMAKELISTS_EXTRA_CODE "add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\" @@ -71,7 +71,7 @@ unset(CTEST_EXTRA_CODE) #----------------------------------------------------------------------------- # add MemorySanitizer test 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 "add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\" From e116f2a5de330ca4dd413e29db62ed39805b2c06 Mon Sep 17 00:00:00 2001 From: Jamie Snape Date: Mon, 23 Jan 2017 10:50:38 -0500 Subject: [PATCH 2/2] ctest_memcheck: Fix sanitizers when MemoryCheckSanitizerOptions is empty --- Source/CTest/cmCTestMemCheckHandler.cxx | 12 +++++++++--- .../ctest_memcheck/testAddressLeakSanitizer.cmake | 2 +- .../ctest_memcheck/testAddressSanitizer.cmake | 2 +- .../RunCMake/ctest_memcheck/testLeakSanitizer.cmake | 2 +- .../ctest_memcheck/testMemorySanitizer.cmake | 4 ++-- .../ctest_memcheck/testThreadSanitizer.cmake | 4 ++-- .../testUndefinedBehaviorSanitizer.cmake | 6 +++--- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index a062e6457c..620e237248 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -607,9 +607,13 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->MemoryTesterDynamicOptions.push_back("-E"); this->MemoryTesterDynamicOptions.push_back("env"); std::string envVar; - std::string extraOptions = ":" + - this->CTest->GetCTestConfiguration("MemoryCheckSanitizerOptions"); + std::string extraOptions; std::string suppressionsOption; + if (!this->CTest->GetCTestConfiguration("MemoryCheckSanitizerOptions") + .empty()) { + extraOptions = ":" + + this->CTest->GetCTestConfiguration("MemoryCheckSanitizerOptions"); + } if (!this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile") .empty()) { suppressionsOption = ":suppressions=" + @@ -631,8 +635,10 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() cmCTestMemCheckHandler::UB_SANITIZER) { envVar = "UBSAN_OPTIONS"; } + // Quote log_path with single quotes; see + // https://bugs.chromium.org/p/chromium/issues/detail?id=467936 std::string outputFile = - envVar + "=log_path=\"" + this->MemoryTesterOutputFile + "\""; + envVar + "=log_path='" + this->MemoryTesterOutputFile + "'"; this->MemoryTesterEnvironmentVariable = outputFile + suppressionsOption + extraOptions; break; diff --git a/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake index 2a57b11fa4..ca36a7c89d 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 3082e4b5a1..1219666fd4 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 af214c8a56..6d51f83467 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 c87af9a43f..3b3ac22bd7 100644 --- a/Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake @@ -1,8 +1,8 @@ -# this file simulates a program that has been built with thread sanitizer +# this file simulates a program that has been built with MemorySanitizer # 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 d591931469..e7a5c9f460 100644 --- a/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake @@ -1,8 +1,8 @@ -# this file simulates a program that has been built with thread sanitizer +# this file simulates a program that has been built with ThreadSanitizer # 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 8ef3c0aa67..ba6122d6c2 100644 --- a/Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake @@ -1,8 +1,8 @@ -# this file simulates a program that has been built with undefined behavior -# sanitizer options +# this file simulates a program that has been built with +# 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