2015-01-30 07:01:07 +08:00
|
|
|
# Build all these tests with -O0, otherwise optimizations may merge some
|
|
|
|
# basic blocks and we'll fail to discover the targets.
|
|
|
|
# Also enable the coverage instrumentation back (it is disabled
|
|
|
|
# for the Fuzzer lib)
|
2015-05-08 07:33:24 +08:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${LIBFUZZER_FLAGS_BASE} -O0 -fsanitize-coverage=edge,indirect-calls")
|
2015-01-30 07:01:07 +08:00
|
|
|
|
2015-05-09 05:45:19 +08:00
|
|
|
set(DFSanTests
|
2015-07-22 06:51:49 +08:00
|
|
|
MemcmpTest
|
|
|
|
SimpleCmpTest
|
2015-08-06 02:23:01 +08:00
|
|
|
StrcmpTest
|
2015-07-30 10:33:45 +08:00
|
|
|
StrncmpTest
|
2015-08-01 01:05:05 +08:00
|
|
|
SwitchTest
|
2015-05-09 05:45:19 +08:00
|
|
|
)
|
|
|
|
|
2015-01-30 00:58:29 +08:00
|
|
|
set(Tests
|
2016-04-28 03:52:34 +08:00
|
|
|
AccumulateAllocationsTest
|
2016-01-14 07:02:30 +08:00
|
|
|
BufferOverflowOnInput
|
2015-10-23 07:55:39 +08:00
|
|
|
CallerCalleeTest
|
[sanitizer/coverage] Add AFL-style coverage counters (search heuristic for fuzzing).
Introduce -mllvm -sanitizer-coverage-8bit-counters=1
which adds imprecise thread-unfriendly 8-bit coverage counters.
The run-time library maps these 8-bit counters to 8-bit bitsets in the same way
AFL (http://lcamtuf.coredump.cx/afl/technical_details.txt) does:
counter values are divided into 8 ranges and based on the counter
value one of the bits in the bitset is set.
The AFL ranges are used here: 1, 2, 3, 4-7, 8-15, 16-31, 32-127, 128+.
These counters provide a search heuristic for single-threaded
coverage-guided fuzzers, we do not expect them to be useful for other purposes.
Depending on the value of -fsanitize-coverage=[123] flag,
these counters will be added to the function entry blocks (=1),
every basic block (=2), or every edge (=3).
Use these counters as an optional search heuristic in the Fuzzer library.
Add a test where this heuristic is critical.
llvm-svn: 231166
2015-03-04 07:27:02 +08:00
|
|
|
CounterTest
|
2016-02-13 10:29:38 +08:00
|
|
|
CustomMutatorTest
|
2015-02-20 11:02:37 +08:00
|
|
|
FourIndependentBranchesTest
|
2015-01-30 07:01:07 +08:00
|
|
|
FullCoverageSetTest
|
2016-01-16 09:23:12 +08:00
|
|
|
InitializeTest
|
2015-07-30 09:34:58 +08:00
|
|
|
MemcmpTest
|
2016-02-04 08:02:17 +08:00
|
|
|
LeakTest
|
2016-03-24 09:32:08 +08:00
|
|
|
LeakTimeoutTest
|
2015-01-30 00:58:29 +08:00
|
|
|
NullDerefTest
|
2016-02-12 10:32:03 +08:00
|
|
|
NthRunCrashTest
|
2016-05-07 07:38:07 +08:00
|
|
|
OutOfMemoryTest
|
2016-01-14 10:36:44 +08:00
|
|
|
RepeatedMemcmp
|
2015-07-22 06:51:49 +08:00
|
|
|
SimpleCmpTest
|
2015-09-04 08:12:11 +08:00
|
|
|
SimpleDictionaryTest
|
2016-03-04 07:45:29 +08:00
|
|
|
SimpleFnAdapterTest
|
2015-09-09 05:22:52 +08:00
|
|
|
SimpleHashTest
|
2015-01-30 00:58:29 +08:00
|
|
|
SimpleTest
|
2016-03-19 04:58:29 +08:00
|
|
|
SpamyTest
|
2015-08-06 02:23:01 +08:00
|
|
|
StrcmpTest
|
2015-07-30 10:33:45 +08:00
|
|
|
StrncmpTest
|
2015-07-31 09:33:06 +08:00
|
|
|
SwitchTest
|
2016-01-06 08:03:35 +08:00
|
|
|
ThreadedTest
|
2015-01-30 00:58:29 +08:00
|
|
|
TimeoutTest
|
|
|
|
)
|
|
|
|
|
2015-05-23 06:35:31 +08:00
|
|
|
set(CustomMainTests
|
|
|
|
)
|
|
|
|
|
2015-11-10 07:17:45 +08:00
|
|
|
set(UninstrumentedTests
|
|
|
|
UninstrumentedTest
|
|
|
|
)
|
|
|
|
|
2015-12-02 10:49:37 +08:00
|
|
|
set(TraceBBTests
|
|
|
|
SimpleTest
|
|
|
|
)
|
2015-03-31 06:09:51 +08:00
|
|
|
|
2016-02-27 05:33:56 +08:00
|
|
|
set(TracePCTests
|
|
|
|
FourIndependentBranchesTest
|
|
|
|
FullCoverageSetTest
|
|
|
|
)
|
|
|
|
|
2015-01-30 00:58:29 +08:00
|
|
|
set(TestBinaries)
|
|
|
|
|
|
|
|
foreach(Test ${Tests})
|
|
|
|
add_executable(LLVMFuzzer-${Test}
|
|
|
|
${Test}.cpp
|
|
|
|
)
|
|
|
|
target_link_libraries(LLVMFuzzer-${Test}
|
|
|
|
LLVMFuzzer
|
|
|
|
)
|
|
|
|
set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test})
|
|
|
|
endforeach()
|
|
|
|
|
2015-05-23 06:35:31 +08:00
|
|
|
foreach(Test ${CustomMainTests})
|
|
|
|
add_executable(LLVMFuzzer-${Test}
|
|
|
|
${Test}.cpp
|
|
|
|
)
|
|
|
|
target_link_libraries(LLVMFuzzer-${Test}
|
|
|
|
LLVMFuzzerNoMain
|
|
|
|
)
|
|
|
|
set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
|
2015-01-31 07:26:57 +08:00
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
|
|
|
)
|
|
|
|
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg
|
|
|
|
)
|
|
|
|
|
|
|
|
include_directories(..)
|
|
|
|
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
|
|
|
|
|
|
|
|
add_executable(LLVMFuzzer-Unittest
|
|
|
|
FuzzerUnittest.cpp
|
2016-03-04 07:45:29 +08:00
|
|
|
FuzzerFnAdapterUnittest.cpp
|
2015-05-23 06:35:31 +08:00
|
|
|
$<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
|
2015-01-31 07:26:57 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(LLVMFuzzer-Unittest
|
|
|
|
gtest
|
|
|
|
gtest_main
|
|
|
|
)
|
|
|
|
|
|
|
|
set(TestBinaries ${TestBinaries} LLVMFuzzer-Unittest)
|
|
|
|
|
2015-03-31 06:09:51 +08:00
|
|
|
add_subdirectory(dfsan)
|
|
|
|
|
|
|
|
foreach(Test ${DFSanTests})
|
2015-05-09 05:45:19 +08:00
|
|
|
set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test}-DFSan)
|
2015-03-31 06:09:51 +08:00
|
|
|
endforeach()
|
|
|
|
|
2015-11-10 07:17:45 +08:00
|
|
|
add_subdirectory(uninstrumented)
|
|
|
|
|
|
|
|
foreach(Test ${UninstrumentedTests})
|
|
|
|
set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test}-Uninstrumented)
|
|
|
|
endforeach()
|
|
|
|
|
2015-12-02 10:49:37 +08:00
|
|
|
add_subdirectory(trace-bb)
|
|
|
|
|
|
|
|
foreach(Test ${TraceBBTests})
|
|
|
|
set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test}-TraceBB)
|
|
|
|
endforeach()
|
2015-03-31 06:09:51 +08:00
|
|
|
|
2016-02-27 05:33:56 +08:00
|
|
|
add_subdirectory(trace-pc)
|
|
|
|
|
|
|
|
foreach(Test ${TracePCTests})
|
|
|
|
set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test}-TracePC)
|
|
|
|
endforeach()
|
|
|
|
|
2015-01-30 00:58:29 +08:00
|
|
|
set_target_properties(${TestBinaries}
|
|
|
|
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
add_lit_testsuite(check-fuzzer "Running Fuzzer tests"
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
2015-02-04 05:57:32 +08:00
|
|
|
DEPENDS ${TestBinaries} FileCheck not
|
2015-01-30 00:58:29 +08:00
|
|
|
)
|