diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index c30577dea..db93aef02 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -1,8 +1,11 @@ +# include(MgThrift) + set(test_prefix memgraph__unit__) find_package(fmt REQUIRED) find_package(gflags REQUIRED) find_package(Threads REQUIRED) +find_package(Folly REQUIRED) add_custom_target(memgraph__unit) @@ -37,7 +40,7 @@ function(_add_unit_test test_cpp custom_main) # used to help create two targets of the same name even though CMake # requires unique logical target names set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${exec_name}) - target_link_libraries(${target_name} mg-memory mg-utils gtest gmock Threads::Threads dl) + target_link_libraries(${target_name} mg-memory mg-utils gtest gmock Threads::Threads dl mg-interface-echo-cpp2) # register test if(TEST_COVERAGE) diff --git a/tests/unit/main.cpp b/tests/unit/main.cpp index 88d266b24..a81ed608c 100644 --- a/tests/unit/main.cpp +++ b/tests/unit/main.cpp @@ -9,11 +9,15 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. +#include <folly/init/Init.h> #include <gtest/gtest.h> #include <utils/logging.hpp> int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); + + folly::Init(&argc, &argv); + memgraph::logging::RedirectToStderr(); spdlog::set_level(spdlog::level::trace); return RUN_ALL_TESTS(); diff --git a/tests/unit/thrift_transport_echo.cpp b/tests/unit/thrift_transport_echo.cpp index a0752e396..679011724 100644 --- a/tests/unit/thrift_transport_echo.cpp +++ b/tests/unit/thrift_transport_echo.cpp @@ -89,10 +89,6 @@ class EchoSvc : public EchoSvIf { TEST(ThriftTransport, Echo) { // TODO(tyler and gabor) use thrift-generated echo, and thrift transport, to send, reply, and receive the response for // a thrift-defined message - int argc = 0; - char **argv; - folly::init(&argc, &argv); - auto ptr1 = std::make_shared<EchoSvc>(); auto ptr2 = std::make_shared<EchoSvc>(); @@ -110,18 +106,19 @@ TEST(ThriftTransport, Echo) { s->serve(); }); - // Wait some time... std::this_thread::sleep_for(4000ms); ptr1->SendOneShotMessage(6666, "original"); - // Wait some time... std::this_thread::sleep_for(4000ms); ptr2->SendOutMessage(6665); - // Wait some time... std::this_thread::sleep_for(4000ms); auto result = ptr1->GetCurrentMessage(); ASSERT_EQ(result, std::string("00original")); + + // Solve this once this is not just a POC. + server_thread2.detach(); + server_thread1.detach(); }