Add fuzz corpus and blackbox tests
This commit is contained in:
+32
-5
@@ -129,6 +129,30 @@ if(BUILD_TREE_VIS)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
|
||||
# corpus tests, which are tests curated by libfuzzer. The goal is to get broad
|
||||
# coverage with a small number of tests.
|
||||
|
||||
file(GLOB CORPUS_TESTS ${CMAKE_SOURCE_DIR}/corpus/*)
|
||||
|
||||
if(NOT APPLE)
|
||||
# libfuzzer target, to generate/manage corpus
|
||||
set(FUZZ_FLAGS "-fsanitize=fuzzer-no-link,address,undefined")
|
||||
include(CheckCXXCompilerFlag)
|
||||
cmake_push_check_state()
|
||||
set(CMAKE_REQUIRED_LINK_OPTIONS -fsanitize=fuzzer-no-link)
|
||||
check_cxx_compiler_flag(-fsanitize=fuzzer-no-link HAS_LIB_FUZZER)
|
||||
cmake_pop_check_state()
|
||||
|
||||
if(HAS_LIB_FUZZER)
|
||||
add_executable(facade_fuzz FacadeFuzz.cpp)
|
||||
target_link_libraries(facade_fuzz PRIVATE ${PROJECT_NAME})
|
||||
target_compile_options(facade_fuzz PRIVATE ${FUZZ_FLAGS} ${TEST_FLAGS})
|
||||
target_link_options(facade_fuzz PRIVATE ${FUZZ_FLAGS} -fsanitize=fuzzer)
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(rootset_test RootSet.cpp)
|
||||
target_compile_definitions(rootset_test PRIVATE ENABLE_ROOTSET_TESTS)
|
||||
target_compile_options(rootset_test PRIVATE -fsanitize=address,undefined
|
||||
@@ -156,11 +180,14 @@ if(BUILD_TESTING)
|
||||
${TEST_FLAGS})
|
||||
target_link_options(facade_test PRIVATE -fsanitize=address,undefined)
|
||||
|
||||
add_executable(facade_fuzz FacadeFuzz.cpp)
|
||||
target_link_libraries(facade_fuzz PRIVATE ${PROJECT_NAME})
|
||||
target_compile_options(facade_fuzz PRIVATE -fsanitize=address,undefined,fuzzer
|
||||
${TEST_FLAGS})
|
||||
target_link_options(facade_fuzz PRIVATE -fsanitize=address,undefined,fuzzer)
|
||||
# blackbox tests
|
||||
add_executable(driver TestDriver.cpp FacadeFuzz.cpp)
|
||||
target_compile_options(driver PRIVATE ${TEST_FLAGS})
|
||||
target_link_libraries(driver PRIVATE ${PROJECT_NAME})
|
||||
foreach(TEST ${CORPUS_TESTS})
|
||||
get_filename_component(hash ${TEST} NAME)
|
||||
add_test(NAME versioned_map_blackbox_${hash} COMMAND driver ${TEST})
|
||||
endforeach()
|
||||
|
||||
# symbol visibility tests
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
std::ifstream t(argv[i], std::ios::binary);
|
||||
std::stringstream buffer;
|
||||
buffer << t.rdbuf();
|
||||
auto str = buffer.str();
|
||||
LLVMFuzzerTestOneInput(reinterpret_cast<const uint8_t *>(str.data()),
|
||||
str.size());
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
}لللل��ض���`'h��
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
'*9
|
||||
@@ -0,0 +1 @@
|
||||
k���������'�'*�
|
||||
@@ -0,0 +1 @@
|
||||
k�����k�������S�S���S�S�
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
~0忖
|
||||
忖���,�������帙��������������������������������������������牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐����垐垐垐垐垐垐垐���������牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐垐牋牋牋�)0�)))))A������
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
*���������'~�@ο�*��2��=���j??���SS
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user