Mercurial > minori
comparison dep/fmt/test/fuzzing/main.cc @ 343:1faa72660932
*: transfer back to cmake from autotools
autotools just made lots of things more complicated than
they should have and many things broke (i.e. translations)
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Thu, 20 Jun 2024 05:56:06 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 342:adb79bdde329 | 343:1faa72660932 |
|---|---|
| 1 #include <cassert> | |
| 2 #include <fstream> | |
| 3 #include <vector> | |
| 4 | |
| 5 #include "fuzzer-common.h" | |
| 6 | |
| 7 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); | |
| 8 | |
| 9 int main(int argc, char** argv) { | |
| 10 for (int i = 1; i < argc; ++i) { | |
| 11 std::ifstream in(argv[i]); | |
| 12 assert(in); | |
| 13 in.seekg(0, std::ios_base::end); | |
| 14 const auto size = in.tellg(); | |
| 15 assert(size >= 0); | |
| 16 in.seekg(0, std::ios_base::beg); | |
| 17 std::vector<char> buf(static_cast<size_t>(size)); | |
| 18 in.read(buf.data(), size); | |
| 19 assert(in.gcount() == size); | |
| 20 LLVMFuzzerTestOneInput(as_bytes(buf.data()), buf.size()); | |
| 21 } | |
| 22 } |
