[lib/Fuzzer] extend the fuzzer interface to allow user-supplied mutators
[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=edge,indirect-calls")
6
7 set(DFSanTests
8   DFSanMemcmpTest
9   DFSanSimpleCmpTest
10   )
11
12 set(Tests
13   CounterTest
14   CxxTokensTest
15   FourIndependentBranchesTest
16   FullCoverageSetTest
17   InfiniteTest
18   NullDerefTest
19   SimpleTest
20   TimeoutTest
21   ${DFSanTests}
22   )
23
24 set(CustomMainTests
25   UserSuppliedFuzzerTest
26   )
27
28
29 set(TestBinaries)
30
31 foreach(Test ${Tests})
32   add_executable(LLVMFuzzer-${Test}
33     ${Test}.cpp
34     )
35   target_link_libraries(LLVMFuzzer-${Test}
36     LLVMFuzzer
37     )
38   set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test})
39 endforeach()
40
41 foreach(Test ${CustomMainTests})
42   add_executable(LLVMFuzzer-${Test}
43     ${Test}.cpp
44     )
45   target_link_libraries(LLVMFuzzer-${Test}
46     LLVMFuzzerNoMain
47     )
48   set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test})
49 endforeach()
50
51
52 configure_lit_site_cfg(
53   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
54   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
55   )
56
57 configure_lit_site_cfg(
58   ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in
59   ${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg
60   )
61
62 include_directories(..)
63 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
64
65 add_executable(LLVMFuzzer-Unittest
66   FuzzerUnittest.cpp
67   $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
68   )
69
70 target_link_libraries(LLVMFuzzer-Unittest
71   gtest
72   gtest_main
73   )
74
75 set(TestBinaries ${TestBinaries} LLVMFuzzer-Unittest)
76
77 add_subdirectory(dfsan)
78
79 foreach(Test ${DFSanTests})
80   set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test}-DFSan)
81 endforeach()
82
83
84 set_target_properties(${TestBinaries}
85   PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
86   )
87
88 add_lit_testsuite(check-fuzzer "Running Fuzzer tests"
89     ${CMAKE_CURRENT_BINARY_DIR}
90     DEPENDS ${TestBinaries} FileCheck not
91     )