From 937e7f8aa6bda1280abdea493583f4f959ee18e8 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 21 Oct 2017 10:09:51 +0100 Subject: [PATCH] Initialize openssl on startup --- src/common/util.cpp | 7 +++++++ tests/core_proxy/core_proxy.cpp | 2 +- tests/core_tests/chaingen_main.cpp | 1 + tests/functional_tests/main.cpp | 2 ++ tests/fuzz/fuzzer.cpp | 2 ++ tests/libwallet_api_tests/main.cpp | 2 ++ tests/net_load_tests/clt.cpp | 1 + tests/net_load_tests/srv.cpp | 1 + tests/performance_tests/main.cpp | 2 ++ tests/unit_tests/main.cpp | 2 ++ 10 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/common/util.cpp b/src/common/util.cpp index 30746f680..1e180d325 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -549,6 +549,13 @@ std::string get_nix_version_display_string() if (!strcmp(ver, "2.25")) MCLOG_RED(el::Level::Warning, "global", "Running with glibc " << ver << ", hangs may occur - change glibc version if possible"); #endif + +#if OPENSSL_VERSION_NUMBER < 0x10100000 + SSL_library_init(); +#else + OPENSSL_init_ssl(0, NULL); +#endif + return true; } void set_strict_default_file_permissions(bool strict) diff --git a/tests/core_proxy/core_proxy.cpp b/tests/core_proxy/core_proxy.cpp index a0be3db96..0dc314b49 100644 --- a/tests/core_proxy/core_proxy.cpp +++ b/tests/core_proxy/core_proxy.cpp @@ -71,7 +71,7 @@ int main(int argc, char* argv[]) TRY_ENTRY(); - + tools::on_startup(); string_tools::set_module_name_and_folder(argv[0]); //set up logging options diff --git a/tests/core_tests/chaingen_main.cpp b/tests/core_tests/chaingen_main.cpp index 3e5b949c8..9eba347cd 100644 --- a/tests/core_tests/chaingen_main.cpp +++ b/tests/core_tests/chaingen_main.cpp @@ -47,6 +47,7 @@ namespace int main(int argc, char* argv[]) { TRY_ENTRY(); + tools::on_startup(); epee::string_tools::set_module_name_and_folder(argv[0]); //set up logging options diff --git a/tests/functional_tests/main.cpp b/tests/functional_tests/main.cpp index 4c9e073d4..35a0bb9bd 100644 --- a/tests/functional_tests/main.cpp +++ b/tests/functional_tests/main.cpp @@ -34,6 +34,7 @@ using namespace epee; #include "common/command_line.h" +#include "common/util.h" #include "transactions_flow_test.h" namespace po = boost::program_options; @@ -58,6 +59,7 @@ namespace int main(int argc, char* argv[]) { TRY_ENTRY(); + tools::on_startup(); string_tools::set_module_name_and_folder(argv[0]); //set up logging options diff --git a/tests/fuzz/fuzzer.cpp b/tests/fuzz/fuzzer.cpp index 3edf8cd19..756a8c847 100644 --- a/tests/fuzz/fuzzer.cpp +++ b/tests/fuzz/fuzzer.cpp @@ -29,6 +29,7 @@ #include #include "include_base_utils.h" #include "common/command_line.h" +#include "common/util.h" #include "fuzzer.h" #if (!defined(__clang__) || (__clang__ < 5)) @@ -48,6 +49,7 @@ using namespace boost::program_options; int run_fuzzer(int argc, const char **argv, Fuzzer &fuzzer) { TRY_ENTRY(); + tools::on_startup(); string_tools::set_module_name_and_folder(argv[0]); //set up logging options diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index a3cf227de..a96c1cf58 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -33,6 +33,7 @@ #include "wallet/wallet2_api.h" #include "wallet/wallet2.h" #include "include_base_utils.h" +#include "common/util.h" #include #include @@ -1138,6 +1139,7 @@ TEST_F(WalletManagerMainnetTest, RecoverAndRefreshWalletMainNetAsync) int main(int argc, char** argv) { + tools::on_startup(); // we can override default values for "TESTNET_DAEMON_ADDRESS" and "WALLETS_ROOT_DIR" const char * testnet_daemon_addr = std::getenv("TESTNET_DAEMON_ADDRESS"); diff --git a/tests/net_load_tests/clt.cpp b/tests/net_load_tests/clt.cpp index 376d7ee53..2572d3bb7 100644 --- a/tests/net_load_tests/clt.cpp +++ b/tests/net_load_tests/clt.cpp @@ -627,6 +627,7 @@ TEST_F(net_load_test_clt, permament_open_and_close_and_connections_closed_by_ser int main(int argc, char** argv) { + tools::on_startup(); epee::debug::get_set_enable_assert(true, false); //set up logging options mlog_configure(mlog_get_default_log_path("net_load_tests_clt.log"), true); diff --git a/tests/net_load_tests/srv.cpp b/tests/net_load_tests/srv.cpp index e6dee1639..2829b0508 100644 --- a/tests/net_load_tests/srv.cpp +++ b/tests/net_load_tests/srv.cpp @@ -215,6 +215,7 @@ namespace int main(int argc, char** argv) { + tools::on_startup(); //set up logging options mlog_configure(mlog_get_default_log_path("net_load_tests_srv.log"), true); diff --git a/tests/performance_tests/main.cpp b/tests/performance_tests/main.cpp index 3c0283eca..459eecba4 100644 --- a/tests/performance_tests/main.cpp +++ b/tests/performance_tests/main.cpp @@ -28,6 +28,7 @@ // // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers +#include "common/util.h" #include "performance_tests.h" #include "performance_utils.h" @@ -48,6 +49,7 @@ int main(int argc, char** argv) { + tools::on_startup(); set_process_affinity(1); set_thread_high_priority(); diff --git a/tests/unit_tests/main.cpp b/tests/unit_tests/main.cpp index 1706c43c9..a6d398883 100644 --- a/tests/unit_tests/main.cpp +++ b/tests/unit_tests/main.cpp @@ -35,6 +35,7 @@ #include "include_base_utils.h" #include "common/command_line.h" +#include "common/util.h" #include "unit_tests_utils.h" namespace po = boost::program_options; @@ -43,6 +44,7 @@ boost::filesystem::path unit_test::data_dir; int main(int argc, char** argv) { + tools::on_startup(); epee::string_tools::set_module_name_and_folder(argv[0]); mlog_configure(mlog_get_default_log_path("unit_tests.log"), true); epee::debug::get_set_enable_assert(true, false);