cmake/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake

48 lines
1.9 KiB
CMake
Raw Normal View History

2017-04-14 19:02:05 +02:00
# this file simulates a program that has been built with LeakSanitizer
2015-04-27 22:25:09 +02:00
# options
2017-04-14 19:02:05 +02:00
message("LSAN_OPTIONS = [$ENV{LSAN_OPTIONS}]")
2020-08-30 11:54:41 +02:00
string(REGEX REPLACE ".*log_path='([^']*)'.*" "\\1" LOG_FILE "$ENV{LSAN_OPTIONS}")
2015-04-27 22:25:09 +02:00
message("LOG_FILE=[${LOG_FILE}]")
2017-04-14 19:02:05 +02:00
# if we are not asked to simulate LeakSanitizer don't do it
if(NOT "$ENV{LSAN_OPTIONS}]" MATCHES "simulate_sanitizer.1")
2015-04-27 22:25:09 +02:00
return()
endif()
2017-04-14 19:02:05 +02:00
# clear the log files
2015-04-27 22:25:09 +02:00
file(REMOVE "${LOG_FILE}.2343")
file(REMOVE "${LOG_FILE}.2344")
2017-04-14 19:02:05 +02:00
# create an error of each type of LeakSanitizer
2015-04-27 22:25:09 +02:00
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
2023-07-02 19:51:09 +02:00
#2 0x7fa72bee476c in __libc_start_main /build/eglibc-2.15/csu/libc-start.c:226
2015-04-27 22:25:09 +02:00
2017-04-14 19:02:05 +02:00
SUMMARY: LeakSanitizer: 4436 byte(s) leaked in 2 allocation(s).
2015-04-27 22:25:09 +02:00
")
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
2023-07-02 19:51:09 +02:00
#3 0x7fa72bee476c in __libc_start_main /build/eglibc-2.15/csu/libc-start.c:226
2015-04-27 22:25:09 +02:00
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
2023-07-02 19:51:09 +02:00
#3 0x7fa72bee476c in __libc_start_main /build/eglibc-2.15/csu/libc-start.c:226
2015-04-27 22:25:09 +02:00
2017-04-14 19:02:05 +02:00
SUMMARY: LeakSanitizer: 4436 byte(s) leaked in 2 allocation(s).
2015-04-27 22:25:09 +02:00
")