From a54b9a2dc4f0baadc1431795341e6d41b6ffd642 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 3 Jan 2019 21:54:26 +0000 Subject: [PATCH] Fix UTPTest test failures --- CMakeLists.txt | 2 +- llarp/logic.cpp | 2 +- llarp/logic.hpp | 2 +- test/utp_unittest.cpp | 13 ++++--------- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d3fe03be..c09709eee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,7 +116,7 @@ if(NOT DEBIAN) endif(NOT DEBIAN) if(ASAN) - set(DEBUG_FLAGS ${DEBUG_FLAGS} -fsanitize=address -fno-omit-frame-pointer) + set(DEBUG_FLAGS ${DEBUG_FLAGS} -fsanitize=thread -fno-omit-frame-pointer) set(OPTIMIZE_FLAGS "-O0") endif(ASAN) diff --git a/llarp/logic.cpp b/llarp/logic.cpp index 6dcf1d38e..8071885dc 100644 --- a/llarp/logic.cpp +++ b/llarp/logic.cpp @@ -55,7 +55,7 @@ namespace llarp } uint32_t - Logic::call_later(struct llarp_timeout_job job) + Logic::call_later(const llarp_timeout_job& job) { llarp_timeout_job j; j.user = job.user; diff --git a/llarp/logic.hpp b/llarp/logic.hpp index e8982fc51..c1e47ae3f 100644 --- a/llarp/logic.hpp +++ b/llarp/logic.hpp @@ -44,7 +44,7 @@ namespace llarp queue_job(struct llarp_thread_job job); uint32_t - call_later(struct llarp_timeout_job job); + call_later(const llarp_timeout_job& job); void cancel_call(uint32_t id); diff --git a/test/utp_unittest.cpp b/test/utp_unittest.cpp index b8cd0890d..d7a40b6c1 100644 --- a/test/utp_unittest.cpp +++ b/test/utp_unittest.cpp @@ -102,30 +102,25 @@ struct UTPTest : public ::testing::Test bool success = false; llarp_ev_loop* netLoop; - std::unique_ptr< llarp::Logic > logic; llarp_time_t oldRCLifetime; + std::unique_ptr< llarp::Logic > logic; + UTPTest() : crypto(llarp::Crypto::sodium{}) , Alice(crypto) , Bob(crypto) , netLoop(nullptr) + , oldRCLifetime(llarp::RouterContact::Lifetime) { - } - - void - SetUp() - { - oldRCLifetime = llarp::RouterContact::Lifetime; llarp::RouterContact::IgnoreBogons = true; llarp::RouterContact::Lifetime = 500; llarp_ev_loop_alloc(&netLoop); logic.reset(new llarp::Logic()); } - void - TearDown() + ~UTPTest() { Alice.TearDown(); Bob.TearDown();