[fuzzer] Separate main() into a new file

This commit is contained in:
Behdad Esfahbod 2016-12-20 20:50:38 -06:00
parent 7ed71eb347
commit de14c19d14
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,4 @@
#include <hb.h>
#include <stddef.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);

21
test/fuzzing/main.cc Normal file
View File

@ -0,0 +1,21 @@
#include "hb-fuzzer.hh"
#include <iostream>
#include <iterator>
#include <fstream>
#include <assert.h>
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<char>(T)),
std::istreambuf_iterator<char>());
}
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());
}
}