testLeakSanitizer.cmake 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # this file simulates a program that has been built with LeakSanitizer
  2. # options
  3. message("LSAN_OPTIONS = [$ENV{LSAN_OPTIONS}]")
  4. string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{LSAN_OPTIONS}")
  5. message("LOG_FILE=[${LOG_FILE}]")
  6. # if we are not asked to simulate LeakSanitizer don't do it
  7. if(NOT "$ENV{LSAN_OPTIONS}]" MATCHES "simulate_sanitizer.1")
  8. return()
  9. endif()
  10. # clear the log files
  11. file(REMOVE "${LOG_FILE}.2343")
  12. file(REMOVE "${LOG_FILE}.2344")
  13. # create an error of each type of LeakSanitizer
  14. file(APPEND "${LOG_FILE}.2343"
  15. "=================================================================
  16. ==25308==ERROR: LeakSanitizer: detected memory leaks
  17. Direct leak of 4360 byte(s) in 1 object(s) allocated from:
  18. #0 0x46c669 in operator new[](unsigned long) (/home/kitware/msan/a.out+0x46c669)
  19. #1 0x4823b4 in main /home/kitware/msan/memcheck.cxx:12
  20. #2 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
  21. SUMMARY: LeakSanitizer: 4436 byte(s) leaked in 2 allocation(s).
  22. ")
  23. file(APPEND "${LOG_FILE}.2342"
  24. "=================================================================
  25. ==25308==ERROR: LeakSanitizer: detected memory leaks
  26. Direct leak of 76 byte(s) in 1 object(s) allocated from:
  27. #0 0x46c669 in operator new[](unsigned long) (/home/kitware/msan/a.out+0x46c669)
  28. #1 0x4821b8 in foo() /home/kitware/msan/memcheck.cxx:4
  29. #2 0x4823f2 in main /home/kitware/msan/memcheck.cxx:14
  30. #3 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
  31. Indirect leak of 76 byte(s) in 1 object(s) allocated from:
  32. #0 0x46c669 in operator new[](unsigned long) (/home/kitware/msan/a.out+0x46c669)
  33. #1 0x4821b8 in foo() /home/kitware/msan/memcheck.cxx:4
  34. #2 0x4823f2 in main /home/kitware/msan/memcheck.cxx:14
  35. #3 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
  36. SUMMARY: LeakSanitizer: 4436 byte(s) leaked in 2 allocation(s).
  37. ")