DFSan-based fuzzer (proof of concept).
[oota-llvm.git] / lib / Fuzzer / test / CMakeLists.txt
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   FourIndependentBranchesTest
10   FullCoverageSetTest
11   InfiniteTest
12   NullDerefTest
13   SimpleTest
14   TimeoutTest
15   )
16
17 set(DFSanTests
18   DFSanSimpleCmpTest
19   )
20
21 set(TestBinaries)
22
23 foreach(Test ${Tests})
24   add_executable(LLVMFuzzer-${Test}
25     ${Test}.cpp
26     )
27   target_link_libraries(LLVMFuzzer-${Test}
28     LLVMFuzzer
29     )
30   set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test})
31 endforeach()
32
33 configure_lit_site_cfg(
34   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
35   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
36   )
37
38 configure_lit_site_cfg(
39   ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in
40   ${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg
41   )
42
43 include_directories(..)
44 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
45
46 add_executable(LLVMFuzzer-Unittest
47   FuzzerUnittest.cpp
48   $<TARGET_OBJECTS:LLVMFuzzerNoMain>
49   )
50
51 target_link_libraries(LLVMFuzzer-Unittest
52   gtest
53   gtest_main
54   )
55
56 set(TestBinaries ${TestBinaries} LLVMFuzzer-Unittest)
57
58 add_subdirectory(dfsan)
59
60 foreach(Test ${DFSanTests})
61   set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test})
62 endforeach()
63
64
65 set_target_properties(${TestBinaries}
66   PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
67   )
68
69 add_lit_testsuite(check-fuzzer "Running Fuzzer tests"
70     ${CMAKE_CURRENT_BINARY_DIR}
71     DEPENDS ${TestBinaries} FileCheck not
72     )