Skip to content

Commit

Permalink
clean up api.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
martinus committed Jul 14, 2022
1 parent 064ed8f commit d8d4b50
Showing 1 changed file with 0 additions and 47 deletions.
47 changes: 0 additions & 47 deletions test/fuzz/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,50 +137,3 @@ extern "C" auto LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) -> int
return 0;
}
#endif

#if 0

# include <cassert>
# include <chrono>
# include <filesystem>
# include <fstream>

__attribute__((weak)) extern auto LLVMFuzzerInitialize(int* argc, char*** argv) -> int;


auto main(int argc, char** argv) -> int {
using namespace std::literals;

if (nullptr != LLVMFuzzerInitialize) {
LLVMFuzzerInitialize(&argc, &argv);
}

auto total_files = 0;
for (int i = 1; i < argc; ++i) {
auto dir = std::filesystem::path(argv[i]);
auto it = std::filesystem::directory_iterator(dir);
total_files += std::distance(begin(it), end(it));
}

auto log = Periodic(200ms);
auto const pb = ProgressBar(50, total_files);

auto num_files = size_t();
for (int i = 1; i < argc; ++i) {
auto dir = std::filesystem::path(argv[i]);
for (auto const& dir_entry : std::filesystem::directory_iterator(dir)) {
++num_files;
auto const& path = dir_entry.path();
auto f = std::ifstream(path);
auto content = std::string((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
LLVMFuzzerTestOneInput(reinterpret_cast<uint8_t const*>(content.data()), content.size());

if (log) {
fmt::print(stderr, "\r|{}| {:7}/{:7} ", pb(num_files), num_files, total_files);
}
}
}
fmt::print(stderr, "\r|{}| {:7}/{:7} \n", pb(num_files), num_files, total_files);
}

#endif

0 comments on commit d8d4b50

Please sign in to comment.