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