diff --git a/examples/control_application/control_daemon.cpp b/examples/control_application/control_daemon.cpp index 9b149d30e..59404855c 100644 --- a/examples/control_application/control_daemon.cpp +++ b/examples/control_application/control_daemon.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include "ipc_dropin/socket.hpp" #include "control.hpp" @@ -30,7 +30,7 @@ int main(int argc, char** argv) { signal(SIGINT, signalHandler); signal(SIGTERM, signalHandler); - score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); + score::mw::lifecycle::report_running(); ipc_dropin::Socket(sizeof(RunTargetInfo)), control_socket_capacity> sm_control_socket{}; if (sm_control_socket.create(control_socket_path, 600) != ipc_dropin::ReturnCode::kOk) { diff --git a/examples/cpp_supervised_app/main.cpp b/examples/cpp_supervised_app/main.cpp index ab09f5d9e..f6705e65c 100644 --- a/examples/cpp_supervised_app/main.cpp +++ b/examples/cpp_supervised_app/main.cpp @@ -23,7 +23,7 @@ #include #endif -#include +#include #include #include #include @@ -146,7 +146,7 @@ int main(int argc, char** argv) hm.start(); - score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); + score::mw::lifecycle::report_running(); auto deadline_mon = std::move(*deadline_monitor_res); diff --git a/score/launch_manager/daemon/src/alive_monitor/details/daemon/PhmDaemon.hpp b/score/launch_manager/daemon/src/alive_monitor/details/daemon/PhmDaemon.hpp index 547601a9e..c453edf6f 100644 --- a/score/launch_manager/daemon/src/alive_monitor/details/daemon/PhmDaemon.hpp +++ b/score/launch_manager/daemon/src/alive_monitor/details/daemon/PhmDaemon.hpp @@ -19,7 +19,6 @@ #include #include -#include "score/mw/lifecycle/lifecycle_client.h" #include "score/mw/lifecycle/control_client.h" #include "score/mw/launch_manager/alive_monitor/details/daemon/PhmDaemonConfig.hpp" #include "score/mw/launch_manager/alive_monitor/details/daemon/SwClusterHandler.hpp" diff --git a/score/launch_manager/lifecycle_client/BUILD b/score/launch_manager/lifecycle_client/BUILD index 8598e7955..d9f1a5673 100644 --- a/score/launch_manager/lifecycle_client/BUILD +++ b/score/launch_manager/lifecycle_client/BUILD @@ -21,7 +21,6 @@ cc_library( deps = [ ":aasapplicationcontainer", ":application", - ":lifecycleclient_internal", ":lifecyclemanager", ":report_running", ":runapplication", @@ -145,26 +144,7 @@ cc_library( tags = ["FUSA"], visibility = ["//score/launch_manager:__subpackages__"], deps = [ - ":lifecycleclient_internal", - ], -) - -cc_library( - name = "lifecycleclient_internal", - srcs = [ - "src/lifecycle_client.cpp", - ], - hdrs = [ - "src/lifecycle_client.h", - ], - features = COMPILER_WARNING_FEATURES, - include_prefix = "score/mw/lifecycle", - strip_include_prefix = "/score/launch_manager/lifecycle_client/src", - tags = ["FUSA"], - visibility = ["//score/launch_manager/lifecycle_client:__subpackages__"], - deps = [ - "//score/launch_manager:error_event", - "//score/launch_manager/lifecycle_client/src/details:lifecycle_client_impl", + "//score/launch_manager/lifecycle_client/src/details:report_running_impl", ], ) diff --git a/score/launch_manager/lifecycle_client/src/details/BUILD b/score/launch_manager/lifecycle_client/src/details/BUILD index 4cf280792..4d98609c1 100644 --- a/score/launch_manager/lifecycle_client/src/details/BUILD +++ b/score/launch_manager/lifecycle_client/src/details/BUILD @@ -13,9 +13,9 @@ load("@rules_cc//cc:defs.bzl", "cc_library") cc_library( - name = "lifecycle_client_impl", - srcs = ["lifecycle_client_impl.cpp"], - hdrs = ["lifecycle_client_impl.hpp"], + 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/lifecycle_client/src/details", visibility = ["//score/launch_manager/lifecycle_client:__pkg__"], diff --git a/score/launch_manager/lifecycle_client/src/details/lifecycle_client_impl.cpp b/score/launch_manager/lifecycle_client/src/details/report_running_impl.cpp similarity index 89% rename from score/launch_manager/lifecycle_client/src/details/lifecycle_client_impl.cpp rename to score/launch_manager/lifecycle_client/src/details/report_running_impl.cpp index bc3e09274..a52cfb6ad 100644 --- a/score/launch_manager/lifecycle_client/src/details/lifecycle_client_impl.cpp +++ b/score/launch_manager/lifecycle_client/src/details/report_running_impl.cpp @@ -23,18 +23,18 @@ #include "score/mw/launch_manager/osal/ipc_comms.hpp" #include "score/mw/launch_manager/common/constants.hpp" #include "score/mw/lifecycle/execution_error.h" -#include "score/mw/lifecycle/lifecycle_client/details/lifecycle_client_impl.hpp" +#include "score/mw/lifecycle/lifecycle_client/details/report_running_impl.hpp" using namespace score::lcm::internal::osal; namespace score::mw::lifecycle { - std::atomic_bool LifecycleClientImpl::reported{false}; + std::atomic_bool ReportRunningImpl::reported{false}; - LifecycleClientImpl::LifecycleClientImpl() noexcept = default; + ReportRunningImpl::ReportRunningImpl() noexcept = default; - LifecycleClientImpl::~LifecycleClientImpl() noexcept = default; + ReportRunningImpl::~ReportRunningImpl() noexcept = default; - score::Result LifecycleClientImpl::ReportRunningState() const noexcept + score::Result ReportRunningImpl::ReportRunningState() const noexcept { score::Result retVal{score::MakeUnexpected(ExecErrc::kCommunicationError)}; @@ -51,7 +51,7 @@ namespace score::mw::lifecycle { return retVal; } - score::Result LifecycleClientImpl::reportKRunningtoDaemon() const noexcept + score::Result ReportRunningImpl::reportKRunningtoDaemon() const noexcept { score::Result comms_error {score::MakeUnexpected(ExecErrc::kCommunicationError)}; @@ -103,7 +103,7 @@ namespace score::mw::lifecycle { return comms_error; } - + // Final post to semaphore, so LM know that communication channel can be closed now sync->send_sync_.post(); // Mark as reported if successful diff --git a/score/launch_manager/lifecycle_client/src/details/lifecycle_client_impl.hpp b/score/launch_manager/lifecycle_client/src/details/report_running_impl.hpp similarity index 67% rename from score/launch_manager/lifecycle_client/src/details/lifecycle_client_impl.hpp rename to score/launch_manager/lifecycle_client/src/details/report_running_impl.hpp index 4bfa0380b..f84c8ee2b 100644 --- a/score/launch_manager/lifecycle_client/src/details/lifecycle_client_impl.hpp +++ b/score/launch_manager/lifecycle_client/src/details/report_running_impl.hpp @@ -12,8 +12,8 @@ ********************************************************************************/ -#ifndef _INCLUDED_LIFECYCLECLIENTIMPL_ -#define _INCLUDED_LIFECYCLECLIENTIMPL_ +#ifndef _INCLUDED_REPORTRUNNINGIMPL_ +#define _INCLUDED_REPORTRUNNINGIMPL_ #include @@ -22,22 +22,21 @@ namespace score::mw::lifecycle { -/// @brief Class implementing Pimpl (pointer to implementation) design pattern for LifecycleClient (an AUTOSAR data type). -/// The lifecycle_client_lib strive to provide ABI compatibility as much as we can, so for this reason Pimpl pattern is deployed. -/// Design of this class fulfil the needs of the pattern mentioned. -/// More info can be found here: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ri-pimpl -class LifecycleClientImpl final { +/// @brief Implementation class for report_running(), handling the actual IPC +/// communication with the Launch Manager to signal that this process has +/// entered its Running state. +class ReportRunningImpl final { public: - /// @brief Constructor that creates LifecycleClientImpl (implementation of Lifecycle Client) - LifecycleClientImpl() noexcept; + /// @brief Constructor + ReportRunningImpl() noexcept; - /// @brief Destructor of the LifecycleClientImpl (implementation of Lifecycle Client) - ~LifecycleClientImpl() noexcept; + /// @brief Destructor + ~ReportRunningImpl() noexcept; // This class is trivially copyable / movable // For this reason we are applying the rule of zero - /// @brief Implementation of a interface for a Process to report its running state to Launch Manager. + /// @brief Reports the Running state to the Launch Manager. /// /// @returns An instance of score::Result. The instance holds an ErrorCode containing either one of the specified errors or a void-value. /// @error score::mw::lifecycle::ExecErrc::kCommunicationError Communication error between Application and Launch Manager, e.g. unable to report state for Non-reporting Process. @@ -46,10 +45,10 @@ class LifecycleClientImpl final { private: /// @brief Variable to remember if kRunning was already reported for the process using lifecycle_client_lib. - /// Please note that LifecycleClient::ReportRunningState() method, the original method, is declared as a const method. + /// Please note that ReportRunningState() method is declared as a const method. /// Thanks to this, user can choose to declare instance of this class as a constant variable and reporting kRunning will still work. /// However, this prevent us from implementing certain optimizations, after initial kRunning was reported. - /// To mitigate this, we can store this information outside of LifecycleClientImpl class or have a mutable variable. + /// To mitigate this, we can store this information outside of ReportRunningImpl class or have a mutable variable. /// After short discussion, mutable variable was chosen. /// True if kRunning was already reported by the process using this library. /// False if kRunning was not yet reported by the process using this library. @@ -62,4 +61,4 @@ class LifecycleClientImpl final { } // namespace score::mw::lifecycle -#endif // _INCLUDED_LIFECYCLECLIENTIMPL_ +#endif // _INCLUDED_REPORTRUNNINGIMPL_ diff --git a/score/launch_manager/lifecycle_client/src/lifecycle_client.cpp b/score/launch_manager/lifecycle_client/src/lifecycle_client.cpp deleted file mode 100644 index 94b9fa85a..000000000 --- a/score/launch_manager/lifecycle_client/src/lifecycle_client.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -#include "score/mw/launch_manager/common/log.hpp" -#include "score/mw/lifecycle/execution_error.h" -#include "score/mw/lifecycle/lifecycle_client.h" -#include "score/mw/lifecycle/lifecycle_client/details/lifecycle_client_impl.hpp" - - -namespace score::mw::lifecycle { - -LifecycleClient::LifecycleClient() noexcept -{ - try { - lifecycle_client_impl_ = std::make_unique(); - } catch (...) { - lifecycle_client_impl_ = nullptr; - } -} - -LifecycleClient::~LifecycleClient() noexcept = default; - -LifecycleClient::LifecycleClient(LifecycleClient&& rval) noexcept = default; - -LifecycleClient& LifecycleClient::operator=(LifecycleClient&& rval) noexcept { - if (this != &rval) { - // let's the move assignment operator from std::unique_ptr, - // take care of the move - lifecycle_client_impl_.operator=(std::move(rval.lifecycle_client_impl_)); - } - - return *this; -} - -score::Result LifecycleClient::ReportExecutionState(ExecutionState state) const noexcept { - - // Check if the state is valid - if (ExecutionState::kRunning != state) - { - LM_LOG_ERROR() << "[Lifecycle Client] Invalid execution state!"; - return score::Result{score::MakeUnexpected(ExecErrc::kInvalidTransition)}; - } - - // Check if the lifecycle_client_impl is valid - if( lifecycle_client_impl_ ) - { - return lifecycle_client_impl_->ReportRunningState(); - } - else - { - return score::Result{score::MakeUnexpected(ExecErrc::kCommunicationError)}; - } -} - -} // namespace score::mw::lifecycle - -#ifdef __cplusplus -extern "C" { -#endif - -int8_t score_lcm_ReportExecutionStateRunning(void) { - // RULECHECKER_comment(1, 2, check_static_object_dynamic_initialization, "static variable is in function scope so this initlization is safe", false) - static score::mw::lifecycle::LifecycleClient g_lm{}; - const auto result = g_lm.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - if (!result) { - return -1; - } - return 0; -} - -#ifdef __cplusplus -} -#endif diff --git a/score/launch_manager/lifecycle_client/src/lifecycle_client.h b/score/launch_manager/lifecycle_client/src/lifecycle_client.h deleted file mode 100644 index ecf4c80c3..000000000 --- a/score/launch_manager/lifecycle_client/src/lifecycle_client.h +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -#ifndef SCORE_LCM_LIFECYCLECLIENT_H_ -#define SCORE_LCM_LIFECYCLECLIENT_H_ - -#ifdef __cplusplus -#include -#include -#include - -#include "score/result/result.h" - -namespace score::mw::lifecycle { - -/// @brief Defines the internal states of a Process (see 7.3.1). Scoped Enumeration of uint8_t -enum class ExecutionState : std::uint8_t { - /// @brief After a Process has been started by Launch Manager, it reports ExecutionState kRunning - kRunning = 0 -}; - -class LifecycleClientImpl; - -/// @brief Class to implement operations on Lifecycle Client -class LifecycleClient final { - public: - /// @brief Constructor that creates the Lifecycle Client - /// @note Constructor for LifecycleClient which opens the Launch Manager communication channel (e.g. POSIX FIFO) for reporting the Execution State. Each Process shall create an instance of this class to report its state - LifecycleClient() noexcept; - - /// @brief Destructor of the Lifecycle Client instance - ~LifecycleClient() noexcept; - - // Applying the rule of five to R21-11 - // Class will not be copyable, but it will be movable - - /// @brief Suppress default copy construction for LifecycleClient. - LifecycleClient(const LifecycleClient&) = delete; - - /// @brief Suppress default copy assignment for LifecycleClient. - LifecycleClient& operator=(const LifecycleClient&) = delete; - - /// @brief Intentional use of default move constructor for LifecycleClient. - /// - /// @param[in] rval reference to move - LifecycleClient(LifecycleClient&& rval) noexcept; - - /// @brief Intentional use of default move assignment for LifecycleClient. - /// - /// @param[in] rval reference to move - /// @returns the new reference - LifecycleClient& operator=(LifecycleClient&& rval) noexcept; - - /// @brief Interface for a Process to report its internal state to Launch Manager. - /// - /// @param state Value of the Execution State - /// @returns An instance of score::Result. The instance holds an ErrorCode containing either one of the specified errors or a void-value. - /// @error score::mw::lifecycle::ExecErrc::kGeneralError if some unspecified error occurred - /// @error score::mw::lifecycle::ExecErrc::kCommunicationError Communication error between Application and Launch Manager, e.g. unable to report state for Non-reporting Process. - /// @error score::mw::lifecycle::ExecErrc::kInvalidTransition Invalid transition request (e.g. to Running when already in Running state) - score::Result ReportExecutionState(ExecutionState state) const noexcept; - - private: - /// @brief Pointer to implementation (Pimpl), we use this pattern to provide ABI compatibility. - std::unique_ptr lifecycle_client_impl_; -}; - -} // namespace score::mw::lifecycle - -extern "C" { -#else -#include -#endif - -/// @brief C API for reporting kRunning to LCM -/// -/// C-API is required for dlt-daemon -/// -/// @return int8_t -/// @retval 0 Success -/// @retval -1 General Error -int8_t score_lcm_ReportExecutionStateRunning(void); - -#ifdef __cplusplus -} -#endif - -#endif // SCORE_LCM_LIFECYCLECLIENT_H_ diff --git a/score/launch_manager/lifecycle_client/src/report_running.cpp b/score/launch_manager/lifecycle_client/src/report_running.cpp index 57066958f..78956e2dd 100644 --- a/score/launch_manager/lifecycle_client/src/report_running.cpp +++ b/score/launch_manager/lifecycle_client/src/report_running.cpp @@ -12,11 +12,26 @@ ********************************************************************************/ #include "score/mw/lifecycle/report_running.h" - -#include "score/mw/lifecycle/lifecycle_client.h" +#include "score/mw/lifecycle/lifecycle_client/details/report_running_impl.hpp" void score::mw::lifecycle::report_running() noexcept { - static_cast( - score::mw::lifecycle::LifecycleClient{}.ReportExecutionState( - score::mw::lifecycle::ExecutionState::kRunning)); -} \ No newline at end of file + static_cast(score::mw::lifecycle::ReportRunningImpl{}.ReportRunningState()); +} + +#ifdef __cplusplus +extern "C" { +#endif + +int8_t score_lcm_ReportRunning(void) { + // RULECHECKER_comment(1, 2, check_static_object_dynamic_initialization, "static variable is in function scope so this initialization is safe", false) + static score::mw::lifecycle::ReportRunningImpl g_impl{}; + const auto result = g_impl.ReportRunningState(); + if (!result) { + return -1; + } + return 0; +} + +#ifdef __cplusplus +} +#endif diff --git a/score/launch_manager/lifecycle_client/src/rust/BUILD b/score/launch_manager/lifecycle_client/src/rust/BUILD index 333cf0285..86416973a 100644 --- a/score/launch_manager/lifecycle_client/src/rust/BUILD +++ b/score/launch_manager/lifecycle_client/src/rust/BUILD @@ -20,7 +20,7 @@ rust_library( ], visibility = ["//score/launch_manager:__subpackages__"], deps = [ - "//score/launch_manager/lifecycle_client:lifecycleclient_internal", + "//score/launch_manager/lifecycle_client:report_running", "@score_crates//:libc", ], ) diff --git a/score/launch_manager/lifecycle_client/src/rust/src/lifecycle.rs b/score/launch_manager/lifecycle_client/src/rust/src/lifecycle.rs index 3d7686d0b..c024e2a12 100644 --- a/score/launch_manager/lifecycle_client/src/rust/src/lifecycle.rs +++ b/score/launch_manager/lifecycle_client/src/rust/src/lifecycle.rs @@ -12,11 +12,11 @@ // ******************************************************************************* use libc::c_int; -#[link(name = "lifecycleclient_internal")] +#[link(name = "report_running")] unsafe extern "C" { - fn score_lcm_ReportExecutionStateRunning() -> c_int; + fn score_lcm_ReportRunning() -> c_int; } pub fn report_execution_state_running() -> bool { - unsafe { score_lcm_ReportExecutionStateRunning() == 0 } + unsafe { score_lcm_ReportRunning() == 0 } } diff --git a/tests/integration/complex_monitoring/component_complex_monitoring.cpp b/tests/integration/complex_monitoring/component_complex_monitoring.cpp index ffd221351..441cb583d 100644 --- a/tests/integration/complex_monitoring/component_complex_monitoring.cpp +++ b/tests/integration/complex_monitoring/component_complex_monitoring.cpp @@ -13,7 +13,7 @@ #include #include -#include "score/mw/lifecycle/lifecycle_client.h" +#include "score/mw/lifecycle/report_running.h" #include "score/mw/log/rust/stdout_logger_init.h" #include "tests/utils/test_helper/test_helper.hpp" #include @@ -44,10 +44,9 @@ TEST(ComplexMonitoring, ComponentComplexMonitoring) hm.start(); - TEST_STEP("Report kRunning") + TEST_STEP("Report running") { - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - ASSERT_TRUE(result.has_value()) << "ReportExecutionState() failed: " << result.error().Message(); + score::mw::lifecycle::report_running(); } auto time_to_report_checkpoints_until = std::chrono::steady_clock::now() + 1s; diff --git a/tests/integration/complex_monitoring/control_client_mock.cpp b/tests/integration/complex_monitoring/control_client_mock.cpp index 94c46e84d..c83bb537f 100644 --- a/tests/integration/complex_monitoring/control_client_mock.cpp +++ b/tests/integration/complex_monitoring/control_client_mock.cpp @@ -15,7 +15,7 @@ #include "tests/utils/test_helper/test_helper.hpp" #include -#include +#include TEST(ComplexMonitoring, ControlClientMock) @@ -24,10 +24,9 @@ TEST(ComplexMonitoring, ControlClientMock) ASSERT_TRUE(check_clean({test_end_location, fallback_file})); - TEST_STEP("Report kRunning") + TEST_STEP("Report running") { - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - ASSERT_TRUE(result.has_value()) << "ReportExecutionState() failed: " << result.error().Message(); + score::mw::lifecycle::report_running(); } TEST_STEP("Launch monitored process") diff --git a/tests/integration/crash_on_startup/control_client_mock.cpp b/tests/integration/crash_on_startup/control_client_mock.cpp index ba49f4bd2..c0dcd1be0 100644 --- a/tests/integration/crash_on_startup/control_client_mock.cpp +++ b/tests/integration/crash_on_startup/control_client_mock.cpp @@ -15,7 +15,7 @@ #include "tests/utils/test_helper/test_helper.hpp" #include -#include +#include TEST(CrashOnStartup, ControlClientMock) @@ -24,10 +24,9 @@ TEST(CrashOnStartup, ControlClientMock) ASSERT_TRUE(check_clean({crashed_once_file, crashed_twice_file, test_end_location, fallback_file})); - TEST_STEP("Report kRunning") + TEST_STEP("Report running") { - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - ASSERT_TRUE(result.has_value()) << "ReportExecutionState() failed: " << result.error().Message(); + score::mw::lifecycle::report_running(); } // Given a process that crashes on startup twice diff --git a/tests/integration/crash_on_startup/crash_on_startup.py b/tests/integration/crash_on_startup/crash_on_startup.py index b6670dbd8..eaed6b45a 100644 --- a/tests/integration/crash_on_startup/crash_on_startup.py +++ b/tests/integration/crash_on_startup/crash_on_startup.py @@ -27,7 +27,7 @@ ) def test_crash_on_startup(target, setup_test, assert_test_results, remote_test_dir): """ - Objective: Verifies that the launch manager correctly handles processes that crash before reporting kRunning. + Objective: Verifies that the launch manager correctly handles processes that crash before reporting running. Case 1: Process crashes before Running state but eventually starts up successfully before the configured number of restart attempts is exceeded. Expected Behaviour: Process startup successful, RunTarget activation successful diff --git a/tests/integration/crash_on_startup/process_crashing_on_startup_twice.cpp b/tests/integration/crash_on_startup/process_crashing_on_startup_twice.cpp index c783b1cf0..473b270ee 100644 --- a/tests/integration/crash_on_startup/process_crashing_on_startup_twice.cpp +++ b/tests/integration/crash_on_startup/process_crashing_on_startup_twice.cpp @@ -15,14 +15,13 @@ #include #include "tests/utils/test_helper/test_helper.hpp" -#include +#include TEST(CrashOnStartup, ProcessCrashingOnStartupTwice) { - TEST_STEP("Report kRunning") + TEST_STEP("Report running") { - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - ASSERT_TRUE(result.has_value()) << "ReportExecutionState() failed: " << result.error().Message(); + score::mw::lifecycle::report_running(); } } diff --git a/tests/integration/incorrect_config_non_reporting/non_reporting_process.cpp b/tests/integration/incorrect_config_non_reporting/non_reporting_process.cpp index 96ecfd880..d78d05c76 100644 --- a/tests/integration/incorrect_config_non_reporting/non_reporting_process.cpp +++ b/tests/integration/incorrect_config_non_reporting/non_reporting_process.cpp @@ -20,7 +20,7 @@ #include "score/mw/launch_manager/osal/ipc_comms.hpp" #include "tests/utils/test_helper/test_helper.hpp" -#include +#include TEST(NonReporting, Process) { @@ -38,9 +38,9 @@ TEST(NonReporting, Process) ASSERT_NE(dup_res, -1) << "dup2 failed: " << strerror(errno); } - // Invalid kRunning report - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - EXPECT_FALSE(result.has_value()) << "ReportExecutionState() should not succeed"; + // Invalid running report + score::mw::lifecycle::report_running(); + // If the process is still alive, it means it did not crash on invalid report_running, which is expected close(ipc::sync_fd); } diff --git a/tests/integration/incorrect_config_non_reporting/test_incorrect_config_non_reporting.py b/tests/integration/incorrect_config_non_reporting/test_incorrect_config_non_reporting.py index 2625326e9..80aa42dc2 100644 --- a/tests/integration/incorrect_config_non_reporting/test_incorrect_config_non_reporting.py +++ b/tests/integration/incorrect_config_non_reporting/test_incorrect_config_non_reporting.py @@ -28,7 +28,7 @@ def test_incorrect_config_non_reporting( """ Objective: Test robustness of LifecycleClient API Input: Component wrongly configured as `native` application type, acquires a file descriptor ordinarily used by LM communication, and reports the Running state to LaunchManager. - Expected Outcome: Reporting Running state fails, LifecycleClient API returns an error. + Expected Outcome: Process does not crash. """ run_until_file_deployed( target=target, diff --git a/tests/integration/process_complex_rep_failure/control_client_mock.cpp b/tests/integration/process_complex_rep_failure/control_client_mock.cpp index 42b32d3f3..b505ee0be 100644 --- a/tests/integration/process_complex_rep_failure/control_client_mock.cpp +++ b/tests/integration/process_complex_rep_failure/control_client_mock.cpp @@ -14,7 +14,7 @@ #include "tests/utils/test_helper/test_helper.hpp" #include -#include +#include // Given a correct configuration with: // - An initial Run Target named "Startup" containing component named @@ -32,11 +32,8 @@ TEST(RecoveryActionComplexRepFailure, ControlClientMock) { ASSERT_TRUE(check_clean({test_end_location, fallback_file})); // Establish communication with launch manager - TEST_STEP("Report kRunning from ControlClientMock") { - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState( - score::mw::lifecycle::ExecutionState::kRunning); - ASSERT_TRUE(result.has_value()) - << "ReportExecutionState() failed: " << result.error().Message(); + TEST_STEP("Report running from ControlClientMock") { + score::mw::lifecycle::report_running(); } // Start the run target run_target_app_does_report_krunning_in_time TEST_STEP("Activate RunTarget run_target_app_does_report_krunning_in_time") { diff --git a/tests/integration/process_complex_rep_failure/process_complex_rep_failure.py b/tests/integration/process_complex_rep_failure/process_complex_rep_failure.py index b3b5753fe..068861b57 100644 --- a/tests/integration/process_complex_rep_failure/process_complex_rep_failure.py +++ b/tests/integration/process_complex_rep_failure/process_complex_rep_failure.py @@ -31,13 +31,13 @@ def test_recovery_action_complex_rep_failure( target, setup_test, assert_test_results, remote_test_dir ): """ - Objective: Verifies that recovery action is executed when the reporting of kRunning via mw::lifecycle library (named "complex reporting" in the following) is not happening in time and vice versa. + Objective: Verifies that recovery action is executed when the reporting of running via mw::lifecycle library (named "complex reporting" in the following) is not happening in time and vice versa. - Case 1: Using complex reporting, the process does report kRunning in time (500ms below boundary) - Expected Behaviour: Reporting kRunning is successful, recovery action is not executed. + Case 1: Using complex reporting, the process does report running in time (500ms below boundary) + Expected Behaviour: Reporting running is successful, recovery action is not executed. - Case 2: Using complex reporting, the process does not report kRunning in time (500ms above boundary) - Expected Behaviour: Reporting kRunning is not successful, recovery action is executed. + Case 2: Using complex reporting, the process does not report running in time (500ms above boundary) + Expected Behaviour: Reporting running is not successful, recovery action is executed. The recovery action switches to the fallback run target, the activation of the fallback run target is verified in the test. """ diff --git a/tests/integration/process_crash_monitoring/control_client_mock.cpp b/tests/integration/process_crash_monitoring/control_client_mock.cpp index 827a0a26d..7bd5c14de 100644 --- a/tests/integration/process_crash_monitoring/control_client_mock.cpp +++ b/tests/integration/process_crash_monitoring/control_client_mock.cpp @@ -15,7 +15,7 @@ #include "tests/utils/test_helper/test_helper.hpp" #include #include -#include +#include // Given a correct configuration with: @@ -29,10 +29,9 @@ TEST(ProcessCrashMonitoring, ControlClientMock) ASSERT_TRUE(check_clean({test_end_location, fallback_file})); // Establish communication with launch manager - TEST_STEP("Report kRunning") + TEST_STEP("Report running") { - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - ASSERT_TRUE(result.has_value()) << "ReportExecutionState() failed: " << result.error().Message(); + score::mw::lifecycle::report_running(); } TEST_STEP("Start crashing process") diff --git a/tests/integration/process_crash_monitoring/process_crash_monitoring.py b/tests/integration/process_crash_monitoring/process_crash_monitoring.py index 061982f79..d81344f86 100644 --- a/tests/integration/process_crash_monitoring/process_crash_monitoring.py +++ b/tests/integration/process_crash_monitoring/process_crash_monitoring.py @@ -27,7 +27,7 @@ def test_process_crash_monitoring( """ Objective: Verifies that the launch manager correctly detects an abnormal process termination at runtime and executes a recovery action. - A process reports kRunning successfully and then crashes after run target activation completes. + A process reports running successfully and then crashes after run target activation completes. Expected Behaviour: Launch manager detects the crash and activates the fallback run target. """ diff --git a/tests/integration/process_crash_monitoring/process_crashing_on_runtime.cpp b/tests/integration/process_crash_monitoring/process_crashing_on_runtime.cpp index ba596a06f..096fbfba0 100644 --- a/tests/integration/process_crash_monitoring/process_crashing_on_runtime.cpp +++ b/tests/integration/process_crash_monitoring/process_crashing_on_runtime.cpp @@ -13,14 +13,13 @@ #include #include "tests/utils/test_helper/test_helper.hpp" -#include +#include TEST(ProcessCrashMonitoring, CrashingProcess) { - TEST_STEP("Report kRunning") + TEST_STEP("Report running") { - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - ASSERT_TRUE(result.has_value()) << "ReportExecutionState() failed: " << result.error().Message(); + score::mw::lifecycle::report_running(); } } diff --git a/tests/integration/process_launch_args/process_initial.cpp b/tests/integration/process_launch_args/process_initial.cpp index 1c1820a15..b552cf6d5 100644 --- a/tests/integration/process_launch_args/process_initial.cpp +++ b/tests/integration/process_launch_args/process_initial.cpp @@ -13,7 +13,7 @@ #include #include "tests/utils/test_helper/test_helper.hpp" -#include +#include int g_argc; char** g_argv; @@ -29,10 +29,9 @@ TEST(ProcessLaunchArgs, ProcessInitial) { ASSERT_TRUE(check_clean({test_end_location})); // Then, the process is started and: - TEST_STEP("Report kRunning") + TEST_STEP("Report running") { - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - EXPECT_TRUE(result.has_value()) << "ReportExecutionState() failed: " << result.error().Message(); + score::mw::lifecycle::report_running(); } TEST_STEP("Check args") { diff --git a/tests/integration/process_launch_args/process_launch_args.py b/tests/integration/process_launch_args/process_launch_args.py index 524afa1d8..f10569c01 100644 --- a/tests/integration/process_launch_args/process_launch_args.py +++ b/tests/integration/process_launch_args/process_launch_args.py @@ -31,7 +31,7 @@ def test_process_launch_args(target, setup_test, assert_test_results, remote_tes Objective: Verifies that the launch manager correctly passes configured launch arguments to processes. A process is configured with a command line argument and launched via the initial run target. - Expected Behaviour: Process starts successfully, reports kRunning, and receives the configured argument value. + Expected Behaviour: Process starts successfully, reports running, and receives the configured argument value. """ run_until_file_deployed( diff --git a/tests/integration/process_simple_rep_failure/control_client_mock.cpp b/tests/integration/process_simple_rep_failure/control_client_mock.cpp index 7b6f96870..a30ca8b24 100644 --- a/tests/integration/process_simple_rep_failure/control_client_mock.cpp +++ b/tests/integration/process_simple_rep_failure/control_client_mock.cpp @@ -14,7 +14,7 @@ #include "tests/utils/test_helper/test_helper.hpp" #include -#include +#include // Given a correct configuration with: // - An initial Run Target named "Startup" containing component named @@ -32,11 +32,8 @@ TEST(RecoveryActionSimpleRepFailure, ControlClientMock) { ASSERT_TRUE(check_clean({test_end_location, fallback_file})); // Establish communication with launch manager - TEST_STEP("Report kRunning from ControlClientMock") { - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState( - score::mw::lifecycle::ExecutionState::kRunning); - ASSERT_TRUE(result.has_value()) - << "ReportExecutionState() failed: " << result.error().Message(); + TEST_STEP("Report running from ControlClientMock") { + score::mw::lifecycle::report_running(); } // Start the run target run_target_app_does_report_krunning_in_time TEST_STEP("Activate RunTarget run_target_app_does_report_krunning_in_time") { diff --git a/tests/integration/process_simple_rep_failure/process_simple_rep_failure.py b/tests/integration/process_simple_rep_failure/process_simple_rep_failure.py index 77cfc5e5f..98e4497d5 100644 --- a/tests/integration/process_simple_rep_failure/process_simple_rep_failure.py +++ b/tests/integration/process_simple_rep_failure/process_simple_rep_failure.py @@ -31,13 +31,13 @@ def test_recovery_action_simple_rep_failure( target, setup_test, assert_test_results, remote_test_dir ): """ - Objective: Verifies that recovery action is executed when the reporting of kRunning via LifecycleClient API (named "simple reporting" in the following) is not happening in time and vice versa. + Objective: Verifies that recovery action is executed when the reporting of running via LifecycleClient API (named "simple reporting" in the following) is not happening in time and vice versa. - Case 1: Using simple reporting, the process does report kRunning in time (500ms below boundary) - Expected Behaviour: Reporting kRunning is successful, recovery action is not executed. + Case 1: Using simple reporting, the process does report running in time (500ms below boundary) + Expected Behaviour: Reporting running is successful, recovery action is not executed. - Case 2: Using simple reporting, the process does not report kRunning in time (500ms above boundary) - Expected Behaviour: Reporting kRunning is not successful, recovery action is executed. + Case 2: Using simple reporting, the process does not report running in time (500ms above boundary) + Expected Behaviour: Reporting running is not successful, recovery action is executed. The recovery action switches to the fallback run target, the activation of the fallback run target is verified in the test. """ diff --git a/tests/integration/process_simple_rep_failure/process_simple_reporting.cpp b/tests/integration/process_simple_rep_failure/process_simple_reporting.cpp index 9258315ed..d00a47120 100644 --- a/tests/integration/process_simple_rep_failure/process_simple_reporting.cpp +++ b/tests/integration/process_simple_rep_failure/process_simple_reporting.cpp @@ -16,7 +16,7 @@ #include #include "tests/utils/test_helper/test_helper.hpp" -#include +#include int g_argc; char** g_argv; @@ -29,13 +29,12 @@ TEST(ProcessSimpleRepFailure, ProcessSimpleReporting) ASSERT_GT(g_argc, 1) << "Wrong number of arguments"; ASSERT_FALSE((g_argv[1][0] != '0') && (atoi(g_argv[1])) == 0) << "Argument must be a number"; } - // Report kRunning with the appropriate delay - TEST_STEP("Report kRunning from ProcessSimpleReporting") + // Report running with the appropriate delay + TEST_STEP("Report running from ProcessSimpleReporting") { std::this_thread::sleep_for(std::chrono::milliseconds(atoi(g_argv[1]))); - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - EXPECT_TRUE(result.has_value()) << "ReportExecutionState() failed: " << result.error().Message(); + score::mw::lifecycle::report_running(); } } diff --git a/tests/integration/smoke/control_daemon_mock.cpp b/tests/integration/smoke/control_daemon_mock.cpp index 598f1c2d2..7e6484bf9 100644 --- a/tests/integration/smoke/control_daemon_mock.cpp +++ b/tests/integration/smoke/control_daemon_mock.cpp @@ -17,18 +17,16 @@ #include "tests/utils/test_helper/test_helper.hpp" #include -#include +#include TEST(Smoke, Daemon) { score::mw::lifecycle::ControlClient client{}; ASSERT_TRUE(check_clean({test_end_location})); - TEST_STEP("Control daemon report kRunning") + TEST_STEP("Control daemon report running") { - // report kRunning - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState( - score::mw::lifecycle::ExecutionState::kRunning); - ASSERT_TRUE(result.has_value()) << "client.ReportExecutionState() failed: " << result.error().Message(); + // report running + score::mw::lifecycle::report_running(); } TEST_STEP("Activate RunTarget Running") diff --git a/tests/integration/smoke/gtest_process.cpp b/tests/integration/smoke/gtest_process.cpp index e9bb33891..5f663550d 100644 --- a/tests/integration/smoke/gtest_process.cpp +++ b/tests/integration/smoke/gtest_process.cpp @@ -15,14 +15,12 @@ #include #include -#include +#include #include "tests/utils/test_helper/test_helper.hpp" TEST(Smoke, Process) { - // report kRunning - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - - ASSERT_TRUE(result.has_value()) << "client.ReportExecutionState() failed"; + // report running + score::mw::lifecycle::report_running(); } int main() { diff --git a/tests/integration/smoke/smoke.py b/tests/integration/smoke/smoke.py index 125a86ca9..928827227 100644 --- a/tests/integration/smoke/smoke.py +++ b/tests/integration/smoke/smoke.py @@ -27,7 +27,7 @@ def test_smoke(target, setup_test, assert_test_results, remote_test_dir): Objective: Verifies the basic end-to-end lifecycle flow of the launch manager, including process startup, run target transitions, and execution state reporting. The launch manager starts with an initial run target. The control daemon activates the "Running" run target (starting the managed process), then transitions back to "Startup", and finally activates "Off". - Expected Behaviour: All run target transitions complete successfully and all processes report kRunning. + Expected Behaviour: All run target transitions complete successfully and all processes report running. """ run_until_file_deployed( target=target, diff --git a/tests/integration/switch_run_target/component_a.cpp b/tests/integration/switch_run_target/component_a.cpp index 383e44942..57059029c 100644 --- a/tests/integration/switch_run_target/component_a.cpp +++ b/tests/integration/switch_run_target/component_a.cpp @@ -14,15 +14,14 @@ #include "common.hpp" #include "tests/utils/test_helper/test_helper.hpp" -#include +#include TEST(ComponentA, RunAndVerify) { TEST_STEP("Report running") { EXPECT_TRUE(touch_file(a_started)) << "failed to deploy file"; - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - EXPECT_TRUE(result.has_value()) << "ReportExecutionState() failed: " << result.error().Message(); + score::mw::lifecycle::report_running(); } TEST_STEP("Verify startup order") { diff --git a/tests/integration/switch_run_target/component_b.cpp b/tests/integration/switch_run_target/component_b.cpp index e21d060ef..e08935808 100644 --- a/tests/integration/switch_run_target/component_b.cpp +++ b/tests/integration/switch_run_target/component_b.cpp @@ -14,7 +14,7 @@ #include "common.hpp" #include "tests/utils/test_helper/test_helper.hpp" -#include +#include TEST(ComponentB, RunAndVerify) { @@ -26,8 +26,7 @@ TEST(ComponentB, RunAndVerify) TEST_STEP("Report running") { EXPECT_TRUE(touch_file(b_started)) << "failed to deploy file"; - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - EXPECT_TRUE(result.has_value()) << "ReportExecutionState() failed: " << result.error().Message(); + score::mw::lifecycle::report_running(); } while (!TestRunner::exitRequested) { diff --git a/tests/integration/switch_run_target/component_d.cpp b/tests/integration/switch_run_target/component_d.cpp index fe9d104de..8e1376e12 100644 --- a/tests/integration/switch_run_target/component_d.cpp +++ b/tests/integration/switch_run_target/component_d.cpp @@ -14,15 +14,14 @@ #include "common.hpp" #include "tests/utils/test_helper/test_helper.hpp" -#include +#include TEST(ComponentD, RunAndVerify) { TEST_STEP("Report running") { EXPECT_TRUE(touch_file(d_started)) << "failed to deploy file"; - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - EXPECT_TRUE(result.has_value()) << "ReportExecutionState() failed: " << result.error().Message(); + score::mw::lifecycle::report_running(); } while (!TestRunner::exitRequested) { diff --git a/tests/integration/switch_run_target/control_client_mock.cpp b/tests/integration/switch_run_target/control_client_mock.cpp index aad7b42f0..c349a828c 100644 --- a/tests/integration/switch_run_target/control_client_mock.cpp +++ b/tests/integration/switch_run_target/control_client_mock.cpp @@ -15,7 +15,7 @@ #include "tests/utils/test_helper/test_helper.hpp" #include -#include +#include // Given a configuration with the following dependency tree: @@ -38,10 +38,9 @@ TEST(SwitchRunTarget, ControlClientMock) score::mw::lifecycle::ControlClient client; ASSERT_TRUE(check_clean({test_end_location, a_started, b_started, d_started, e_started})); - TEST_STEP("Report kRunning") + TEST_STEP("Report running") { - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - EXPECT_TRUE(result.has_value()) << "ReportExecutionState() failed: " << result.error().Message(); + score::mw::lifecycle::report_running(); } // When we switch run to run target A // Then diff --git a/tests/utils/test_helper/complex_reporting_process.cpp b/tests/utils/test_helper/complex_reporting_process.cpp index bcbeaaef3..31ee0e370 100644 --- a/tests/utils/test_helper/complex_reporting_process.cpp +++ b/tests/utils/test_helper/complex_reporting_process.cpp @@ -18,7 +18,6 @@ #include "tests/utils/test_helper/test_helper.hpp" #include "score/mw/lifecycle/application.h" #include "score/mw/lifecycle/runapplication.h" -#include /// @file complex_reporting_process.cpp /// @brief Monitored test process using mw::lifecycle (score::mw::lifecycle::Application / @@ -49,8 +48,8 @@ TEST(ComplexReportingProcess, ReportsRunning) { ASSERT_FALSE((g_argv[1][0] != '0') && (atoi(g_argv[1])) == 0) << "Argument must be a number"; } - // Report kRunning with the appropriate delay - TEST_STEP("Report kRunning from ProcessComplexReporting") { + // Report running with the appropriate delay + TEST_STEP("Report running from ProcessComplexReporting") { std::this_thread::sleep_for(std::chrono::milliseconds(atoi(g_argv[1]))); score::mw::lifecycle::run_application(g_argc, g_argv); diff --git a/tests/utils/test_helper/reporting_process.cpp b/tests/utils/test_helper/reporting_process.cpp index 53082dc15..8797cb76a 100644 --- a/tests/utils/test_helper/reporting_process.cpp +++ b/tests/utils/test_helper/reporting_process.cpp @@ -15,12 +15,11 @@ #include #include "tests/utils/test_helper/test_helper.hpp" -#include +#include TEST(ReportingProcess, ReportsRunning) { - auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning); - EXPECT_TRUE(result.has_value()) << "ReportExecutionState() failed: " << result.error().Message(); + score::mw::lifecycle::report_running(); } int main()