fix(glog) init in tests
All checks were successful
Verification / Is-Buildable (push) Successful in 3m10s

:Release Notes:
-

:Detailed Notes:
-

:Testing Performed:
-

:QA Notes:
-

:Issues Addressed:
-
This commit is contained in:
Artur Mukhamadiev 2026-05-20 13:16:28 +03:00
parent 33dd44f454
commit 9de6f5a82d
12 changed files with 75 additions and 5 deletions

View File

@ -28,6 +28,7 @@ class TestThread {
~TestThread() { join(); }
void routine() {
LOG(INFO) << "Started routine";
size_t distance{0};
std::unique_lock lock(mtx);
const std::stop_token stoken = thr.get_stop_token();

View File

@ -13,7 +13,9 @@
class Base64Test : public ::testing::Test {
protected:
void SetUp() override {
FLAGS_logtostderr = true;
if (!google::IsGoogleLoggingInitialized())
google::InitGoogleLogging("TestCli");
}
void TearDown() override {

View File

@ -1,11 +1,17 @@
#include "cloud_point_rpc/rpc_coder.hpp"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <glog/logging.h>
using namespace score;
class Base64EdgeCaseTest : public ::testing::Test {
protected:
void SetUp() override {
FLAGS_logtostderr = true;
if (!google::IsGoogleLoggingInitialized())
google::InitGoogleLogging("TestRPC");
}
Base64RPCCoder coder;
};

View File

@ -5,6 +5,7 @@
#include <glog/logging.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <thread>
class TestCApi : public ::testing::Test {
protected:
@ -19,7 +20,6 @@ class TestCApi : public ::testing::Test {
};
TEST_F(TestCApi, Base) {
rpc_string name;
name.s = "test";
static std::promise<bool> task;
@ -163,6 +163,30 @@ TEST_F(TestCApi, ScheduleCall) {
test_idx.template operator()<3>();
}
TEST(TestTestCApi, InitDeinitOnLongRunningTask) {
using namespace std::chrono_literals;
FLAGS_logtostderr = true;
if (!google::IsGoogleLoggingInitialized())
google::InitGoogleLogging("TestRPC");
EXPECT_NO_THROW(crpc_test_init());
static std::promise<bool> bridge;
std::string_view name = "long running task";
crpc_test_add_method(
+[](rpc_string *) -> rpc_string * {
static bool installed = false;
if (!installed) {
installed = true;
bridge.set_value(true);
}
std::string_view res = "res";
std::this_thread::sleep_for(3s);
return crpc_str_create(res.data(), res.size());
},
crpc_str_create(name.data(), name.size()));
std::this_thread::sleep_for(500ms);
crpc_test_deinit();
}
TEST_F(TestCApi, String) {
rpc_string name;
name.s = "test";

View File

@ -19,6 +19,9 @@ public:
protected:
void SetUp() override {
FLAGS_logtostderr = true;
if (!google::IsGoogleLoggingInitialized())
google::InitGoogleLogging("TestCli");
server_ip = "127.0.0.1";
server_port = 9096;

View File

@ -16,6 +16,9 @@ using namespace score;
class IntegrationTest : public ::testing::Test {
protected:
void SetUp() override {
FLAGS_logtostderr = true;
if (!google::IsGoogleLoggingInitialized())
google::InitGoogleLogging("TestCli");
// Create a temporary config file for testing
std::ofstream config_file("config.yaml");
config_file

View File

@ -15,6 +15,9 @@ class RpcServerTest : public ::testing::Test {
Service service;
void SetUp() override {
FLAGS_logtostderr = true;
if (!google::IsGoogleLoggingInitialized())
google::InitGoogleLogging("TestCli");
server.register_method("get-intrinsic-params", [&](const json &) {
return service.get_intrinsic_params();
});

View File

@ -2,6 +2,7 @@
#include "server_api.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <glog/logging.h>
#include <nlohmann/json.hpp>
#include <string>
#include <thread>
@ -15,6 +16,9 @@ class RpcServerEdgeCaseTest : public ::testing::Test {
RpcServer server;
void SetUp() override {
FLAGS_logtostderr = true;
if (!google::IsGoogleLoggingInitialized())
google::InitGoogleLogging("TestCli");
server.register_method(
"echo", [&](const json &j) { return j.get<std::string>(); });
server.register_method("thrower", [&](const json &) -> std::string {

View File

@ -1,11 +1,19 @@
#include "cloud_point_rpc/serialize.hpp"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <glog/logging.h>
#include <limits>
using namespace score;
class SerializeEdgeCaseTest : public ::testing::Test {};
class SerializeEdgeCaseTest : public ::testing::Test {
protected:
void SetUp() override {
FLAGS_logtostderr = true;
if (!google::IsGoogleLoggingInitialized())
google::InitGoogleLogging("TestRPC");
}
};
// uint8_t round-trip
TEST_F(SerializeEdgeCaseTest, Uint8RoundTrip) {

View File

@ -4,7 +4,14 @@
using namespace score;
class ServiceEdgeCaseTest : public ::testing::Test {};
class ServiceEdgeCaseTest : public ::testing::Test {
protected:
void SetUp() override {
FLAGS_logtostderr = true;
if (!google::IsGoogleLoggingInitialized())
google::InitGoogleLogging("TestRPC");
}
};
// Default constructor (no data)
TEST_F(ServiceEdgeCaseTest, DefaultConstructorFallbacks) {

View File

@ -15,6 +15,9 @@ class TcpTest : public ::testing::Test {
protected:
void SetUp() override {
FLAGS_logtostderr = true;
if (!google::IsGoogleLoggingInitialized())
google::InitGoogleLogging("TestRPC");
server_ = std::make_unique<score::TcpServer>(
"127.0.0.1", 12345, [this](const std::string &request) {
EXPECT_EQ(request, expected_);
@ -55,4 +58,4 @@ TEST_F(TcpTest, HugeBuffer) {
ExpectedResponse(data);
score::TCPConnector connector("127.0.0.1", 12345);
auto res = connector.Send(data);
}
}

View File

@ -28,6 +28,12 @@ class TcpEdgeCaseTest : public ::testing::Test {
}
}
void SetUp() override {
FLAGS_logtostderr = true;
if (!google::IsGoogleLoggingInitialized())
google::InitGoogleLogging("TestRPC");
}
void TearDown() override { StopServer(); }
};