[fuzzer] Add proper dependensices to the fuzzer tests
[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 "${CMAKE_CXX_FLAGS_RELEASE} -O0 -fsanitize-coverage=4")
6
7 set(Tests
8   FullCoverageSetTest
9   InfiniteTest
10   NullDerefTest
11   SimpleTest
12   TimeoutTest
13   )
14
15 set(TestBinaries)
16
17 foreach(Test ${Tests})
18   add_executable(LLVMFuzzer-${Test}
19     EXCLUDE_FROM_ALL
20     ${Test}.cpp
21     )
22   target_link_libraries(LLVMFuzzer-${Test}
23     LLVMFuzzer
24     )
25   set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test})
26 endforeach()
27
28 configure_lit_site_cfg(
29   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
30   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
31   )
32
33 configure_lit_site_cfg(
34   ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in
35   ${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg
36   )
37
38 include_directories(..)
39 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
40
41 add_executable(LLVMFuzzer-Unittest
42   FuzzerUnittest.cpp
43   $<TARGET_OBJECTS:LLVMFuzzerNoMain>
44   )
45
46 target_link_libraries(LLVMFuzzer-Unittest
47   gtest
48   gtest_main
49   )
50
51 set(TestBinaries ${TestBinaries} LLVMFuzzer-Unittest)
52
53 set_target_properties(${TestBinaries}
54   PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
55   )
56
57 add_lit_testsuite(check-fuzzer "Running Fuzzer tests"
58     ${CMAKE_CURRENT_BINARY_DIR}
59     DEPENDS ${TestBinaries} FileCheck not
60     )