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=edge,indirect-calls")
      6 
      7 set(DFSanTests
      8   MemcmpTest
      9   SimpleCmpTest
     10   StrcmpTest
     11   StrncmpTest
     12   SwitchTest
     13   )
     14 
     15 set(Tests
     16   CallerCalleeTest
     17   CounterTest
     18   FourIndependentBranchesTest
     19   FullCoverageSetTest
     20   MemcmpTest
     21   NullDerefTest
     22   SimpleCmpTest
     23   SimpleDictionaryTest
     24   SimpleHashTest
     25   SimpleTest
     26   StrcmpTest
     27   StrncmpTest
     28   SwitchTest
     29   TimeoutTest
     30   )
     31 
     32 set(CustomMainTests
     33   UserSuppliedFuzzerTest
     34   )
     35 
     36 set(UninstrumentedTests
     37   UninstrumentedTest
     38   )
     39 
     40 set(TraceBBTests
     41   SimpleTest
     42   )
     43 
     44 set(TestBinaries)
     45 
     46 foreach(Test ${Tests})
     47   add_executable(LLVMFuzzer-${Test}
     48     ${Test}.cpp
     49     )
     50   target_link_libraries(LLVMFuzzer-${Test}
     51     LLVMFuzzer
     52     )
     53   set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test})
     54 endforeach()
     55 
     56 foreach(Test ${CustomMainTests})
     57   add_executable(LLVMFuzzer-${Test}
     58     ${Test}.cpp
     59     )
     60   target_link_libraries(LLVMFuzzer-${Test}
     61     LLVMFuzzerNoMain
     62     )
     63   set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test})
     64 endforeach()
     65 
     66 
     67 configure_lit_site_cfg(
     68   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
     69   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
     70   )
     71 
     72 configure_lit_site_cfg(
     73   ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in
     74   ${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg
     75   )
     76 
     77 include_directories(..)
     78 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
     79 
     80 add_executable(LLVMFuzzer-Unittest
     81   FuzzerUnittest.cpp
     82   $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
     83   )
     84 
     85 target_link_libraries(LLVMFuzzer-Unittest
     86   gtest
     87   gtest_main
     88   )
     89 
     90 set(TestBinaries ${TestBinaries} LLVMFuzzer-Unittest)
     91 
     92 add_subdirectory(dfsan)
     93 
     94 foreach(Test ${DFSanTests})
     95   set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test}-DFSan)
     96 endforeach()
     97 
     98 add_subdirectory(uninstrumented)
     99 
    100 foreach(Test ${UninstrumentedTests})
    101   set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test}-Uninstrumented)
    102 endforeach()
    103 
    104 add_subdirectory(trace-bb)
    105 
    106 foreach(Test ${TraceBBTests})
    107   set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test}-TraceBB)
    108 endforeach()
    109 
    110 set_target_properties(${TestBinaries}
    111   PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    112   )
    113 
    114 add_lit_testsuite(check-fuzzer "Running Fuzzer tests"
    115     ${CMAKE_CURRENT_BINARY_DIR}
    116     DEPENDS ${TestBinaries} FileCheck not
    117     )
    118