CMake/Tests/CTestTestMemcheck/testThreadSanitizer.cmake
Bill Hoffman 49948f7221 ctest_memcheck: Add support for ThreadSanitizer
This commit adds support for ThreadSanitizer to ctest.  ThreadSanitizer
is part of the clang compiler and also gcc 4.8 and later. You have to
compile the code with special flags. Then your code gets the the
ThreadSanitizer ability built into it. To pass options to the
ThreadSanitizer you use an environment variable. This commit teaches
ctest to parse the output from ThreadSanitizer and send it to CDash.
2014-07-09 09:48:35 -04:00

48 lines
1.4 KiB
CMake

# this file simulates a program that has been built with thread sanitizer
# options
message("TSAN_OPTIONS = [$ENV{TSAN_OPTIONS}]")
string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{TSAN_OPTIONS}")
message("LOG_FILE=[${LOG_FILE}]")
set(error_types
"data race"
"data race on vptr (ctor/dtor vs virtual call)"
"heap-use-after-free"
"thread leak"
"destroy of a locked mutex"
"double lock of a mutex"
"unlock of an unlocked mutex (or by a wrong thread)"
"read lock of a write locked mutex"
"read unlock of a write locked mutex"
"signal-unsafe call inside of a signal"
"signal handler spoils errno"
"lock-order-inversion (potential deadlock)"
)
# 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
foreach(error_type ${error_types} )
file(APPEND "${LOG_FILE}.2343"
"==================
WARNING: ThreadSanitizer: ${error_type} (pid=27978)
Write of size 4 at 0x7fe017ce906c by thread T1:
#0 Thread1 ??:0 (exe+0x000000000bb0)
#1 <null> <null>:0 (libtsan.so.0+0x00000001b279)
Previous write of size 4 at 0x7fe017ce906c by main thread:
#0 main ??:0 (exe+0x000000000c3c)
Thread T1 (tid=27979, running) created by main thread at:
#0 <null> <null>:0 (libtsan.so.0+0x00000001ed7b)
#1 main ??:0 (exe+0x000000000c2c)
SUMMARY: ThreadSanitizer: ${error_type} ??:0 Thread1
==================
")
endforeach()