Home | History | Annotate | Download | only in test
      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)
      5 set(CMAKE_CXX_FLAGS_RELEASE "${LIBFUZZER_FLAGS_BASE} -O0 -fsanitize-coverage=4")
      6 
      7 set(Tests
      8   CounterTest
      9   CxxTokensTest
     10   FourIndependentBranchesTest
     11   FullCoverageSetTest
     12   InfiniteTest
     13   NullDerefTest
     14   SimpleTest
     15   TimeoutTest
     16   )
     17 
     18 set(DFSanTests
     19   DFSanSimpleCmpTest
     20   )
     21 
     22 set(TestBinaries)
     23 
     24 foreach(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})
     32 endforeach()
     33 
     34 configure_lit_site_cfg(
     35   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
     36   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
     37   )
     38 
     39 configure_lit_site_cfg(
     40   ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in
     41   ${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg
     42   )
     43 
     44 include_directories(..)
     45 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
     46 
     47 add_executable(LLVMFuzzer-Unittest
     48   FuzzerUnittest.cpp
     49   $<TARGET_OBJECTS:LLVMFuzzerNoMain>
     50   )
     51 
     52 target_link_libraries(LLVMFuzzer-Unittest
     53   gtest
     54   gtest_main
     55   )
     56 
     57 set(TestBinaries ${TestBinaries} LLVMFuzzer-Unittest)
     58 
     59 add_subdirectory(dfsan)
     60 
     61 foreach(Test ${DFSanTests})
     62   set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test})
     63 endforeach()
     64 
     65 
     66 set_target_properties(${TestBinaries}
     67   PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
     68   )
     69 
     70 add_lit_testsuite(check-fuzzer "Running Fuzzer tests"
     71     ${CMAKE_CURRENT_BINARY_DIR}
     72     DEPENDS ${TestBinaries} FileCheck not
     73     )
     74