Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ lm_cc_test(
"-Wl,--wrap=sem_trywait",
"-Wl,--wrap=sem_post",
"-Wl,--wrap=msync",
"-Wl,--wrap=close",
"-Wl,--wrap=fstat",
],
linkstatic = True,
deps = [
Expand Down
46 changes: 45 additions & 1 deletion score/launch_manager/src/lifecycle_client/src/details/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@score_baselibs//score/language/safecpp:toolchain_features.bzl", "COMPILER_WARNING_FEATURES")
load("//tests/utils/bazel:unit_test.bzl", "linker_wrap_symbols", "lm_cc_test")

cc_library(
name = "report_running_impl",
srcs = ["report_running_impl.cpp"],
hdrs = ["report_running_impl.hpp"],
include_prefix = "score/mw/lifecycle/lifecycle_client/details",
strip_include_prefix = "/score/launch_manager/src/lifecycle_client/src/details",
visibility = ["//score/launch_manager/src/lifecycle_client:__pkg__"],
visibility = [
"//score/launch_manager/src/lifecycle_client:__pkg__",
"//tests/utils/accessors:__pkg__",
],
deps = [
"//score/launch_manager:error_event",
"//score/launch_manager/src/daemon/src/common:constants",
Expand Down Expand Up @@ -49,3 +53,43 @@ cc_library(
"@score_baselibs//score/result",
],
)

lm_cc_test(
name = "report_running_impl_UT",
srcs = ["report_running_impl_UT.cpp"],
copts = ["-DUNIT_TEST"],
linkopts = linker_wrap_symbols([
"fstat",
"close",
"getpid",
"mmap",
"fork",
"execve",
"kill",
"wait",
"shm_open",
"shm_unlink",
"ftruncate",
"access",
"munmap",
"setpgid",
"setgid",
"setuid",
"sched_setscheduler",
"chdir",
"setrlimit",
"fcntl",
"sem_init",
"sem_destroy",
"sem_trywait",
"sem_post",
"msync",
]),
linkstatic = True,
deps = [
":report_running_impl",
"//tests/utils/accessors:accessor_report_running_impl",
"//tests/utils/mocks:mock_syscalls",
"@googletest//:gtest_main",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ score::Result<std::monostate> ReportRunningImpl::reportKRunningtoDaemon() const
return comms_error;
}

if ((sync->comms_type_ == CommsType::kReporting) && close(sync_fd) < 0)
if (close(sync_fd) < 0)
{
LM_LOG_ERROR() << "[Lifecycle Client] Closing file descriptor failed.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class ReportRunningImpl final
/// False if kRunning was not yet reported by the process using this library.
static std::atomic_bool reported;

/// @brief Friend class for accessing and mutating private class contents
/// @note For testing purposes only
friend class ReportRunningImplTestAccessor;

public:
/// @brief Helper method to handle the reporting the kRunning to Daemon operation
/// @returns An instance of score::Result
score::Result<std::monostate> reportKRunningtoDaemon() const noexcept;
Expand Down
Loading
Loading