diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2020-05-15 17:17:24 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2020-05-15 17:18:27 +0000 |
commit | 81773f55a430e75fe5c6bee355ca518f16286dd1 (patch) | |
tree | fc7ac88a76cc6a06cf5310ef2a353be92d6bb931 /tests/fuzz/levin.cpp | |
parent | Merge pull request #6510 (diff) | |
download | monero-81773f55a430e75fe5c6bee355ca518f16286dd1.tar.xz |
fuzz_tests: refactor and add OSS-Fuzz compatibility
Diffstat (limited to 'tests/fuzz/levin.cpp')
-rw-r--r-- | tests/fuzz/levin.cpp | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/tests/fuzz/levin.cpp b/tests/fuzz/levin.cpp index 6c16a0a85..ab7bbb6da 100644 --- a/tests/fuzz/levin.cpp +++ b/tests/fuzz/levin.cpp @@ -279,26 +279,10 @@ namespace #endif } -class LevinFuzzer: public Fuzzer -{ -public: - LevinFuzzer() {} //: handler(endpoint, config, context) {} - virtual int init(); - virtual int run(const std::string &filename); - -private: - //epee::net_utils::connection_context_base context; - //epee::levin::async_protocol_handler<> handler; -}; +BEGIN_INIT_SIMPLE_FUZZER() +END_INIT_SIMPLE_FUZZER() -int LevinFuzzer::init() -{ - return 0; -} - -int LevinFuzzer::run(const std::string &filename) -{ - std::string s; +BEGIN_SIMPLE_FUZZER() #if 0 epee::levin::bucket_head2 req_head; @@ -313,13 +297,6 @@ int LevinFuzzer::run(const std::string &filename) fwrite(&req_head,sizeof(req_head),1, f); fclose(f); #endif - if (!epee::file_io_utils::load_file_to_string(filename, s)) - { - std::cout << "Error: failed to load file " << filename << std::endl; - return 1; - } - try - { //std::unique_ptr<test_connection> conn = new test(); boost::asio::io_service io_service; test_levin_protocol_handler_config m_handler_config; @@ -329,21 +306,5 @@ int LevinFuzzer::run(const std::string &filename) conn->start(); //m_commands_handler.invoke_out_buf(expected_out_data); //m_commands_handler.return_code(expected_return_code); - conn->m_protocol_handler.handle_recv(s.data(), s.size()); - } - 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(); - LevinFuzzer fuzzer; - return run_fuzzer(argc, argv, fuzzer); - CATCH_ENTRY_L0("main", 1); -} - + conn->m_protocol_handler.handle_recv(buf, len); +END_SIMPLE_FUZZER() |