Add blackbox, valgrind tests
This commit is contained in:
@@ -101,15 +101,31 @@ endif()
|
|||||||
|
|
||||||
file(GLOB CORPUS_TESTS ${CMAKE_SOURCE_DIR}/corpus/*)
|
file(GLOB CORPUS_TESTS ${CMAKE_SOURCE_DIR}/corpus/*)
|
||||||
|
|
||||||
add_executable(conflict_set_test_driver ConflictSet.cpp TestDriver.cpp)
|
add_executable(fuzz_driver ConflictSet.cpp FuzzTestDriver.cpp)
|
||||||
target_compile_options(conflict_set_test_driver PRIVATE ${TEST_FLAGS})
|
target_compile_options(fuzz_driver PRIVATE ${TEST_FLAGS})
|
||||||
target_compile_definitions(conflict_set_test_driver PRIVATE ENABLE_FUZZ)
|
target_compile_definitions(fuzz_driver PRIVATE ENABLE_FUZZ)
|
||||||
target_include_directories(conflict_set_test_driver
|
target_include_directories(fuzz_driver
|
||||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
foreach(TEST ${CORPUS_TESTS})
|
foreach(TEST ${CORPUS_TESTS})
|
||||||
get_filename_component(hash ${TEST} NAME)
|
get_filename_component(hash ${TEST} NAME)
|
||||||
add_test(NAME conflict_set_corpus_${hash} COMMAND conflict_set_test_driver
|
add_test(NAME conflict_set_fuzz_${hash} COMMAND fuzz_driver ${TEST})
|
||||||
${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()
|
endforeach()
|
||||||
|
|
||||||
# api smoke tests
|
# api smoke tests
|
||||||
|
@@ -1,16 +1,17 @@
|
|||||||
#include <cstddef>
|
#include "Internal.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
|
printf("Running: %s\n", argv[i]);
|
||||||
std::ifstream t(argv[i], std::ios::binary);
|
std::ifstream t(argv[i], std::ios::binary);
|
||||||
std::stringstream buffer;
|
std::stringstream buffer;
|
||||||
buffer << t.rdbuf();
|
buffer << t.rdbuf();
|
||||||
auto str = buffer.str();
|
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