mirror of
https://github.com/monero-project/monero.git
synced 2025-05-02 13:36:05 -04:00
fuzz_tests: refactor and add OSS-Fuzz compatibility
This commit is contained in:
parent
77a008f714
commit
81773f55a4
16 changed files with 232 additions and 538 deletions
|
@ -58,48 +58,11 @@ private:
|
|||
std::string data;
|
||||
};
|
||||
|
||||
class HTTPClientFuzzer: public Fuzzer
|
||||
{
|
||||
public:
|
||||
HTTPClientFuzzer() {}
|
||||
virtual int init();
|
||||
virtual int run(const std::string &filename);
|
||||
static epee::net_utils::http::http_simple_client_template<dummy_client> client;
|
||||
|
||||
private:
|
||||
epee::net_utils::http::http_simple_client_template<dummy_client> client;
|
||||
};
|
||||
|
||||
int HTTPClientFuzzer::init()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int HTTPClientFuzzer::run(const std::string &filename)
|
||||
{
|
||||
std::string s;
|
||||
|
||||
if (!epee::file_io_utils::load_file_to_string(filename, s))
|
||||
{
|
||||
std::cout << "Error: failed to load file " << filename << std::endl;
|
||||
return 1;
|
||||
}
|
||||
try
|
||||
{
|
||||
client.test(s, std::chrono::milliseconds(1000));
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
std::cerr << "Failed to test http client: " << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
HTTPClientFuzzer fuzzer;
|
||||
return run_fuzzer(argc, argv, fuzzer);
|
||||
CATCH_ENTRY_L0("main", 1);
|
||||
}
|
||||
BEGIN_INIT_SIMPLE_FUZZER()
|
||||
END_INIT_SIMPLE_FUZZER()
|
||||
|
||||
BEGIN_SIMPLE_FUZZER()
|
||||
client.test(std::string((const char*)buf, len), std::chrono::milliseconds(1000));
|
||||
END_SIMPLE_FUZZER()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue