diff options
author | Brad King <brad.king@kitware.com> | 2017-01-11 14:58:55 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2017-01-11 14:58:55 (GMT) |
commit | 12d5ccd10a451301bf3cbdefe8fde744bf6c9467 (patch) | |
tree | fd9ac2a5e522207f547706e0893c0ff78612ecc5 /Tests/RunCMake | |
parent | 9a670222758bff23645df36a5cb9d98cb1bafa8e (diff) | |
parent | e537bd91129fc1616f787b64024f1b08d0f7ae45 (diff) | |
download | CMake-12d5ccd10a451301bf3cbdefe8fde744bf6c9467.zip CMake-12d5ccd10a451301bf3cbdefe8fde744bf6c9467.tar.gz CMake-12d5ccd10a451301bf3cbdefe8fde744bf6c9467.tar.bz2 |
Merge topic 'ctest_memcheck-leak_sanitizer'
e537bd91 ctest_memcheck: do not add detect_leaks=1 to ASAN_OPTIONS
0a2e5885 ctest_memcheck: join *SAN_OPTIONS with :
cdacfbd2 MEMORYCHECK_SUPPRESSIONS_FILE: add support for sanitizers
cf590c12 ctest_memcheck: add support for standalone LeakSanitizer
Diffstat (limited to 'Tests/RunCMake')
6 files changed, 82 insertions, 17 deletions
diff --git a/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-result.txt b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stderr.txt b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stderr.txt new file mode 100644 index 0000000..327bd5c --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stderr.txt @@ -0,0 +1 @@ +Cannot find memory tester output file: .*/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-build/Testing/Temporary/MemoryChecker.1.log\.\* diff --git a/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stdout.txt new file mode 100644 index 0000000..97a8a9b --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stdout.txt @@ -0,0 +1,3 @@ +Memory checking results: +Direct leak - 2 +Indirect leak - 1 diff --git a/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake b/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake index 212bfdb..352a381 100644 --- a/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake @@ -30,22 +30,22 @@ unset(CMAKELISTS_EXTRA_CODE) unset(CTEST_EXTRA_CODE) #----------------------------------------------------------------------------- -# add LeakSanitizer test +# add standalone LeakSanitizer test set(CTEST_EXTRA_CODE -"set(CTEST_MEMORYCHECK_SANITIZER_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}\" -P \"${RunCMake_SOURCE_DIR}/testLeakSanitizer.cmake\") ") -run_mc_test(DummyLeakSanitizer "" -DMEMCHECK_TYPE=AddressSanitizer) +run_mc_test(DummyLeakSanitizer "" -DMEMCHECK_TYPE=LeakSanitizer) unset(CMAKELISTS_EXTRA_CODE) unset(CTEST_EXTRA_CODE) #----------------------------------------------------------------------------- # add AddressSanitizer test set(CTEST_EXTRA_CODE -"set(CTEST_MEMORYCHECK_SANITIZER_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}\" @@ -56,9 +56,22 @@ unset(CMAKELISTS_EXTRA_CODE) unset(CTEST_EXTRA_CODE) #----------------------------------------------------------------------------- +# add AddressSanitizer/LeakSanitizer test +set(CTEST_EXTRA_CODE +"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}\" +-P \"${RunCMake_SOURCE_DIR}/testAddressLeakSanitizer.cmake\") +") +run_mc_test(DummyAddressLeakSanitizer "" -DMEMCHECK_TYPE=AddressSanitizer) +unset(CMAKELISTS_EXTRA_CODE) +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_COMMAND_OPTIONS \"simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55\") ") set(CMAKELISTS_EXTRA_CODE "add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\" @@ -151,13 +164,13 @@ unset(CTEST_SUFFIX_CODE) set(CTEST_SUFFIX_CODE "message(\"Defect count: \${defect_count}\")") set(CTEST_MEMCHECK_ARGS "DEFECT_COUNT defect_count") set(CTEST_EXTRA_CODE -"set(CTEST_MEMORYCHECK_SANITIZER_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}\" -P \"${RunCMake_SOURCE_DIR}/testLeakSanitizer.cmake\") ") -run_mc_test(DummyLeakSanitizerPrintDefects "" -DMEMCHECK_TYPE=AddressSanitizer) +run_mc_test(DummyLeakSanitizerPrintDefects "" -DMEMCHECK_TYPE=LeakSanitizer) unset(CMAKELISTS_EXTRA_CODE) unset(CTEST_EXTRA_CODE) unset(CTEST_MEMCHECK_ARGS) diff --git a/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake new file mode 100644 index 0000000..2a57b11 --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake @@ -0,0 +1,47 @@ +# this file simulates a program that has been built with AddressSanitizer +# options + +message("ASAN_OPTIONS = [$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 +if(NOT "$ENV{ASAN_OPTIONS}]" MATCHES "simulate_sanitizer.1") + return() +endif() + +# clear the log files +file(REMOVE "${LOG_FILE}.2343") +file(REMOVE "${LOG_FILE}.2344") + +# create an error of each type of LeakSanitizer + +file(APPEND "${LOG_FILE}.2343" +"================================================================= +==25308==ERROR: LeakSanitizer: detected memory leaks + +Direct leak of 4360 byte(s) in 1 object(s) allocated from: + #0 0x46c669 in operator new[](unsigned long) (/home/kitware/msan/a.out+0x46c669) + #1 0x4823b4 in main /home/kitware/msan/memcheck.cxx:12 + #2 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 + +SUMMARY: AddressSanitizer: 4436 byte(s) leaked in 2 allocation(s). +") +file(APPEND "${LOG_FILE}.2342" +"================================================================= +==25308==ERROR: LeakSanitizer: detected memory leaks + +Direct leak of 76 byte(s) in 1 object(s) allocated from: + #0 0x46c669 in operator new[](unsigned long) (/home/kitware/msan/a.out+0x46c669) + #1 0x4821b8 in foo() /home/kitware/msan/memcheck.cxx:4 + #2 0x4823f2 in main /home/kitware/msan/memcheck.cxx:14 + #3 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 + +Indirect leak of 76 byte(s) in 1 object(s) allocated from: + #0 0x46c669 in operator new[](unsigned long) (/home/kitware/msan/a.out+0x46c669) + #1 0x4821b8 in foo() /home/kitware/msan/memcheck.cxx:4 + #2 0x4823f2 in main /home/kitware/msan/memcheck.cxx:14 + #3 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 + +SUMMARY: AddressSanitizer: 4436 byte(s) leaked in 2 allocation(s). +") diff --git a/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake index 02030be..af214c8 100644 --- a/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake @@ -1,20 +1,20 @@ -# this file simulates a program that has been built with thread sanitizer +# this file simulates a program that has been built with LeakSanitizer # options -message("ASAN_OPTIONS = [$ENV{ASAN_OPTIONS}]") -string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}") +message("LSAN_OPTIONS = [$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 leak sanitizer don't do it -if(NOT "$ENV{ASAN_OPTIONS}]" MATCHES "simulate_sanitizer.1") + +# if we are not asked to simulate LeakSanitizer don't do it +if(NOT "$ENV{LSAN_OPTIONS}]" MATCHES "simulate_sanitizer.1") return() endif() -# clear the log file +# clear the log files file(REMOVE "${LOG_FILE}.2343") file(REMOVE "${LOG_FILE}.2344") -# create an error of each type of thread santizer -# these names come from tsan_report.cc in llvm +# create an error of each type of LeakSanitizer file(APPEND "${LOG_FILE}.2343" "================================================================= @@ -25,7 +25,7 @@ Direct leak of 4360 byte(s) in 1 object(s) allocated from: #1 0x4823b4 in main /home/kitware/msan/memcheck.cxx:12 #2 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 -SUMMARY: AddressSanitizer: 4436 byte(s) leaked in 2 allocation(s). +SUMMARY: LeakSanitizer: 4436 byte(s) leaked in 2 allocation(s). ") file(APPEND "${LOG_FILE}.2342" "================================================================= @@ -43,5 +43,5 @@ Indirect leak of 76 byte(s) in 1 object(s) allocated from: #2 0x4823f2 in main /home/kitware/msan/memcheck.cxx:14 #3 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 -SUMMARY: AddressSanitizer: 4436 byte(s) leaked in 2 allocation(s). +SUMMARY: LeakSanitizer: 4436 byte(s) leaked in 2 allocation(s). ") |