diff --git a/test/fuzzing/hb-fuzzer.hh b/test/fuzzing/hb-fuzzer.hh new file mode 100644 index 000000000..d0c617e09 --- /dev/null +++ b/test/fuzzing/hb-fuzzer.hh @@ -0,0 +1,4 @@ +#include +#include + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); diff --git a/test/fuzzing/main.cc b/test/fuzzing/main.cc new file mode 100644 index 000000000..4692f7b5f --- /dev/null +++ b/test/fuzzing/main.cc @@ -0,0 +1,21 @@ +#include "hb-fuzzer.hh" + +#include +#include +#include +#include + +std::string FileToString(const std::string &Path) { + /* TODO This silently passes if file does not exist. Fix it! */ + std::ifstream T(Path.c_str()); + return std::string((std::istreambuf_iterator(T)), + std::istreambuf_iterator()); +} + +int main(int argc, char **argv) { + for (int i = 1; i < argc; i++) { + std::string s = FileToString(argv[i]); + std::cout << argv[i] << std::endl; + LLVMFuzzerTestOneInput((const unsigned char*)s.data(), s.size()); + } +}