diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2014-10-07 17:51:55 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-10-07 19:27:34 (GMT) |
commit | 7345a1f71d8a7b39680413b5180b0089dc80cc57 (patch) | |
tree | ae6cbfc2975975347bb47ef90f0f9182623ad750 /Tests/CTestTestMemcheck | |
parent | 0c6330da38bb04467eaa4d38c659b02222029ae3 (diff) | |
download | CMake-7345a1f71d8a7b39680413b5180b0089dc80cc57.zip CMake-7345a1f71d8a7b39680413b5180b0089dc80cc57.tar.gz CMake-7345a1f71d8a7b39680413b5180b0089dc80cc57.tar.bz2 |
tests: Add a test for ctest_memcheck MemorySanitizer
Diffstat (limited to 'Tests/CTestTestMemcheck')
-rw-r--r-- | Tests/CTestTestMemcheck/CMakeLists.txt | 17 | ||||
-rw-r--r-- | Tests/CTestTestMemcheck/testMemorySanitizer.cmake | 27 |
2 files changed, 44 insertions, 0 deletions
diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index 7fb4a0f..2023e74 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -152,6 +152,23 @@ set_tests_properties(CTestTestMemcheckDummyAddressSanitizer PROPERTIES ".*Memory checking results:.*heap-buffer-overflow - 1.*") #----------------------------------------------------------------------------- +# add MemorySanitizer test +set(CTEST_EXTRA_CODE +"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}\" +-P \"${CMAKE_CURRENT_SOURCE_DIR}/testMemorySanitizer.cmake\") +") +gen_mc_test_internal(DummyMemorySanitizer "" -DMEMCHECK_TYPE=MemorySanitizer) +set(CMAKELISTS_EXTRA_CODE ) +set(CTEST_EXTRA_CODE) +set_tests_properties(CTestTestMemcheckDummyMemorySanitizer PROPERTIES + PASS_REGULAR_EXPRESSION + ".*Memory checking results:.*use-of-uninitialized-value - 1.*") + +#----------------------------------------------------------------------------- # add UndefinedBehaviorSanitizer test set(CTEST_EXTRA_CODE "set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1\") diff --git a/Tests/CTestTestMemcheck/testMemorySanitizer.cmake b/Tests/CTestTestMemcheck/testMemorySanitizer.cmake new file mode 100644 index 0000000..c87af9a --- /dev/null +++ b/Tests/CTestTestMemcheck/testMemorySanitizer.cmake @@ -0,0 +1,27 @@ +# this file simulates a program that has been built with thread sanitizer +# options + +message("MSAN_OPTIONS = [$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 +if(NOT "$ENV{MSAN_OPTIONS}]" MATCHES "simulate_sanitizer.1") + return() +endif() +# clear the log file +file(REMOVE "${LOG_FILE}.2343") + +# create an error of each type of thread santizer +# these names come from tsan_report.cc in llvm + +file(APPEND "${LOG_FILE}.2343" +"================================================================= +==28423== WARNING: MemorySanitizer: use-of-uninitialized-value + #0 0x7f4364210dd9 in main (/home/kitware/msan/msan-bin/umr+0x7bdd9) + #1 0x7f4362d9376c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 + #2 0x7f4364210b0c in _start (/home/kitware/msan/msan-bin/umr+0x7bb0c) + +SUMMARY: MemorySanitizer: use-of-uninitialized-value ??:0 main +Exiting +") |