1# Build all these tests with -O0, otherwise optimizations may merge some 2# basic blocks and we'll fail to discover the targets. 3# Also enable the coverage instrumentation back (it is disabled 4# for the Fuzzer lib) 5set(CMAKE_CXX_FLAGS_RELEASE "${LIBFUZZER_FLAGS_BASE} -O0 -fsanitize-coverage=4") 6 7set(Tests 8 CounterTest 9 CxxTokensTest 10 FourIndependentBranchesTest 11 FullCoverageSetTest 12 InfiniteTest 13 NullDerefTest 14 SimpleTest 15 TimeoutTest 16 ) 17 18set(DFSanTests 19 DFSanSimpleCmpTest 20 ) 21 22set(TestBinaries) 23 24foreach(Test ${Tests}) 25 add_executable(LLVMFuzzer-${Test} 26 ${Test}.cpp 27 ) 28 target_link_libraries(LLVMFuzzer-${Test} 29 LLVMFuzzer 30 ) 31 set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test}) 32endforeach() 33 34configure_lit_site_cfg( 35 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in 36 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg 37 ) 38 39configure_lit_site_cfg( 40 ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in 41 ${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg 42 ) 43 44include_directories(..) 45include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include) 46 47add_executable(LLVMFuzzer-Unittest 48 FuzzerUnittest.cpp 49 $<TARGET_OBJECTS:LLVMFuzzerNoMain> 50 ) 51 52target_link_libraries(LLVMFuzzer-Unittest 53 gtest 54 gtest_main 55 ) 56 57set(TestBinaries ${TestBinaries} LLVMFuzzer-Unittest) 58 59add_subdirectory(dfsan) 60 61foreach(Test ${DFSanTests}) 62 set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test}) 63endforeach() 64 65 66set_target_properties(${TestBinaries} 67 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 68 ) 69 70add_lit_testsuite(check-fuzzer "Running Fuzzer tests" 71 ${CMAKE_CURRENT_BINARY_DIR} 72 DEPENDS ${TestBinaries} FileCheck not 73 ) 74