diff --git a/tests/unit/coward_the_cowardly_dog.h b/tests/unit/coward_the_cowardly_dog.h new file mode 100644 index 000000000..31eaf2c36 --- /dev/null +++ b/tests/unit/coward_the_cowardly_dog.h @@ -0,0 +1,22 @@ +// Copyright 2022 Memgraph Ltd. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source +// License, and you may not use this file except in compliance with the Business Source License. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +#include <string> +#include "gtest/gtest.h" + +namespace clahelper { +inline std::string g_command_line_arg; +} + +class MyTestEnvironment : public testing::Environment { + public: + explicit MyTestEnvironment(const std::string &command_line_arg) { clahelper::g_command_line_arg = command_line_arg; } +}; diff --git a/tests/unit/main.cpp b/tests/unit/main.cpp index c21c5b2cf..0b23dfbd2 100644 --- a/tests/unit/main.cpp +++ b/tests/unit/main.cpp @@ -12,9 +12,15 @@ #include <gtest/gtest.h> #include <utils/logging.hpp> +#include "coward_the_cowardly_dog.h" + int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); + std::string command_line_arg(argv[0]); + testing::InitGoogleTest(&argc, argv); + testing::AddGlobalTestEnvironment(new MyTestEnvironment(command_line_arg)); + 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 679011724..d849edc6f 100644 --- a/tests/unit/thrift_transport_echo.cpp +++ b/tests/unit/thrift_transport_echo.cpp @@ -25,6 +25,8 @@ #include "io/thrift/thrift_transport.hpp" +#include "coward_the_cowardly_dog.h" + using namespace memgraph::io; using namespace apache::thrift; @@ -89,6 +91,12 @@ 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 = 1; + const char *arg2 = clahelper::g_command_line_arg.c_str(); + char *arg = const_cast<char *>(arg2); + char **argv = &arg; + folly::Init(&argc, &argv); + auto ptr1 = std::make_shared<EchoSvc>(); auto ptr2 = std::make_shared<EchoSvc>();