[lib/Fuzzer] build tests that work well with dfsan also w/o dfsan
[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
25 set(TestBinaries)
26
27 foreach(Test ${Tests})
28   add_executable(LLVMFuzzer-${Test}
29     ${Test}.cpp
30     )
31   target_link_libraries(LLVMFuzzer-${Test}
32     LLVMFuzzer
33     )
34   set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test})
35 endforeach()
36
37 configure_lit_site_cfg(
38   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
39   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
40   )
41
42 configure_lit_site_cfg(
43   ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in
44   ${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg
45   )
46
47 include_directories(..)
48 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
49
50 add_executable(LLVMFuzzer-Unittest
51   FuzzerUnittest.cpp
52   $<TARGET_OBJECTS:LLVMFuzzerNoMain>
53   )
54
55 target_link_libraries(LLVMFuzzer-Unittest
56   gtest
57   gtest_main
58   )
59
60 set(TestBinaries ${TestBinaries} LLVMFuzzer-Unittest)
61
62 add_subdirectory(dfsan)
63
64 foreach(Test ${DFSanTests})
65   set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test}-DFSan)
66 endforeach()
67
68
69 set_target_properties(${TestBinaries}
70   PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
71   )
72
73 add_lit_testsuite(check-fuzzer "Running Fuzzer tests"
74     ${CMAKE_CURRENT_BINARY_DIR}
75     DEPENDS ${TestBinaries} FileCheck not
76     )