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