Index: lib/Fuzzer/test/CMakeLists.txt =================================================================== --- lib/Fuzzer/test/CMakeLists.txt +++ lib/Fuzzer/test/CMakeLists.txt @@ -62,7 +62,6 @@ ############################################################################### set(Tests - AccumulateAllocationsTest BufferOverflowOnInput CallerCalleeTest CounterTest @@ -72,8 +71,6 @@ FullCoverageSetTest InitializeTest MemcmpTest - LeakTest - LeakTimeoutTest NullDerefTest NullDerefOnEmptyTest NthRunCrashTest @@ -93,6 +90,21 @@ TimeoutTest ) +if(APPLE) + # LeakSanitizer is not supported on OSX right now + set(HAS_LSAN 0) + message(WARNING "Leak sanitizer is not supported on Apple platforms." + " Building and running LibFuzzer leak sanitizer tests is disabled." + ) +else() + list(APPEND Tests + AccumulateAllocationsTest + LeakTest + LeakTimeoutTest + ) + set(HAS_LSAN 1) +endif() + foreach(Test ${Tests}) add_libfuzzer_test(${Test} SOURCES ${Test}.cpp) endforeach() Index: lib/Fuzzer/test/fuzzer-leak.test =================================================================== --- lib/Fuzzer/test/fuzzer-leak.test +++ lib/Fuzzer/test/fuzzer-leak.test @@ -1,3 +1,4 @@ +REQUIRES: lsan RUN: not LLVMFuzzer-LeakTest -runs=100000 -detect_leaks=1 2>&1 | FileCheck %s --check-prefix=LEAK_DURING LEAK_DURING: ERROR: LeakSanitizer: detected memory leaks LEAK_DURING: Direct leak of 4 byte(s) in 1 object(s) allocated from: Index: lib/Fuzzer/test/lit.cfg =================================================================== --- lib/Fuzzer/test/lit.cfg +++ lib/Fuzzer/test/lit.cfg @@ -19,3 +19,9 @@ else: lit_config.note('dfsan feature unavailable') +if config.has_lsan: + lit_config.note('lsan feature available') + config.available_features.add('lsan') +else: + lit_config.note('lsan feature unavailable') + Index: lib/Fuzzer/test/lit.site.cfg.in =================================================================== --- lib/Fuzzer/test/lit.site.cfg.in +++ lib/Fuzzer/test/lit.site.cfg.in @@ -1,4 +1,5 @@ config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@" config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" config.has_dfsan = True if @HAS_DFSAN@ == 1 else False +config.has_lsan = True if @HAS_LSAN@ == 1 else False lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")