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