Add blackbox, valgrind tests
This commit is contained in:
@@ -101,15 +101,31 @@ endif()
|
||||
|
||||
file(GLOB CORPUS_TESTS ${CMAKE_SOURCE_DIR}/corpus/*)
|
||||
|
||||
add_executable(conflict_set_test_driver ConflictSet.cpp TestDriver.cpp)
|
||||
target_compile_options(conflict_set_test_driver PRIVATE ${TEST_FLAGS})
|
||||
target_compile_definitions(conflict_set_test_driver PRIVATE ENABLE_FUZZ)
|
||||
target_include_directories(conflict_set_test_driver
|
||||
add_executable(fuzz_driver ConflictSet.cpp FuzzTestDriver.cpp)
|
||||
target_compile_options(fuzz_driver PRIVATE ${TEST_FLAGS})
|
||||
target_compile_definitions(fuzz_driver PRIVATE ENABLE_FUZZ)
|
||||
target_include_directories(fuzz_driver
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
foreach(TEST ${CORPUS_TESTS})
|
||||
get_filename_component(hash ${TEST} NAME)
|
||||
add_test(NAME conflict_set_corpus_${hash} COMMAND conflict_set_test_driver
|
||||
${TEST})
|
||||
add_test(NAME conflict_set_fuzz_${hash} COMMAND fuzz_driver ${TEST})
|
||||
endforeach()
|
||||
|
||||
add_executable(driver TestDriver.cpp)
|
||||
target_link_libraries(driver PRIVATE ${PROJECT_NAME})
|
||||
find_program(VALGRIND_EXE valgrind)
|
||||
|
||||
if(VALGRIND_EXE)
|
||||
add_test(NAME conflict_set_blackbox_valgrind
|
||||
COMMAND ${VALGRIND_EXE} --error-exitcode=99 -- $<TARGET_FILE:driver>
|
||||
${CORPUS_TESTS})
|
||||
else()
|
||||
|
||||
endif()
|
||||
|
||||
foreach(TEST ${CORPUS_TESTS})
|
||||
get_filename_component(hash ${TEST} NAME)
|
||||
add_test(NAME conflict_set_blackbox_${hash} COMMAND driver ${TEST})
|
||||
endforeach()
|
||||
|
||||
# api smoke tests
|
||||
|
@@ -1,16 +1,17 @@
|
||||
#include <cstddef>
|
||||
#include "Internal.h"
|
||||
#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) {
|
||||
printf("Running: %s\n", argv[i]);
|
||||
std::ifstream t(argv[i], std::ios::binary);
|
||||
std::stringstream buffer;
|
||||
buffer << t.rdbuf();
|
||||
auto str = buffer.str();
|
||||
LLVMFuzzerTestOneInput((const uint8_t *)str.data(), str.size());
|
||||
TestDriver<ConflictSet> driver{(const uint8_t *)str.data(), str.size()};
|
||||
while (!driver.next())
|
||||
;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user