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